// now the same as an empty string verifyTorrent($info_hash) or evilReject($ip, $peer_id, $port); $peer_exists = getPeerInfo($peer_id, $info_hash); if (!is_array($peer_exists)) { start($info_hash, $ip, $port, $peer_id, $left, $uploaded, $clientVer); } else { quickQuery("UPDATE x{$info_hash} SET bytes=0, status=\"seeder\", uploaded={$uploaded} WHERE sequence=\"{$GLOBALS["trackerid"]}\""); // Race check if (mysql_affected_rows() == 1) { summaryAdd("leechers", -1); summaryAdd("seeds", 1); summaryAdd("finished", 1); } } updatePeer($peer_id, $info_hash); collectBytes($peer_exists, $info_hash, $left, $uploaded); $peers = getRandomPeers($info_hash); sendPeerList($peers); } else { showError("Invalid event= from client."); } if ($GLOBALS["countbytes"] && !$GLOBALS["heavyload"]) { // Once every minute or so, we run the speed update checker. $query = @mysql_query("SELECT UNIX_TIMESTAMP() - lastSpeedCycle FROM summary WHERE info_hash=\"{$info_hash}\""); $results = mysql_fetch_row($query); if ($results[0] >= $GLOBALS["spdrefresh"]) { if (Lock("SPEED:{$info_hash}")) { @runSpeed($info_hash, $results[0]); Unlock("SPEED:{$info_hash}"); } }
verifyTorrent($info_hash) or show_error("Torrent is not authorized for use on this tracker."); $peer_exists = getPeerInfo($peer_id, $info_hash); $where = "WHERE natuser = '******'"; if (!is_array($peer_exists)) { $where = start($info_hash, $ip, $port, $peer_id, $left, $downloaded, $uploaded, $pid); } if ($peer_exists["bytes"] != 0 && $left == 0) { quickQuery("UPDATE peers SET bytes = 0, status = 'seeder' WHERE sequence = '" . $GLOBALS['trackerid'] . "' AND infohash = '" . $info_hash . "'"); if ($db->affected_rows == 1) { summaryAdd("leechers", -1); summaryAdd("seeds", 1); summaryAdd("finished", 1); summaryAdd("lastcycle", "UNIX_TIMESTAMP()", true); } } collectBytes($peer_exists, $info_hash, $left, $downloaded, $uploaded, $pid); if ($GLOBALS["peercaching"]) { sendRandomPeers($info_hash); } else { $peers = getRandomPeers($info_hash, ''); sendPeerList($peers); } break; // not valid event // not valid event default: show_error("Invalid event = from client."); } if ($GLOBALS["countbytes"]) { // Once every minute or so, we run the speed update checker. $results = MCached::get('ann::count::bytes::' . $info_hash);
if ($event == "completed") { verifyTorrent($info_hash) or evilReject($ip, $peer_id, $port); $peer_exists = getPeerInfo($peer_id, $info_hash); if (!is_array($peer_exists)) { start($info_hash, $ip, $port, $peer_id, $left); } else { quickQuery("UPDATE x{$info_hash} SET bytes=0, status=\"seeder\" WHERE sequence=\"{$GLOBALS["trackerid"]}\""); // Race check if (mysql_affected_rows() == 1) { summaryAdd("leechers", -1); summaryAdd("seeds", 1); summaryAdd("finished", 1); } } updatePeer($peer_id, $info_hash); collectBytes($peer_exists, $info_hash, $left); $peers = getRandomPeers($info_hash); sendPeerList($peers); } else { showError("Invalid event= from client."); } } } } if ($GLOBALS["countbytes"]) { // Once every minute or so, we run the speed update checker. $query = @mysql_query("SELECT UNIX_TIMESTAMP() - lastSpeedCycle FROM BTPHP_summary WHERE info_hash=\"{$info_hash}\""); $results = mysql_fetch_row($query); if ($results[0] >= 60) { if (Lock("SPEED:{$info_hash}")) { @runSpeed($info_hash, $results[0]);