$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 parseXover($subj, $from, $date, $messageid, $rsaKeys) { // initialiseer wat variabelen $spot = array(); /* * De "From" header is als volgt opgebouwd: * * From: [Nickname] <[RANDOM or PUBLICKEY]@[CAT][KEY-ID][SUBCAT].[SIZE].[RANDOM].[DATE].[CUSTOM-ID].[CUSTOM-VALUE].[SIGNATURE]> * * We willen nu alles extracten wat achter de '@' staat, maar omdat een nickname theoretisch ook een @ kan bevatten * doen we eerst wat meer moeite */ $fromInfoPos = strpos($from, '<'); if ($fromInfoPos === false) { return false; } else { # Haal de postername en de <>'s weg $fromAddress = explode('@', substr($from, $fromInfoPos + 1, -1)); if (count($fromAddress) < 2) { return false; } # if $spot['selfsignedpubkey'] = $this->unSpecialString($fromAddress[0]); $spot['header'] = $fromAddress[1]; } # if /* * Initialiseer wat basis variabelen, doordat we verified op false zetten * zal de spot altijd nog genegeerd worden ook al geven we nu de spot array * terug */ $spot['verified'] = false; $spot['filesize'] = 0; $spot['messageid'] = substr($messageid, 1, strlen($messageid) - 2); $spot['stamp'] = strtotime($date); /* * Breek de .-delimited velden op in een array zodat we er makkelijker wat * mee kunnen doen. We hebben tenminste 6 velden nodig, anders is de spot * sowieso ongeldig. Meer velden kan (zie spec) */ $fields = explode('.', $spot['header']); if (count($fields) < 6) { return false; } # if /* * De velden die voor het oprapen liggen, halen we nu ook op */ $spot['poster'] = substr($from, 0, $fromInfoPos - 1); $spot['category'] = substr($fields[0], 0, 1) - 1.0; $spot['keyid'] = (int) substr($fields[0], 1, 1); $spot['filesize'] = $fields[1]; $spot['subcata'] = ''; $spot['subcatb'] = ''; $spot['subcatc'] = ''; $spot['subcatd'] = ''; $spot['subcatz'] = ''; $isRecentKey = $spot['keyid'] != 1; /* * Als er sowieso geen geldige keyid is, is de spot ook ongeldig */ if ($spot['keyid'] < 0) { return false; } # if /* * De lijst met subcategorieen is opgebouwd afhankelijk van hoe recent de spot is. * * FTD spots zetten alle subcategorieen gewoon achter elkaar, dus bv: a9b4c0d5d15d11 * nieuwere spots reserveren steeds 3 karakters voor elke categorie, dus: a09b04c00d05d15d11. * * Omdat beide feitelijk dezelfde karakteristieken hebben, parseren we die op dezelfde * manier. We voegen aan de $strCatLis een extra token toe zodat de laatste categorie ook geparsd * kan worden. We voegen drie karakters toe zodat een eventuele sanitycheck (strlen() % 3 = 0) nog * zou valideren. */ $strCatList = strtolower(substr($fields[0], 2)) . '!!!'; $strCatListLen = strlen($strCatList); /* * We initialiseren wat tijdelijke variables zodat we hier de sanity checking * kunnen doen */ $validSubcats = array('a' => true, 'b' => true, 'c' => true, 'd' => true, 'z' => true); $tmpCatBuild = ''; /* Probeer nu alle subcategorieen te extracten */ for ($i = 0; $i < $strCatListLen; $i++) { # Als het huidige karakter geen getal is, dan hebben we de volgende # categorie gevonden, voeg die toe aan de lijst met categorieen if (!is_numeric($strCatList[$i]) && !empty($tmpCatBuild)) { if (isset($validSubcats[$tmpCatBuild[0]])) { $spot['subcat' . $tmpCatBuild[0]] .= $tmpCatBuild[0] . (int) substr($tmpCatBuild, 1) . '|'; } # if $tmpCatBuild = ''; } # if $tmpCatBuild .= $strCatList[$i]; } # for # We vullen hier de z categorieen alvast op in het geval er geen Z category gegeven is if (empty($spot['subcatz'])) { $spot['subcatz'] = SpotCategories::createSubcatz($spot['category'], $spot['subcata'] . $spot['subcatb'] . $spot['subcatd']); } # if if (strpos($subj, '=?') !== false && strpos($subj, '?=') !== false) { # Make sure its as simple as possible $subj = str_replace('?= =?', '?==?', $subj); $subj = str_replace('\\r', '', trim($this->oldEncodingParse($subj))); $subj = str_replace('\\n', '', $subj); } # if if ($isRecentKey) { $tmp = explode('|', $subj); $spot['title'] = trim($tmp[0]); if (count($tmp) > 1) { $spot['tag'] = trim($tmp[1]); } else { $spot['tag'] = ''; } # else } else { $tmp = explode('|', $subj); if (count($tmp) <= 1) { $tmp = array($subj); } # if $spot['tag'] = trim($tmp[count($tmp) - 1]); # remove the tags from the array array_pop($tmp); array_pop($tmp); $spot['title'] = trim(implode('|', $tmp)); if (strpos($spot['title'], chr(0xc2)) !== false | strpos($spot['title'], chr(0xc3)) !== false) { $spot['title'] = trim($this->oldEncodingParse($spot['title'])); } # if } # if recentKey # Een title en poster zijn verplicht, anders kan de signature niet gechecked worden if (strlen($spot['title']) == 0 || strlen($spot['poster']) == 0) { return $spot; } # if # Als er een recentkey is (key <> 1), OF de spot is na 2010 geplaatst, dan moet # de spot gesigned zijn. $mustbeSigned = $isRecentKey | $spot['stamp'] > 1293870080; if ($mustbeSigned) { $spot['headersign'] = $fields[count($fields) - 1]; if (strlen($spot['headersign']) != 0) { $spot['wassigned'] = true; # KeyID 7 betekent dat een hashcash vereist is if ($spot['keyid'] == 7) { $userSignedHash = sha1('<' . $spot['messageid'] . '>', false); $spot['verified'] = substr($userSignedHash, 0, 3) == '0000'; /* * Create a fake RSA keyarray so we can validate it using our standard * infrastructure */ if ($spot['verified']) { /* Not sure about this $userRsaKey = array(7 => array('modulo' => $spot['selfsignedpubkey'], 'exponent' => 'AQAB')); $spot['verified'] = $this->_spotSigning->verifySpotHeader($spot, $signature, $userRsaKey); */ } # if } else { # the signature this header is signed with $signature = $this->unspecialString($spot['headersign']); $spot['verified'] = $this->_spotSigning->verifySpotHeader($spot, $signature, $rsaKeys); } # else } # if } else { $spot['verified'] = true; $spot['wassigned'] = false; } # if doesnt need to be signed, pretend that it is # Nu zetten we de titel en dergelijke om naar utf8, we kunnen # dat niet eerder doen omdat anders de RSA signature niet meer # klopt. if ($spot !== false && $spot['verified']) { $spot['title'] = utf8_encode($spot['title']); $spot['poster'] = utf8_encode($spot['poster']); $spot['tag'] = utf8_encode($spot['tag']); # als de spot in de toekomst ligt, dan corrigeren we dat naar nu if (time() < $spot['stamp']) { $spot['stamp'] = time(); } # if } # if return $spot; }
<?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']); echo "<td>"; echo "<input type='checkbox' name='" . htmlspecialchars('messageid[]') . "' value='" . $multispotid . "'>"; echo "</td>"; } # if
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 }
<tr><th> Categorie </th> <td><a href="<?php echo $tplHelper->makeCatUrl($spot); ?> " title='Zoek spots in de categorie "<?php echo $spot['catname']; ?> "'><?php echo $spot['catname']; ?> </a></td> </tr> <?php if (!empty($spot['subcatlist'])) { foreach ($spot['subcatlist'] as $sub) { $subcatType = substr($sub, 0, 1); echo "\t\t\t\t\t\t<tr><th> " . SpotCategories::SubcatDescription($spot['category'], $subcatType) . "</th>"; echo "<td><a href='" . $tplHelper->makeSubCatUrl($spot, $sub) . "' title='Zoek spots in de categorie " . SpotCategories::Cat2Desc($spot['category'], $sub) . "'>" . SpotCategories::Cat2Desc($spot['category'], $sub) . "</a></td> </tr>\r\n"; } # foreach } # if ?> <tr><th> Omvang </th> <td> <?php echo $tplHelper->format_size($spot['filesize']); ?> </td> </tr> <tr><td class="break" colspan="2"> </td> </tr> <tr><th> Website </th> <td> <a href='<?php echo $spot['website']; ?> '><?php echo $spot['website'];
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(); }
<?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>";
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 }
public static function startTranslation() { /* * Make sure we only translate once */ if (self::$_namesTranslated) { return; } # if self::$_namesTranslated = true; # Translate the head categories foreach (self::$_head_categories as $key => $value) { self::$_head_categories[$key] = _($value); # Translate the subcat descriptions foreach (self::$_subcat_descriptions[$key] as $subkey => $subvalue) { self::$_subcat_descriptions[$key][$subkey] = _($subvalue); } # foreach # Translate the shortcat descriptions foreach (self::$_shortcat[$key] as $subkey => $subvalue) { self::$_shortcat[$key][$subkey] = _($subvalue); } # foreach # and translate the actual categories foreach (self::$_categories[$key] as $subkey => $subvalue) { foreach (self::$_categories[$key][$subkey] as $subsubkey => $subsubvalue) { if (is_array($subsubvalue)) { self::$_categories[$key][$subkey][$subsubkey][0] = _($subsubvalue[0]); } else { self::$_categories[$key][$subkey][$subsubkey] = _($subsubvalue); } # else } # foreach } # foreach } # foreach }
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; }
" title='<?php echo _('Find spots in this category'); ?> "<?php echo $spot['catname']; ?> "'><?php echo $spot['catname']; ?> </a></td> </tr> <?php if (!empty($spot['subcatlist'])) { foreach ($spot['subcatlist'] as $sub) { $subcatType = substr($sub, 0, 1); echo "\t\t\t\t\t\t<tr><th> " . SpotCategories::SubcatDescription($spot['category'], $subcatType) . "</th>"; echo "<td><a href='" . $tplHelper->makeSubCatUrl($spot, $sub) . "' title='" . _('Find spots in this category') . ' ' . SpotCategories::Cat2Desc($spot['category'], $sub) . "'>" . SpotCategories::Cat2Desc($spot['category'], $sub) . "</a></td> </tr>\r\n"; } # foreach } # if ?> <tr><th> <?php echo _('Date'); ?> </th> <td title='<?php echo $tplHelper->formatDate($spot['stamp'], 'force_spotlist'); ?> '> <?php echo $tplHelper->formatDate($spot['stamp'], 'spotdetail'); ?> </td> </tr>
$spot = $tplHelper->formatSpotHeader($spot); $newSpotClass = $tplHelper->isSpotNew($spot) ? 'new' : ''; $tipTipClass = $show_mouseover_subcats ? 'showTipTip' : ''; $dateTitleText = $tplHelper->formatDate($spot['stamp'], 'force_spotlist'); $commentCountValue = $spot['commentcount']; if (isset($newCommentCount[$spot['messageid']])) { $commentCountValue .= '*'; } # if $catMap = array(); foreach (array('a', 'b', 'c', 'd', 'z') as $subcatType) { $subList = explode('|', $spot['subcat' . $subcatType]); foreach ($subList as $sub) { if (!empty($sub)) { $subCatDesc = SpotCategories::SubcatDescription($spot['category'], $subcatType); $catDesc = SpotCategories::Cat2Desc($spot['category'], $sub); if (isset($catMap[$subCatDesc])) { $catMap[$subCatDesc] .= ', ' . $catDesc; } else { $catMap[$subCatDesc] = $catDesc; } # else } # if } # foreach } # foreach if ($settings->get('imageover_subcats') > 0) { $catMap['image'] = '<center><br><img src="?page=getimage&messageid=' . $spot['messageid'] . '&image[height]=260&image[width]=130" height="175px" width="auto"></center>'; }
private function createStatsPerCategory($dateLimit) { $title = $this->makeTitle('spotspercategory', $dateLimit); $prepData = $this->getStatisticsData('spotspercategory', $dateLimit); $legend = array(_(SpotCategories::HeadCat2Desc(0)), _(SpotCategories::HeadCat2Desc(1)), _(SpotCategories::HeadCat2Desc(2)), _(SpotCategories::HeadCat2Desc(3))); return $this->_svcImageChart->renderChart('3Dpie', $title, $prepData, $legend); }
<?php if (isset($settings['sabnzbd']['apikey'])) { ?> <th> sabnzbd </th> <?php } ?> </tr> <?php $count = 0; foreach ($spots as $spot) { $count++; echo "\t\t\t\t\t"; echo "<tr class='" . ($count % 2 ? "even" : "odd") . "' >" . "<td>" . SpotCategories::Cat2Desc($spot['category'], $spot['subcata']) . "</td>" . "<td>" . SpotCategories::HeadCat2Desc($spot['category']) . "</td>" . "<td><a href='?page=getspot&messageid=" . $spot['messageid'] . "'>" . $spot['title'] . "</a></td>" . "<td>" . SpotCategories::Cat2Desc($spot['category'], $spot['subcat' . SpotCategories::SubcatNumberFromHeadcat($spot['category'])]) . "</td>" . "<td>" . $spot['poster'] . "</td>" . "<td>" . strftime("%a, %d-%b-%Y (%H:%M)", $spot['stamp']) . "</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'] . "'>NZB</a></td>"; } # if # display the sabnzbd button if (!empty($spot['sabnzbdurl'])) { echo "<td><a target='_blank' href='" . $spot['sabnzbdurl'] . "' ><img height='16 widt='16' class='sabnzbd-button' src='images/download-small.png'></a></td>"; } # if } else { if ($settings['show_nzbbutton']) { echo "<td> </td>"; }
} # if SpotTiming::stop('auth'); /* * And check if the security groups need updating */ if (!$currentSession['security']->securityValid()) { throw new SecurityNotUpgradedException(); } # if # User session has been loaded, let's translate the categories if ($currentSession['user']['prefs']['user_language'] != 'en_US') { SpotTranslation::initialize($currentSession['user']['prefs']['user_language']); } # if SpotCategories::startTranslation(); /* * Let the form handler know what userid we are using so * we can make the CSRF cookie be user-bounded */ $req->setUserId($currentSession['user']['userid']); /* * Only now it is safe to check wether the user is actually alowed * to authenticate with an API key */ if ($req->doesExist('apikey')) { /* * To use the Spotweb API we need the actual permission */ $currentSession['security']->fatalPermCheck(SpotSecurity::spotsec_consume_api, ''); /*
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 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 parseXover($subj, $from, $date, $messageid, $rsakeys) { $_CAT = 0; $_FSIZE = 1; // initialiseer wat variabelen $spot = array(); // Eerst splitsen we de header string op in enkel de category info e.d. $fromInfoPos = strpos($from, '<'); if ($fromInfoPos === false) { return false; } else { # Haal de postername en de <>'s weg $fromAddress = explode('@', substr($from, $fromInfoPos + 1, -1)); if (count($fromAddress) < 2) { return false; } # if $spot['header'] = $fromAddress[1]; } # if $spot['verified'] = false; $spot['filesize'] = 0; $spot['messageid'] = substr($messageid, 1, strlen($messageid) - 2); # als de spot in de toekomst ligt, dan corrigeren we dat naar nu if (time() < strtotime($date)) { $spot['stamp'] = time(); } else { $spot['stamp'] = strtotime($date); } # if $fields = explode('.', $spot['header']); if (count($fields) >= 6) { $spot['filesize'] = $fields[$_FSIZE]; $spot['category'] = substr($fields[$_CAT], 0, 1) - 1.0; // extract de posters name $spot['poster'] = substr($from, 0, $fromInfoPos - 1); // key id $spot['keyid'] = (int) substr($fields[$_CAT], 1, 1); if ($spot['keyid'] >= 0) { $expression = ''; $strInput = substr($fields[$_CAT], 2); $recentKey = $spot['keyid'] != 1; if ($recentKey) { if (strlen($strInput) == 0 || strlen($strInput) % 3 != 0) { return; } # if $subcatAr = $this->splitBySizEx($strInput, 3); foreach ($subcatAr as $str) { if (strlen($str) > 0) { $expression .= strtolower(substr($str, 0, 1)) . (int) substr($str, 1) . '|'; } # if } # foeeach } else { $list = array(); for ($i = 0; $i < strlen($strInput); $i++) { if ($strInput[$i] == 0 && !is_numeric($strInput[$i]) && strlen($expression) > 0) { $list[] = $expression; $expression = ''; } # if $expression .= $strInput[$i]; } # for $list[] = $expression; $expression = ''; foreach ($list as $str) { $expression .= strtolower(substr($str, 0, 1)) . substr($str, 1) . '|'; } # foreach } # else if $recentKey # Break up the subcategories per subcat-type if (strlen($expression) > 0) { $subcats = explode('|', $expression); $spot['subcata'] = ''; $spot['subcatb'] = ''; $spot['subcatc'] = ''; $spot['subcatd'] = ''; $spot['subcatz'] = ''; foreach ($subcats as $subcat) { if (in_array(strtolower(substr($subcat, 0, 1)), array('a', 'b', 'c', 'd', 'z')) !== false) { $spot['subcat' . strtolower(substr($subcat, 0, 1))] .= $subcat . '|'; } # if } # foreach # We vullen hier de z categorieen alvast op in het geval er geen Z category gegeven is if (empty($spot['subcatz'])) { $spot['subcatz'] = SpotCategories::createSubcatz($spot['category'], $spot['subcata'] . $spot['subcatb'] . $spot['subcatd']); } # if } # if if (strpos($subj, '=?') !== false && strpos($subj, '?=') !== false) { # Make sure its as simple as possible $subj = str_replace('?= =?', '?==?', $subj); $subj = str_replace('\\r', '', trim($this->oldEncodingParse($subj))); $subj = str_replace('\\n', '', $subj); } # if if ($recentKey) { $tmp = explode('|', $subj); $spot['title'] = trim($tmp[0]); if (count($tmp) > 1) { $spot['tag'] = trim($tmp[1]); } else { $spot['tag'] = ''; } # else } else { $tmp = explode('|', $subj); if (count($tmp) <= 1) { $tmp = array($subj); } # if $spot['tag'] = trim($tmp[count($tmp) - 1]); # remove the tags from the array array_pop($tmp); array_pop($tmp); $spot['title'] = trim(implode('|', $tmp)); if (strpos($spot['title'], chr(0xc2)) !== false | strpos($spot['title'], chr(0xc3)) !== false) { $spot['title'] = trim($this->oldEncodingParse($spot['title'])); } # if } # if recentKey if (strlen($spot['title']) != 0 && strlen($spot['poster']) != 0) { # Als er een recentkey is (key <> 1), OF de spot is na 2010 geplaatst, dan moet # de spot gesigned zijn. $mustbeSigned = $recentKey | $spot['stamp'] > 1293870080; if ($mustbeSigned) { $spot['headersign'] = $fields[count($fields) - 1]; if (strlen($spot['headersign']) != 0) { $spot['wassigned'] = true; # KeyID 7 betekent dat alleen een hashcash vereist is if ($spot['keyid'] == 7) { $userSignedHash = sha1('<' . $spot['messageid'] . '>', false); $spot['verified'] = substr($userSignedHash, 0, 3) == '0000'; } else { # the signature this header is signed with $signature = $this->unspecialString($spot['headersign']); $spotSigning = new SpotSigning(); $spot['verified'] = $spotSigning->verifySpotHeader($spot, $signature, $rsakeys); } # else } # if } else { $spot['verified'] = true; $spot['wassigned'] = false; } # if doesnt need to be signed, pretend that it is } # if } # if } # if # Nu zetten we de titel en dergelijke om naar utf8, we kunnen # dat niet eerder doen omdat anders de RSA signature niet meer # klopt. if ($spot !== false && $spot['verified']) { $spot['title'] = utf8_encode($spot['title']); $spot['poster'] = utf8_encode($spot['poster']); $spot['tag'] = utf8_encode($spot['tag']); } # f return $spot; }
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()
if ($tplHelper->isBeingWatched($spot) == false) { echo " style='display: none;'"; } echo " id='watchremove_" . $spot['id'] . "'><img src='templates/we1rdo/img/fav.png' alt='Verwijder uit watchlist' title='Verwijder uit watchlist'/></a>"; echo "<a onclick=\"toggleWatchSpot('" . $spot['messageid'] . "','add'," . $spot['id'] . ")\""; if ($tplHelper->isBeingWatched($spot) == true) { echo " style='display: none;'"; } echo " id='watchadd_" . $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 echo "<td>" . SpotCategories::Cat2Desc($spot['category'], $spot['subcat' . SpotCategories::SubcatNumberFromHeadcat($spot['category'])]) . "</td>" . "<td><a href='" . $tplHelper->makePosterUrl($spot) . "' title='Zoek spots van " . $spot['poster'] . "'>" . $spot['poster'] . "</a></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='" . $tplHelper->makeNzbUrl($spot) . "' title ='Download NZB' class='nzb'>NZB"; if ($tplHelper->hasBeenDownloaded($spot)) { echo '*'; } # if echo "</a></td>"; } # if if ($settings['show_multinzb']) { $multispotid = htmlspecialchars($spot['messageid']); echo "<td>"; echo "<input type='checkbox' name='" . htmlspecialchars('messageid[]') . "' value='" . $multispotid . "'>";
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 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='" . $tplHelper->makeNzbUrl($spot) . "' title ='Download NZB' class='nzb'>NZB"; if ($tplHelper->hasBeenDownloaded($spot)) { echo '*'; } # if echo "</a></td>"; } # if
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); }
function parseHeader($subj, $from, $date, $messageid, $rsaKeys) { # Initialize an empty array, we create a basic template in a few $spot = array(); /* * The "From" header is created using the following system: * * From: [Nickname] <[RANDOM or PUBLICKEY]@[CAT][KEY-ID][SUBCAT].[SIZE].[RANDOM].[DATE].[CUSTOM-ID].[CUSTOM-VALUE].[SIGNATURE]> * or * From: [Nickname] <[PUBLICKEY-MODULO.USERSIGNATURE]@[CAT][KEY-ID][SUBCAT].[SIZE].[RANDOM].[DATE].[CUSTOM-ID].[CUSTOM-VALUE].[SIGNATURE]> * * * First we want to extract everything after the @ but because a nickname could contain an @, we have to mangle it a bit */ $fromInfoPos = strpos($from, '<'); if ($fromInfoPos === false) { return false; } else { # Remove the posters' name and the <> characters $fromAddress = explode('@', substr($from, $fromInfoPos + 1, -1)); if (count($fromAddress) < 2) { return false; } # if $spot['header'] = $fromAddress[1]; /* * It is possible the part before the @ contains both the * users' signature as the spots signature as signed by the user */ $headerSignatureTemp = explode('.', $fromAddress[0]); $spot['selfsignedpubkey'] = $this->_util->spotUnprepareBase64($headerSignatureTemp[0]); if (isset($headerSignatureTemp[1])) { $spot['user-signature'] = $this->_util->spotUnprepareBase64($headerSignatureTemp[1]); } # if } # if /* * Initialize some basic variables. We set 'verified' to false so we can * exit this function at any time and the gathered data for this spot up til * then is stil ignored. */ $spot['verified'] = false; $spot['filesize'] = 0; $spot['messageid'] = $messageid; $spot['stamp'] = strtotime($date); /* * Split the .-delimited fields into an array so we can mangle it. We require * atleast six fields, if any less we can safely assume the spot is invalid */ $fields = explode('.', $spot['header']); if (count($fields) < 6) { return false; } # if /* * Extract the fixed fields from the header */ $spot['poster'] = substr($from, 0, $fromInfoPos - 1); $spot['category'] = substr($fields[0], 0, 1) - 1.0; $spot['keyid'] = (int) substr($fields[0], 1, 1); $spot['filesize'] = $fields[1]; $spot['subcata'] = ''; $spot['subcatb'] = ''; $spot['subcatc'] = ''; $spot['subcatd'] = ''; $spot['subcatz'] = ''; $spot['wassigned'] = false; $spot['spotterid'] = ''; $isRecentKey = $spot['keyid'] != 1; /* * If the keyid is invalid, abort trying to parse it */ if ($spot['keyid'] < 0) { return false; } # if /* * Listings of subcategories is dependent on the age of the spot. * * FTD spots just list all subcategories like: a9b4c0d5d15d11 * Newer spots always use three characters for each subcategory like: a09b04c00d05d15d11. * * We really do not care for this, we just parse them using the same code as the * first one. * * We pad $strCatList with an extra set of tokes so we always parse te last category, * we make sure any sanitycheck is passed by adding 3 tokens. */ $strCatList = strtolower(substr($fields[0], 2)) . '!!!'; $strCatListLen = strlen($strCatList); /* * Initialize some basic variables to use for sanitychecking (eg: valid subcats) */ $validSubcats = array('a' => true, 'b' => true, 'c' => true, 'd' => true, 'z' => true); $tmpCatBuild = ''; /* And just try to extract all given subcategories */ for ($i = 0; $i < $strCatListLen; $i++) { /* * If the current character is not an number, we found the next * subcategory. Add the current one to the list, and start * parsing the new one */ if (!is_numeric($strCatList[$i]) && !empty($tmpCatBuild)) { if (isset($validSubcats[$tmpCatBuild[0]])) { $spot['subcat' . $tmpCatBuild[0]] .= $tmpCatBuild[0] . (int) substr($tmpCatBuild, 1) . '|'; } # if $tmpCatBuild = ''; } # if $tmpCatBuild .= $strCatList[$i]; } # for /* * subcatz is a subcategory introduced in later Spotnet formats, we prefer to * always have this subcategory so we just fake it if it's not listed. */ if (empty($spot['subcatz'])) { $spot['subcatz'] = SpotCategories::createSubcatz($spot['category'], $spot['subcata'] . $spot['subcatb'] . $spot['subcatd']); } # if # map deprecated genre categories to their new genre category $spot['subcatd'] = SpotCategories::mapDeprecatedGenreSubCategories($spot['category'], $spot['subcatd'], $spot['subcatz']); $spot['subcatc'] = SpotCategories::mapLanguageSubCategories($spot['category'], $spot['subcatc'], $spot['subcatz']); if (strpos($subj, '=?') !== false && strpos($subj, '?=') !== false) { # This is an old format to parse, instantiate the legacy parsing $legacyParser = new Services_Format_ParsingLegacy(); # Make sure its as simple as possible $subj = str_replace('?= =?', '?==?', $subj); $subj = str_replace('\\r', '', trim($legacyParser->oldEncodingParse($subj))); $subj = str_replace('\\n', '', $subj); } # if if ($isRecentKey) { $tmp = explode('|', $subj); $spot['title'] = trim($tmp[0]); if (count($tmp) > 1) { $spot['tag'] = trim($tmp[1]); } else { $spot['tag'] = ''; } # else } else { $tmp = explode('|', $subj); if (count($tmp) <= 1) { $tmp = array($subj); } # if $spot['tag'] = trim($tmp[count($tmp) - 1]); # remove the tags from the array array_pop($tmp); array_pop($tmp); $spot['title'] = trim(implode('|', $tmp)); if (strpos($spot['title'], chr(0xc2)) !== false | strpos($spot['title'], chr(0xc3)) !== false) { # This is an old format to parse, instantiate the legacy parsing $legacyParser = new Services_Format_ParsingLegacy(); $spot['title'] = trim($legacyParser->oldEncodingParse($spot['title'])); } # if } # if recentKey # Title and poster fields are mandatory, we require it to validate the signature if (strlen($spot['title']) == 0 || strlen($spot['poster']) == 0) { return $spot; } # if /* * For any recentkey ( >1) or spots created after year-2010, we require the spot * to be signed */ $mustbeSigned = $isRecentKey | $spot['stamp'] > 1293870080; if ($mustbeSigned) { $spot['headersign'] = $fields[count($fields) - 1]; $spot['wassigned'] = strlen($spot['headersign']) != 0; } else { $spot['verified'] = true; $spot['wassigned'] = false; } # if doesnt need to be signed, pretend that it is /* * Don't verify spots which are already verified */ if ($spot['wassigned']) { /* * There are currently two known methods to which Spots are signed, * each having different charachteristics, making it a bit difficult * to work with this. * * The oldest method uses a secret private key and a signing server, we * name this method SPOTSIGN_V1. The users' public key is only available * in the XML header, not in the From header. This is the preferred method. * * The second method uses a so-called "self signed" spot (the spotter signs * the spots, posts the public key in the header and a hashcash is used to * prevent spamming). This method is called SPOTSIGN_V2. * */ if ($spot['keyid'] == 7) { /* * KeyID 7 has a special meaning, it defines a self-signed spot and * requires a hashcash */ $signingMethod = 2; } else { $signingMethod = 1; } # else switch ($signingMethod) { case 1: # the signature this header is signed with $signature = $this->_util->spotUnprepareBase64($spot['headersign']); /* * Make sure the key specified is an actual known key */ if (isset($rsaKeys[$spot['keyid']])) { if ($spot['keyid'] == 2 && ($spot['filesize'] = 999 && strlen($spot['selfsignedpubkey']) > 50)) { /* Check personal dispose message */ $signature = $this->_util->spotUnprepareBase64($spot['headersign']); $userSignedHash = sha1('<' . $spot['messageid'] . '>', false); $spot['verified'] = substr($userSignedHash, 0, 4) === '0000'; if ($spot['verified']) { $userRsaKey = array(2 => array('modulo' => $spot['selfsignedpubkey'], 'exponent' => 'AQAB')); if ($this->_spotSigning->verifySpotHeader($spot, $signature, $userRsaKey)) { $spot['spotterid'] = $this->_util->calculateSpotterId($spot['selfsignedpubkey']); } # if } # if } else { $spot['verified'] = $this->_spotSigning->verifySpotHeader($spot, $signature, $rsaKeys); } } # if break; # SPOTSIGN_V1 # SPOTSIGN_V1 case 2: # the signature this header is signed with $signature = $this->_util->spotUnprepareBase64($spot['headersign']); $userSignedHash = sha1('<' . $spot['messageid'] . '>', false); $spot['verified'] = substr($userSignedHash, 0, 4) === '0000'; /* * Create a fake RSA keyarray so we can validate it using our standard * infrastructure */ if ($spot['verified']) { $userRsaKey = array(7 => array('modulo' => $spot['selfsignedpubkey'], 'exponent' => 'AQAB')); /* * We cannot use this as a full measure to check the spot's validness yet, * because at least one Spotnet client feeds us invalid data for now */ if ($this->_spotSigning->verifySpotHeader($spot, $signature, $userRsaKey)) { /* * The users' public key (modulo) is posted in the header, lets * try this. */ $spot['spotterid'] = $this->_util->calculateSpotterId($spot['selfsignedpubkey']); } # if } # if break; # SPOTSIGN_V2 } # switch /* * Even more recent spots, contain the users' full publickey * in the header. This allows us to uniquely identify and verify * the poster of the spot. * * Try to extract this information. */ if ($spot['verified'] && !empty($spot['user-signature']) && !empty($spot['selfsignedpubkey'])) { /* * Extract the public key */ $spot['spotterid'] = $this->_util->calculateSpotterId($spot['selfsignedpubkey']); $spot['user-key'] = array('modulo' => $spot['selfsignedpubkey'], 'exponent' => 'AQAB'); /* * The spot contains the signature in the header of the spot */ $spot['verified'] = $this->_spotSigning->verifyFullSpot($spot); } # if } # if was signed /* * We convert the title and other fields to UTF8, we cannot * do this any earlier because it would break the RSA signature */ if ($spot !== false && $spot['verified']) { $spot['title'] = utf8_encode($spot['title']); $spot['poster'] = utf8_encode($spot['poster']); $spot['tag'] = utf8_encode($spot['tag']); # If a spot is in the future, fix it if (time() < $spot['stamp']) { $spot['stamp'] = time(); } # if } # if return $spot; }
echo $spot['title']; ?> </h3> <table class="spotinfo"> <tbody> <tr><th> Categorie </th> <td> <?php echo $spot['catname']; ?> </td> </tr> <?php if (!empty($spot['subcatlist'])) { foreach ($spot['subcatlist'] as $sub) { $subcatType = substr($sub, 0, 1); echo "\t\t\t\t\t\t<tr><th> " . SpotCategories::SubcatDescription($spot['category'], $subcatType) . "</th> <td> " . SpotCategories::Cat2Desc($spot['category'], $sub) . " </td> </tr>\r\n"; } # foreach } # if ?> <tr><th> Omvang </th> <td> <?php echo $tplHelper->format_size($spot['filesize']); ?> </td> </tr> <tr><th> Website </th> <td> <a href='<?php echo $spot['website']; ?> ' target="_blank">BEKIJK</a> </td> </tr> <tr><th> Afzender </th> <td> <?php echo $spot['poster'];
</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>
function createStatistics($graph, $limit, $lastUpdate, $language) { SpotTranslation::initialize($language); $spotStatistics = new SpotStatistics($this->_db); include_once "images/pchart/pData.class.php"; include_once "images/pchart/pDraw.class.php"; include_once "images/pchart/pImage.class.php"; $width = 800; $height = 500; $titleHeight = 20; $dataSet = array(); $graphs = $this->getValidStatisticsGraphs(); $limits = $this->getValidStatisticsLimits(); switch ($graph) { case 'spotsperhour': $prepData = $this->prepareData($spotStatistics->getSpotCountPerHour($limit, $lastUpdate)); $legend = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23'); for ($x = 0; $x <= 23; $x++) { $dataSet[] = @$prepData[$x]; } $graphicType = "bar"; break; case 'spotsperweekday': $prepData = $this->prepareData($spotStatistics->getSpotCountPerWeekday($limit, $lastUpdate)); $legend = array(_("Monday"), _("Tuesday"), _("Wednesday"), _("Thursday"), _("Friday"), _("Saturday"), _("Sunday")); $dataSet = array(@$prepData[1], @$prepData[2], @$prepData[3], @$prepData[4], @$prepData[5], @$prepData[6], @$prepData[0]); $graphicType = "bar"; break; case 'spotspermonth': $prepData = $this->prepareData($spotStatistics->getSpotCountPerMonth($limit, $lastUpdate)); $legend = array(_("January"), _("February"), _("March"), _("April"), _("May"), _("June"), _("July"), _("August"), _("September"), _("October"), _("November"), _("December")); for ($x = 1; $x <= 12; $x++) { $dataSet[] = @$prepData[$x]; } $graphicType = "bar"; break; case 'spotspercategory': $prepData = $this->prepareData($spotStatistics->getSpotCountPerCategory($limit, $lastUpdate)); $legend = array(_(SpotCategories::HeadCat2Desc(0)), _(SpotCategories::HeadCat2Desc(1)), _(SpotCategories::HeadCat2Desc(2)), _(SpotCategories::HeadCat2Desc(3))); for ($x = 0; $x <= 3; $x++) { $dataSet[] = @$prepData[$x]; } $graphicType = "3Dpie"; break; } # switch array_walk($dataSet, create_function('& $item, $key', 'if ($item === NULL) $item = 0;')); $title = $graphs[$graph]; if (!empty($limit)) { $title .= " (" . $limits[$limit] . ")"; } # if $imgData = new pData(); if ($graphicType == "bar") { $imgData->addPoints($dataSet, "data"); $imgData->addPoints($legend, "legend"); $imgData->setAbscissa("legend"); $imgData->setPalette("data", array("R" => 0, "G" => 108, "B" => 171, "Alpha" => 100)); $img = new pImage($width, $height, $imgData); $img->drawGradientArea(0, $titleHeight, $width, $height, DIRECTION_VERTICAL, array("StartR" => 200, "StartG" => 200, "StartB" => 200, "EndR" => 18, "EndG" => 52, "EndB" => 86, "Alpha" => 100)); $img->drawGradientArea(0, 0, $width, $titleHeight, DIRECTION_VERTICAL, array("StartR" => 18, "StartG" => 52, "StartB" => 86, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 100)); $img->setFontProperties(array("FontName" => "images/ttf/liberation-sans/LiberationSans-Bold.ttf", "FontSize" => 10)); $img->drawText($width / 2, 13, $title, array("Align" => TEXT_ALIGN_MIDDLEMIDDLE, "R" => 255, "G" => 255, "B" => 255)); $img->setFontProperties(array("R" => 255, "G" => 255, "B" => 255, "FontName" => "images/ttf/liberation-sans/LiberationSans-Regular.ttf", "FontSize" => 9)); $img->setGraphArea(60, $titleHeight + 20, $width - 50, $height - 30); $img->drawScale(array("GridR" => 200, "GridG" => 200, "GridB" => 200, "Mode" => SCALE_MODE_START0)); $img->drawBarChart(array("Gradient" => TRUE, "GradientMode" => GRADIENT_EFFECT_CAN, "DisplayPos" => LABEL_POS_INSIDE, "DisplayValues" => TRUE, "Surrounding" => 10)); } elseif ($graphicType == "3Dpie") { include_once "images/pchart/pPie.class.php"; $imgData->addPoints($dataSet, "data"); $imgData->addPoints($legend, "legend"); $imgData->setAbscissa("legend"); $img = new pImage($width, $height, $imgData, TRUE); $PieChart = new pPie($img, $imgData); $img->drawGradientArea(0, $titleHeight, $width, $height, DIRECTION_VERTICAL, array("StartR" => 200, "StartG" => 200, "StartB" => 200, "EndR" => 18, "EndG" => 52, "EndB" => 86, "Alpha" => 100)); $img->drawGradientArea(0, 0, $width, $titleHeight, DIRECTION_VERTICAL, array("StartR" => 18, "StartG" => 52, "StartB" => 86, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 100)); $img->setFontProperties(array("FontName" => "images/ttf/liberation-sans/LiberationSans-Bold.ttf", "FontSize" => 10)); $img->drawText($width / 2, 13, $title, array("Align" => TEXT_ALIGN_MIDDLEMIDDLE, "R" => 255, "G" => 255, "B" => 255)); $PieChart->setSliceColor(0, array("R" => 0, "G" => 108, "B" => 171)); $PieChart->setSliceColor(1, array("R" => 205, "G" => 159, "B" => 0)); $PieChart->setSliceColor(2, array("R" => 0, "G" => 171, "B" => 0)); $PieChart->setSliceColor(3, array("R" => 171, "G" => 28, "B" => 0)); $img->setFontProperties(array("FontName" => "images/ttf/liberation-sans/LiberationSans-Regular.ttf", "FontSize" => 9)); $PieChart->draw3DPie($width / 2, $height / 2 + $titleHeight, array("Radius" => $width / 2 - 100, "SecondPass" => TRUE, "DrawLabels" => TRUE, "WriteValues" => TRUE, "Precision" => 2, "ValueR" => 0, "ValueG" => 0, "ValueB" => 0, "ValueAlpha" => 100, "SkewFactor" => 0.6, "LabelR" => 255, "LabelG" => 255, "LabelB" => 255, "LabelAlpha" => 100)); } # if if (isset($img)) { ob_start(); $img->render(NULL); $imageString = ob_get_clean(); $data = $this->getImageInfoFromString($imageString); return array('metadata' => $data['metadata'], 'content' => $imageString); } # img }