/web/kaklik's_web/torrentflux/searchEngines/NewNovaEngine.php |
---|
0,0 → 1,595 |
<?php |
/************************************************************* |
* TorrentFlux PHP Torrent Manager |
* www.torrentflux.com |
**************************************************************/ |
/* |
This file is part of TorrentFlux. |
TorrentFlux is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
TorrentFlux is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with TorrentFlux; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
*/ |
/* |
v 1.00 - Mar 31, 06 - Created |
*/ |
class SearchEngine extends SearchEngineBase |
{ |
var $dateAdded = ""; |
function SearchEngine($cfg) |
{ |
$this->mainURL = "newnova.org"; |
$this->altURL = "newnova.org"; |
$this->mainTitle = "NewNova"; |
$this->engineName = "NewNova"; |
$this->author = "kboy"; |
$this->version = "1.00"; |
$this->updateURL = "http://www.torrentflux.com/forum/index.php?topic=1002.0.html"; |
$this->Initialize($cfg); |
} |
//---------------------------------------------------------------- |
// Function to Get Main Categories |
function populateMainCategories() |
{ |
$this->mainCatalog["1"] = "Games"; |
$this->mainCatalog["2"] = "Movies"; |
$this->mainCatalog["3"] = "TV Shows"; |
$this->mainCatalog["4"] = "Music"; |
$this->mainCatalog["5"] = "Apps"; |
$this->mainCatalog["6"] = "Miscellaneous"; |
$this->mainCatalog["7"] = "Anime"; |
} |
//---------------------------------------------------------------- |
// Function to Get Sub Categories |
function getSubCategories($mainGenre) |
{ |
$output = array(); |
$mainGenreName = $this->GetMainCatName($mainGenre); |
if($mainGenre == "6") |
{ |
$mainGenreName = "Misc"; |
} |
$request = '/list_torrents/' . str_replace(" ","",strtolower($mainGenreName)) . '.html'; |
if ($this->makeRequest($request)) |
{ |
$thing = $this->htmlPage; |
if (is_integer(strpos($thing,"seperator"))) |
{ |
$thing = substr($thing,strpos($thing,"seperator")+strlen("seperator")); |
$thing = substr($thing,strpos($thing,"<table")); |
$thing = substr($thing,0,strpos($thing,"</table>")); |
while (is_integer(strpos($thing,"href=\"JavaScript:showTbl2("))) |
{ |
$thing = substr($thing,strpos($thing,"href=\"JavaScript:showTbl2(")+strlen("href=\"JavaScript:showTbl2(")); |
$tmpStr = substr($thing,0,strpos($thing,')')); |
$tmpArr = split(",",$tmpStr); |
$subid = substr($tmpArr[0],strpos($tmpArr[0],'/')+1); |
while(is_integer(strpos($subid,"/"))) |
{ |
$subid = substr($subid,strpos($subid,'/')+1); |
} |
$subid = str_replace(array("'"),"",$subid); |
$subname = str_replace(array("'"),"",$tmpArr[1]); |
if($subname != $mainGenreName) |
{ |
$output[$subid] = $subname; |
} |
} |
} |
} |
return $output; |
} |
//---------------------------------------------------------------- |
// Function to get Latest.. |
function getLatest() |
{ |
//http://www.newnova.org/list_news.html |
$request = "/list_news.html"; |
if (array_key_exists("mode",$_REQUEST)) |
{ |
if($_REQUEST["mode"] == "yesterday" ) |
{ |
$request = "/list_news_1.html"; |
} |
} |
if (array_key_exists("subGenre",$_REQUEST)) |
{ |
$request = "/list_torrents/".$_REQUEST["subGenre"].".html"; |
} |
if (array_key_exists("dteAdded",$_REQUEST)) |
{ |
$this->dateAdded = $_REQUEST["dteAdded"]; |
} |
if ($this->makeRequest($request)) |
{ |
return $this->parseResponse(); |
} |
else |
{ |
return $this->msg; |
} |
} |
//---------------------------------------------------------------- |
// Function to perform Search. |
function performSearch($searchTerm) |
{ |
$request = "/search.foo?data[searchTerm]=".$searchTerm."&"; |
if ($this->makeRequest($request)) |
{ |
return $this->parseResponse(); |
} |
else |
{ |
return $this->msg; |
} |
} |
//---------------------------------------------------------------- |
// Override the base to show custom table header. |
// Function to setup the table header |
function tableHeader() |
{ |
$output = "<table width=\"100%\" cellpadding=3 cellspacing=0 border=0>"; |
$output .= "<br>\n"; |
$output .= "<tr bgcolor=\"".$this->cfg["table_header_bg"]."\">"; |
$output .= "<td colspan=7 align=center><strong>".$this->dateAdded."</strong></td>"; |
$output .= "</tr>\n"; |
$output .= "<tr bgcolor=\"".$this->cfg["table_header_bg"]."\">"; |
$output .= " <td> </td>"; |
$output .= " <td><strong>Torrent Name</strong> ("; |
$tmpURI = str_replace(array("?hideSeedless=yes","&hideSeedless=yes","?hideSeedless=no","&hideSeedless=no"),"",$_SERVER["REQUEST_URI"]); |
// Check to see if Question mark is there. |
if (strpos($tmpURI,'?')) |
{ |
$tmpURI .= "&"; |
} |
else |
{ |
$tmpURI .= "?"; |
} |
if($this->hideSeedless == "yes") |
{ |
$output .= "<a href=\"". $tmpURI . "hideSeedless=no\">Show Seedless</a>"; |
} |
else |
{ |
$output .= "<a href=\"". $tmpURI . "hideSeedless=yes\">Hide Seedless</a>"; |
} |
$output .= ")</td>"; |
$output .= " <td><strong>Category</strong></td>"; |
$output .= " <td align=center><strong> Size</strong></td>"; |
$output .= " <td><strong>Seeds</strong></td>"; |
$output .= " <td><strong>Peers</strong></td>"; |
$output .= " <td align=center><strong>Kind</strong></td>"; |
$output .= "</tr>\n"; |
return $output; |
} |
//---------------------------------------------------------------- |
// Function to parse the response. |
function parseResponse() |
{ |
if (is_integer(strpos($this->htmlPage,"seperator"))) |
{ |
$dteAdded = substr($this->htmlPage,strpos($this->htmlPage,"seperator",20)+strlen("seperator")); |
$dteAdded = substr($dteAdded,strpos($dteAdded,">")+1); |
$this->dateAdded = substr($dteAdded,0,strpos($dteAdded,"<")); |
} |
else |
{ |
if (!strlen($this->dateAdded) > 0) |
{ |
$this->dateAdded = date(' j. F Y',time()); |
} |
} |
$output = $this->tableHeader(); |
$thing = $this->htmlPage; |
if (is_integer(strpos($thing,"Loading..."))) |
{ |
$thing = substr($thing,strpos($thing,"Loading...")); |
$thing = substr($thing,strpos($thing,"<script>")+strlen("<script>")); |
$tmpList = substr($thing,0,strpos($thing,"</script>")); |
} |
else |
{ |
$tmpList = $thing; |
} |
// We got a response so display it. |
// Chop the front end off. |
if (is_integer(strpos($tmpList,"at2_nws_hdr"))) |
{ |
$output .= $this->nwsTableRows($tmpList); |
} |
elseif (is_integer(strpos($tmpList,"at2_header"))) |
{ |
$output .= $this->at2TableRows($tmpList); |
} |
else |
{ |
if(is_integer(strpos($thing,"search returned no results"))) |
{ |
$output .= "<center>Your search returned no results. Please refine your search</center><br>"; |
} |
} |
if (is_integer(strpos($thing,"seperator"))) |
{ |
$dteAdd = substr($thing,strpos($thing,"seperator",20)+strlen("seperator")); |
$dteAdd = substr($dteAdd,strpos($dteAdd,">")+1); |
$dteAdd = substr($dteAdd,0,strpos($dteAdd,"<")); |
} |
$output .= "</table>"; |
$pages = ''; |
if(array_key_exists("LATEST",$_REQUEST)) |
{ |
if (array_key_exists("mode",$_REQUEST)) |
{ |
if (! $_REQUEST["mode"] == "yesterday") |
{ |
$pages .= "<br><a href=\"".$this->searchURL()."&LATEST=1&mode=yesterday&dteAdded=".$dteAdd."\" title=\"Yesterday's Latest\">Yesterday's Latest</a>"; |
} |
} |
else |
{ |
$pages .= "<br><a href=\"".$this->searchURL()."&LATEST=1&mode=yesterday&dteAdded=".$dteAdd."\" title=\"Yesterday's Latest\">Yesterday's Latest</a>"; |
} |
$output .= "<br><div align=center>".$pages."</div><br>"; |
} |
return $output; |
} |
function at2TableRows($tmpList) |
{ |
$output = ''; |
$bg = $this->cfg["bgLight"]; |
while (is_integer(strpos($tmpList,"at2_header"))) |
{ |
$tmpList = substr($tmpList,strpos($tmpList,"at2_header(")+strlen("at2_header('")); |
$curCat = substr($tmpList,0,strpos($tmpList,"'")); |
$tmpList = substr($tmpList,strpos($tmpList,"at2(")); |
if (is_int(array_search($curCat,$this->catFilter))) |
{ |
// Skip this category. |
} |
else |
{ |
// We have something to-do. |
if (is_integer(strpos($tmpList,"at2_header("))) |
{ |
$tmpList2 = substr($tmpList,0,strpos($tmpList,"at2_header(")); |
} |
elseif (is_integer(strpos($tmpList,"str.push"))) |
{ |
$tmpList2 = substr($tmpList,0,strpos($tmpList,"str.push")); |
} |
//prepare line |
$tmpList2 = str_replace("at2(","",$tmpList2); |
// ok so now we have the listing. |
$tmpListArr = split(");",$tmpList2); |
$output .= $this->buildTableRows($tmpListArr, $bg); |
} |
// set tmpList to end of this category. |
if (is_integer(strpos($tmpList,"at2_header("))) |
{ |
$tmpList = substr($tmpList,strpos($tmpList,"at2_header(")); |
} |
elseif (is_integer(strpos($tmpList,"str.push"))) |
{ |
$tmpList = substr($tmpList,strpos($tmpList,"str.push")); |
} |
// ok switch colors. |
if ($bg == $this->cfg["bgLight"]) |
{ |
$bg = $this->cfg["bgDark"]; |
} |
else |
{ |
$bg = $this->cfg["bgLight"]; |
} |
} |
return $output; |
} |
function nwsTableRows($tmpList) |
{ |
$output = ''; |
$bg = $this->cfg["bgLight"]; |
while (is_integer(strpos($tmpList,"at2_nws_hdr"))) |
{ |
$tmpList = substr($tmpList,strpos($tmpList,"at2_nws_hdr(")+strlen("at2_nws_hdr('")); |
$curCat = substr($tmpList,0,strpos($tmpList,"'")); |
$tmpList = substr($tmpList,strpos($tmpList,"at2(")); |
if (is_int(array_search($curCat,$this->catFilter))) |
{ |
// Skip this category. |
} |
else |
{ |
// We have something to-do. |
if (is_integer(strpos($tmpList,"at2_nws_hdr("))) |
{ |
$tmpList2 = substr($tmpList,0,strpos($tmpList,"at2_nws_hdr(")); |
} |
elseif (is_integer(strpos($tmpList,"str.push"))) |
{ |
$tmpList2 = substr($tmpList,0,strpos($tmpList,"str.push")); |
} |
//prepare line |
$tmpList2 = str_replace("at2(","",$tmpList2); |
// ok so now we have the listing. |
$tmpListArr = split(");",$tmpList2); |
$output .= $this->buildTableRows($tmpListArr, $bg); |
} |
// set tmpList to end of this category. |
if (is_integer(strpos($tmpList,"at2_nws_hdr("))) |
{ |
$tmpList = substr($tmpList,strpos($tmpList,"at2_nws_hdr(")); |
} |
elseif (is_integer(strpos($tmpList,"str.push"))) |
{ |
$tmpList = substr($tmpList,strpos($tmpList,"str.push")); |
} |
// ok switch colors. |
if ($bg == $this->cfg["bgLight"]) |
{ |
$bg = $this->cfg["bgDark"]; |
} |
else |
{ |
$bg = $this->cfg["bgLight"]; |
} |
} |
return $output; |
} |
function buildTableRows($tmpListArr, $bg) |
{ |
$output = ""; |
foreach($tmpListArr as $key =>$value) |
{ |
$buildLine = true; |
$ts = new tNova($value); |
// Determine if we should build this output |
if (is_int(array_search($ts->MainCategory,$this->catFilter))) |
{ |
$buildLine = false; |
} |
if ($this->hideSeedless == "yes") |
{ |
if($ts->Seeds == "N/A" || $ts->Seeds == "0") |
{ |
$buildLine = false; |
} |
} |
if (!empty($ts->torrentFile) && $buildLine) { |
$output .= trim($ts->BuildOutput($bg, $this->searchURL())); |
// ok switch colors. |
if ($bg == $this->cfg["bgLight"]) |
{ |
$bg = $this->cfg["bgDark"]; |
} |
else |
{ |
$bg = $this->cfg["bgLight"]; |
} |
} |
} |
return $output; |
} |
} |
// This is a worker class that takes in a row in a table and parses it. |
class tNova |
{ |
var $torrentName = ""; |
var $torrentDisplayName = ""; |
var $torrentFile = ""; |
var $torrentSize = ""; |
var $torrentStatus = ""; |
var $MainId = ""; |
var $MainCategory = ""; |
var $SubCategory = ""; |
var $fileCount = ""; |
var $torrentAdded = ""; |
var $Seeds = ""; |
var $Peers = ""; |
var $Data = ""; |
/* |
function at2 ( |
0 torrent_id, |
1 torrent_additiondate_day, |
2 torrent_server_id, |
3 torrent_viewserver_id, |
4 torrent_view_link, |
5 torrent_link_desc, |
6 torrent_name, |
7 torrent_link, |
8 torrent_filesize_mb, |
9 torrent_lastnrseeds, |
10 torrent_lastnrleeches, |
11 torrent_quality, |
12 torrent_submitter_id, |
13 torrent_submitter_nickname, |
14 torrent_submitter_status, |
15 torrent_infolink, |
16 torrent_type_id, |
17 torrent_tracker_has_nostats, |
18 torrent_tracker_has_unknownstats, |
19 torrent_lastcheck_nr_invalid, |
20 torrent_is_moderated, |
21 torrent_is_deleted, |
22 torrent_is_softdeleted, |
23 torrent_has_rights, |
24 torrent_tracker_registered |
) |
*/ |
function tNova( $htmlLine , $dteAdded = "") |
{ |
if (strlen($htmlLine) > 0) |
{ |
$this->Data = $htmlLine; |
// Chunck up the row into columns. |
$tmpListArr = split(",",str_replace(array("'"),"",$htmlLine)); |
if(count($tmpListArr) >= 24) |
{ |
$this->torrentAdded = " | Added" . $dteAdded . " " . $tmpListArr[1]; |
if(strlen($tmpListArr[13])>0) |
{ |
$this->torrentAdded .= " By ". $tmpListArr[13]; |
} |
if( $tmpListArr[2]) |
{ |
$this->torrentFile = "http://www.newnova.org/site/torrents/" . trim($tmpListArr[7]); |
}else{ |
$this->torrentFile = "http://www.newnova.org/get/" . trim($tmpListArr[7]); |
} |
$tmpArr = split(" - ",$tmpListArr[5]); |
if(count($tmpArr) == 2) |
{ |
$this->MainCategory = trim($tmpArr[0]); |
$this->SubCategory = trim($tmpArr[1]); |
} |
else |
{ |
$this->MainCategory = trim($tmpListArr[5]); |
} |
$this->torrentName = $tmpListArr[6]; |
$this->torrentSize = $tmpListArr[8]; |
$this->Seeds = $tmpListArr[9]; |
$this->Peers = $tmpListArr[10]; |
$this->torrentStatus = $tmpListArr[11]; |
if ($this->Peers == '') |
{ |
$this->Peers = "N/A"; |
if (empty($this->Seeds)) $this->Seeds = "N/A"; |
} |
if ($this->Seeds == '') $this->Seeds = "N/A"; |
$this->torrentDisplayName = $this->torrentName; |
if(strlen($this->torrentDisplayName) > 50) |
{ |
$this->torrentDisplayName = substr($this->torrentDisplayName,0,50)."..."; |
} |
} |
} |
} |
//---------------------------------------------------------------- |
// Function to build output for the table. |
function BuildOutput($bg, $searchURL = '') |
{ |
$output = "<tr>\n"; |
$output .= " <td width=16 bgcolor=\"".$bg."\"><a href=\"index.php?url_upload=".$this->torrentFile."\"><img src=\"images/download_owner.gif\" width=\"16\" height=\"16\" title=\"".$this->torrentName." ".$this->torrentAdded."\" border=0></a></td>\n"; |
$output .= " <td bgcolor=\"".$bg."\"><a href=\"index.php?url_upload=".$this->torrentFile."\" title=\"".$this->torrentName."\">".$this->torrentDisplayName."</a></td>\n"; |
if (strlen($this->SubCategory) > 1){ |
$genre = $this->MainCategory . " - " . $this->SubCategory; |
}else{ |
$genre = $this->MainCategory; |
} |
$output .= " <td bgcolor=\"".$bg."\">". $genre ."</td>\n"; |
$output .= " <td bgcolor=\"".$bg."\" align=right>".$this->torrentSize."</td>\n"; |
$output .= " <td bgcolor=\"".$bg."\" align=center>".$this->Seeds."</td>\n"; |
$output .= " <td bgcolor=\"".$bg."\" align=center>".$this->Peers."</td>\n"; |
$output .= " <td bgcolor=\"".$bg."\" align=center>".$this->torrentStatus."</td>\n"; |
$output .= "</tr>\n"; |
return $output; |
} |
} |
?> |
/web/kaklik's_web/torrentflux/searchEngines/SearchEngineBase.php |
---|
0,0 → 1,315 |
<?php |
/************************************************************* |
* TorrentFlux PHP Torrent Manager |
* www.torrentflux.com |
**************************************************************/ |
/* |
This file is part of TorrentFlux. |
TorrentFlux is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
TorrentFlux is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with TorrentFlux; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
*/ |
/* |
This is the base search engine class that is inherited from to |
create specialized search engines. |
Each new Search must use the following nameing standards. |
???Engine.php where ??? is the search engine name. |
!! All changes and customizations should be done in those files and not in this file. !! |
*/ |
// Created By Kboy |
class SearchEngineBase |
{ |
var $engineName = ''; // The Engine Name Must be the same as the File name |
// minus Engine. |
var $mainTitle = ''; // The displayed Main Title for the engine. |
var $mainURL = ''; // The Primary URL used in searching or paging. |
var $altURL = ''; // The alternate URL used in searching or paging. |
var $author = ''; // the author of this engine |
var $version = ''; |
var $updateURL = 'http://www.torrentflux.com/forum/index.php/board,14.0.html'; |
// ------------------------------------------------------------------------------ |
// You should only need to set the above variables in each of the custom classes. |
// ------------------------------------------------------------------------------ |
var $cfg = array(); // The config array that holds the config settings of |
// TorrentFlux at time of initialization |
// This may contain the mainCatalog and catFilter |
// as assigned by the admin tool. |
// If it doesn't then we ask the individual engines for there |
// mainCatalog and catFilter. |
var $mainCatalogName = ''; // The name of the Main Catalog |
var $mainCatalog = array(); // An array of Main Catalog entries. |
var $subCatalog = array(); // An array of Sub Catalog entries. |
var $catFilterName = ''; // Name of Filter used to retrieve from DB. |
var $catFilter = array(); // An array of categories to Filter out from DB. |
var $curRequest =''; // The actual Request sent to the Search Engine |
var $hideSeedless = false; // Boolean to determine if we should hide or show seedless torrents |
var $searchTerm = ''; // Search term passed into the engine |
var $htmlPage = ''; // HTML created by the engine for displaying |
var $msg = ''; // Message to be displayed |
var $pg = ''; // Page Variable used in Paging |
var $fp = ''; // Pointer to a socket connection |
var $initialized = false; // Boolean to determine if the search engine initialized ok. |
/** |
* Constructor |
*/ |
function SearchEngineBase() |
{ |
die('Virtual Class -- cannot instantiate'); |
} |
//---------------------------------------------------------------- |
// Initialize the Search Engine setting up the Catalog and Filters. |
// and Testing the connection. |
function Initialize($cfg) |
{ |
$rtnValue = false; |
$this->cfg = unserialize($cfg); |
$this->pg = getRequestVar('pg'); |
if (empty($this->altURL)) |
$this->altURL = $this->mainURL; |
if (empty($this->cfg)) |
{ |
$this->msg = "Config not passed"; |
$this->initialized = false; |
return; |
} |
$this->catFilterName = $this->engineName."GenreFilter"; |
$this->mainCatalogName = $this->engineName."_catalog"; |
if (array_key_exists('hideSeedless',$_SESSION)) |
$this->hideSeedless = $_SESSION['hideSeedless']; |
if (array_key_exists($this->catFilterName,$this->cfg)) |
$this->catFilter = $this->cfg[$this->catFilterName]; |
else |
$this->catFilter = array(); |
if (array_key_exists($this->mainCatalogName,$this->cfg)) |
$this->mainCatalog = $this->cfg[$this->mainCatalogName]; |
else |
$this->populateMainCategories(); |
if ( $this->getConnection() ) |
$rtnValue = true; |
$this->closeConnection(); |
// in PHP 5 use |
//$this->curRequest = http_build_query($_REQUEST); |
$this->curRequest = $this->http_query_builder($_REQUEST); |
$this->initialized = $rtnValue; |
} |
//------------------------------------------------------------------ |
// This is for backward compatibility. |
function http_query_builder( $formdata, $numeric_prefix = null, $key = null ) |
{ |
$res = array(); |
foreach ((array)$formdata as $k=>$v) { |
$tmp_key = urlencode(is_int($k) ? $numeric_prefix.$k : $k); |
if ($key) $tmp_key = $key.'['.$tmp_key.']'; |
if ( is_array($v) || is_object($v) ) { |
$res[] = http_query_builder($v, null, $tmp_key); |
} else { |
$res[] = $tmp_key."=".urlencode($v); |
} |
} |
$separator = ini_get('arg_separator.output'); |
return implode($separator, $res); |
} |
//---------------------------------------------------------------- |
// Function to populate the mainCatalog |
function populateMainCategories() |
{ |
return; |
} |
//---------------------------------------------------------------- |
// Function to Get Sub Categories |
function getSubCategories($mainGenre) |
{ |
return array(); |
} |
//---------------------------------------------------------------- |
// Function to test Connection. |
function getConnection() |
{ |
// Try to connect |
if (!$this->fp = @fsockopen ($this->mainURL, 80, $errno, $errstr, 30)) |
{ |
// Error Connecting |
$this->msg = "Error connecting to ".$this->mainURL."!"; |
return false; |
} |
return true; |
} |
//---------------------------------------------------------------- |
// Function to Close Connection. |
function closeConnection() |
{ |
if($this->fp) |
{ |
fclose($this->fp); |
} |
} |
//---------------------------------------------------------------- |
// Function to return the URL needed by tf |
function searchURL() |
{ |
return "torrentSearch.php?searchEngine=".$this->engineName; |
} |
//---------------------------------------------------------------- |
// Function to Make the GetRequest |
function makeRequest($request, $useAlt = false) |
{ |
$rtnVal = false; |
if (isset($_SESSION['lastOutBoundURI'])) |
{ |
$refererURI = $_SESSION['lastOutBoundURI']; |
} |
else |
{ |
$refererURI = "http://".$this->mainURL; |
} |
if ($useAlt) |
{ |
$request = "http://".$this->altURL. $request; |
} |
else |
{ |
$request = "http://".$this->mainURL. $request; |
} |
$this->htmlPage = FetchHTML( $request, $refererURI ); |
$rtnVal = true; |
return $rtnVal; |
} |
//---------------------------------------------------------------- |
// Function to Get Main Categories |
function getMainCategories($filtered = true) |
{ |
$output = array(); |
foreach ($this->mainCatalog as $mainId => $mainName) |
{ |
if ($filtered) |
{ |
// see if this is filtered out. |
if (!(@in_array($mainId, $this->catFilter))) |
{ |
$output[$mainId] = $mainName; |
} |
} |
else |
{ |
$output[$mainId] = $mainName; |
} |
} |
return $output; |
} |
//---------------------------------------------------------------- |
// Function to Get Main Category Name |
function GetMainCatName($mainGenre) |
{ |
$mainGenreName = ''; |
foreach ($this->getMainCategories() as $mainId => $mainName) |
{ |
if ($mainId == $mainGenre) |
{ |
$mainGenreName = $mainName; |
} |
} |
return $mainGenreName; |
} |
//---------------------------------------------------------------- |
// Function to setup the table header |
function tableHeader() |
{ |
$output = "<table width=\"100%\" cellpadding=3 cellspacing=0 border=0>"; |
$output .= "<br>\n"; |
$output .= "<tr bgcolor=\"".$this->cfg["table_header_bg"]."\">"; |
$output .= " <td> </td>"; |
$output .= " <td><strong>Torrent Name</strong> ("; |
$tmpURI = str_replace(array("?hideSeedless=yes","&hideSeedless=yes","?hideSeedless=no","&hideSeedless=no"),"",$_SERVER["REQUEST_URI"]); |
// Check to see if Question mark is there. |
if (strpos($tmpURI,'?')) |
{ |
$tmpURI .= "&"; |
} |
else |
{ |
$tmpURI .= "?"; |
} |
if($this->hideSeedless == "yes") |
{ |
$output .= "<a href=\"". $tmpURI . "hideSeedless=no\">Show Seedless</a>"; |
} |
else |
{ |
$output .= "<a href=\"". $tmpURI . "hideSeedless=yes\">Hide Seedless</a>"; |
} |
$output .= ")</td>"; |
$output .= " <td><strong>Category</strong></td>"; |
$output .= " <td align=center><strong> Size</strong></td>"; |
$output .= " <td><strong>Seeds</strong></td>"; |
$output .= " <td><strong>Peers</strong></td>"; |
$output .= "</tr>\n"; |
return $output; |
} |
} |
?> |
/web/kaklik's_web/torrentflux/searchEngines/TorrentBoxEngine.php |
---|
0,0 → 1,390 |
<?php |
/************************************************************* |
* TorrentFlux PHP Torrent Manager |
* www.torrentflux.com |
**************************************************************/ |
/* |
This file is part of TorrentFlux. |
TorrentFlux is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
TorrentFlux is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with TorrentFlux; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
*/ |
class SearchEngine extends SearchEngineBase |
{ |
function SearchEngine($cfg) |
{ |
$this->mainURL = "torrentbox.com"; |
$this->altURL = "torrentbox.com"; |
$this->mainTitle = "TorrentBox"; |
$this->engineName = "TorrentBox"; |
$this->author = "kboy"; |
$this->version = "1.00"; |
$this->updateURL = "http://www.torrentflux.com/forum/index.php/topic,876.0.html"; |
$this->Initialize($cfg); |
} |
function populateMainCategories() |
{ |
$this->mainCatalog["0"] = "(all types)"; |
$this->mainCatalog["9"] = "Anime"; |
$this->mainCatalog["90"] = "Apps"; |
$this->mainCatalog["11"] = "Books"; |
$this->mainCatalog["10"] = "Comics"; |
$this->mainCatalog["91"] = "Games"; |
$this->mainCatalog["6"] = "Misc"; |
$this->mainCatalog["92"] = "Movies"; |
$this->mainCatalog["93"] = "Music"; |
$this->mainCatalog["8"] = "Pics"; |
$this->mainCatalog["3"] = "TV"; |
$this->mainCatalog["13"] = "Videos"; |
} |
//---------------------------------------------------------------- |
// Function to Get Sub Categories |
function getSubCategories($mainGenre) |
{ |
$output = array(); |
switch ($mainGenre) |
{ |
case "90" : |
$output["51"] = "Linux"; |
$output["52"] = "Mac"; |
$output["50"] = "Windows"; |
$output["5"] = "Misc"; |
break; |
case "91" : |
$output["4"] = "Misc"; |
$output["41"] = "PC"; |
$output["42"] = "PS2"; |
$output["43"] = "PSX"; |
$output["44"] = "ROMS"; |
$output["40"] = "Xbox"; |
break; |
case "92" : |
$output["14"] = "DVD-R"; |
$output["100"] = "Action"; |
$output["101"] = "Adventure"; |
$output["102"] = "Animation"; |
$output["103"] = "Comedy"; |
$output["104"] = "Drama"; |
$output["105"] = "Documentary"; |
$output["106"] = "Horror"; |
$output["107"] = "Sci-Fi"; |
$output["1"] = "Misc"; |
break; |
case "93" : |
$output["15"] = "Alternative"; |
$output["16"] = "Blues"; |
$output["17"] = "Electronic"; |
$output["18"] = "Pop"; |
$output["19"] = "Rap"; |
$output["20"] = "Rock"; |
$output["21"] = "Reggae"; |
$output["22"] = "Jazz"; |
$output["23"] = "Dance"; |
$output["24"] = "Christian"; |
$output["25"] = "Spanish"; |
$output["2"] = "Misc"; |
break; |
} |
return $output; |
} |
//---------------------------------------------------------------- |
// Function to Make the Request (overriding base) |
function makeRequest($request) |
{ |
return parent::makeRequest($request, false); |
} |
//---------------------------------------------------------------- |
// Function to get Latest.. |
function getLatest() |
{ |
$cat = getRequestVar('subGenre'); |
if (empty($cat)) $cat = getRequestVar('cat'); |
$request = "/torrents-browse.php"; |
if(!empty($cat)) |
{ |
if(strpos($request,"?")) |
{ |
$request .= "&cat=".$cat; |
} |
else |
{ |
$request .= "?cat=".$cat; |
} |
} |
if (!empty($this->pg)) |
{ |
if(strpos($request,"?")) |
{ |
$request .= "&page=" . $this->pg; |
} |
else |
{ |
$request .= "?page=" . $this->pg; |
} |
} |
if ($this->makeRequest($request)) |
{ |
return $this->parseResponse(); |
} |
else |
{ |
return $this->msg; |
} |
} |
//---------------------------------------------------------------- |
// Function to perform Search. |
function performSearch($searchTerm) |
{ |
$searchTerm = str_replace(" ", "+", $searchTerm); |
$request = "/torrents-search.php?search=".$searchTerm; |
if(!empty($cat)) |
{ |
$request .= "&cat=".$cat; |
} |
$onlyname = getRequestVar('onlyname'); |
if (empty($onlyname)) $onlyname = "no"; |
$request .= "&onlyname=".$onlyname; |
$incldead = getRequestVar('incldead'); |
if (empty($incldead)) $incldead = "0"; |
$request .= "&incldead=".$incldead; |
$request .= "&submit="; |
if (!empty($this->pg)) |
{ |
$request .= "&page=" . $this->pg; |
} |
if ($this->makeRequest($request)) |
{ |
return $this->parseResponse(); |
} |
else |
{ |
return $this->msg; |
} |
} |
//---------------------------------------------------------------- |
// Function to parse the response. |
function parseResponse() |
{ |
$output = $this->tableHeader(); |
$thing = $this->htmlPage; |
// We got a response so display it. |
// Chop the front end off. |
while (is_integer(strpos($thing,">Uploader<"))) |
{ |
$thing = substr($thing,strpos($thing,">Uploader<")); |
$thing = substr($thing,strpos($thing,"<tr")); |
$tmpList = substr($thing,0,strpos($thing,"</table>")); |
// ok so now we have the listing. |
$tmpListArr = split("</tr>",$tmpList); |
$bg = $this->cfg["bgLight"]; |
foreach($tmpListArr as $key =>$value) |
{ |
$buildLine = true; |
if (strpos($value,"download.php")) |
{ |
$ts = new tBox($value); |
// Determine if we should build this output |
if (is_int(array_search($ts->CatName,$this->catFilter))) |
{ |
$buildLine = false; |
} |
if ($this->hideSeedless == "yes") |
{ |
if($ts->Seeds == "N/A" || $ts->Seeds == "0") |
{ |
$buildLine = false; |
} |
} |
if (!empty($ts->torrentFile) && $buildLine) { |
$output .= trim($ts->BuildOutput($bg)); |
// ok switch colors. |
if ($bg == $this->cfg["bgLight"]) |
{ |
$bg = $this->cfg["bgDark"]; |
} |
else |
{ |
$bg = $this->cfg["bgLight"]; |
} |
} |
} |
} |
// set thing to end of this table. |
$thing = substr($thing,strpos($thing,"</table>")); |
} |
$output .= "</table>"; |
//http://www.torrentbox.com/torrents-browse.php?cat=4&page=2 |
// is there paging at the bottom? |
if (strpos($thing, "<span class=\"pager\">") != false) |
{ |
// Yes, then lets grab it and display it! ;) |
$thing = substr($thing,strpos($thing,"<span class=\"pager\">")+strlen("<span class=\"pager\">")); |
$pages = substr($thing,0,strpos($thing,"</span>")); |
if(strpos($this->curRequest,"LATEST")) |
{ |
if(strpos($pages,"cat=")) |
{ |
$pages = str_replace("page=","pg=",str_replace("http://www.torrentbox.com/torrents-browse.php?",$this->searchURL()."&LATEST=1&",$pages)); |
} |
else |
{ |
$pages = str_replace("http://www.torrentbox.com/torrents-browse.php?page=",$this->searchURL()."&LATEST=1&pg=",$pages); |
} |
} |
else |
{ |
$pages = str_replace("page","pg",str_replace("http://www.torrentbox.com/torrents-browse.php?search=",$this->searchURL()."&searchterm=",$pages)); |
} |
$output .= "<div align=center>".$pages."</div>"; |
} |
return $output; |
} |
} |
// This is a worker class that takes in a row in a table and parses it. |
class tBox |
{ |
var $torrentName = ""; |
var $torrentDisplayName = ""; |
var $torrentFile = ""; |
var $torrentSize = ""; |
var $torrentStatus = ""; |
var $CatId = ""; |
var $CatName = ""; |
var $fileCount = ""; |
var $Seeds = ""; |
var $Peers = ""; |
var $Data = ""; |
var $dateAdded = ""; |
var $dwnldCount = ""; |
function tBox( $htmlLine ) |
{ |
if (strlen($htmlLine) > 0) |
{ |
$this->Data = $htmlLine; |
// Fix messed up end td's once in a while. |
$htmlLine = eregi_replace("<(.)*1ff8(.)*/td>",'</td>',$htmlLine); |
$htmlLine = eregi_replace("1ff8",'',$htmlLine); |
// Chunck up the row into columns. |
$tmpListArr = split("</td>",$htmlLine); |
if(count($tmpListArr) > 8) |
{ |
$this->CatName = $this->cleanLine($tmpListArr["0"]); // Cat Name |
if (strpos($this->CatName,">")) |
{ |
$this->CatName = trim(substr($this->CatName,strpos($this->CatName,">")+1)); |
} |
$this->torrentName = $this->cleanLine($tmpListArr["1"]); // TorrentName |
$tmpStr = substr($tmpListArr["2"],strpos($tmpListArr["2"],"href=\"")+strlen("href=\"")); // Download Link |
$this->torrentFile = substr($tmpStr,0,strpos($tmpStr,"\"")); |
$this->dateAdded = $this->cleanLine($tmpListArr["4"]); // Date Added |
$this->torrentSize = $this->cleanLine($tmpListArr["5"]); // Size of File |
$this->dwnldCount = $this->cleanLine($tmpListArr["6"]); // Download Count |
$this->Seeds = $this->cleanLine($tmpListArr["7"]); // Seeds |
$this->Peers = $this->cleanLine($tmpListArr["8"]); // Peers |
//$tmpListArr["9"] = $this->cleanLine($tmpListArr["9"]); // Person who Uploaded it. |
if ($this->Peers == '') |
{ |
$this->Peers = "N/A"; |
if (empty($this->Seeds)) $this->Seeds = "N/A"; |
} |
if ($this->Seeds == '') $this->Seeds = "N/A"; |
$this->torrentDisplayName = $this->torrentName; |
if(strlen($this->torrentDisplayName) > 50) |
{ |
$this->torrentDisplayName = substr($this->torrentDisplayName,0,50)."..."; |
} |
} |
} |
} |
function cleanLine($stringIn,$tags='') |
{ |
if(empty($tags)) |
return trim(str_replace(array(" "," ")," ",strip_tags($stringIn))); |
else |
return trim(str_replace(array(" "," ")," ",strip_tags($stringIn,$tags))); |
} |
//---------------------------------------------------------------- |
// Function to build output for the table. |
function BuildOutput($bg) |
{ |
$output = "<tr>\n"; |
$output .= " <td width=16 bgcolor=\"".$bg."\"><a href=\"index.php?url_upload=".$this->torrentFile."\"><img src=\"images/download_owner.gif\" width=\"16\" height=\"16\" title=\"".$this->torrentName."\" border=0></a></td>\n"; |
$output .= " <td bgcolor=\"".$bg."\"><a href=\"index.php?url_upload=".$this->torrentFile."\" title=\"".$this->torrentName."\">".$this->torrentDisplayName."</a></td>\n"; |
$output .= " <td bgcolor=\"".$bg."\">". $this->CatName ."</td>\n"; |
$output .= " <td bgcolor=\"".$bg."\" align=right>".$this->torrentSize."</td>\n"; |
$output .= " <td bgcolor=\"".$bg."\" align=center>".$this->Seeds."</td>\n"; |
$output .= " <td bgcolor=\"".$bg."\" align=center>".$this->Peers."</td>\n"; |
$output .= "</tr>\n"; |
return $output; |
} |
} |
?> |
/web/kaklik's_web/torrentflux/searchEngines/TorrentPortalEngine.php |
---|
0,0 → 1,458 |
<?php |
/************************************************************* |
* TorrentFlux PHP Torrent Manager |
* www.torrentflux.com |
**************************************************************/ |
/* |
This file is part of TorrentFlux. |
TorrentFlux is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
TorrentFlux is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with TorrentFlux; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
*/ |
/* |
v 1.01 - change in parsing routine |
v 1.02 - Mar 19, 06 - another change in the parsing. and updated paging |
*/ |
class SearchEngine extends SearchEngineBase |
{ |
function SearchEngine($cfg) |
{ |
$this->mainURL = "torrentportal.com"; |
$this->altURL = "tp.searching.com"; |
$this->mainTitle = "TorrentPortal"; |
$this->engineName = "TorrentPortal"; |
$this->author = "kboy"; |
$this->version = "1.02"; |
$this->updateURL = "http://www.torrentflux.com/forum/index.php?topic=875.0.html"; |
$this->Initialize($cfg); |
} |
//---------------------------------------------------------------- |
// Function to Get Main Categories |
function populateMainCategories() |
{ |
$this->mainCatalog["0"] = "(all types)"; |
$this->mainCatalog["1"] = "Games"; |
$this->mainCatalog["2"] = "Movies"; |
$this->mainCatalog["3"] = "TV"; |
$this->mainCatalog["4"] = "Videos"; |
$this->mainCatalog["5"] = "Apps"; |
$this->mainCatalog["6"] = "Anime"; |
$this->mainCatalog["7"] = "Audio"; |
$this->mainCatalog["8"] = "Comics"; |
$this->mainCatalog["9"] = "Unsorted"; |
$this->mainCatalog["10"] = "Porn"; |
} |
//---------------------------------------------------------------- |
// Function to Make the Request (overriding base) |
function makeRequest($request) |
{ |
return parent::makeRequest($request, false); |
} |
//---------------------------------------------------------------- |
// Function to get Latest.. |
function getLatest() |
{ |
$cat = getRequestVar('subGenre'); |
$count = getRequestVar('count'); |
if (empty($cat)) $cat = getRequestVar('cat'); |
if(empty($cat) && empty($this->pg)) |
{ |
$request = "/new-torrents.php"; |
} |
else |
{ |
$request = "/torrents.php"; |
} |
if(!empty($cat)) |
{ |
if(strpos($request,"?")) |
{ |
$request .= "&cat=".$cat; |
} |
else |
{ |
$request .= "?cat=".$cat; |
} |
} |
if(!empty($count)) |
{ |
if(strpos($request,"?")) |
{ |
$request .= "&count=".$count; |
} |
else |
{ |
$request .= "?count=".$count; |
} |
} |
if (!empty($this->pg)) |
{ |
if(strpos($request,"?")) |
{ |
$request .= "&page=" . $this->pg; |
} |
else |
{ |
$request .= "?page=" . $this->pg; |
} |
} |
if ($this->makeRequest($request)) |
{ |
return $this->parseResponse(); |
} |
else |
{ |
return $this->msg; |
} |
} |
//---------------------------------------------------------------- |
// Function to perform Search. |
function performSearch($searchTerm) |
{ |
$searchTerm = str_replace(" ", "+", $searchTerm); |
$request = "/torrents-search.php?search=".$searchTerm; |
if(!empty($cat)) |
{ |
$request .= "&cat=".$cat; |
} |
$count = getRequestVar('count'); |
if(!empty($count)) |
{ |
$request .= "&count=".$count; |
} |
$onlyname = getRequestVar('onlyname'); |
if (empty($onlyname)) $onlyname = "no"; |
$request .= "&onlyname=".$onlyname; |
$incldead = getRequestVar('incldead'); |
if (empty($incldead)) $incldead = "0"; |
$request .= "&incldead=".$incldead; |
$request .= "&submit="; |
if (!empty($this->pg)) |
{ |
$request .= "&page=" . $this->pg; |
} |
if ($this->makeRequest($request,true)) |
{ |
return $this->parseResponse(); |
} |
else |
{ |
return $this->msg; |
} |
} |
//---------------------------------------------------------------- |
// Override the base to show custom table header. |
// Function to setup the table header |
function tableHeader() |
{ |
$output = "<table width=\"100%\" cellpadding=3 cellspacing=0 border=0>"; |
$output .= "<br>\n"; |
$output .= "<tr bgcolor=\"".$this->cfg["table_header_bg"]."\">"; |
$output .= " <td> </td>"; |
$output .= " <td><strong>Torrent Name</strong> ("; |
$tmpURI = str_replace(array("?hideSeedless=yes","&hideSeedless=yes","?hideSeedless=no","&hideSeedless=no"),"",$_SERVER["REQUEST_URI"]); |
// Check to see if Question mark is there. |
if (strpos($tmpURI,'?')) |
{ |
$tmpURI .= "&"; |
} |
else |
{ |
$tmpURI .= "?"; |
} |
if($this->hideSeedless == "yes") |
{ |
$output .= "<a href=\"". $tmpURI . "hideSeedless=no\">Show Seedless</a>"; |
} |
else |
{ |
$output .= "<a href=\"". $tmpURI . "hideSeedless=yes\">Hide Seedless</a>"; |
} |
$output .= ")</td>"; |
$output .= " <td><strong>Category</strong></td>"; |
$output .= " <td align=center><strong> Size</strong></td>"; |
$output .= " <td><strong>Seeds</strong></td>"; |
$output .= " <td><strong>Peers</strong></td>"; |
$output .= " <td><strong>Health</strong></td>"; |
$output .= "</tr>\n"; |
return $output; |
} |
//---------------------------------------------------------------- |
// Function to parse the response. |
function parseResponse() |
{ |
$output = $this->tableHeader(); |
$thing = $this->htmlPage; |
// We got a response so display it. |
// Chop the front end off. |
while (is_integer(strpos($thing,">Health"))) |
{ |
$thing = substr($thing,strpos($thing,">Health")); |
$thing = substr($thing,strpos($thing,"<tr")); |
$tmpList = substr($thing,0,strpos($thing,"</table>")); |
// ok so now we have the listing. |
$tmpListArr = split("<tr>",$tmpList); |
$bg = $this->cfg["bgLight"]; |
foreach($tmpListArr as $key =>$value) |
{ |
$buildLine = true; |
if (strpos($value,"/download/")) |
{ |
$ts = new tPort($value); |
// Determine if we should build this output |
if (is_int(array_search($ts->MainCategory,$this->catFilter))) |
{ |
$buildLine = false; |
} |
if ($this->hideSeedless == "yes") |
{ |
if($ts->Seeds == "N/A" || $ts->Seeds == "0") |
{ |
$buildLine = false; |
} |
} |
if (!empty($ts->torrentFile) && $buildLine) { |
$output .= trim($ts->BuildOutput($bg, $this->searchURL())); |
// ok switch colors. |
if ($bg == $this->cfg["bgLight"]) |
{ |
$bg = $this->cfg["bgDark"]; |
} |
else |
{ |
$bg = $this->cfg["bgLight"]; |
} |
} |
} |
} |
// set thing to end of this table. |
$thing = substr($thing,strpos($thing,"</table>")); |
} |
$output .= "</table>"; |
// is there paging at the bottom? |
/* |
<p align="center"><b>1 - 25</b> | <a href="?search=test&count=87&page=1"><b>26 - 50</b></a> | <a href="?search=test&count=87&page=2"><b>51 - 75</b></a> | <a href="?search=test&count=87&page=3"><b>76 - 87</b></a><br /><b><< Prev</b> <a href="?search=test&count=87&page=1"><b>Next >></b></a></p> |
*/ |
if (strpos($thing, "page=") != false) |
{ |
// Yes, then lets grab it and display it! ;) |
$thing = substr($thing,strpos($thing,"<p align=\"center\">")+strlen("<p align=\"center\">")); |
$pages = substr($thing,0,strpos($thing,"</p>")); |
//$output .= $pages; |
if(strpos($this->curRequest,"LATEST")) |
{ |
if(strpos($pages,"cat=")) |
{ |
$pages = str_replace("page=","pg=",str_replace("?",$this->searchURL()."&LATEST=1&",$pages)); |
} |
else |
{ |
$pages = str_replace("?page=",$this->searchURL()."&LATEST=1&pg=",$pages); |
} |
} |
else |
{ |
if(strpos($pages,"\"?")) |
{ |
$pages = str_replace("?",$this->searchURL()."&",$pages); |
} |
if(strpos($pages,"?search=")) |
{ |
$pages = str_replace("?search=",$this->searchURL()."&searchterm=",$pages); |
} |
if(strpos($pages,"search=")) |
{ |
$pages = str_replace("search=","searchterm=",$pages); |
} |
} |
if(strpos($pages,"torrents.php?")) |
{ |
$pages = str_replace("torrents.php?",$this->searchURL()."&",$pages); |
} |
if(strpos($pages,"torrents-search.php?")) |
{ |
$pages = str_replace("torrents-search.php?",$this->searchURL()."&",$pages); |
} |
$pages = str_replace("page=","pg=",$pages); |
$output .= "<div align=center>".$pages."</div>"; |
} |
return $output; |
} |
} |
// This is a worker class that takes in a row in a table and parses it. |
class tPort |
{ |
var $torrentName = ""; |
var $torrentDisplayName = ""; |
var $torrentFile = ""; |
var $torrentSize = ""; |
var $torrentStatus = ""; |
var $MainId = ""; |
var $MainCategory = ""; |
var $fileCount = ""; |
var $Seeds = ""; |
var $Peers = ""; |
var $Data = ""; |
var $torrentRating = ""; |
function tPort( $htmlLine ) |
{ |
if (strlen($htmlLine) > 0) |
{ |
$this->Data = $htmlLine; |
// Cleanup any bugs in the HTML |
$htmlLine = eregi_replace("</td>\n</td>",'</td>',$htmlLine); |
// Chunck up the row into columns. |
$tmpListArr = split("<td ",$htmlLine); |
if(count($tmpListArr) > 8) |
{ |
$tmpStr = substr($tmpListArr["1"],strpos($tmpListArr["1"],"href=\"")+strlen("href=\"")); // Download Link |
$this->torrentFile = "http://www.torrentportal.com".substr($tmpStr,0,strpos($tmpStr,"\"")); |
$this->MainCategory = $this->cleanLine("<td ".$tmpListArr["3"]."</td>"); // MainCategory |
$tmpStr = substr($tmpListArr["2"],strpos($tmpListArr["2"],"cat=")+strlen("cat=")); // Main Id |
$this->MainId = substr($tmpStr,0,strpos($tmpStr,"\"")); |
$this->torrentName = $this->cleanLine("<td ".$tmpListArr["4"]."</td>"); // TorrentName |
$this->torrentRating = $this->cleanLine("<td ".$tmpListArr["5"]."</td>"); // Rating |
$this->torrentSize = $this->cleanLine("<td ".$tmpListArr["6"]."</td>"); // Size of File |
$this->Seeds = $this->cleanLine("<td ".$tmpListArr["7"]."</td>"); // Seeds |
$this->Peers = $this->cleanLine("<td ".$tmpListArr["8"]."</td>"); // Leech |
$tmpStr = substr($tmpListArr["9"],strpos($tmpListArr["9"],"Health ")+strlen("Health ")); // Health |
$tmpStr = substr($tmpStr,0,strpos($tmpStr,"\"")); |
$tmpArr = split("/",$tmpStr); |
if ($tmpArr["1"] > 0 ) |
{ |
$this->torrentStatus = ($tmpArr["0"] / $tmpArr["1"]) * 100 . "%"; |
} |
else |
{ |
$this->torrentStatus = "0%"; |
} |
if ($this->Peers == '') |
{ |
$this->Peers = "N/A"; |
if (empty($this->Seeds)) $this->Seeds = "N/A"; |
} |
if ($this->Seeds == '') $this->Seeds = "N/A"; |
$this->torrentDisplayName = $this->torrentName; |
if(strlen($this->torrentDisplayName) > 50) |
{ |
$this->torrentDisplayName = substr($this->torrentDisplayName,0,50)."..."; |
} |
} |
} |
} |
function cleanLine($stringIn,$tags='') |
{ |
if(empty($tags)) |
return trim(str_replace(array(" "," ")," ",strip_tags($stringIn))); |
else |
return trim(str_replace(array(" "," ")," ",strip_tags($stringIn,$tags))); |
} |
//---------------------------------------------------------------- |
// Function to build output for the table. |
function BuildOutput($bg, $searchURL = '') |
{ |
$output = "<tr>\n"; |
$output .= " <td width=16 bgcolor=\"".$bg."\"><a href=\"index.php?url_upload=".$this->torrentFile."\"><img src=\"images/download_owner.gif\" width=\"16\" height=\"16\" title=\"".$this->torrentName."\" border=0></a></td>\n"; |
$output .= " <td bgcolor=\"".$bg."\"><a href=\"index.php?url_upload=".$this->torrentFile."\" title=\"".$this->torrentName."\">".$this->torrentDisplayName."</a></td>\n"; |
if (strlen($this->MainCategory) > 1){ |
$genre = "<a href=\"".$searchURL."&mainGenre=".$this->MainId."\">".$this->MainCategory."</a>"; |
}else{ |
$genre = ""; |
} |
$output .= " <td bgcolor=\"".$bg."\">". $genre ."</td>\n"; |
$output .= " <td bgcolor=\"".$bg."\" align=right>".$this->torrentSize."</td>\n"; |
$output .= " <td bgcolor=\"".$bg."\" align=center>".$this->Seeds."</td>\n"; |
$output .= " <td bgcolor=\"".$bg."\" align=center>".$this->Peers."</td>\n"; |
$output .= " <td bgcolor=\"".$bg."\" align=center>".$this->torrentStatus."</td>\n"; |
$output .= "</tr>\n"; |
return $output; |
} |
} |
?> |
/web/kaklik's_web/torrentflux/searchEngines/TorrentSpyEngine.php |
---|
0,0 → 1,539 |
<?php |
/************************************************************* |
* TorrentFlux PHP Torrent Manager |
* www.torrentflux.com |
**************************************************************/ |
/* |
This file is part of TorrentFlux. |
TorrentFlux is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
TorrentFlux is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with TorrentFlux; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
*/ |
/* |
v 1.01 - Changed Main Categories. (removed TV, changed Movies to Video) |
v 1.02 - Mar 19, 06 - Updated pageing. |
*/ |
class SearchEngine extends SearchEngineBase |
{ |
function SearchEngine($cfg) |
{ |
$this->mainURL = "torrentspy.com"; |
$this->altURL = "ts.searching.com"; |
$this->mainTitle = "TorrentSpy"; |
$this->engineName = "TorrentSpy"; |
$this->author = "kboy"; |
$this->version = "1.02"; |
$this->updateURL = "http://www.torrentflux.com/forum/index.php/topic,874.0.html"; |
$this->Initialize($cfg); |
} |
function populateMainCategories() |
{ |
$this->mainCatalog["11"] = "Adult"; |
$this->mainCatalog["6"] = "Anime"; |
$this->mainCatalog["1"] = "Applications"; |
$this->mainCatalog["2"] = "Games"; |
$this->mainCatalog["13"] = "Handheld"; |
$this->mainCatalog["7"] = "Hentai"; |
$this->mainCatalog["8"] = "Linux"; |
$this->mainCatalog["9"] = "Macintosh"; |
$this->mainCatalog["10"] = "Misc"; |
$this->mainCatalog["3"] = "Music"; |
$this->mainCatalog["14"] = "Non-English"; |
$this->mainCatalog["12"] = "Unsorted/Other"; |
$this->mainCatalog["4"] = "Videos"; |
} |
//---------------------------------------------------------------- |
// Function to Get Sub Categories |
function getSubCategories($mainGenre) |
{ |
$output = array(); |
if (strpos($mainGenre,'/')) |
{ |
$request = '/directory/' . $mainGenre; |
} |
else |
{ |
$request = '/directory.asp?mode=main&id=' . $mainGenre; |
} |
$mainGenreName = $this->GetMainCatName($mainGenre); |
if ($this->makeRequest($request)) |
{ |
$thing = $this->htmlPage; |
while (is_integer(strpos($thing,"href=\"/directory/"))) |
{ |
$thing = substr($thing,strpos($thing,"href=\"/directory/")+strlen("href=\"/directory/")); |
$tmpStr = str_replace(array("%2f","+")," ",substr($thing,0,strpos($thing,"\""))); |
$tmpStr = str_replace("%2d","-",$tmpStr); |
$subid = $tmpStr; |
$thing = substr($thing,strpos($thing,">")+strlen(">")); |
$subname = trim(substr($thing,0,strpos($thing,"<"))); |
if($subname != $mainGenreName) |
{ |
$output[$subid] = $subname; |
} |
} |
} |
return $output; |
} |
//---------------------------------------------------------------- |
// Function to Make the Request (overriding base) |
function makeRequest($request) |
{ |
if (strpos($request,"search.asp")) |
{ |
return parent::makeRequest($request, true); |
} |
else |
{ |
return parent::makeRequest($request, false); |
} |
} |
//---------------------------------------------------------------- |
// Function to get Latest.. |
function getLatest() |
{ |
$request = '/latest.asp'; |
// Added mode to support yesterday request. |
if (array_key_exists("mode",$_REQUEST)) |
{ |
$request .='?mode='.$_REQUEST["mode"]; |
if (array_key_exists("id",$_REQUEST)) |
{ |
$request .= '&id=' . $_REQUEST["id"]; |
} |
if (!empty($this->pg)) |
{ |
$request .= '&pg=' . $this->pg; |
} |
} |
elseif (array_key_exists("subGenre",$_REQUEST)) |
{ |
if (strpos($_REQUEST["subGenre"],"/")>0) |
{ |
$request ='/directory.asp?mode=sub&id=' . substr($_REQUEST["subGenre"],0,strpos($_REQUEST["subGenre"],"/")); |
} |
else |
{ |
$request ='/directory.asp?mode=sub&id=' . $_REQUEST["subGenre"]; |
} |
if (!empty($this->pg)) |
{ |
$request .= '&pg=' . $this->pg; |
} |
} |
elseif (!empty($this->pg)) |
{ |
$request .= '?pg=' . $this->pg; |
} |
if ($this->makeRequest($request)) |
{ |
return $this->parseResponse(); |
} |
else |
{ |
return $this->msg; |
} |
} |
//---------------------------------------------------------------- |
// Function to perform Search. |
function performSearch($searchTerm) |
{ |
if (array_key_exists("directory",$_REQUEST)) |
{ |
$request = "/directory/" . str_replace("%2F","/",urlencode($_REQUEST["directory"])); |
if (!empty($this->pg)) |
{ |
$request .= "?pg=" . $this->pg; |
} |
} |
elseif (array_key_exists("getMain",$_REQUEST)) |
{ |
$request = '/directory'; |
} |
elseif (array_key_exists("mainGenre",$_REQUEST)) |
{ |
if (strpos($_REQUEST["mainGenre"],'/')) |
{ |
$request .= '/' . $_REQUEST["mainGenre"]; |
} |
else |
{ |
if (!empty($this->pg)) |
{ |
$request = '/directory.asp?mode=main&id=' . $_REQUEST["mainGenre"] . '&pg=' . $this->pg; |
} |
else |
{ |
$request = '/directory.asp?mode=main&id=' . $_REQUEST["mainGenre"]; |
} |
} |
} |
elseif (array_key_exists("subGenre",$_REQUEST)) |
{ |
if (strpos($_REQUEST["subGenre"],'/')) |
{ |
$request = "/directory/" . $_REQUEST["subGenre"]; |
} |
else |
{ |
if ($_REQUEST["subGenre"] != "") |
{ |
if (!empty($this->pg)) |
{ |
$request = '/directory.asp?mode=sub&id=' . $_REQUEST["subGenre"] . '&pg=' . $this->pg; |
} |
else |
{ |
$request = '/directory.asp?mode=sub&id=' . $_REQUEST["subGenre"]; |
} |
} |
} |
} |
else |
{ |
$searchTerm = str_replace(" ", "+", $searchTerm); |
if ( $this->pg != '' && array_key_exists("db",$_REQUEST)) |
{ |
$request = '/search.asp?query=' . $searchTerm . '&pg=' . $this->pg . '&db=' . $_REQUEST["db"] . '&submit.x=24&submit.y=10'; |
} |
else |
{ |
$request = '/search.asp?query=' . $searchTerm . '&submit.x=24&submit.y=10'; |
} |
} |
if ($this->makeRequest($request)) |
{ |
return $this->parseResponse(); |
} |
else |
{ |
return $this->msg; |
} |
} |
//---------------------------------------------------------------- |
// Function to parse the response. |
function parseResponse() |
{ |
$output = $this->tableHeader(); |
$thing = $this->htmlPage; |
if (strpos($thing, "experiencing high load") > 0) |
{ |
$output .= "<b>We're experiencing high load at this time. Please use the directory until further notice.</b>"; |
}else{ |
// We got a response so display it. |
// Chop the front end off. |
while (is_integer(strpos($thing,">Health<"))) |
{ |
$thing = substr($thing,strpos($thing,">Health<")); |
$thing = substr($thing,strpos($thing,"<tr")); |
$tmpList = substr($thing,0,strpos($thing,"</table>")); |
// ok so now we have the listing. |
$tmpListArr = split("</tr>",$tmpList); |
$langFile = _FILE; |
$bg = $this->cfg["bgLight"]; |
foreach($tmpListArr as $key =>$value) |
{ |
$buildLine = true; |
if (strpos($value,"/torrent/")) |
{ |
$ts = new tSpy($value); |
// Determine if we should build this output |
if (is_int(array_search($ts->MainId,$this->catFilter))) |
{ |
$buildLine = false; |
} |
if ($this->hideSeedless == "yes") |
{ |
if($ts->Seeds == "N/A" || $ts->Seeds == "0") |
{ |
$buildLine = false; |
} |
} |
if (!empty($ts->torrentFile) && $buildLine) { |
$output .= trim($ts->BuildOutput($bg,$langFile,$this->searchURL())); |
// ok switch colors. |
if ($bg == $this->cfg["bgLight"]) |
{ |
$bg = $this->cfg["bgDark"]; |
} |
else |
{ |
$bg = $this->cfg["bgLight"]; |
} |
} |
} |
} |
// set thing to end of this table. |
$thing = substr($thing,strpos($thing,"</table>")); |
} |
} |
$output .= "</table>"; |
// is there paging at the bottom? |
if (strpos($thing, "<p class=\"pagenav\">Pages (") !== false) |
{ |
// Yes, then lets grab it and display it! ;) |
$thing = substr($thing,strpos($thing,"<p class=\"pagenav\">Pages (")+strlen("<p class=\"pagenav\">")); |
$pages = substr($thing,0,strpos($thing,"</p>")); |
$page1 = substr($pages,0,strpos($pages,"<img")); |
$page2 = substr($pages,strlen($page1)); |
$page2 = substr($page2,strpos($page2,'>')+1); |
$pages = $page1.$page2; |
if (strpos($pages,"directory")) |
{ |
$pages = str_replace("?","&",$pages); |
$pages = str_replace("/directory/", $this->searchURL()."&directory=", $pages); |
} |
elseif (strpos($pages, "search.asp?")) |
{ |
$pages = str_replace("search.asp?", $this->searchURL()."&", $pages); |
} |
elseif (strpos($pages, "/search/")) |
{ |
$pages = str_replace("&","&",$pages); |
$pages = str_replace("?","&",$pages); |
$pages = str_replace("/search/", $this->searchURL()."&searchterm=", $pages); |
} |
elseif (strpos($pages,"latest.asp?")) |
{ |
$pages = str_replace("latest.asp?mode=", $this->searchURL()."&LATEST=1&mode=", $pages); |
if (!array_key_exists("mode",$_REQUEST)) |
{ |
$pages .= "<br><a href=\"".$this->searchURL()."&LATEST=1&mode=yesterday\" title=\"Yesterday's Latest\">Yesterday's Latest</a>"; |
} |
elseif (! $_REQUEST["mode"] == "yesterday") |
{ |
$pages .= "<br><a href=\"".$this->searchURL()."&LATEST=1&mode=yesterday\" title=\"Yesterday's Latest\">Yesterday's Latest</a>"; |
} |
else |
{ |
$pages .= "<br><b>Yesterday's Latest</b>"; |
} |
} |
$output .= "<br><div align=center>".$pages."</div><br>"; |
} |
elseif(array_key_exists("LATEST",$_REQUEST)) |
{ |
$pages = ''; |
if (!array_key_exists("mode",$_REQUEST)) |
{ |
$pages .= "<br><a href=\"".$this->searchURL()."&LATEST=1&mode=yesterday\" title=\"Yesterday's Latest\">Yesterday's Latest</a>"; |
} |
elseif (! $_REQUEST["mode"] == "yesterday") |
{ |
$pages .= "<br><a href=\"".$this->searchURL()."&LATEST=1&mode=yesterday\" title=\"Yesterday's Latest\">Yesterday's Latest</a>"; |
} |
else |
{ |
$pages .= "<br><b>Yesterday's Latest</b>"; |
} |
$output .= "<br><div align=center>".$pages."</div><br>"; |
} |
return $output; |
} |
} |
// This is a worker class that takes in a row in a table and parses it. |
class tSpy |
{ |
var $torrentName = ""; |
var $torrentDisplayName = ""; |
var $torrentFile = ""; |
var $torrentStatus = ""; |
var $MainId = ""; |
var $MainCategory = ""; |
var $SubId = ""; |
var $SubCategory = ""; |
var $torrentSize = ""; |
var $fileCount = ""; |
var $Seeds = ""; |
var $Peers = ""; |
var $Data = ""; |
function tSpy( $htmlLine ) |
{ |
if (strlen($htmlLine) > 0) |
{ |
$this->Data = $htmlLine; |
// Chunck up the row into columns. |
$tmpListArr = split("</td>",$htmlLine); |
if(count($tmpListArr) > 5) |
{ |
$tmpListArr["0"]; // Torrent Name, Download Link, Status |
$this->torrentDisplayName = $this->cleanLine($tmpListArr["0"]); // TorrentName |
$tmpStr = substr($tmpListArr["0"],strpos($tmpListArr["0"],"/torrent/")+strlen("/torrent/")); // Download Link |
$this->torrentFile = "http://www.torrentspy.com/download.asp?id=" . substr($tmpStr,0,strpos($tmpStr,"/")); |
$tmpStatus = substr($tmpStr,strpos($tmpStr,"title=\"")+strlen("title=\"")); |
$tmpStatus = substr($tmpStatus,0,strpos($tmpStatus,">")); |
if (strpos($tmpStatus,"password")) |
{ |
$this->torrentStatus = "P"; |
}elseif (strpos($tmpStatus,"register")) |
{ |
$this->torrentStatus = "R"; |
} |
$tmpStr = substr($tmpStr,strpos($tmpStr,">")+strlen(">")); |
if(strpos($tmpStr,"/torrent/") > 0) |
{ |
$tmpStr = substr($tmpStr,strpos($tmpStr,"/torrent/")+strlen("/torrent/")); |
} |
$tmpStr = substr($tmpStr,strpos($tmpStr,"title=\"")+strlen("title=\"")); |
$this->torrentName = substr($tmpStr,0,strpos($tmpStr,"\"")); |
$tmpStr = $tmpListArr["1"]; // Categories |
if(strpos($tmpStr,"mode=")){ |
$tmpStr = substr($tmpStr,strpos($tmpStr,"mode=main&id=")+strlen("mode=main&id=")); |
$this->MainId = substr($tmpStr,0,strpos($tmpStr,"\"")); |
}else{ |
$tmpStr = substr($tmpStr,strpos($tmpStr,"/directory/")+strlen("/directory/")); |
$this->MainId = substr($tmpStr,0,strpos($tmpStr,"/")); |
} |
$tmpStr = substr($tmpStr,strpos($tmpStr,"title=\"")+strlen("title=\"")); |
$this->MainCategory = substr($tmpStr,0,strpos($tmpStr,"\"")); |
if(strpos($tmpStr,"mode=")){ |
$tmpStr = substr($tmpStr,strpos($tmpStr,"mode=sub&id=")+strlen("mode=sub&id=")); |
$this->SubId = substr($tmpStr,0,strpos($tmpStr,"\"")); |
}else{ |
$tmpStr = substr($tmpStr,strpos($tmpStr,"/directory/")+strlen("/directory/")); |
$this->SubId = substr($tmpStr,0,strpos($tmpStr,"/")); |
} |
$tmpStr = substr($tmpStr,strpos($tmpStr,"title=\"")+strlen("title=\"")); |
$this->SubCategory = substr($tmpStr,0,strpos($tmpStr,"\"")); |
$this->torrentSize = $this->cleanLine($tmpListArr["2"]); // Size of File |
$this->fileCount = $this->cleanLine($tmpListArr["3"]); // File Count |
$this->Seeds = $this->cleanLine($tmpListArr["4"]); // Seeds |
$this->Peers = $this->cleanLine($tmpListArr["5"]); // Peers |
//$tmpListArr["6"] = $this->cleanLine($tmpListArr["6"]); // Health |
if ($this->Peers == '') |
{ |
$this->Peers = "N/A"; |
if (empty($this->Seeds)) $this->Seeds = "N/A"; |
} |
if ($this->Seeds == '') $this->Seeds = "N/A"; |
if(strlen($this->torrentDisplayName) > 50) |
{ |
$this->torrentDisplayName = substr($this->torrentDisplayName,0,50)."..."; |
} |
} |
} |
} |
function cleanLine($stringIn,$tags='') |
{ |
if(empty($tags)) |
return trim(str_replace(array(" "," ")," ",strip_tags($stringIn))); |
else |
return trim(str_replace(array(" "," ")," ",strip_tags($stringIn,$tags))); |
} |
//---------------------------------------------------------------- |
// Function to build output for the table. |
function BuildOutput($bg,$langFILE, $searchURL = '') |
{ |
$output = "<tr>\n"; |
$output .= " <td width=16 bgcolor=\"".$bg."\"><a href=\"index.php?url_upload=".$this->torrentFile."\"><img src=\"images/download_owner.gif\" width=\"16\" height=\"16\" title=\"".$this->torrentName." - ".$this->fileCount." ".$langFILE."\" border=0></a></td>\n"; |
$output .= " <td bgcolor=\"".$bg."\"><a href=\"index.php?url_upload=".$this->torrentFile."\" title=\"".$this->torrentName."\">".$this->torrentDisplayName."</a>"; |
switch ($this->torrentStatus) |
{ |
case "R": |
$output .= " <span title=Registration_Needed><b>R</b></span>"; |
break; |
case "P": |
$output .= " <span title=Password_Needed><b>P</b></span>"; |
break; |
} |
$output .= "</td>\n"; |
if (strlen($this->MainCategory) > 1){ |
if (strlen($this->SubCategory) > 1){ |
$mainGenre = "<a href=\"".$searchURL."&mainGenre=".$this->MainId."\">".$this->MainCategory."</a>"; |
$subGenre = "<a href=\"".$searchURL."&subGenre=".$this->SubId."\">".$this->SubCategory."</a>"; |
$genre = $mainGenre."-".$subGenre; |
}else{ |
$genre = "<a href=\"".$searchURL."&mainGenre=".$this->MainId."\">".$this->MainCategory."</a>"; |
} |
}else{ |
$genre = "<a href=\"".$searchURL."&subGenre=".$this->SubId."\">".$this->SubCategory."</a>"; |
} |
$output .= " <td bgcolor=\"".$bg."\">". $genre ."</td>\n"; |
$output .= " <td bgcolor=\"".$bg."\" align=right>".$this->torrentSize."</td>\n"; |
$output .= " <td bgcolor=\"".$bg."\" align=center>".$this->Seeds."</td>\n"; |
$output .= " <td bgcolor=\"".$bg."\" align=center>".$this->Peers."</td>\n"; |
$output .= "</tr>\n"; |
return $output; |
} |
} |
?> |
/web/kaklik's_web/torrentflux/searchEngines/isoHuntEngine.php |
---|
0,0 → 1,383 |
<?php |
/************************************************************* |
* TorrentFlux PHP Torrent Manager |
* www.torrentflux.com |
**************************************************************/ |
/* |
This file is part of TorrentFlux. |
TorrentFlux is free software; you can redistribute it and/or modify |
it under the terms of the GNU General Public License as published by |
the Free Software Foundation; either version 2 of the License, or |
(at your option) any later version. |
TorrentFlux is distributed in the hope that it will be useful, |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
You should have received a copy of the GNU General Public License |
along with TorrentFlux; if not, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
*/ |
class SearchEngine extends SearchEngineBase |
{ |
function SearchEngine($cfg) |
{ |
$this->mainURL = "isohunt.com"; |
$this->altURL = "isohunt.com"; |
$this->mainTitle = "isoHunt"; |
$this->engineName = "isoHunt"; |
$this->author = "kboy"; |
$this->version = "1.00"; |
$this->updateURL = "http://www.torrentflux.com/forum/index.php/topic,878.0.html"; |
$this->Initialize($cfg); |
} |
//---------------------------------------------------------------- |
// Function to Make the Request (overriding base) |
function makeRequest($request) |
{ |
return parent::makeRequest($request, true); |
} |
//---------------------------------------------------------------- |
// Function to get Latest.. |
function getLatest() |
{ |
$request = "/latest.php?mode=bt"; |
if (!empty($this->pg)) |
{ |
$request .= "&pg=" . $this->pg; |
} |
if ($this->makeRequest($request)) |
{ |
return $this->parseResponse(true); |
} |
else |
{ |
return $this->msg; |
} |
} |
//---------------------------------------------------------------- |
// Function to perform Search. |
function performSearch($searchTerm) |
{ |
// This is what isohunt is looking for in a request. |
// http://isohunt.com/torrents.php?ihq=test&ext=&op=and |
// create the request string. |
$searchTerm = str_replace(" ", "+", $searchTerm); |
$request = "/torrents.php?ihq=".$searchTerm; |
$request .= "&ext=&op=and"; |
if (!empty($this->pg)) |
{ |
$request .= "&ihs1=18&iho1=d&iht=-1&ihp=" . $this->pg; |
} |
$request .= "&submit=Torrents"; |
// make the request if successful call the parse routine. |
if ($this->makeRequest($request)) |
{ |
return $this->parseResponse(false); |
} |
else |
{ |
return $this->msg; |
} |
} |
//---------------------------------------------------------------- |
// Function to parse the response. |
function parseResponse($latest = true) |
{ |
$output = $this->tableHeader(); |
$thing = $this->htmlPage; |
// Strip out those Nasty Iframes. |
$thing = eregi_replace("<table[[:space:]]width=[[:punct:]]100%[[:punct:]][[:space:]]cellspacing=[[:punct:]]0[[:punct:]][[:space:]]cellpadding=[[:punct:]]0[[:punct:]][[:space:]]border=[[:punct:]]0[[:punct:]]><tr><td[[:space:]]width=[[:punct:]]10[[:punct:]]></td><td[[:space:]]style=[[:punct:]]border[[:punct:]]3px[[:space:]]solid[[:space:]]#003366[[:punct:]]><iframe[[:space:]]frameborder=[[:punct:]]0[[:punct:]][[:space:]]width=[[:punct:]]100%[[:punct:]][[:space:]]id=[[:punct:]]([a-zA-Z0-9])*[[:punct:]]></iframe></td></tr></table>",'',$thing); |
// We got a response so display it. |
// Chop the front end off. |
while (is_integer(strpos($thing,"<table"))) |
{ |
$thing = substr($thing,strpos($thing,"<table")); |
$thing = substr($thing,strpos($thing,"</tr>")); |
$tmpList = substr($thing,0,strpos($thing,"</table>")); |
// ok so now we have the listing. |
$tmpListArr = split("</tr>",$tmpList); |
$bg = $this->cfg["bgLight"]; |
foreach($tmpListArr as $key =>$value) |
{ |
//echo $value; |
$buildLine = true; |
if (strpos($value,"id=")) |
{ |
$ts = new isoHunt($value,$latest); |
// Determine if we should build this output |
if (is_int(array_search($ts->CatName,$this->catFilter))) |
{ |
$buildLine = false; |
} |
if ($this->hideSeedless == "yes") |
{ |
if($ts->Seeds == "N/A" || $ts->Seeds == "0") |
{ |
$buildLine = false; |
} |
} |
if (!empty($ts->torrentFile) && $buildLine) { |
$output .= trim($ts->BuildOutput($bg)); |
// ok switch colors. |
if ($bg == $this->cfg["bgLight"]) |
{ |
$bg = $this->cfg["bgDark"]; |
} |
else |
{ |
$bg = $this->cfg["bgLight"]; |
} |
} |
} |
} |
// set thing to end of this table. |
$thing = substr($thing,strpos($thing,"</table>")); |
} |
$output .= "</table>"; |
// is there paging at the bottom? |
if (strpos($this->htmlPage, "<table class='pager'>") != false) |
{ |
// Yes, then lets grab it and display it! ;) |
$thing = substr($this->htmlPage,strpos($this->htmlPage,"<table class='pager'>")+strlen("<table class='pager'>")); |
$pages = substr($thing,0,strpos($thing,"</table>")); |
$pages = str_replace(" ",'',strip_tags($pages,"<a><b>")); |
$tmpPageArr = split("</a>",$pages); |
array_pop($tmpPageArr); |
$pagesout = ''; |
foreach($tmpPageArr as $key => $value) |
{ |
$value .= "</a> "; |
$tmpVal = substr($value,strpos($value,"/torrents.php"),strpos($value,"\>")-1); |
$pgNum = substr($tmpVal,strpos($tmpVal,"ihp=")+strlen("ihp=")); |
$pagesout .= str_replace($tmpVal,"XXXURLXXX".$pgNum,$value); |
} |
if(strpos($this->curRequest,"LATEST")) |
{ |
$pages = str_replace("XXXURLXXX",$this->searchURL()."&LATEST=1&pg=",$pagesout); |
} |
else |
{ |
$pages = str_replace("XXXURLXXX",$this->searchURL()."&searchterm=".$_REQUEST["searchterm"]."&pg=",$pagesout); |
} |
$pages = strip_tags($pages,"<a><b>"); |
$output .= "<div align=center>".$pages."</div>"; |
} |
return $output; |
} |
} |
// This is a worker class that takes in a row in a table and parses it. |
class isoHunt |
{ |
var $torrentName = ""; |
var $torrentDisplayName = ""; |
var $torrentFile = ""; |
var $torrentSize = ""; |
var $torrentStatus = ""; |
var $CatId = ""; |
var $CatName = ""; |
var $fileCount = ""; |
var $Seeds = ""; |
var $Peers = ""; |
var $Data = ""; |
var $dateAdded = ""; |
var $dwnldCount = ""; |
function isoHunt( $htmlLine , $latest = true) |
{ |
if (strlen($htmlLine) > 0) |
{ |
$this->Data = $htmlLine; |
// Fix messed up end td's once in a while. |
$htmlLine = eregi_replace("<(.)*1ff8(.)*/td>",'</td>',$htmlLine); |
// Chunck up the row into columns. |
$tmpListArr = split("</td>",$htmlLine); |
array_pop($tmpListArr); |
//Age Type Torrent Names MB F S L D |
if(count($tmpListArr) > 6) |
{ |
if ($latest) |
{ |
// Latest Request // |
if(strpos($tmpListArr["3"],"[DL]")) |
{ |
//$tmpListArr["1"] = $this->cleanLine($tmpListArr["1"]); // Age |
$this->CatName = $this->cleanLine($tmpListArr["2"]); // Type |
$tmpStr = $tmpListArr["3"]; // TorrentName and Download Link |
// move to the [DL] area. and remove [REL] line |
$tmpStr = substr($tmpStr,strpos($tmpStr,"[DL]")+strlen("[DL]"), strpos($tmpStr,"[REL]")); |
$tmpStr = substr($tmpStr,strpos($tmpStr,"href=\"")+strlen("href=\"")); // Download Link |
$this->torrentFile = "http://isohunt.com".substr($tmpStr,0,strpos($tmpStr,"\"")); |
$tmpStr = substr($tmpStr,strpos($tmpStr,"title=\"")+strlen("title=\"")); |
$tmpStr = substr($tmpStr,0,strpos($tmpStr,"\"")); |
$tmpStr = substr($tmpStr,strpos($tmpStr,'\'')); |
$this->torrentName = str_replace("'",'',$tmpStr); |
$this->torrentSize = $this->cleanLine($tmpListArr["4"]); // MB |
$this->fileCount = $this->cleanLine($tmpListArr["5"]); // Files |
$this->Seeds = $this->cleanLine($tmpListArr["6"]); // Seeds |
$this->Peers = $this->cleanLine($tmpListArr["7"]); // Peers / Leechers |
$this->dwnldCount = $this->cleanLine($tmpListArr["8"]); // Download Count |
} |
else |
{ |
$this->CatName = $this->cleanLine($tmpListArr["1"]); // Type |
$tmpStr = $tmpListArr["0"]; // TorrentName and Download Link |
$tmpStr = substr($tmpStr,strpos($tmpStr,"id=")); |
$this->torrentFile = "http://isohunt.com/download.php?mode=bt&".substr($tmpStr,0,strpos($tmpStr,"'")); |
$this->torrentName = $this->cleanLine($tmpListArr["2"]); |
$this->torrentSize = $this->cleanLine($tmpListArr["3"]); // MB |
$this->fileCount = $this->cleanLine($tmpListArr["4"]); // Files |
$this->Seeds = $this->cleanLine($tmpListArr["5"]); // Seeds |
$this->Peers = $this->cleanLine($tmpListArr["6"]); // Peers / Leechers |
$this->dwnldCount = $this->cleanLine($tmpListArr["7"]); // Download Count |
} |
} |
else |
{ |
// Search Request // |
if(strpos($tmpListArr["2"],"[DL]")) |
{ |
$this->CatName = $this->cleanLine($tmpListArr["0"]); // Type |
//$tmpListArr["1"] = $this->cleanLine($tmpListArr["1"]); // Age |
$tmpStr = $tmpListArr["2"]; // TorrentName and Download Link |
// move to the [DL] area. and remove [REL] line |
$tmpStr = substr($tmpStr,strpos($tmpStr,"[DL]")+strlen("[DL]"), strpos($tmpStr,"[REL]")); |
$tmpStr = substr($tmpStr,strpos($tmpStr,"href=\"")+strlen("href=\"")); // Download Link |
$this->torrentFile = "http://isohunt.com".substr($tmpStr,0,strpos($tmpStr,"\"")); |
$tmpStr = substr($tmpStr,strpos($tmpStr,"title=\"")+strlen("title=\"")); |
$tmpStr = substr($tmpStr,0,strpos($tmpStr,"\"")); |
$tmpStr = substr($tmpStr,strpos($tmpStr,'\'')); |
$this->torrentName = str_replace(array("'","Download .torrent here: "),'',$tmpStr); |
} |
else |
{ |
$tmpStr = $tmpListArr["0"]; // Download ID and Type |
$this->CatName = $this->cleanLine($tmpStr); // Download ID and Type |
$tmpStr = substr($tmpStr,strpos($tmpStr,"&id=")+strlen("&id=")); |
$this->torrentFile = "http://isohunt.com/download.php?mode=bt&id=".substr($tmpStr,0,strpos($tmpStr,",")-1); |
//$tmpListArr["1"] = $this->cleanLine($tmpListArr["1"]); // Age |
$this->torrentName = $this->cleanLine($tmpListArr["2"]); |
} |
$this->torrentSize = $this->cleanLine($tmpListArr["3"]); // MB |
$this->fileCount = $this->cleanLine($tmpListArr["4"]); // Files |
$this->Seeds = $this->cleanLine($tmpListArr["5"]); // Seeds |
$this->Peers = $this->cleanLine($tmpListArr["6"]); // Peers / Leechers |
$this->dwnldCount = $this->cleanLine($tmpListArr["7"]); // Download Count |
$this->torrentDisplayName = $this->torrentName; |
} |
if ($this->Peers == '') |
{ |
$this->Peers = "N/A"; |
if (empty($this->Seeds)) $this->Seeds = "N/A"; |
} |
if ($this->Seeds == '') $this->Seeds = "N/A"; |
$this->torrentDisplayName = str_replace(".torrent",'',$this->torrentName); |
if(strlen($this->torrentDisplayName) > 50) |
{ |
$this->torrentDisplayName = substr($this->torrentDisplayName,0,50)."..."; |
} |
} |
} |
} |
function cleanLine($stringIn,$tags='') |
{ |
if(empty($tags)) |
return trim(str_replace(array(" "," ")," ",strip_tags($stringIn))); |
else |
return trim(str_replace(array(" "," ")," ",strip_tags($stringIn,$tags))); |
} |
function dumpArray($arrIn) |
{ |
foreach($arrIn as $key => $value) |
{ |
echo "\nkey(".$key.")"."value(".$value.")"; |
} |
} |
//---------------------------------------------------------------- |
// Function to build output for the table. |
function BuildOutput($bg) |
{ |
$output = "<tr>\n"; |
$output .= " <td width=16 bgcolor=\"".$bg."\"><a href=\"index.php?url_upload=".$this->torrentFile."\"><img src=\"images/download_owner.gif\" width=\"16\" height=\"16\" title=\"".$this->torrentName."\" border=0></a></td>\n"; |
$output .= " <td bgcolor=\"".$bg."\"><a href=\"index.php?url_upload=".$this->torrentFile."\" title=\"".$this->torrentName."\">".$this->torrentDisplayName."</a></td>\n"; |
$output .= " <td bgcolor=\"".$bg."\">". $this->CatName ."</td>\n"; |
$output .= " <td bgcolor=\"".$bg."\" align=right>".$this->torrentSize."</td>\n"; |
$output .= " <td bgcolor=\"".$bg."\" align=center>".$this->Seeds."</td>\n"; |
$output .= " <td bgcolor=\"".$bg."\" align=center>".$this->Peers."</td>\n"; |
$output .= "</tr>\n"; |
return $output; |
} |
} |
?> |