<? // be cautious with this ! require_once("bittorrent.inc.php"); require_once("bencode.php"); function url_validate( $link,$id ) { { $documentpath = $url_parts["path"]; //if (substr($documentpath, -6)=="scrape") { $documentpath.="/";} } else { $documentpath = "/"; } { $documentpath .= "?" . $url_parts["query"]; } $host = $url_parts["host"]; $port = $url_parts["port"]; // Now (HTTP-)GET $documentpath at $host"; if (!$socket) { return(false); mysql_query("UPDATE torrents SET reason=\"Tracker seems to be dead,so it was skipped\" WHERE id = $id"); } else { // change this value if you want : 1s is enough for fast trackers, else it will slow too much bytestats // if ( ereg("200", $http_response, $regs ) || ereg("302", $http_response, $regs ) ) //{ return(true); // } else //{ //echo "HTTP-Response: $http_response<br>"; // return(false); //mysql_query("UPDATE torrents SET reason=\"Tracker gave an abnormal answer,so it was skipped\" WHERE id = $id"); //mysql_query("UPDATE torrents SET skip=\"yes\" WHERE id = $id"); // } } } function hex2bin($hex) { $result = ''; return $result; } function hexesc($matches) { } function docleanup() { do { $id = $row[0]; $ar[$id] = 1; } break; if (!$dp) break; continue; $id = $m[1]; $ar2[$id] = 1; continue; $ff = $torrent_dir . "/$file"; } break; continue; $delids[] = $k; } $id = $row[0]; continue; $delids[] = $id; } $id = $row[0]; if (@$ar[$id]) continue; $delids[] = $id; } } while (0); $deadtime = deadtime(); $deadtime -= $max_dead_torrent_time; mysql_query("UPDATE torrents SET visible='no' WHERE visible='yes' AND last_action < FROM_UNIXTIME($deadtime)"); mysql_query("DELETE FROM users WHERE status = 'pending' AND added < FROM_UNIXTIME($deadtime) AND last_login < FROM_UNIXTIME($deadtime) AND last_access < FROM_UNIXTIME($deadtime)"); if ($row["seeder"] == "yes") $key = "seeders"; else $key = "leechers"; $torrents[$row["torrent"]][$key] = $row["c"]; } $torrents[$row["torrent"]]["comments"] = $row["c"]; } // i thing it is here that modifications need to be made ! $id = $row["id"]; $torr = @$torrents[$id]; foreach ($fields as $field) { $torr[$field] = 0; } foreach ($fields as $field) { if ($torr[$field] != $row[$field]) $update[] = "$field = " . $torr[$field]; } // temporary fix :( { } } $sql = 'SELECT id FROM torrents WHERE skip = "no" '; // on envoie la requete // on fait une boucle qui va faire un tour pour chaque enregistrements { $id = $data["id"]; $row[0] = '?' ; $row[1] = '?' ; // on affiche les informations de l'enregistrements en cours $sql2 = "SELECT info_hash,scrape_url FROM torrents WHERE id = $id"; { $max_cache_file_age = '360'; // $scrape = file_get_contents('http://torrentstats./bytestats.php?tracker='.$dat["scrape_url"].'&infohash='.$hash); $bencode = new BEncodeLib(); // some optimisations can be made here : do not get twice or more the same scrape file from the same tracker ... $tracker_md5 = $infohash; $info = $bencode->bdecode($scrape); $torrentseeds = $info['files'][hex2bin($infohash)]['complete']; $torrentpeers = $info['files'][hex2bin($infohash)]['incomplete']; // debug purposes only echo "<br>".$dat["scrape_url"]." - $infohash - $torrentseeds - $torrentpeers"; } if (url_validate($dat["scrape_url"],$id)) { $refresh='1'; $info = $bencode->bdecode($scrape); $torrentseeds = $info['files'][hex2bin($infohash)]['complete']; $torrentpeers = $info['files'][hex2bin($infohash)]['incomplete']; // debug purposes only echo "<br>".$dat["scrape_url"]." - $infohash - $torrentseeds - $torrentpeers"; } } else { mysql_query("UPDATE torrents SET reason=\"Tracker seems to be dead,so it was skipped\" WHERE id = $id"); } } if (url_validate($dat["scrape_url"],$id)) { $refresh='1'; $info = $bencode->bdecode($scrape); $torrentseeds = $info['files'][hex2bin($infohash)]['complete']; $torrentpeers = $info['files'][hex2bin($infohash)]['incomplete']; // debug purposes only echo "<br>".$dat["scrape_url"]." - $infohash - $torrentseeds - $torrentpeers"; } else { mysql_query("UPDATE torrents SET reason=\"Tracker seems to be dead,so it was skipped\" WHERE id = $id"); } } } } } } ?> |
|