Пример #1
0
 function render()
 {
     $spotsOverview = new SpotsOverview($this->_db, $this->_settings);
     $filter = $spotsOverview->filterToQuery($this->_params['search']);
     # Haal de offset uit de URL en zet deze als startid voor de volgende zoektocht
     # Als de offset niet in de url staat, zet de waarde als 0, het is de eerste keer
     # dat de index pagina wordt aangeroepen
     $pageNr = $this->_params['page'];
     $nextPage = $pageNr + 1;
     if ($nextPage == 1) {
         $prevPage = -1;
     } else {
         $prevPage = max($pageNr - 1, 0);
     }
     # else
     # laad de spots
     $spotsTmp = $spotsOverview->loadSpots($pageNr, $this->_prefs['perpage'], $filter, array('field' => $this->_params['sortby'], 'direction' => $this->_params['sortdir']));
     # als er geen volgende pagina is, ook niet tonen
     if (!$spotsTmp['hasmore']) {
         $nextPage = -1;
     }
     # if
     # query wanneer de laatste keer de spots geupdate werden
     $lastUpdateTime = $this->_db->getLastUpdate($this->_settings['nntp_hdr']['host']);
     # zet de page title
     $this->_pageTitle = "overzicht";
     #- display stuff -#
     $this->template('header');
     $this->template('filters', array('search' => $this->_params['search'], 'lastupdate' => $lastUpdateTime, 'filters' => $this->_settings['filters'], 'activefilter' => $this->_params['search']));
     $this->template('spots', array('spots' => $spotsTmp['list'], 'nextPage' => $nextPage, 'prevPage' => $prevPage, 'lastupdate' => $lastUpdateTime, 'activefilter' => $this->_params['search']));
     $this->template('footer');
 }
Пример #2
0
 function render()
 {
     SpotTiming::start(__FUNCTION__);
     # Controleer de users' rechten
     $this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_view_spots_index, '');
     # als een zoekopdracht is meegegevne, moeten er ook rechten zijn om te mogen zoeken
     if (!empty($this->_params['search'])) {
         $this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_perform_search, '');
     }
     # if
     $spotsOverview = new SpotsOverview($this->_db, $this->_settings);
     # Zet the query parameters om naar een lijst met filters, velden,
     # en sorteringen etc
     $spotUserSystem = new SpotUserSystem($this->_db, $this->_settings);
     $parsedSearch = $spotsOverview->filterToQuery($this->_params['search'], array('field' => $this->_params['sortby'], 'direction' => $this->_params['sortdir']), $this->_currentSession, $spotUserSystem->getIndexFilter($this->_currentSession['user']['userid']));
     # Haal de offset uit de URL en zet deze als startid voor de volgende zoektocht
     # Als de offset niet in de url staat, zet de waarde als 0, het is de eerste keer
     # dat de index pagina wordt aangeroepen
     $pageNr = $this->_params['pagenr'];
     $nextPage = $pageNr + 1;
     if ($nextPage == 1) {
         $prevPage = -1;
     } else {
         $prevPage = max($pageNr - 1, 0);
     }
     # else
     # afhankelijk van wat er gekozen is, voer het uit
     if (isset($parsedSearch['filterValueList'][0]['fieldname']) && $parsedSearch['filterValueList'][0]['fieldname'] == "Watch") {
         # Controleer de users' rechten
         $this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_keep_own_watchlist, '');
         switch ($this->_action) {
             case 'remove':
                 $this->_db->removeFromSpotStateList(SpotDb::spotstate_Watch, $this->_params['messageid'], $this->_currentSession['user']['userid']);
                 $spotsNotifications = new SpotNotifications($this->_db, $this->_settings, $this->_currentSession);
                 $spotsNotifications->sendWatchlistHandled($this->_action, $this->_params['messageid']);
                 break;
             case 'add':
                 $this->_db->addToSpotStateList(SpotDb::spotstate_Watch, $this->_params['messageid'], $this->_currentSession['user']['userid'], '');
                 $spotsNotifications = new SpotNotifications($this->_db, $this->_settings, $this->_currentSession);
                 $spotsNotifications->sendWatchlistHandled($this->_action, $this->_params['messageid']);
                 break;
             default:
         }
         # switch
     }
     # if
     # laad de spots
     $spotsTmp = $spotsOverview->loadSpots($this->_currentSession['user']['userid'], $pageNr, $this->_currentSession['user']['prefs']['perpage'], $parsedSearch);
     # als er geen volgende pagina is, ook niet tonen
     if (!$spotsTmp['hasmore']) {
         $nextPage = -1;
     }
     # if
     # zet de page title
     $this->_pageTitle = "overzicht";
     #- display stuff -#
     $this->template('spots', array('spots' => $spotsTmp['list'], 'quicklinks' => $this->_settings->get('quicklinks'), 'filters' => $this->_db->getFilterList($this->_currentSession['user']['userid'], 'filter'), 'nextPage' => $nextPage, 'prevPage' => $prevPage, 'parsedsearch' => $parsedSearch, 'data' => $this->_params['data']));
     SpotTiming::stop(__FUNCTION__);
 }
