function spotDetails($outputtype) { if (empty($this->_params['messageid'])) { $this->showApiError(200); return; } # if # Make sure the specific permissions are implemented $this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_view_spotdetail, ''); # spot ophalen try { $fullSpot = $this->_tplHelper->getFullSpot($this->_params['messageid'], true); } catch (Exception $x) { $this->showApiError(300); return; } # catch $nzbhandling = $this->_currentSession['user']['prefs']['nzbhandling']; /* * Ugly @ operator, but we cannot reliably fix the library for the moment */ $spot = @$this->_tplHelper->formatSpot($fullSpot); if ($outputtype == "json") { $doc = array(); $doc['ID'] = $spot['id']; $doc['name'] = $spot['title']; $doc['size'] = $spot['filesize']; $doc['adddate'] = date('Y-m-d H:i:s', $spot['stamp']); $doc['guid'] = $spot['messageid']; $doc['fromname'] = $spot['poster']; $doc['completion'] = 100; $nabCat = explode("|", $this->Cat2NewznabCat($spot['category'], $spot['subcata'])); if ($nabCat[0] != "" && is_numeric($nabCat[0])) { $doc['categoryID'] = $nabCat[0]; $cat = implode(",", $nabCat); } # if $nabCat = explode("|", $this->Cat2NewznabCat($spot['category'], $spot['subcatb'])); if ($nabCat[0] != "" && is_numeric($nabCat[0])) { $cat .= "," . $nabCat[0]; } # if $doc['comments'] = $spot['commentcount']; $doc['category_name'] = SpotCategories::HeadCat2Desc($spot['category']) . ': ' . SpotCategories::Cat2ShortDesc($spot['category'], $spot['subcata']); $doc['category_ids'] = $cat; echo json_encode($doc); } else { $nzbUrl = $this->_tplHelper->makeBaseUrl("full") . 'api?t=g&id=' . $spot['messageid'] . $this->_tplHelper->makeApiRequestString(); # 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'); $rss->setAttribute('xmlns:newznab', 'http://www.newznab.com/DTD/2010/feeds/attributes/'); $rss->setAttribute('encoding', 'utf-8'); $doc->appendChild($rss); $channel = $doc->createElement('channel'); $channel->appendChild($doc->createElement('title', 'Spotweb')); $channel->appendChild($doc->createElement('language', 'nl')); $channel->appendChild($doc->createElement('description', 'Spotweb Index Api Detail')); $channel->appendChild($doc->createElement('link', $this->_settings->get('spotweburl'))); $channel->appendChild($doc->createElement('webMaster', $this->_currentSession['user']['mail'] . ' (' . $this->_currentSession['user']['firstname'] . ' ' . $this->_currentSession['user']['lastname'] . ')')); $channel->appendChild($doc->createElement('category', '')); $rss->appendChild($channel); $image = $doc->createElement('image'); $image->appendChild($doc->createElement('url', $this->_tplHelper->makeImageUrl($spot, 300, 300))); $image->appendChild($doc->createElement('title', 'Spotweb Index')); $image->appendChild($doc->createElement('link', $this->_settings->get('spotweburl'))); $image->appendChild($doc->createElement('description', 'Visit Spotweb Index')); $channel->appendChild($image); $poster = empty($spot['spotterid']) ? $spot['poster'] : $spot['poster'] . " (" . $spot['spotterid'] . ")"; $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', htmlspecialchars($spot['title'], ENT_QUOTES, "UTF-8"))); $item->appendChild($guid); $item->appendChild($doc->createElement('link', $nzbUrl)); $item->appendChild($doc->createElement('pubDate', date('r', $spot['stamp']))); $item->appendChild($doc->createElement('category', SpotCategories::HeadCat2Desc($spot['category']) . " > " . SpotCategories::Cat2ShortDesc($spot['category'], $spot['subcata']))); $item->appendChild($description); $channel->appendChild($item); $enclosure = $doc->createElement('enclosure'); $enclosure->setAttribute('url', html_entity_decode($nzbUrl)); $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); $nabCat = explode("|", $this->Cat2NewznabCat($spot['category'], $spot['subcata'])); if ($nabCat[0] != "" && is_numeric($nabCat[0])) { $attr = $doc->createElement('newznab:attr'); $attr->setAttribute('name', 'category'); $attr->setAttribute('value', $nabCat[0]); $item->appendChild($attr); $attr = $doc->createElement('newznab:attr'); $attr->setAttribute('name', 'category'); $attr->setAttribute('value', $nabCat[1]); $item->appendChild($attr); } # if $nabCat = explode("|", $this->Cat2NewznabCat($spot['category'], $spot['subcatb'])); if ($nabCat[0] != "" && is_numeric($nabCat[0])) { $attr = $doc->createElement('newznab:attr'); $attr->setAttribute('name', 'category'); $attr->setAttribute('value', $nabCat[0]); $item->appendChild($attr); } # if $attr = $doc->createElement('newznab:attr'); $attr->setAttribute('name', 'size'); $attr->setAttribute('value', $spot['filesize']); $item->appendChild($attr); $attr = $doc->createElement('newznab:attr'); $attr->setAttribute('name', 'poster'); $attr->setAttribute('value', $spot['poster'] . '@spot.net (' . $spot['poster'] . ')'); $item->appendChild($attr); $attr = $doc->createElement('newznab:attr'); $attr->setAttribute('name', 'comments'); $attr->setAttribute('value', $spot['commentcount']); $item->appendChild($attr); $this->sendContentTypeHeader('xml'); echo $doc->saveXML(); } # if }
</ul> </div><!-- /navbar --> </div> <div data-role="content"> <ul data-role="listview"> <?php $count = 0; foreach($spots as $spot) { # Format the spot header $spot = $tplHelper->formatSpotHeader($spot); echo "<li><a href='". $setpath . "index.php?page=getspotmobile&messageid=" . $spot['messageid'] . "' data-rel='dialog' data-transition='slidedown'><h3>[". SpotCategories::Cat2ShortDesc($spot['category'], $spot['subcata']) . "] ".$spot['title'] . "</h3><p>". strtoupper($tplHelper->formatDate($spot['stamp'], 'spotlist')) ."</p></a></li>\n"; } ?> </ul> <fieldset class="ui-grid-a"> <?php if ($prevPage >= 0) { ?> <div class="ui-block-a"><a href="<?php echo $setpath;?>index.php?direction=prev&pagenr=<?php echo $prevPage . $getUrl;?>#spots" disabled data-theme="a" rel=external data-role="button" data-icon="arrow-l" >Vorige</a></div> <?php }else{ ?> <div class="ui-block-a"><a href="<?php echo $setpath;?>#" disabled data-theme="c" rel=external data-role="button" data-icon="minus"> </a></div> <?php } ?> <?php if ($nextPage > 0) { ?> <div class="ui-block-b"><a href="<?php echo $setpath;?>index.php?pagenr=spots&direction=next&page=<?php echo $nextPage . $getUrl;?>#spots" data-theme="a" rel="external" data-role="button" data-icon="arrow-r">Volgende</a></div> <?php } ?> </fieldset>
<?php $count = 0; foreach ($spots as $spot) { # fix the sabnzbdurl en searchurl $spot['sabnzbdurl'] = $tplHelper->makeSabnzbdUrl($spot); $spot['searchurl'] = $tplHelper->makeSearchUrl($spot); if ($tplHelper->newSinceLastVisit($spot)) { $newSpotClass = 'new'; } else { $newSpotClass = ''; } # else $subcatFilter = SpotCategories::SubcatToFilter($spot['category'], $spot['subcata']); $count++; echo "\t\t\t\t\t\t\t"; echo "<tr class='" . $tplHelper->cat2color($spot) . ' ' . ($count % 2 ? "even" : "odd") . $spot['subcata'] . $spot['subcatb'] . $spot['subcatc'] . $spot['subcatd'] . "'>" . "<td class='category'><a href='?search[tree]=" . $subcatFilter . "' title='Ga naar de categorie \"" . SpotCategories::Cat2ShortDesc($spot['category'], $spot['subcata']) . "\"'>" . SpotCategories::Cat2ShortDesc($spot['category'], $spot['subcata']) . "</a></td>" . "<td class='title " . $newSpotClass . "'><a href='?page=getspot&messageid=" . $spot['messageid'] . "' title='" . $spot['title'] . "' class='spotlink'>" . $spot['title'] . "</a></td>" . "<td class='comments'><a href='?page=getspot&messageid=" . $spot['messageid'] . "#comments' title='" . $tplHelper->getCommentCount($spot) . " comments bij \"" . $spot['title'] . "\"' class='spotlink'>" . $tplHelper->getCommentCount($spot) . "</a></td>" . "<td>" . SpotCategories::Cat2Desc($spot['category'], $spot['subcat' . SpotCategories::SubcatNumberFromHeadcat($spot['category'])]) . "</td>" . "<td>" . $spot['poster'] . "</td>" . "<td>" . $tplHelper->formatDate($spot['stamp'], 'spotlist') . "</td>"; # only display the NZB button from 24 nov or later if ($spot['stamp'] > 1290578400) { if ($settings['show_nzbbutton']) { echo "<td><a href='?page=getnzb&messageid=" . $spot['messageid'] . "' title ='Download NZB' class='nzb'>NZB"; if ($tplHelper->hasBeenDownloaded($spot)) { echo '*'; } # if echo "</a></td>"; } # if # display the sabnzbd button if (!empty($spot['sabnzbdurl'])) { //echo "<td><a target='_blank' href='" . $spot['sabnzbdurl'] . "' title='Voeg spot toe aan SabNZBd+ queue'><img height='16' width='16' class='sabnzbd-button' src='images/download-small.png'></a></td>"; echo "<td><a class='sabnzbd-button' target='_blank' href='" . $spot['sabnzbdurl'] . "' title='Add NZB to SabNZBd queue'><img height='16' width='16' class='sabnzbd-button' src='images/download-small.png'></a></td>";
$newSpotClass = ''; } # else if($tplHelper->isModerated($spot)) { $markSpot = '<span class="markSpot">!</span>'; } else { $markSpot = ''; } $subcatFilter = SpotCategories::SubcatToFilter($spot['category'], $spot['subcata']); $count++; echo "\t\t\t\t\t\t\t"; echo "<tr class='" . $tplHelper->cat2color($spot) . ' ' . ($count % 2 ? "even" : "odd") . "'>" . "<td class='category'><a href='?search[tree]=" . $subcatFilter . "' title='Ga naar de categorie \"" . SpotCategories::Cat2ShortDesc($spot['category'], $spot['subcata']) . "\"'>" . SpotCategories::Cat2ShortDesc($spot['category'], $spot['subcata']) . "</a></td>" . "<td class='title " . $newSpotClass . "'><a href='" . $tplHelper->makeSpotUrl($spot) . "' title='" . $spot['title'] . "' class='spotlink'>" . $spot['title'] . $markSpot . "</a></td>"; echo "<td class='watch'>"; if($tplHelper->isBeingWatched($spot)) { echo "<a onclick=\"removeWatchSpot('".$spot['messageid']."',".$spot['id'].")\" id='watched_".$spot['id']."'><img src='templates_we1rdo/img/fav.png' alt='Verwijder uit watchlist' title='Verwijder uit watchlist'/></a>"; echo "<a onclick=\"addWatchSpot('".$spot['messageid']."',".$spot['id'].")\" style='display: none;' id='watch_".$spot['id']."'><img src='templates_we1rdo/img/fav_light.png' alt='Plaats in watchlist' title='Plaats in watchlist' /></a>"; } else { echo "<a onclick=\"removeWatchSpot('".$spot['messageid']."',".$spot['id'].")\" style='display: none;' id='watched_".$spot['id']."'><img src='templates_we1rdo/img/fav.png' alt='Verwijder uit watchlist' title='Verwijder uit watchlist'/></a>"; echo "<a onclick=\"addWatchSpot('".$spot['messageid']."',".$spot['id'].")\" id='watch_".$spot['id']."'><img src='templates_we1rdo/img/fav_light.png' alt='Plaats in watchlist' title='Plaats in watchlist' /></a>"; } echo "</td>"; if ($settings['retrieve_comments']) { echo "<td class='comments'><a href='" . $tplHelper->makeSpotUrl($spot) . "#comments' title='" . $tplHelper->getCommentCount($spot) . " comments bij \"" . $spot['title'] . "\"' class='spotlink'>" . $tplHelper->getCommentCount($spot) . "</a></td>"; } # if
function render() { # Make sure the proper permissions are met $this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_view_spotdetail, ''); $this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_view_spots_index, ''); $this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_view_rssfeed, ''); $nzbhandling = $this->_currentSession['user']['prefs']['nzbhandling']; # Don't allow the RSS feed to be cached $this->sendExpireHeaders(true); /* * Transform the query parameters to a list of filters, fields, * sortings, etc. */ $svcUserFilter = new Services_User_Filters($this->_daoFactory, $this->_settings); $svcSearchQp = new Services_Search_QueryParser($this->_daoFactory->getConnection()); $parsedSearch = $svcSearchQp->filterToQuery($this->_params['search'], array('field' => $this->_params['sortby'], 'direction' => $this->_params['sortdir']), $this->_currentSession, $svcUserFilter->getIndexFilter($this->_currentSession['user']['userid'])); /* * Actually fetch the spots */ $pageNr = $this->_params['page']; $svcProvSpotList = new Services_Providers_SpotList($this->_daoFactory->getSpotDao()); $spotsTmp = $svcProvSpotList->fetchSpotList($this->_currentSession['user']['userid'], $pageNr, $this->_currentSession['user']['prefs']['perpage'], $parsedSearch); # Create an XML document for RSS $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); # Retrieve full spots so we can show images for spots etc. foreach ($spotsTmp['list'] as $spotHeaders) { try { $spot = $this->_tplHelper->getFullSpot($spotHeaders['messageid'], false); /* * We supress the error by using this ugly operator simply because the library * sometimes gives an notice and we cannot be bothered to fix it, but it does * give an incorrect and unusable RSS feed */ $spot = @$this->_tplHelper->formatSpot($spot); $title = str_replace(array('<', '>', '&'), array('<', '>', '&'), $spot['title']); $poster = empty($spot['spotterid']) ? $spot['poster'] : $spot['poster'] . " (" . $spot['spotterid'] . ")"; $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&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); } catch (Exception $x) { // Article not found. ignore. } # catch } # foreach # Output XML $this->sendContentTypeHeader('rss'); echo $doc->saveXML(); }
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('<', '>'), $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&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()
$selfUrl = htmlspecialchars($tplHelper->selfUrl()); $indexUrl = htmlspecialchars($tplHelper->changePage('index')); ?> <title>SpotWeb Spot overzicht</title> <link href="<?php echo $selfUrl ?>" rel="self" /> <link href="<?php echo $indexUrl ?>" rel="alternate" /> <id><?php echo $selfUrl?></id> <updated><?php echo date('c')?></updated> <generator>Spotweb</generator> <icon><?echo $baseUrl?>images/touch-icon-iphone4.png</icon> <?php foreach($spots as $spot): $spotLink = $tplHelper->spotUrl($spot); $id = 'tag:' . $tplHelper->host() . ',2011:spot/'. urlencode($spot['messageid']); $spot['description'] = @$tplHelper->formatDescription($spot['description']); ?> <entry> <title><?php echo htmlspecialchars($spot['title']) ?></title> <author><name><?php echo htmlspecialchars($spot['poster'])?></name></author> <link rel="alternate" type="text/html" href="<?php echo $spotLink ?>"/> <link rel="alternate" type="application/x-nzb" href="<?php echo $tplHelper->nzbUrl($spot)?>" title="NZB"/> <link rel="related" type="text/html" href="<?php echo htmlspecialchars($spot['website'])?>" /> <id><?php echo $id ?></id> <published><? echo date('c', $spot['stamp'])?></published> <updated><? echo date('c', $spot['stamp'])?></updated> <category label="<?echo SpotCategories::HeadCat2Desc($spot['category'])?>" term="cat<?echo $spot['category']?>"/> <category label="<?echo SpotCategories::Cat2ShortDesc($spot['category'],$spot['subcat'])?>" term="<?echo SpotCategories::SubcatToFilter($spot['category'],$spot['subcat'])?>"/> <content type="html"><![CDATA[<?php echo $spot['description']?><br/><img src="<?php echo $spot['image'] ?>"/>]]></content> </entry> <?php endforeach; ?> </feed>
function showResults($spots, $offset, $outputtype) { $nzbhandling = $this->_currentSession['user']['prefs']['nzbhandling']; if ($outputtype == "json") { echo json_encode($spots); //TODO:make that a more specific array of data to return rather than resultset } else { # 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'); $rss->setAttribute('xmlns:newznab', 'http://www.newznab.com/DTD/2010/feeds/attributes/'); $doc->appendChild($rss); $atomSelfLink = $doc->createElement('atom:link'); $atomSelfLink->setAttribute('href', $this->_settings->get('spotweburl') . 'api'); $atomSelfLink->setAttribute('rel', 'self'); $atomSelfLink->setAttribute('type', 'application/rss+xml'); $channel = $doc->createElement('channel'); $channel->appendChild($atomSelfLink); $channel->appendChild($doc->createElement('title', 'Spotweb Index')); $channel->appendChild($doc->createElement('description', 'Spotweb Index API Results')); $channel->appendChild($doc->createElement('link', $this->_settings->get('spotweburl'))); $channel->appendChild($doc->createElement('language', 'en-gb')); $channel->appendChild($doc->createElement('webMaster', $this->_currentSession['user']['mail'] . ' (' . $this->_currentSession['user']['firstname'] . ' ' . $this->_currentSession['user']['lastname'] . ')')); $channel->appendChild($doc->createElement('category', '')); $rss->appendChild($channel); $image = $doc->createElement('image'); $image->appendChild($doc->createElement('url', $this->_settings->get('spotweburl') . 'images/spotnet.gif')); $image->appendChild($doc->createElement('title', 'Spotweb Index')); $image->appendChild($doc->createElement('link', $this->_settings->get('spotweburl'))); $image->appendChild($doc->createElement('description', 'SpotWeb Index API Results')); $channel->appendChild($image); $newznabResponse = $doc->createElement('newznab:response'); $newznabResponse->setAttribute('offset', $offset); $newznabResponse->setAttribute('total', count($spots['list'])); $channel->appendChild($newznabResponse); foreach($spots['list'] as $spot) { $spot = $this->_tplHelper->formatSpotHeader($spot); $title = preg_replace(array('/</', '/>/'), array('<', '>'), $spot['title']); $guid = $doc->createElement('guid', $spot['messageid']); $guid->setAttribute('isPermaLink', 'false'); $item = $doc->createElement('item'); $item->appendChild($doc->createElement('title', $title)); $item->appendChild($guid); $item->appendChild($doc->createElement('link', $this->_tplHelper->makeNzbUrl($spot))); $item->appendChild($doc->createElement('pubDate', date('r', $spot['stamp']))); $item->appendChild($doc->createElement('category', SpotCategories::HeadCat2Desc($spot['category']) . " > " . SpotCategories::Cat2ShortDesc($spot['category'], $spot['subcata']))); $channel->appendChild($item); $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); $nabCat = explode("|", $this->Cat2NewznabCat($spot['category'], $spot['subcata'])); if ($nabCat[0] != "" && is_numeric($nabCat[0])) { $attr = $doc->createElement('newznab:attr'); $attr->setAttribute('name', 'category'); $attr->setAttribute('value', $nabCat[0]); $item->appendChild($attr); $attr = $doc->createElement('newznab:attr'); $attr->setAttribute('name', 'category'); $attr->setAttribute('value', $nabCat[1]); $item->appendChild($attr); } # if $nabCat = explode("|", $this->Cat2NewznabCat($spot['category'], $spot['subcatb'])); if ($nabCat[0] != "" && is_numeric($nabCat[0])) { $attr = $doc->createElement('newznab:attr'); $attr->setAttribute('name', 'category'); $attr->setAttribute('value', $nabCat[0]); $item->appendChild($attr); } $attr = $doc->createElement('newznab:attr'); $attr->setAttribute('name', 'size'); $attr->setAttribute('value', $spot['filesize']); $item->appendChild($attr); if ($this->_params['extended'] != "0") { $attr = $doc->createElement('newznab:attr'); $attr->setAttribute('name', 'poster'); $attr->setAttribute('value', $spot['poster'] . '@spot.net'); $item->appendChild($attr); $attr = $doc->createElement('newznab:attr'); $attr->setAttribute('name', 'comments'); $attr->setAttribute('value', $spot['commentcount']); $item->appendChild($attr); } # if } # foreach header('Content-Type: text/xml; charset=UTF-8'); echo $doc->saveXML(); } } # showResults
function formatSpot($spot, $comments) { # fix the sabnzbdurl en searchurl $spot['sabnzbdurl'] = $this->makeSabnzbdUrl($spot); $spot['searchurl'] = $this->makeSearchUrl($spot); // Category is altijd een integer bij ons $spot['category'] = (int) $spot['category']; // Geen website? Dan standaard naar de zoekmachine if (empty($spot['website'])) { $spot['website'] = $this->makeSearchUrl($spot); } # if // geef de category een fatsoenlijke naam $spot['catname'] = SpotCategories::HeadCat2Desc($spot['category']); $spot['formatname'] = SpotCategories::Cat2ShortDesc($spot['category'], $spot['subcata']); // properly escape sevreal urls if (!is_array($spot['image'])) { $spot['image'] = htmlentities($spot['image']); } else { $spot['image'] = ''; } # else $spot['website'] = htmlentities($spot['website']); $spot['poster'] = htmlentities(strip_tags($spot['poster']), ENT_QUOTES); $spot['tag'] = htmlentities(strip_tags($spot['tag'])); // title escapen $spot['title'] = htmlentities(strip_tags($spot['title']), ENT_QUOTES); // description $spot['description'] = htmlentities(strip_tags($this->formatDescription($spot['description'])), ENT_QUOTES); // escape de HTML voor de comments $commentCount = count($comments); for ($i = 0; $i < $commentCount; $i++) { $comments[$i]['body'] = array_map('strip_tags', $comments[$i]['body']); } # for return array($spot, $comments); }
<?php } ?> <th class='delete'> DEL </th> </tr> <?php foreach ($watchlist as $watch) { $watch['sabnzbdurl'] = $tplHelper->makeSabnzbdUrl($watch); $watch['searchurl'] = $tplHelper->makeSearchUrl($watch); if ($tplHelper->isModerated($watch)) { $markSpot = '<span class="markSpot">!</span>'; } else { $markSpot = ''; } echo "<tr class='" . $tplHelper->cat2color($watch) . "'>" . "<td class='category'><a href='?search[tree]=" . $subcatFilter . "' title='Ga naar de categorie \"" . SpotCategories::Cat2ShortDesc($watch['category'], $watch['subcata']) . "\"'>" . SpotCategories::Cat2ShortDesc($watch['category'], $watch['subcata']) . "</a></td>" . "<td class='title " . $newSpotClass . "'><a href='" . $tplHelper->makeSpotUrl($watch) . "' title='" . $watch['title'] . "' class='spotlink'>" . $watch['title'] . $markSpot . "</a></td>"; if ($settings['retrieve_comments']) { echo "<td class='comments'><a href='" . $tplHelper->makeSpotUrl($watch) . "#comments' title='" . $tplHelper->getCommentCount($watch) . " comments bij \"" . $watch['title'] . "\"' class='spotlink'>" . $tplHelper->getCommentCount($watch) . "</a></td>"; } # if echo "<td>" . SpotCategories::Cat2Desc($watch['category'], $watch['subcat' . SpotCategories::SubcatNumberFromHeadcat($watch['category'])]) . "</td>" . "<td>" . $watch['poster'] . "</td>" . "<td>" . $tplHelper->formatDate($watch['stamp'], 'spotlist') . "</td>"; # only display the NZB button from 24 nov or later if ($watch['stamp'] > 1290578400) { if ($settings['show_nzbbutton']) { echo "<td><a href='" . $tplHelper->makeNzbUrl($watch) . "' title ='Download NZB' class='nzb'>NZB"; if ($tplHelper->hasBeenDownloaded($watch)) { echo '*'; } # if echo "</a></td>"; $multispotid = htmlspecialchars($watch['messageid']);
function formatSpot($spot) { # formatteer de spot $spot = $this->formatSpotHeader($spot); // Category is altijd een integer bij ons $spot['category'] = (int) $spot['category']; // Geen website? Dan standaard naar de zoekmachine if (empty($spot['website'])) { $spot['website'] = $this->makeSearchUrl($spot); } # if // geef de category een fatsoenlijke naam $spot['catname'] = SpotCategories::HeadCat2Desc($spot['category']); $spot['formatname'] = SpotCategories::Cat2ShortDesc($spot['category'], $spot['subcata']); // properly escape several urls if (!is_array($spot['image'])) { $spot['image'] = htmlspecialchars($spot['image']); } # if $spot['website'] = htmlspecialchars($spot['website']); $spot['tag'] = htmlspecialchars(strip_tags($spot['tag']), ENT_QUOTES, 'UTF-8'); // description $spot['description'] = $this->formatContent($spot['description']); return $spot; }
function spotDetails($outputtype) { if (empty($this->_params['messageid'])) { $this->showApiError(200); } # if # Controleer de users' rechten $this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_view_spotdetail, ''); # spot ophalen try { $fullSpot = $this->_tplHelper->getFullSpot($this->_params['messageid'], true); } catch (Exception $x) { $this->showApiError(300); } # catch $nzbhandling = $this->_currentSession['user']['prefs']['nzbhandling']; # 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 onbruikbaar resultaat oplevert $spot = @$this->_tplHelper->formatSpot($fullSpot); if ($outputtype == "json") { $doc = array(); $doc['ID'] = $spot['id']; $doc['name'] = $spot['title']; $doc['size'] = $spot['filesize']; $doc['adddate'] = date('Y-m-d H:i:s', $spot['stamp']); $doc['guid'] = $spot['messageid']; $doc['fromname'] = $spot['poster']; $doc['completion'] = 100; $nabCat = explode("|", $this->Cat2NewznabCat($spot['category'], $spot['subcata'])); if ($nabCat[0] != "" && is_numeric($nabCat[0])) { $doc['categoryID'] = $nabCat[0]; $cat = implode(",", $nabCat); } # if $nabCat = explode("|", $this->Cat2NewznabCat($spot['category'], $spot['subcatb'])); if ($nabCat[0] != "" && is_numeric($nabCat[0])) { $cat .= "," . $nabCat[0]; } # if $doc['comments'] = $spot['commentcount']; $doc['category_name'] = SpotCategories::HeadCat2Desc($spot['category']) . ': ' . SpotCategories::Cat2ShortDesc($spot['category'], $spot['subcata']); $doc['category_ids'] = $cat; echo json_encode($doc); } else { $nzbUrl = $this->_tplHelper->makeBaseUrl("full") . 'api?t=g&id=' . $spot['messageid'] . $this->_tplHelper->makeApiRequestString(); # 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'); $rss->setAttribute('xmlns:newznab', 'http://www.newznab.com/DTD/2010/feeds/attributes/'); $rss->setAttribute('encoding', 'utf-8'); $doc->appendChild($rss); $channel = $doc->createElement('channel'); $channel->appendChild($doc->createElement('title', 'Spotweb')); $channel->appendChild($doc->createElement('language', 'nl')); $channel->appendChild($doc->createElement('description', 'Spotweb Index Api Detail')); $channel->appendChild($doc->createElement('link', $this->_settings->get('spotweburl'))); $channel->appendChild($doc->createElement('webMaster', $this->_currentSession['user']['mail'] . ' (' . $this->_currentSession['user']['firstname'] . ' ' . $this->_currentSession['user']['lastname'] . ')')); $channel->appendChild($doc->createElement('category', '')); $rss->appendChild($channel); $image = $doc->createElement('image'); $image->appendChild($doc->createElement('url', $this->_tplHelper->makeImageUrl($spot, 300, 300))); $image->appendChild($doc->createElement('title', 'Spotweb Index')); $image->appendChild($doc->createElement('link', $this->_settings->get('spotweburl'))); $image->appendChild($doc->createElement('description', 'Visit Spotweb Index')); $channel->appendChild($image); $title = preg_replace(array('/</', '/>/'), array('<', '>'), $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', $nzbUrl)); $item->appendChild($doc->createElement('pubDate', date('r', $spot['stamp']))); $item->appendChild($doc->createElement('category', SpotCategories::HeadCat2Desc($spot['category']) . " > " . SpotCategories::Cat2ShortDesc($spot['category'], $spot['subcata']))); $item->appendChild($description); $channel->appendChild($item); $enclosure = $doc->createElement('enclosure'); $enclosure->setAttribute('url', html_entity_decode($nzbUrl)); $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); $nabCat = explode("|", $this->Cat2NewznabCat($spot['category'], $spot['subcata'])); if ($nabCat[0] != "" && is_numeric($nabCat[0])) { $attr = $doc->createElement('newznab:attr'); $attr->setAttribute('name', 'category'); $attr->setAttribute('value', $nabCat[0]); $item->appendChild($attr); $attr = $doc->createElement('newznab:attr'); $attr->setAttribute('name', 'category'); $attr->setAttribute('value', $nabCat[1]); $item->appendChild($attr); } # if $nabCat = explode("|", $this->Cat2NewznabCat($spot['category'], $spot['subcatb'])); if ($nabCat[0] != "" && is_numeric($nabCat[0])) { $attr = $doc->createElement('newznab:attr'); $attr->setAttribute('name', 'category'); $attr->setAttribute('value', $nabCat[0]); $item->appendChild($attr); } # if $attr = $doc->createElement('newznab:attr'); $attr->setAttribute('name', 'size'); $attr->setAttribute('value', $spot['filesize']); $item->appendChild($attr); $attr = $doc->createElement('newznab:attr'); $attr->setAttribute('name', 'poster'); $attr->setAttribute('value', $spot['poster'] . '@spot.net (' . $spot['poster'] . ')'); $item->appendChild($attr); $attr = $doc->createElement('newznab:attr'); $attr->setAttribute('name', 'comments'); $attr->setAttribute('value', $spot['commentcount']); $item->appendChild($attr); header('Content-Type: text/xml; charset=UTF-8'); echo $doc->saveXML(); } # if }
function formatSpot($spot) { # formatteer de spot $spot = $this->formatSpotHeader($spot); // Category is altijd een integer bij ons $spot['category'] = (int) $spot['category']; // Geen website? Dan standaard naar de zoekmachine if (empty($spot['website'])) { $spot['website'] = $this->makeSearchUrl($spot); } # if // geef de category een fatsoenlijke naam $spot['catname'] = SpotCategories::HeadCat2Desc($spot['category']); $spot['formatname'] = SpotCategories::Cat2ShortDesc($spot['category'], $spot['subcata']); // properly escape several urls if (!is_array($spot['image'])) { $spot['image'] = htmlspecialchars($spot['image']); } # if $spot['website'] = htmlspecialchars($spot['website']); $spot['tag'] = htmlspecialchars(strip_tags($spot['tag']), ENT_QUOTES, 'UTF-8'); // description $spot['description'] = $this->formatContent($spot['description']); // Stripped stuff like 'Subs by:..., -releasegroup, mpg, hd, subs, nlsubs, r1.hdtv.blabla, etc. for the usage of (the imdb) api('s). // After that it wil remove the spaces left behind, replacing them with only one space. // It will probably not filter all but it will filter a lot. // It will only filter cat0 (beeld). if ($spot['category'] == 0) { $spot['cleantitle'] = preg_replace('/(([Ss][uU][Bb][Ss]) ([Mm][Aa][Dd][Ee]\\s)?([bB][yY])\\s?:?.{0,15}\\S)|(~.+~)|' . '( \\S{2,}( ?/ ?\\S{2,})+)|(\\*+.+\\*+)|(-=?.{0,10}=?-)|(\\d{3,4}[pP])|([Hh][Qq])|' . '(\\(\\w+(\\s\\w+)?\\))|(\\S*([Ss][Uu][Bb](([Ss])|([Bb][Ee][Dd])))\\S*)|((-\\S+)$)|' . '([Nn][Ll])|([\\s\\/][Ee][Nn][Gg]?[\\s\\/])|(AC3)|(DD(5.1)?)|([Xx][Vv][Ii][Dd])|' . '([Dd][Ii][Vv][Xx])|([Tt][Ss])|(\\d+\\s([Mm]|[Kk]|[Gg])[Bb])|([Mm][Kk][Vv])|' . '([xX]\\d{3}([Hh][Dd])?)|([Dd][Ll])|([Bb][Ll][Uu]([Ee])?\\s?-?[Rr][Aa][Yy])|' . '([Rr][Ee][Aa][Dd]\\s?[Nn][Ff][Oo])|(([Hh][Dd])([Tt][Vv])?)|(R\\d)|(S\\d+E\\d+)|' . '(2[Hh][Dd])|(5 1)|([Dd][Tt][Ss]-?[Hh][Dd])|([Aa][Vv][Cc])|' . '(([Bb][Dd])?[Rr][Ee][Mm][Uu][Xx])|([Nn][Tt][Ss][Cc])|([Pp][Aa][Ll])|' . '(\\S+(\\.\\S+)+)|([Cc][Uu][Ss][Tt][Oo][Mm])|([Mm][Pp][Ee]?[Gg]-([Hh][Dd])?)/', "", $spot['title']); $spot['cleantitle'] = preg_replace('/ {2,}/', " ", $spot['cleantitle']); $spot['cleantitle'] = preg_replace('\\s', "", $spot['cleantitle']); if (empty($spot['cleantitle'])) { // Use $spot['title'] if my regex screws up.. $spot['cleantitle'] = $spot['title']; } # if } else { // Prevent gigantic failures from happening. $spot['cleantitle'] = $spot['title']; } return $spot; }
<?php $count = 0; foreach ($spots as $spot) { # Format the spot header $spot = $tplHelper->formatSpotHeader($spot); if ($tplHelper->newSinceLastVisit($spot)) { $newSpotClass = 'new'; } else { $newSpotClass = ''; } # else $subcatFilter = SpotCategories::SubcatToFilter($spot['category'], $spot['subcata']); $count++; echo "\t\t\t\t\t\t\t"; echo "<tr class='" . $tplHelper->cat2color($spot) . ' ' . ($count % 2 ? "even" : "odd") . $spot['subcata'] . $spot['subcatb'] . $spot['subcatc'] . $spot['subcatd'] . "'>" . "<td class='category'><a href='?search[tree]=" . $subcatFilter . "' title='Ga naar de categorie \"" . SpotCategories::Cat2ShortDesc($spot['category'], $spot['subcata']) . "\"'>" . SpotCategories::Cat2ShortDesc($spot['category'], $spot['subcata']) . "</a></td>" . "<td class='title " . $newSpotClass . "'><a href='?page=getspot&messageid=" . $spot['messageid'] . "' title='" . utf8_encode($spot['title']) . "' class='spotlink'>" . utf8_encode($spot['title']) . "</a></td>"; if ($settings['retrieve_comments']) { echo "<td class='comments'><a href='?page=getspot&messageid=" . $spot['messageid'] . "#comments' title='" . $tplHelper->getCommentCount($spot) . " comments bij \"" . $spot['title'] . "\"' class='spotlink'>" . $tplHelper->getCommentCount($spot) . "</a></td>"; } echo "<td>" . SpotCategories::Cat2Desc($spot['category'], $spot['subcat' . SpotCategories::SubcatNumberFromHeadcat($spot['category'])]) . "</td>" . "<td>" . $spot['poster'] . "</td>" . "<td>" . $tplHelper->formatDate($spot['stamp'], 'spotlist') . "</td>"; # only display the NZB button from 24 nov or later if ($spot['stamp'] > 1290578400) { if ($settings['show_nzbbutton']) { echo "<td><a href='?page=getnzb&messageid=" . $spot['messageid'] . "' title ='Download NZB' class='nzb'>NZB"; if ($tplHelper->hasBeenDownloaded($spot)) { echo '*'; } # if echo "</a></td>"; } # if
if ($show_watchlist_button) { ?> <th class='watch'></th> <?php } ?> </tr> <?php $count = 0; foreach($spots as $spot) { # Format the spot header $spot = $tplHelper->formatSpotHeader($spot); $newSpotClass = ($tplHelper->isSpotNew($spot)) ? 'new' : ''; $count++; echo "\t\t\t\t\t\t\t"; echo "<tr class='" . $tplHelper->cat2color($spot) . ' ' . ($count % 2 ? "even" : "odd") . $spot['subcata'].$spot['subcatb'].$spot['subcatc'].$spot['subcatd']."'>" . "<td class='category'><a href='" . $spot['caturl'] . "' title='Ga naar de categorie \"" . SpotCategories::Cat2ShortDesc($spot['category'], $spot['subcata']) . "\"'>" . SpotCategories::Cat2ShortDesc($spot['category'], $spot['subcata']) . "</a></td>" . "<td class='title " . $newSpotClass . "'><a href='?page=getspot&messageid=" . $spot['messageid'] . "' title='" . utf8_encode($tplHelper->remove_extensive_dots($spot['title'])) . "' class='spotlink'>" . utf8_encode($tplHelper->remove_extensive_dots($spot['title'])) . "</a></td>"; if($settings->get('retrieve_comments')) echo "<td class='comments'><a href='?page=getspot&messageid=" . $spot['messageid'] . "#comments' title='" . $spot['commentcount'] . " comments bij \"" . $spot['title'] . "\"' class='spotlink'>" . $spot['commentcount'] . "</a></td>"; echo "<td>" . SpotCategories::Cat2Desc($spot['category'], $spot['subcat' . SpotCategories::SubcatNumberFromHeadcat($spot['category'])]) . "</td>" . "<td>" . $spot['poster'] . "</td>" . "<td>" . $tplHelper->formatDate($spot['stamp'], 'spotlist') . "</td>"; # only display the NZB button from 24 nov or later if ($spot['stamp'] > 1290578400) { if ($show_nzb_button) { echo "<td><a href='?page=getnzb&messageid=" . $spot['messageid'] . "' title ='Download NZB' class='nzb'>NZB"; if ($spot['hasbeendownloaded']) {