/** * Find a torrent by its hash. * * @param mixed $rpc_url * @param mixed $hash * @return Torrent|null * @todo Inefficient. Re-implement to not suck. **/ public static function findOneByHash($rpc_url, $hash) { $torrents = Torrent::findByStatus($rpc_url, 'all'); foreach ($torrents as $torrent) { if ($torrent->getHash() == $hash) { return $torrent; } } // end loop return null; }
$feed_id = stripinput($_REQUEST['feed_id']); $feed = new RSSFeed($db); if ($feed_id == null) { $feed = $feed->findOneByDefault('Y'); } else { $feed = $feed->findOneByRssFeedId($feed_id); } if ($feed == null) { $ERRORS[] = 'RSS feed not found.'; } if (sizeof($ERRORS) > 0) { draw_errors($ERRORS); } else { // Build a hash of torrents being downloaded. The RSS feed's items will // be compared against this hash, and any matching item are surpressed. $torrents = Torrent::findByStatus($APP_CONFIG['rpc_uri'], 'all'); $TORRENTING = array(); foreach ($torrents as $torrent) { $TORRENTING[] = $torrent->getTitle(); /* print "<pre>\n"; var_dump($torrent->getTitle()); print ' - '; print mb_detect_encoding($torrent->getTitle()); print "</pre>\n"; */ } // end array // Get the list of feeds for the dropdown menu. $feed_list = new RSSFeed($db); $feed_list = $feed_list->findBy(array());