Пример #3
0
 function render()
 {
     $spotsOverview = new SpotsOverview($this->_db, $this->_settings);
     $filter = $spotsOverview->filterToQuery($this->_params['search']);
     $pageNr = $this->_params['page'];
     # laad de spots
     $spotsTmp = $spotsOverview->loadSpots($pageNr, $this->_prefs['perpage'], $filter, array('field' => $this->_params['sortby'], 'direction' => $this->_params['sortdir']));
     $fullSpots = array();
     $spotnntp = new SpotNntp($this->_settings['nntp_hdr'], $this->_settings['use_openssl']);
     foreach ($spotsTmp['list'] as $spot) {
         try {
             $fullSpots[] = $spotsOverview->getFullSpot($spot['messageid'], $spotnntp);
         } catch (Exception $x) {
             // Article not found. ignore.
         }
     }
     $this->template('atom', array('spots' => $fullSpots));
 }
Пример #4
0
	function render() {
		# Controleer de users' rechten
		$this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_view_spotdetail, '');
		$this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_view_spots_index, '');
		$this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_view_rssfeed, '');

		$spotsOverview = new SpotsOverview($this->_db, $this->_settings);
		$nzbhandling = $this->_currentSession['user']['prefs']['nzbhandling'];

		# we willen niet dat de RSS feed gecached wordt
		$this->sendExpireHeaders(true);
		
		# Zet the query parameters om naar een lijst met filters, velden,
		# en sorteringen etc
		$parsedSearch = $spotsOverview->filterToQuery($this->_params['search'],
							array('field' => $this->_params['sortby'],
								  'direction' => $this->_params['sortdir']),
						    $this->_currentSession);
		$this->_params['search'] = $parsedSearch['search'];

		# laad de spots
		$pageNr = $this->_params['page'];
		$spotsTmp = $spotsOverview->loadSpots($this->_currentSession['user']['userid'],
							$pageNr,
							$this->_currentSession['user']['prefs']['perpage'],
							$parsedSearch);

		# Opbouwen XML
		$doc = new DOMDocument('1.0', 'utf-8');
		$doc->formatOutput = true;

		$rss = $doc->createElement('rss');
		$rss->setAttribute('version', '2.0');
		$rss->setAttribute('xmlns:atom', 'http://www.w3.org/2005/Atom');
		$doc->appendChild($rss);

		$atomSelfLink = $doc->createElementNS('http://www.w3.org/2005/Atom', 'atom10:link');
		$atomSelfLink->setAttribute('href', html_entity_decode($this->_tplHelper->makeSelfUrl("full")));
		$atomSelfLink->setAttribute('rel', 'self');
		$atomSelfLink->setAttribute('type', 'application/rss+xml');

		$channel = $doc->createElement('channel');
		$channel->appendChild($doc->createElement('generator', 'Spotweb v' . SPOTWEB_VERSION));
		$channel->appendChild($doc->createElement('language', 'nl'));
		$channel->appendChild($doc->createElement('title', 'Spotweb'));
		$channel->appendChild($doc->createElement('description', 'Spotweb RSS Feed'));
		$channel->appendChild($doc->createElement('link', $this->_tplHelper->makeBaseUrl("full")));
		$channel->appendChild($atomSelfLink);
		$channel->appendChild($doc->createElement('webMaster', $this->_currentSession['user']['mail'] . ' (' . $this->_currentSession['user']['firstname'] . ' ' . $this->_currentSession['user']['lastname'] . ')'));
		$channel->appendChild($doc->createElement('pubDate', date('r')));
		$rss->appendChild($channel);

		# Fullspots ophalen en aan XML toevoegen
		foreach($spotsTmp['list'] as $spotHeaders) {
			try {
				$spot = $this->_tplHelper->getFullSpot($spotHeaders['messageid'], false);
				# Normaal is fouten oplossen een beter idee, maar in dit geval is het een bug in de library (?)
				# Dit voorkomt Notice: Uninitialized string offset: 0 in lib/ubb/TagHandler.inc.php on line 142
				# wat een onbruikbare RSS oplevert
				$spot = @$this->_tplHelper->formatSpot($spot);

				$title = preg_replace(array('/</', '/>/'), array('&#x3C;', '&#x3E;'), $spot['title']);
				$poster = (empty($spot['userid'])) ? $spot['poster'] : $spot['poster'] . " (" . $spot['userid'] . ")";

				$guid = $doc->createElement('guid', $spot['messageid']);
				$guid->setAttribute('isPermaLink', 'false');

				$description = $doc->createElement('description');
				$descriptionCdata = $doc->createCDATASection($spot['description'] . '<br /><font color="#ca0000">Door: ' . $poster . '</font>');
				$description->appendChild($descriptionCdata);

				$item = $doc->createElement('item');
				$item->appendChild($doc->createElement('title', $title));
				$item->appendChild($guid);
				$item->appendChild($doc->createElement('link', $this->_tplHelper->makeBaseUrl("full") . '?page=getspot&amp;messageid=' . urlencode($spot['messageid']) . $this->_tplHelper->makeApiRequestString()));
				$item->appendChild($description);
				$item->appendChild($doc->createElement('author', $spot['messageid'] . ' (' . $poster . ')'));
				$item->appendChild($doc->createElement('pubDate', date('r', $spot['stamp'])));
				$item->appendChild($doc->createElement('category', SpotCategories::HeadCat2Desc($spot['category']) . ': ' . SpotCategories::Cat2ShortDesc($spot['category'], $spot['subcata'])));

				$enclosure = $doc->createElement('enclosure');
				$enclosure->setAttribute('url', html_entity_decode($this->_tplHelper->makeNzbUrl($spot)));
				$enclosure->setAttribute('length', $spot['filesize']);
				switch ($nzbhandling['prepare_action']) {
					case 'zip'	: $enclosure->setAttribute('type', 'application/zip'); break;
					default		: $enclosure->setAttribute('type', 'application/x-nzb');
				} # switch
				$item->appendChild($enclosure);

				$channel->appendChild($item);
			} # try
			catch(Exception $x) {
				// Article not found. ignore.
			} # catch
		} # foreach

		# XML output
		header('Content-Type: application/rss+xml; charset=UTF-8');
		echo $doc->saveXML();
	} # render()
