--- html/torrentspy.php Sat Oct 15 11:48:01 2005 +++ html/torrentspy.php Sat Oct 15 12:01:29 2005 @@ -22,12 +22,13 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -// Original code posted by heddock in the TorrentFlux forums, modified by Qrome +// Original code posted by heddock in the TorrentFlux forums, modified by Qrome and Kboy include_once("config.php"); include_once("functions.php"); $msg = ""; +$thing = ""; // Try to connect if (!$fp = @fsockopen ("www.torrentspy.com", 80, $errno, $errstr, 30)) @@ -42,11 +43,15 @@ // break the search terms up so they can be handled by the search engine $searchterm=str_replace(" ", "+",$_REQUEST["spysearch"]); + if (empty($searchterm)) + { + $searchterm = $_REQUEST["query"]; + } - if ($_REQUEST["genre"] != "") + if ($_REQUEST["mainGenre"] != "") { - $request = 'GET /directory.asp?mode=sub&id='. $_REQUEST["genre"] . ' HTTP/1.1' ."\r\n". + $request = 'GET /directory.asp?mode=main&id='. $_REQUEST["mainGenre"] . ' HTTP/1.1' ."\r\n". 'Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*' ."\r\n". 'Referer: http://www.torrentspy.com/latest.asp' ."\r\n". 'Accept-Language: en-us' ."\r\n". @@ -57,11 +62,11 @@ } else { - if ($_REQUEST["LATEST"] != 1) + if ($_REQUEST["subGenre"] != "") { - $request = 'GET /search.asp?query='. $searchterm . '&submit.x=24&submit.y=10 HTTP/1.1' ."\r\n". + $request = 'GET /directory.asp?mode=sub&id='. $_REQUEST["subGenre"] . ' HTTP/1.1' ."\r\n". 'Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*' ."\r\n". - 'Referer: http://www.torrentspy.com/' ."\r\n". + 'Referer: http://www.torrentspy.com/latest.asp' ."\r\n". 'Accept-Language: en-us' ."\r\n". 'User-Agent: '.$_SERVER['HTTP_USER_AGENT'] ."\r\n". 'Host: www.torrentspy.com' ."\r\n". @@ -70,7 +75,32 @@ } else { - $request = 'GET /latest.asp HTTP/1.1' ."\r\n". + switch ($_REQUEST["LATEST"]) + { + case "1": + $request = 'GET /latest.asp?pg='.$_REQUEST["pg"].' HTTP/1.1' ."\r\n". + 'Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*' ."\r\n". + 'Referer: http://www.torrentspy.com/' ."\r\n". + 'Accept-Language: en-us' ."\r\n". + 'User-Agent: '.$_SERVER['HTTP_USER_AGENT'] ."\r\n". + 'Host: www.torrentspy.com' ."\r\n". + 'Connection: Close' ."\r\n". + 'Cookie: ' ."\r\n\r\n"; + break; + + case "-1": + $request = 'GET /directory.asp?mode='.$_REQUEST["mode"].'&id='.$_REQUEST["id"].'&pg='.$_REQUEST["pg"].'&submit.x=24&submit.y=10 HTTP/1.1' ."\r\n". + 'Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*' ."\r\n". + 'Referer: http://www.torrentspy.com/' ."\r\n". + 'Accept-Language: en-us' ."\r\n". + 'User-Agent: '.$_SERVER['HTTP_USER_AGENT'] ."\r\n". + 'Host: www.torrentspy.com' ."\r\n". + 'Connection: Close' ."\r\n". + 'Cookie: ' ."\r\n\r\n"; + break; + + default: + $request = 'GET /search.asp?query='. $searchterm .'&pg='.$_REQUEST["pg"].'&db='.$_REQUEST["db"].'&submit.x=24&submit.y=10 HTTP/1.1' ."\r\n". 'Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*' ."\r\n". 'Referer: http://www.torrentspy.com/' ."\r\n". 'Accept-Language: en-us' ."\r\n". @@ -78,6 +108,8 @@ 'Host: www.torrentspy.com' ."\r\n". 'Connection: Close' ."\r\n". 'Cookie: ' ."\r\n\r\n"; + break; + } } } @@ -92,9 +124,9 @@ } fclose($fp); - $thing = substr($thing,strpos($thing,"\r\n\r\n")+4); + //$thing = substr($thing,strpos($thing,"\r\n\r\n")+4); - $thing = substr($thing,strpos($thing,"Torrent Name")+12); + //$thing = substr($thing,strpos($thing,"Torrent Name")+12); } DisplayHead("TorrentSpy "._SEARCH); @@ -105,9 +137,21 @@ echo ""; echo "
"; echo _SEARCH." TorrentSpy:
"; -echo " "; +echo " "; echo "  Show Latest Torrents       Visit: TorrentSpy.com

