function setUser($username, $userid) { $this->dict->hashSetter('[\'value\'][\'created by\']', bdec(benc_str("{$username}"))); $this->dict->hashSetter('[\'value\'][\'publisher\']', bdec(benc_str("{$username}"))); $this->dict->hashSetter('[\'value\'][\'publisher.utf-8\']', bdec(benc_str("username"))); $this->dict->hashSetter('[\'value\'][\'publisher-url\']', bdec(benc_str(DEFAULTBASEURL . "/users/view/{$userid}"))); $this->dict->hashSetter('[\'value\'][\'publisher-url.utf-8\']', bdec(benc_str(DEFAULTBASEURL . "/users/view/{$userid}"))); }
function benc_dict($d) { $s = "d"; $keys = array_keys($d); sort($keys); foreach ($keys as $k) { $v = $d[$k]; $s .= benc_str($k); $s .= benc($v); } $s .= "e"; return $s; }
} if (!count($ffa)) { bark($lang_takeupload['std_filename_errors']); } $ffe = implode("/", $ffa); $filelist[] = array($ffe, $ll); } $type = "multi"; } $dict['value']['announce'] = bdec(benc_str(get_protocol_prefix() . $announce_urls[0])); // change announce url to local $dict['value']['info']['value']['private'] = bdec('i1e'); // add private tracker flag //The following line requires uploader to re-download torrents after uploading //even the torrent is set as private and with uploader's passkey in it. $dict['value']['info']['value']['source'] = bdec(benc_str("[{$BASEURL}] {$SITENAME}")); unset($dict['value']['announce-list']); // remove multi-tracker capability unset($dict['value']['nodes']); // remove cached peers (Bitcomet & Azareus) $dict = bdec(benc($dict)); // double up on the becoding solves the occassional misgenerated infohash list($ann, $info) = dict_check($dict, "announce(string):info"); $infohash = pack("H*", sha1($info["string"])); function hex_esc2($matches) { return sprintf("%02x", ord($matches[0])); } //die(phpinfo()); //die("magic:" . get_magic_quotes_gpc()); //die("\\' pos:" . strpos($infohash,"\\") . ", after sqlesc:" . (strpos(sqlesc($infohash),"\\") == false ? "gone" : strpos(sqlesc($infohash),"\\")));
<?php require_once 'include/bittorrent_announce.php'; require_once 'include/benc.php'; dbconn_announce(); // BLOCK ACCESS WITH WEB BROWSERS AND CHEATS! block_browser(); preg_match_all('/info_hash=([^&]*)/i', $_SERVER["QUERY_STRING"], $info_hash_array); $fields = "info_hash, times_completed, seeders, leechers"; if (count($info_hash_array[1]) < 1) { $query = "SELECT {$fields} FROM torrents ORDER BY id"; } else { $query = "SELECT {$fields} FROM torrents WHERE " . hash_where_arr('info_hash', $info_hash_array[1]); } $r = "d" . benc_str("files") . "d"; $res = sql_query($query); if (mysql_num_rows($res) < 1) { err("Torrent not registered with this tracker."); } 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"; } $r .= "ee"; benc_resp_raw($r);
$no_peer_id = $_GET['no_peer_id'] == 1; unset($self); while ($row = mysql_fetch_array($res)) { if ($row['peer_id'] == $peer_id) { $userid = $row['userid']; $self = $row; continue; } if ($compact) { $peer_ip = explode('.', $row["ip"]); $plist .= pack("C*", $peer_ip[0], $peer_ip[1], $peer_ip[2], $peer_ip[3]) . pack("n*", (int) $row["port"]); } else { $resp .= 'd' . benc_str('ip') . benc_str($row['ip']) . (!$no_peer_id ? benc_str("peer id") . benc_str($row["peer_id"]) : '') . benc_str('port') . 'i' . $row['port'] . 'e' . 'e'; } } $resp .= ($compact ? benc_str($plist) : '') . (substr($peer_id, 0, 4) == '-BC0' ? "e7:privatei1ee" : "ee"); $selfwhere = 'torrent = ' . $torrentid . ' AND passkey = ' . sqlesc($passkey); if (!isset($self)) { $res = mysql_query('SELECT ' . $fields . ' FROM peers WHERE ' . $selfwhere) or err(mysql_error()); $row = mysql_fetch_array($res); if ($row) { $userid = $row['userid']; $self = $row; } } if (function_exists('getallheaders')) { $headers = getallheaders(); } else { $headers = emu_getallheaders(); } if (isset($headers['Cookie']) || isset($headers['Accept-Language']) || isset($headers['Accept-Charset'])) {
function err($msg) { mysql_close(); return benc_resp_raw("d" . benc_str("failure reason") . benc_str($msg) . "e"); }
$resp = 'd' . benc_str("interval") . 'i' . $INSTALLER09['announce_interval'] . 'e' . benc_str("private") . 'i1e' . benc_str("min interval") . 'i' . 300 . 'e5:' . 'peers'; } $peer = array(); $peer_num = 0; while ($row = mysqli_fetch_assoc($res)) { if ($_GET['compact'] != 1) { $row["peer_id"] = str_pad($row["peer_id"], 20); if ($row["peer_id"] === $peer_id) { $self = $row; continue; } $resp .= "d" . benc_str("ip") . benc_str($row["ip"]); if (!$_GET['no_peer_id']) { $resp .= benc_str("peer id") . benc_str($row["peer_id"]); } $resp .= benc_str("port") . "i" . $row["port"] . "e" . "e"; } else { $peer_ip = explode('.', $row["ip"]); $peer_ip = pack("C*", $peer_ip[0], $peer_ip[1], $peer_ip[2], $peer_ip[3]); $peer_port = pack("n*", (int) $row["port"]); $time = intval(TIME_NOW % 7680 / 60); if ($_GET['left'] == 0) { $time += 128; } $time = pack("C", $time); $peer[] = $time . $peer_ip . $peer_port; $peer_num++; } } if ($_GET['compact'] != 1) { $resp .= "ee";
// moddifed logginorreturn by retro//Remember to change the following line to match your server print "<html><h1>Not Found</h1><p>The requested URL /{$_SERVER['PHP_SELF']} was not found on this server.</p><hr /><address>Apache/1.1.11 " . $SITENAME . " Server at " . $_SERVER['SERVER_NAME'] . " Port 80</address></body></html>\n"; die; } if (!preg_match(':^/(\\d{1,10})/(.+)\\.torrent$:', $_SERVER["PATH_INFO"], $matches)) { httperr(); } $id = 0 + $matches[1]; if (!$id) { httperr(); } $res = mysql_query("SELECT name FROM torrents WHERE id = {$id}") or sqlerr(__FILE__, __LINE__); $row = mysql_fetch_assoc($res); $fn = "{$torrent_dir}/{$id}.torrent"; if (!$row || !is_file($fn) || !is_readable($fn)) { httperr(); } mysql_query("UPDATE torrents SET hits = hits + 1 WHERE id = {$id}"); require_once "include/benc.php"; if (strlen($CURUSER['passkey']) != 32) { $CURUSER['passkey'] = md5($CURUSER['username'] . get_date_time() . $CURUSER['passhash']); mysql_query("UPDATE users SET passkey='{$CURUSER['passkey']}' WHERE id={$CURUSER['id']}"); } $dict = bdec_file($fn, 1024 * 1024); $dict['value']['announce']['value'] = "{$announce_urls['0']}"; $dict['value']['announce']['string'] = strlen($dict['value']['announce']['value']) . ":" . $dict['value']['announce']['value']; $dict['value']['announce']['strlen'] = strlen($dict['value']['announce']['string']); $dict['value']['created by'] = bdec(benc_str("" . $CURUSER['username'] . "")); //header('Content-Disposition: attachment; filename="'.$torrent['filename'].'"'); header("Content-Type: application/x-bittorrent"); print benc($dict);
$recommended = unesc($_POST['recommended']); $tube = unesc($_POST['tube']); $url = unesc($_POST['url']); $dict['value']['announce'] = bdec(benc_str($announce_urls[0])); // change announce url to local $dict['value']['info']['value']['private'] = bdec('i1e'); // add private tracker flag $dict['value']['info']['value']['source'] = bdec(benc_str("[{$DEFAULTBASEURL}] {$SITENAME}")); // add link for bitcomet users unset($dict['value']['announce-list']); // remove multi-tracker capability unset($dict['value']['nodes']); // remove cached peers (Bitcomet & Azareus) $dict = bdec(benc($dict)); // double up on the becoding solves the occassional misgenerated infohash $dict['value']['comment'] = bdec(benc_str("In using this torrent you are bound by the '{$SITENAME}' Confidentiality Agreement By Law")); // change torrent comment list($ann, $info) = dict_check($dict, "announce(string):info"); unset($dict['value']['created by']); //Null the created_by field/// $infohash = pack("H*", sha1($info["string"])); $uclass = $CURUSER["class"]; // Replace punctuation characters with spaces $torrent = str_replace("_", " ", $torrent); // /////////pretime//////// /* $pre = getpre($torrent,1); $timestamp = strtotime($pre); $tid = time(); if (empty($pre)) { $predif = "N/A";
// remove cached peers (Bitcomet & Azareus) unset($dict['value']['info']['value']['crc32']); // remove crc32 unset($dict['value']['info']['value']['ed2k']); // remove ed2k unset($dict['value']['info']['value']['md5sum']); // remove md5sum unset($dict['value']['info']['value']['sha1']); // remove sha1 unset($dict['value']['info']['value']['tiger']); // remove tiger unset($dict['value']['azureus_properties']); // remove azureus properties $dict = bdec(benc($dict)); // double up on the becoding solves the occassional misgenerated infohash $dict['value']['comment'] = bdec(benc_str("Torrent created for SceneBits")); // change torrent comment list($ann, $info) = dict_check($dict, "announce(string):info"); #End of Private Tracker Patch $infohash = pack("H*", sha1($info["string"])); // Replace punctuation characters with spaces $pretime = 0 + @file_get_contents("http://xxxxx/abcd.php?name=" . trim($torrent)); $poster = isset($_POST['poster']) ? unesc($_POST['poster']) : ""; //$torrent = str_replace("_", " ", $torrent); $anonymous = 'yes'; $ret = mysql_query("INSERT INTO torrents (search_text, filename, owner, visible, scene, freeleech, url, anonymous, vip, info_hash, poster, name, size, numfiles, type, descr, ori_descr, category, save_as, added, last_action, nfo, pretime) VALUES (" . implode(",", array_map("sqlesc", array(searchfield("{$shortfname} {$dname} {$torrent}"), $fname, $CURUSER["id"], "no", $scene, $freeleech, $url, $anonymous, $vip, $infohash, $poster, $torrent, $totallen, count($filelist), $type, $descr, $descr, 0 + $_POST["type"], $dname))) . ", '" . get_date_time() . "', '" . get_date_time() . "', {$nfo}, '" . $pretime . "')"); if (!$ret) { if (mysql_errno() == 1062) { bark("torrent already uploaded!"); } bark("mysql puked: " . mysql_error());
continue; } if ($compact == 1) { $longip = ip2long($row['ip']); if ($longip) { //Ignore ipv6 address $peer_list .= pack("Nn", sprintf("%d", $longip), $row['port']); } } elseif ($no_peer_id == 1) { $peer_list .= "d" . benc_str("ip") . benc_str($row["ip"]) . benc_str("port") . "i" . $row["port"] . "e" . "e"; } else { $peer_list .= "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"; } } if ($compact == 1) { $resp .= benc_str($peer_list); } else { $resp .= "l" . $peer_list . "e"; } $resp .= "e"; $selfwhere = "torrent = {$torrentid} AND " . hash_where("peer_id", $peer_id); //no found in the above random selection if (!isset($self)) { $res = sql_query("SELECT {$fields} FROM peers WHERE {$selfwhere} LIMIT 1"); $row = mysql_fetch_assoc($res); if ($row) { $self = $row; } } // min announce time if (isset($self) && $self['prevts'] > TIMENOW - $announce_wait) {
} if (!count($ffa)) { stderr($lang['takeupload_failed'], $lang['takeupload_error']); } $ffe = implode("/", $ffa); $filelist[] = array($ffe, $ll); } $type = "multi"; } $dict['value']['announce'] = bdec(benc_str($INSTALLER09['announce_urls'][0])); // change announce url to local $dict['value']['info']['value']['private'] = bdec('i1e'); // add private tracker flag $dict['value']['info']['value']['source'] = bdec(benc_str("{$INSTALLER09['baseurl']} {$INSTALLER09['site_name']}")); // add link for bitcomet users $dict['value']['comment'] = bdec(benc_str("In using this torrent you are bound by the {$INSTALLER09['site_name']} Confidentiality Agreement By Law")); // change torrent comment unset($dict['value']['announce-list']); // remove multi-tracker capability unset($dict['value']['nodes']); // remove cached peers (Bitcomet & Azareus) $dict = bdec(benc($dict)); // double up on the becoding solves the occassional misgenerated infohash list($ann, $info) = dict_check($dict, "announce(string):info"); $infohash = sha1($info["string"]); unset($info); /* $pretime = 0 + @file_get_contents('http://ransackedcrew.net/gettime.php?name='.trim($torrent)); if ($pretime > 0){ $pretime = get_pretime($pretime); } else {
} $ffa[] = $ffe["value"]; } if (!count($ffa)) { stderr($lang['takeupload_failed'], $lang['takeupload_error']); } $ffe = implode("/", $ffa); $filelist[] = array($ffe, $ll); } $type = "multi"; } $dict['value']['announce'] = bdec(benc_str($TBDEV['announce_urls'][0])); // change announce url to local $dict['value']['info']['value']['private'] = bdec('i1e'); // add private tracker flag $dict['value']['info']['value']['source'] = bdec(benc_str("{$TBDEV['baseurl']} {$TBDEV['site_name']}")); // add link for bitcomet users unset($dict['value']['announce-list']); // remove multi-tracker capability unset($dict['value']['nodes']); // remove cached peers (Bitcomet & Azareus) $dict = bdec(benc($dict)); // double up on the becoding solves the occassional misgenerated infohash list($ann, $info) = dict_check($dict, "announce(string):info"); $infohash = sha1($info["string"]); unset($info); // Replace punctuation characters with spaces $torrent = str_replace("_", " ", $torrent); $url = unesc($_POST['url']); $poster = unesc($_POST['poster']); $ret = sql_query("INSERT INTO torrents (search_text, filename, owner, visible, poster, anonymous, allow_comments, info_hash, name, size, numfiles, type, url, descr, ori_descr, category, free, save_as, added, last_action, nfo, client_created_by) VALUES (" . implode(",", array_map("sqlesc", array(searchfield("{$shortfname} {$dname} {$torrent}"), $fname, $CURUSER["id"], "no", $poster, $anonymous, $allow_comments, $infohash, $torrent, $totallen, count($filelist), $type, $url, $descr, $descr, 0 + $_POST["type"], $free, $dname))) . ", " . time() . ", " . time() . ", {$nfo}, {$tmaker})");
$db->port = $data['port']; $db->uploaded = 0; $db->downloaded = 0; $db->to_go = $data['left']; $db->seeder = $data['seeder']; $db->started = time(); $db->last_action = time(); $db->passkey = $data['passkey']; $db->connectable = $data['connectable']; $db->insert(); if ($data['seeder']) { $torrent_query[] = "torrent_seeders = torrent_seeders + 1"; } else { $torrent_query[] = "torrent_leechers = torrent_leechers + 1"; } } } if ($data['seeder']) { $torrent_query[] = "torrent_visible = '1'"; $torrent_query[] = "torrent_last_action = '" . time() . "'"; } $db = new DB(); if (count($torrent_query)) { $db->query("UPDATE {PREFIX}torrents SET " . implode(", ", $torrent_query) . " WHERE torrent_id = '{$torrent_id}'"); } $callback[] = benc_str("private") . 'i1e'; benc_resp_raw(implode("", $callback)); } catch (Exception $e) { benc_resp(array('failure reason' => array('type' => 'string', 'value' => $e->getMessage()))); exit; }
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"; } $r .= "ee"; } header("Content-Type: text/plain"); if(!empty($r)) echo $r; ?>
$resp = 'd'.benc_str('interval').'i'.$announce_interval.'e'.benc_str('peers').'l'; unset($self); while ($row = mysql_fetch_assoc($res)) { $row['peer_id'] = hash_pad($row['peer_id']); 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; } }