mainURL = "torrentspy.com"; $this->altURL = "www.torrentspy.com"; $this->mainTitle = "TorrentSpy"; $this->engineName = "TorrentSpy"; $this->author = "kboy"; $this->version = "1.04-tfb"; $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?h=&query=' . $searchTerm . '&pg=' . $this->pg . '&db=' . $_REQUEST["db"] . '&submit.x=24&submit.y=10'; } else { $request = '/search.asp?h=&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 .= "We're experiencing high load at this time. Please use the directory until further notice."; }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,"")); // ok so now we have the listing. $tmpListArr = explode("",$tmpList); $langFile = $this->cfg['_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->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,$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,"")); } } $output .= ""; // is there paging at the bottom? if (strpos($thing, "

Pages (") !== false) { // Yes, then lets grab it and display it! ;) $thing = substr($thing,strpos($thing,"

Pages (")+strlen("

")); $pages = substr($thing,0,strpos($thing,"

")); $page1 = substr($pages,0,strpos($pages,"')+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 .= "
searchURL()."&LATEST=1&mode=yesterday\" title=\"Yesterday's Latest\">Yesterday's Latest"; } elseif (! $_REQUEST["mode"] == "yesterday") { $pages .= "
searchURL()."&LATEST=1&mode=yesterday\" title=\"Yesterday's Latest\">Yesterday's Latest"; } else { $pages .= "
Yesterday's Latest"; } } $output .= "
".$pages."

"; } elseif(array_key_exists("LATEST",$_REQUEST)) { $pages = ''; if (!array_key_exists("mode",$_REQUEST)) { $pages .= "
searchURL()."&LATEST=1&mode=yesterday\" title=\"Yesterday's Latest\">Yesterday's Latest"; } elseif (! $_REQUEST["mode"] == "yesterday") { $pages .= "
searchURL()."&LATEST=1&mode=yesterday\" title=\"Yesterday's Latest\">Yesterday's Latest"; } else { $pages .= "
Yesterday's Latest"; } $output .= "
".$pages."

"; } 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 = explode("",$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/torrent/" . 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 = "\n"; $output .= " torrentFile."\">torrentName."\" border=0>\n"; $output .= " torrentFile."\" title=\"".$this->torrentName."\">".$this->torrentDisplayName.""; switch ($this->torrentStatus) { case "R": $output .= " R"; break; case "P": $output .= " P"; break; } $output .= "\n"; if (strlen($this->MainCategory) > 1){ if (strlen($this->SubCategory) > 1){ $mainGenre = "MainId."\">".$this->MainCategory.""; $subGenre = "SubId."\">".$this->SubCategory.""; $genre = $mainGenre."-".$subGenre; }else{ $genre = "MainId."\">".$this->MainCategory.""; } }else{ $genre = "SubId."\">".$this->SubCategory.""; } $output .= " ". $genre ."\n"; $output .= " ".$this->torrentSize."\n"; $output .= " ".$this->Seeds."\n"; $output .= " ".$this->Peers."\n"; $output .= "\n"; return $output; } } ?>