+------------------------------------------------ | $Date$ | $Revision$ | $Author$ | $URL$ +------------------------------------------------ */ require_once "include/config.php"; if (!@mysql_connect($TBDEV['mysql_host'], $TBDEV['mysql_user'], $TBDEV['mysql_pass'])) { exit; } @mysql_select_db($TBDEV['mysql_db']) or exit; function hash_where($name, $hash) { $shhash = preg_replace('/ *$/s', "", $hash); return "{$name} = '" . mysql_real_escape_string($hash) . "'"; } $r = 'd5:filesd'; $fields = "info_hash, times_completed, seeders, leechers"; if (!isset($_GET["info_hash"])) { $query = "SELECT {$fields} FROM torrents ORDER BY info_hash"; } else { $query = "SELECT {$fields} FROM torrents WHERE " . hash_where("info_hash", @pack('H*', stripslashes($_GET["info_hash"]))); } $res = mysql_query($query); while ($row = mysql_fetch_assoc($res)) { $r .= '20:' . str_pad($row['info_hash'], 20) . 'd8:completei' . $row['seeders'] . 'e10:downloadedi' . $row['times_completed'] . 'e10:incompletei' . $row['leechers'] . 'ee'; } $r .= 'ee'; header("Content-Type: text/plain"); print $r;
} $time = pack("C", $time); $peer[] = $time . $peer_ip . $peer_port; $peer_num++; } } if ($_GET['compact'] != 1) { $resp .= "ee"; } else { $o = ""; for ($i = 0; $i < $peer_num; $i++) { $o .= substr($peer[$i], 1, 6); } $resp .= strlen($o) . ':' . $o . 'e'; } $selfwhere = "torrent = {$torrentid} AND " . hash_where("peer_id", $peer_id); // /////////////////////////// End compact mode//////////////////////////////// if (!isset($self)) { $res = mysql_query("SELECT {$fields} FROM peers WHERE {$selfwhere}"); $row = mysql_fetch_assoc($res); if ($row) { $userid = $row["userid"]; $self = $row; } } // === stop banned IPs $nip = ip2long($ip); $res = mysql_query("SELECT id FROM bans WHERE {$nip} >= first AND {$nip} <= last"); if (mysql_num_rows($res) > 0) { err("Yer Banned - Stop Hammering ffs"); }
} $time = pack("C", $time); $peer[] = $time . $peer_ip . $peer_port; $peer_num++; } } if ($_GET['compact'] != 1) { $resp .= "ee"; } else { $o = ""; for ($i = 0; $i < $peer_num; $i++) { $o .= substr($peer[$i], 1, 6); } $resp .= strlen($o) . ':' . $o . 'e'; } $selfwhere = "torrent = " . ann_sqlesc($torrentid) . " AND " . hash_where("peer_id", $peer_id); if (!isset($self)) { $res = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT {$fields} FROM peers WHERE {$selfwhere}") or ann_sqlerr(__FILE__, __LINE__); $row = mysqli_fetch_assoc($res); if ($row) { $userid = (int) $row['userid']; $self = $row; } } //// Up/down stats shit//////////////////////////////////////////////////////////// $useragent = substr($peer_id, 0, 8); $agentarray = array("R34", "-AZ21", "-AZ22", "-AZ24", "AZ2500BT", "BS", "exbc", "-TS", "Mbrst", "-BB", "-SZ", "XBT", "turbo", "A301", "A310", "-UT11", "-UT12", "-UT13", "-UT14", "-UT15", "FUTB", "-BC", "LIME", "eX", "-ML", "FRS", "-AG"); foreach ($agentarray as $bannedclient) { if (strpos($useragent, $bannedclient) !== false) { err("Client is banned. Please use uTorrent 1.6 > or Azureus 2.5 >!"); }
require_once "include/secrets.php"; require_once "include/bittorrent.php"; //require_once("include/benc.php"); if (!@mysql_connect($mysql_host, $mysql_user, $mysql_pass)) { exit; } @mysql_select_db($mysql_db) or exit; function hash_where($name, $hash) { $shhash = preg_replace('/ *$/s', "", $hash); return "({$name} = " . sqlesc($hash) . " OR {$name} = " . sqlesc($shhash) . ")"; } function benc_str($s) { return strlen($s) . ":{$s}"; } $r = "d" . benc_str("files") . "d"; $fields = "info_hash, times_completed, seeders, leechers"; if (!isset($_GET["info_hash"])) { $query = "SELECT {$fields} FROM torrents ORDER BY info_hash"; } else { $query = "SELECT {$fields} FROM torrents WHERE " . hash_where("info_hash", unesc($_GET["info_hash"])); } $res = mysql_query($query); while ($row = mysql_fetch_assoc($res)) { $r .= "20:" . str_pad($row["info_hash"], 20) . "d" . benc_str("complete") . "i" . $row["seeders"] . "e" . benc_str("downloaded") . "i" . $row["times_completed"] . "e" . benc_str("incomplete") . "i" . $row["leechers"] . "e" . "e"; } $r .= "ee"; header("Content-Type: text/plain"); print $r;
/** * https://09source.kicks-ass.net:8443/svn/installer09/ * Licence Info: GPL * Copyright (C) 2010 Installer09 v.2 * A bittorrent tracker source based on TBDev.net/tbsource/bytemonsoon. * Project Leaders: Mindless,putyn,kidvision. **/ require_once "include/config.php"; if (!@mysql_connect($INSTALLER09['mysql_host'], $INSTALLER09['mysql_user'], $INSTALLER09['mysql_pass'])) { exit; } @mysql_select_db($INSTALLER09['mysql_db']) or exit; if (!isset($_GET['info_hash']) or strlen($_GET['info_hash']) != 20) { error('Invalid hash'); } $res = @mysql_query("SELECT info_hash, seeders, leechers, times_completed FROM torrents WHERE " . hash_where($_GET['info_hash'])); if (!mysql_num_rows($res)) { error('No torrent with that hash found'); } $benc = 'd5:files'; while ($row = mysql_fetch_assoc($res)) { $benc .= 'd20:' . pack('H*', $row['info_hash']) . "d8:completei{$row['seeders']}e10:downloadedi{$row['times_completed']}e10:incompletei{$row['leechers']}eeee"; } header('Content-Type: text/plain; charset=UTF-8'); header('Pragma: no-cache'); print $benc; function error($err) { header('Content-Type: text/plain; charset=UTF-8'); header('Pragma: no-cache'); exit("d14:failure reason" . strlen($err) . ":{$err}ed5:flagsd20:min_request_intervali1800eeee");
} function hash_pad($hash) { return str_pad($hash, 20); } // End bittorrent.php dbconn(false); $r = "d" . benc_str("files") . "d"; $fields = "info_hash, times_completed, seeders, leechers"; if (isset($_GET["info_hash"])) $query = "SELECT $fields FROM torrents WHERE " . hash_where("info_hash", $_GET["info_hash"]); //else // $query = "SELECT $fields FROM torrents ORDER BY info_hash"; $r = ''; if(isset($query)) { $res = mysql_query($query); while ($row = mysql_fetch_assoc($res)) { $r .= "20:" . hash_pad($row["info_hash"]) . "d" . benc_str("complete") . "i" . $row["seeders"] . "e" . benc_str("downloaded") . "i" . $row["times_completed"] . "e" . benc_str("incomplete") . "i" . $row["leechers"] . "e" . "e"; }
} $peer->select("peer_torrent = '" . $torrent->id . "'"); while ($peer->nextRecord()) { $peer->peer_id = str_pad($peer->peer_id, 20); if ($peer->peer_id === $data['peer_id']) { $self = $peer; continue; } $callback[] = "d" . Bcode::benc_str("ip") . Bcode::benc_str($peer->ip); if (!$_GET['no_peer_id']) { $callback[] = Bcode::benc_str("peer id") . Bcode::benc_str($peer->peer_id); } $callback[] = Bcode::benc_str("port") . "i" . $peer->port . "e" . "e"; } $callback[] = "ee"; $self_query = "peer_torrent = '" . $torrent_id . "' AND " . hash_where("peer_peer_id", $data['peer_id']); if (!isset($self)) { $db = new DB("peers"); $db->setCols($peer_cols); $db->setColPrefix("peer_"); $db->select($self_query); if ($db->numRows()) { $db->nextRecord(); $self = $db; $data['user_id'] = $self->userid; } } $torrent_query = array(); if (!isset($self)) { $db = new DB("peers"); $db->select($self_query);
if ($row['peer_id'] === $peer_id) { $userid = $row['userid']; $self = $row; continue; } $resp .= 'd'. benc_str('ip').benc_str($row['ip']). benc_str('peer id').benc_str($row['peer_id']). benc_str('port').'i'.$row['port'].'e'. 'e'; } $resp .= 'ee'; $selfwhere = 'torrent='.$torrentid.' AND '.hash_where('peer_id',$peer_id); if (!isset($self)) { $res = mysql_query('SELECT '.$fields.' FROM peers WHERE '.$selfwhere.' LIMIT 1') or sqlerr(__FILE__,__LINE__); $row = mysql_fetch_assoc($res); if ($row) { $userid = $row['userid']; $self = $row; } } //// Up/down stats //////////////////////////////////////////////////////////// if (!isset($self)) { $sql = 'SELECT COUNT(*) FROM peers WHERE passkey='.sqlesc($passkey).' AND torrent='.$torrentid; $res = mysql_query($sql) or sqlerr(__FILE__,__LINE__);