Пример #5
0
	function search($outputtype) {
		$spotsOverview = new SpotsOverview($this->_db, $this->_settings);
		$search = array();

		if (($this->_params['t'] == "t" || $this->_params['t'] == "tvsearch") && $this->_params['rid'] != "") {
			# validate input
			if (!preg_match('/^[0-9]{1,6}$/', $this->_params['rid'])) {
				$this->showApiError(201);
			} # if

			# fetch remote content
			$dom = new DomDocument();
			$dom->prevservWhiteSpace = false;

			if (!@$dom->load('http://services.tvrage.com/feeds/showinfo.php?sid=' . $this->_params['rid'] . '/')) {
				$this->showApiError(300);
			} # if
			$showTitle = $dom->getElementsByTagName('showname');
			$tvSearch = $showTitle->item(0)->nodeValue;

			$epSearch = '';
			if (preg_match('/^[sS][0-9]{1,2}$/', $this->_params['season']) || preg_match('/^[0-9]{1,2}$/', $this->_params['season'])) {
				$epSearch = (is_numeric($this->_params['season'])) ? ' AND S' . str_pad($this->_params['season'], 2, "0", STR_PAD_LEFT) : ' AND ' . $this->_params['season'];
			} elseif ($this->_params['season'] != "") {
				$this->showApiError(201);
			} # if

			if (preg_match('/^[eE][0-9]{1,2}$/', $this->_params['ep']) || preg_match('/^[0-9]{1,2}$/', $this->_params['ep'])) {
				$episode = (is_numeric($this->_params['ep'])) ? 'E' . str_pad($this->_params['ep'], 2, "0", STR_PAD_LEFT) : $this->_params['ep'];
				$epSearch .= (!empty($epSearch)) ? $episode : ' AND ' . $episode;
			} elseif ($this->_params['ep'] != "") {
				$this->showApiError(201);
			} # if

			$search['value'][] = "Titel:" . trim($tvSearch) . $epSearch;
		} elseif ($this->_params['t'] == "m" || $this->_params['t'] == "movie") {
			# validate input
			if ($this->_params['imdbid'] == "") {
				$this->showApiError(200);
			} elseif (!preg_match('/^[0-9]{1,8}$/', $this->_params['imdbid'])) {
				$this->showApiError(201);
			} # if

			# fetch remote content
			if (!@$imdb_content = file_get_contents('http://uk.imdb.com/title/tt' . $this->_params['imdbid'] . '/')) {
				$this->showApiError(300);
			} # if
			preg_match('/<title>(.*?) \(.*?<\/title>/ms', $imdb_content, $movieTitle);
			$search['value'][] = "Titel:\"" . trim($movieTitle[1]) . "\"";
		} elseif (!empty($this->_params['q'])) {
			$search['value'][] = "Titel:" . $this->_params['q'];
		} # elseif

		if ($this->_params['maxage'] != "" && is_numeric($this->_params['maxage']))
			$search['value'][] = "date:>:-" . $this->_params['maxage'] . "days";

		$search['tree'] = $this->nabcat2spotcat($this->_params['cat']);

		# Spots met een filesize 0 niet opvragen
		$search['value'][] = "filesize:>:0";

		$limit = $this->_currentSession['user']['prefs']['perpage'];
		if ($this->_params['limit'] != "" && is_numeric($this->_params['limit']) && $this->_params['limit'] < 500)
			$limit = $this->_params['limit'];

		$pageNr = ($this->_params['offset'] != "" && is_numeric($this->_params['offset'])) ? $this->_params['offset'] : 0;
		$offset = $pageNr*$limit;

		$parsedSearch = $spotsOverview->filterToQuery($search, array('field' => 'stamp', 'direction' => 'DESC'), $this->_currentSession);
		$spots = $spotsOverview->loadSpots($this->_currentSession['user']['userid'],
						$pageNr,
						$limit,
						$parsedSearch);
		$this->showResults($spots, $offset, $outputtype);
	} # search
