setPrefs(); $queueType = $error = ''; $queue = null; switch (Settings::settingValue('apps.sabnzbplus.integrationtype')) { case SABnzbd::INTEGRATION_TYPE_NONE: if ($this->userdata->queuetype === 2) { $queueType = 'NZBGet'; $queue = new NZBGet($this); } break; case SABnzbd::INTEGRATION_TYPE_USER: switch ((int) $this->userdata->queuetype) { case 1: $queueType = 'Sabnzbd'; $queue = new SABnzbd($this); break; case 2: $queueType = 'NZBGet'; $queue = new NZBGet($this); break; } break; } if ($queue !== null) { if ($queueType === 'Sabnzbd') { if (empty($queue->url)) { $error = 'ERROR: The Sabnzbd URL is missing!'; } if (empty($queue->apikey)) { if ($error === '') { $error = 'ERROR: The Sabnzbd API key is missing!'; } else { $error .= ' The Sabnzbd API key is missing!'; } } } if ($error === '') { if ($request->has('del')) { $queue->delFromQueue($request->input('del')); } if ($request->has('pause')) { $queue->pauseFromQueue($request->input('pause')); } if ($request->has('resume')) { $queue->resumeFromQueue($request->input('resume')); } if ($request->has('pall')) { $queue->pauseAll(); } if ($request->has('rall')) { $queue->resumeAll(); } $this->smarty->assign('serverURL', $queue->url); } } $this->smarty->assign( [ 'queueType' => $queueType, 'error' => $error, 'user' => $this->userdata, ] ); $title = 'Your '.$queueType.' Download Queue'; $meta_title = 'View'.$queueType.' Queue'; $meta_keywords = 'view,'.strtolower($queueType).',queue'; $meta_description = 'View'.$queueType.' Queue'; $content = $this->smarty->fetch('viewqueue.tpl'); $this->smarty->assign(compact('title', 'content', 'meta_title', 'meta_keywords', 'meta_description')); $this->pagerender(); } /** * @throws \Exception */ public function nzbget() { $this->setPrefs(); $nzbGet = new NZBGet($this); $output = ''; $data = $nzbGet->getQueue(); if ($data !== false) { if (\count($data) > 0) { $status = $nzbGet->status(); if ($status !== false) { $output .= "
| # | Name | Size | Left(+pars) | Done | Status | Delete | Pause all | Resume all |
|---|---|---|---|---|---|---|---|---|
| ".$count.' | '. "".$item['NZBName'].' | '. "".$item['FileSizeMB'].' MB | '. "".$item['RemainingSizeMB'].' MB | '. "".($item['FileSizeMB'] === 0 ? 0 : round(100 - ($item['RemainingSizeMB'] / $item['FileSizeMB']) * 100)).'% | '. "".($item['ActiveDownloads'] > 0 ? 'Downloading' : 'Paused').' | '. "Delete | ". "Pause | ". "Resume | ". '
The queue is currently empty.
"; } } else { $output .= "Error retreiving queue.
"; } echo $output; } /** * @throws \Exception */ public function sabnzbd() { $this->setPrefs(); $sab = new SABnzbd($this); $output = ''; $json = $sab->getAdvQueue(); if ($json !== false) { $obj = json_decode($json); $queue = $obj->{'queue'}; $count = 1; $output .= "| # | Name | Size | Left | Done | Time Left | Delete | Pause all | Resume all |
|---|---|---|---|---|---|---|---|---|
| ".$count.' | '. "".$item->{'filename'}.' | '. "".round($item->{'mb'}, 2).' MB | '. "".round($item->{'mbleft'}, 2).' MB | '. "".($item->{'mb'} === 0 ? 0 : round(100 - ($item->{'mbleft'} / $item->{'mb'}) * 100)).'% | '. "".$item->{'timeleft'}.' | '. "Delete | ". "Pause | ". "Resume | ". '
The queue is currently empty.
"; } } else { $output .= "Error retrieving queue.
"; } echo $output; } /** * @throws \Exception */ public function nzbVortex() { $this->setPrefs(); try { if (isset($_GET['isAjax'])) { $vortex = new NZBVortex; // I guess we Ajax this way. if (isset($_GET['getOverview'])) { $overview = $vortex->getOverview(); $this->smarty->assign('overview', $overview); $content = $this->smarty->fetch('nzbvortex-ajax.tpl'); echo $content; exit; } if (isset($_GET['addQueue'])) { $nzb = $_GET['addQueue']; $vortex->addQueue($nzb); exit; } if (isset($_GET['resume'])) { $vortex->resume((int) $_GET['resume']); exit; } if (isset($_GET['pause'])) { $vortex->pause((int) $_GET['pause']); exit; } if (isset($_GET['moveup'])) { $vortex->moveUp((int) $_GET['moveup']); exit; } if (isset($_GET['movedown'])) { $vortex->moveDown((int) $_GET['movedown']); exit; } if (isset($_GET['movetop'])) { $vortex->moveTop((int) $_GET['movetop']); exit; } if (isset($_GET['movebottom'])) { $vortex->moveBottom((int) $_GET['movebottom']); exit; } if (isset($_GET['delete'])) { $vortex->delete((int) $_GET['delete']); exit; } if (isset($_GET['filelist'])) { $response = $vortex->getFilelist((int) $_GET['filelist']); echo json_encode($response); exit; } } } catch (\Exception $e) { header('HTTP/1.1 500 Internal Server Error'); printf($e->getMessage()); exit; } $title = 'NZBVortex'; $content = $this->smarty->fetch('nzbvortex.tpl'); $this->smarty->assign(compact('title', 'content')); $this->pagerender(); } }