Esempio n. 1
0
 function __construct(SpotSettings $settings, $currentSession, SpotDb $db, $params)
 {
     $this->_settings = $settings;
     $this->_currentSession = $currentSession;
     $this->_spotSec = $currentSession['security'];
     $this->_db = $db;
     $this->_params = $params;
     # We hebben SpotsOverview altijd nodig omdat we die ook voor het
     # maken van de sorturl nodig hebben, dus maken we deze hier aan
     $this->_spotsOverview = new SpotsOverview($db, $settings);
     # We initialiseren hier een NzbHandler object om te voorkomen
     # dat we voor iedere spot een nieuw object initialiseren, een property
     # zou mooier zijn, maar daar is PHP dan weer te traag voor
     $nzbHandlerFactory = new NzbHandler_Factory();
     if (isset($currentSession['user']['prefs']['nzbhandling'])) {
         $this->_nzbHandler = $nzbHandlerFactory->build($settings, $currentSession['user']['prefs']['nzbhandling']['action'], $currentSession['user']['prefs']['nzbhandling']);
     }
     # if
 }
Esempio n. 2
0
	function handleNzbAction($messageids, $userSession, $action, $hdr_spotnntp, $nzb_spotnntp) {
		if (!is_array($messageids)) {
			$messageids = array($messageids);
		} # if
		
		# Controleer de security
		$userSession['security']->fatalPermCheck(SpotSecurity::spotsec_retrieve_nzb, '');
		if ($action != 'display') {
			$userSession['security']->fatalPermCheck(SpotSecurity::spotsec_download_integration, $action);
		} # if
			
		# Haal de volledige spot op en gebruik de informatie daarin om de NZB file op te halen
		$spotsOverview = new SpotsOverview($this->_db, $this->_settings);
		
		$nzbList = array();
		foreach($messageids as $thisMsgId) {
			$fullSpot = $spotsOverview->getFullSpot($thisMsgId, $userSession['user']['userid'], $hdr_spotnntp);
			
			if (!empty($fullSpot['nzb'])) {
				$nzbList[] = array('spot' => $fullSpot, 
								   'nzb' => $spotsOverview->getNzb($fullSpot['nzb'], $nzb_spotnntp));
			} # if
		} # foreach

		# send nzblist to NzbHandler plugin
		$nzbHandlerFactory = new NzbHandler_Factory();
		$nzbHandler = $nzbHandlerFactory->build($this->_settings, $action, $userSession['user']['prefs']['nzbhandling']);

		$nzbHandler->processNzb($fullSpot, $nzbList);

		# en voeg hem toe aan de lijst met downloads
		if ($userSession['user']['prefs']['keep_downloadlist']) {
			if ($userSession['security']->allowed(SpotSecurity::spotsec_keep_own_downloadlist, '')) {
				foreach($messageids as $thisMsgId) {
					$this->_db->addToSpotStateList(SpotDb::spotstate_Down, $thisMsgId, $userSession['user']['userid']);
				} # foreach
			} # if
		} # if
		
		# en verstuur een notificatie
		$spotsNotifications = new SpotNotifications($this->_db, $this->_settings, $userSession);
		$spotsNotifications->sendNzbHandled($action, $fullSpot);
	} # handleNzbAction
Esempio n. 3
0
	function __construct(SpotSettings $settings, $currentSession, SpotDb $db, $params) {
		$this->_settings = $settings;
		$this->_currentSession = $currentSession;
		$this->_spotSec = $currentSession['security'];
		$this->_db = $db;
		$this->_params = $params;
		
		# We initialiseren hier een SpotNzb object omdat we die
		# voor het maken van de sabnzbd categorieen nodig hebben.
		# Door die hier aan te maken verplaatsen we een boel allocaties
		$this->_spotnzb = new SpotNzb($db, $settings);

		# We initialiseren hier een NzbHandler object om te voorkomen
		# dat we voor iedere spot een nieuw object initialiseren, een property
		# zou mooier zijn, maar daar is PHP dan weer te traag voor
		$nzbHandlerFactory = new NzbHandler_Factory();
		$this->_nzbHandler = $nzbHandlerFactory->build($settings, 
					$currentSession['user']['prefs']['nzbhandling']['action'], 
					$currentSession['user']['prefs']['nzbhandling']);
	} # ctor
Esempio n. 4
0
 function render()
 {
     # Controleer de users' rechten
     $this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_use_sabapi, '');
     parse_str($_SERVER['QUERY_STRING'], $request);
     $apikey = $this->_currentSession['user']['apikey'];
     if ($this->_tplHelper->apiToHash($apikey) != $request['nzbhandlerapikey']) {
         error_log('API Key Incorrect');
         die('API Key Incorrect');
     }
     $nzbHandlerFactory = new NzbHandler_Factory();
     $this->_nzbHandler = $nzbHandlerFactory->build($this->_settings, $this->_currentSession['user']['prefs']['nzbhandling']['action'], $this->_currentSession['user']['prefs']['nzbhandling']);
     if ($this->_nzbHandler->hasApiSupport() !== false) {
         $action = strtolower($request['action']);
         switch ($action) {
             # actions on the entire queue
             case 'getstatus':
                 $result = $this->_nzbHandler->getStatus();
                 break;
             case 'pausequeue':
                 $result = $this->_nzbHandler->pauseQueue();
                 break;
             case 'resumequeue':
                 $result = $this->_nzbHandler->resumeQueue();
                 break;
             case 'setspeedlimit':
                 $result = $this->_nzbHandler->setSpeedLimit($request['limit']);
                 break;
                 # actions on a specific download
             # actions on a specific download
             case 'movedown':
                 $result = $this->_nzbHandler->moveDown($request['id']);
                 break;
             case 'moveup':
                 $result = $this->_nzbHandler->moveUp($request['id']);
                 break;
             case 'movetop':
                 $result = $this->_nzbHandler->moveTop($request['id']);
                 break;
             case 'movebottom':
                 $result = $this->_nzbHandler->moveBottom($request['id']);
                 break;
             case 'setcategory':
                 $result = $this->_nzbHandler->setCategory($request['id'], $request['category']);
                 break;
             case 'setpriority':
                 $result = $this->_nzbHandler->setPriority($request['id'], $request['priority']);
                 break;
             case 'setpassword':
                 $result = $this->_nzbHandler->setPassword($request['id'], $request['password']);
                 break;
             case 'delete':
                 $result = $this->_nzbHandler->delete($request['id']);
                 break;
             case 'rename':
                 $result = $this->_nzbHandler->rename($request['id'], $request['name']);
                 break;
             case 'pause':
                 $result = $this->_nzbHandler->pause($request['id']);
                 break;
             case 'resume':
                 $result = $this->_nzbHandler->resume($request['id']);
                 break;
                 # non download related actions
             # non download related actions
             case 'getcategories':
                 $result = $this->_nzbHandler->getCategories();
                 break;
             case 'getversion':
                 $tmp = $this->_nzbHandler->getVersion();
                 if ($tmp === false) {
                     $result = false;
                 } else {
                     $result['version'] = $tmp;
                 }
                 break;
             default:
                 # default action
                 $result = false;
         }
     } else {
         error_log('The configured NZB handler has no api support');
         die('The configured NZB handler has no api support');
     }
     # de nzbhandlerapi output moet niet gecached worden
     $this->sendExpireHeaders(true);
     header('Content-type: application/json');
     if ($result === true || $result === false) {
         $tmp['result'] = $result;
         $result = $tmp;
     }
     $result = json_encode($result);
     echo $result;
 }