"; -echo "* Click on Torrent Links to add them to the Torrent Download List"; +echo "* Click on Torrent Links to add them to the Torrent Download List

"; +echo "
"; +echo "Games | "; +echo "Movies | "; +echo "TV | "; +echo "Music | "; +echo "Applications | "; +echo "Anime | "; +echo "Linux | "; +echo "Macintosh | "; +echo "Misc | "; +echo "Unsorted/Other"; +echo "
"; echo "
"; echo ""; @@ -120,6 +164,28 @@ } else { + if ($_REQUEST["mainGenre"] != "") + { + echo "
"; + echo ""; + echo "
"; + $thing = substr($thing,strpos($thing,"Torrent Directory:")+strlen("Torrent Directory:")); + echo "Category: ".substr($thing,0,strpos($thing,"<"))." -> "; + echo " "; + echo ""; + echo "
"; + } + else + { echo "
"; echo ""; echo "  "; @@ -130,13 +196,11 @@ echo " Peers"; echo ""; // We got a response so display it. - while (is_integer(strpos($thing,"")+1); - $genre = substr($thing,0,strpos($thing,"<")); + $mainGenre = substr($thing,0,strpos($thing,"<")); + + $thing = substr($thing,strpos($thing,"id=")+3); + $subid = substr($thing,0,strpos($thing,"\"")); - $thing = substr($thing,strpos($thing,"")+1); - $size = substr($thing,0,strpos($thing,"<")); + $subGenre = substr($thing,0,strpos($thing,"<")); + + } + else + { + $thing = substr($thing,strpos($thing,"id=")+3); + $subid = substr($thing,0,strpos($thing,"\"")); - $thing = substr($thing,strpos($thing,"")+1); + $subGenre = substr($thing,0,strpos($thing,"<")); + } + + + $thing = substr($thing,strpos($thing,"")+11); + $size = substr($thing,0,strpos($thing,"<")); + + + $thing = substr($thing,strpos($thing,"")+11); $files = substr($thing,0,strpos($thing,"<")); - $thing = substr($thing,strpos($thing,"")+1); + + $thing = substr($thing,strpos($thing,"")+11); $seeds = substr($thing,0,strpos($thing,"<")); - $thing = substr($thing,strpos($thing,"")+1); + if ($seeds == "") + { + $seeds = "NA"; + } + + $thing = substr($thing,strpos($thing,"")+11); $peers = substr($thing,0,strpos($thing,"<")); + if ($peers == "") + { + $peers = "NA"; + } + // See what the bg color is and switch it if ($bg == $cfg["bgLight"]) { $bg = $cfg["bgDark"]; @@ -181,17 +281,68 @@ } + // Ok hide the rows that don't have seed info + //if ($seeds != "NA" ) + //{ echo ""; - echo " "; + echo " "; echo " ".$displayname.""; - echo " ". $genre .""; + + if (strlen($mainGenre) > 1) + { + if (strlen($subGenre) > 1) + { + $mainGenre = "". $mainGenre .""; + $subGenre = "". $subGenre .""; + $genre = $mainGenre."-".$subGenre; + } + else + { + $genre = "". $mainGenre .""; + } + } + else + { + $genre = "". $subGenre .""; + } + + echo " ". $genre .""; + + //echo " ". $genre .""; + echo " ".$size.""; echo " ". $seeds.""; echo " ". $peers.""; echo ""; + //} + } } } echo ""; + +// 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,"

")); + $pages = str_replace(" ", "", $pages); + if (strpos($pages, "search.asp?")) + { + $pages = str_replace("search.asp?", "torrentspy.php?LATEST=0&", $pages); + } + if (strpos($pages, "directory.asp?")) + { + //http://qrome/torrent/directory.asp?mode=sub&id=12&pg=3 + $pages = str_replace("directory.asp?", "torrentspy.php?LATEST=-1&", $pages); + } + if (strpos($pages, "latest.asp?")) + { + $pages = str_replace("latest.asp?", "torrentspy.php?LATEST=1&", $pages); + } + + echo "
".$pages."

"; +} DisplayFoot(); ?>