Пример #6
0
 function search($outputtype)
 {
     # Controleer de users' rechten
     $this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_perform_search, '');
     $spotsOverview = new SpotsOverview($this->_db, $this->_settings);
     $search = array();
     if (($this->_params['t'] == "t" || $this->_params['t'] == "tvsearch") && $this->_params['rid'] != "") {
         # validate input
         if (!preg_match('/^[0-9]{1,6}$/', $this->_params['rid'])) {
             $this->showApiError(201);
         }
         # if
         # fetch remote content
         $dom = new DomDocument();
         $dom->prevservWhiteSpace = false;
         if (!@$dom->load('http://services.tvrage.com/feeds/showinfo.php?sid=' . $this->_params['rid'] . '/')) {
             $this->showApiError(300);
         }
         # if
         $showTitle = $dom->getElementsByTagName('showname');
         $tvSearch = $showTitle->item(0)->nodeValue;
         $epSearch = '';
         if (preg_match('/^[sS][0-9]{1,2}$/', $this->_params['season']) || preg_match('/^[0-9]{1,2}$/', $this->_params['season'])) {
             $epSearch = is_numeric($this->_params['season']) ? 'S' . str_pad($this->_params['season'], 2, "0", STR_PAD_LEFT) : $this->_params['season'];
         } elseif ($this->_params['season'] != "") {
             $this->showApiError(201);
         }
         # if
         if (preg_match('/^[eE][0-9]{1,2}$/', $this->_params['ep']) || preg_match('/^[0-9]{1,2}$/', $this->_params['ep'])) {
             $epSearch .= is_numeric($this->_params['ep']) ? 'E' . str_pad($this->_params['ep'], 2, "0", STR_PAD_LEFT) : $this->_params['ep'];
         } elseif ($this->_params['ep'] != "") {
             $this->showApiError(201);
         }
         # if
         $search['value'][] = "Titel:=:" . trim($tvSearch) . " " . $epSearch;
     } elseif ($this->_params['t'] == "music") {
         if (empty($this->_params['artist']) && empty($this->_params['cat'])) {
             $this->_params['cat'] = 3000;
         } else {
             $search['value'][] = "Titel:=:\"" . $this->_params['artist'] . "\"";
         }
         # if
     } elseif ($this->_params['t'] == "m" || $this->_params['t'] == "movie") {
         # validate input
         if ($this->_params['imdbid'] == "") {
             $this->showApiError(200);
         } elseif (!preg_match('/^[0-9]{1,8}$/', $this->_params['imdbid'])) {
             $this->showApiError(201);
         }
         # if
         # fetch remote content
         if (!@($imdb_content = file_get_contents('http://uk.imdb.com/title/tt' . $this->_params['imdbid'] . '/'))) {
             $this->showApiError(300);
         }
         # if
         preg_match('/<h1 class="header" itemprop="name">([^\\<]*)<span>/ms', $imdb_content, $movieTitle);
         $search['value'][] = "Titel:=:\"" . trim($movieTitle[1]) . "\"";
     } elseif (!empty($this->_params['q'])) {
         $searchTerm = str_replace(" ", " +", $this->_params['q']);
         $search['value'][] = "Titel:=:+" . $searchTerm;
     }
     # elseif
     if ($this->_params['maxage'] != "" && is_numeric($this->_params['maxage'])) {
         $search['value'][] = "date:>:-" . $this->_params['maxage'] . "days";
     }
     $tmpCat = array();
     foreach (explode(",", $this->_params['cat']) as $category) {
         $tmpCat[] = $this->nabcat2spotcat($category);
     }
     # foreach
     $search['tree'] = implode(",", $tmpCat);
     # Spots met een filesize 0 niet opvragen
     $search['value'][] = "filesize:>:0";
     $limit = $this->_currentSession['user']['prefs']['perpage'];
     if ($this->_params['limit'] != "" && is_numeric($this->_params['limit']) && $this->_params['limit'] < 500) {
         $limit = $this->_params['limit'];
     }
     $pageNr = $this->_params['offset'] != "" && is_numeric($this->_params['offset']) ? $this->_params['offset'] : 0;
     $offset = $pageNr * $limit;
     $spotUserSystem = new SpotUserSystem($this->_db, $this->_settings);
     $parsedSearch = $spotsOverview->filterToQuery($search, array('field' => 'stamp', 'direction' => 'DESC'), $this->_currentSession, $spotUserSystem->getIndexFilter($this->_currentSession['user']['userid']));
     $spots = $spotsOverview->loadSpots($this->_currentSession['user']['userid'], $pageNr, $limit, $parsedSearch);
     $this->showResults($spots, $offset, $outputtype);
 }