GetRich |
15th October 2015 01:12 |
Here is details.php... Where is the overflow problem?
Code:
ob_start("ob_gzhandler");
require_once("include/bittorrent.php");
function getagent($httpagent, $peer_id="")
{
if (preg_match("/^Azureus ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]\_B([0-9][0-9|*])(.+)$)/", $httpagent, $matches))
return "Azureus/$matches[1]";
elseif (preg_match("/^Azureus ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]\_CVS)/", $httpagent, $matches))
return "Azureus/$matches[1]";
elseif (preg_match("/^Java\/([0-9]+\.[0-9]+\.[0-9]+)/", $httpagent, $matches))
return "Azureus/<2.0.7.0";
elseif (preg_match("/^Azureus ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/", $httpagent, $matches))
return "Azureus/$matches[1]";
elseif (preg_match("/BitTorrent\/S-([0-9]+\.[0-9]+(\.[0-9]+)*)/", $httpagent, $matches))
return "Shadow's/$matches[1]";
elseif (preg_match("/BitTorrent\/U-([0-9]+\.[0-9]+\.[0-9]+)/", $httpagent, $matches))
return "UPnP/$matches[1]";
elseif (preg_match("/^BitTor(rent|nado)\\/T-(.+)$/", $httpagent, $matches))
return "BitTornado/$matches[2]";
elseif (preg_match("/^BitTornado\\/T-(.+)$/", $httpagent, $matches))
return "BitTornado/$matches[1]";
elseif (preg_match("/^BitTorrent\/ABC-([0-9]+\.[0-9]+(\.[0-9]+)*)/", $httpagent, $matches))
return "ABC/$matches[1]";
elseif (preg_match("/^ABC ([0-9]+\.[0-9]+(\.[0-9]+)*)\/ABC-([0-9]+\.[0-9]+(\.[0-9]+)*)/", $httpagent, $matches))
return "ABC/$matches[1]";
elseif (preg_match("/^Python-urllib\/.+?, BitTorrent\/([0-9]+\.[0-9]+(\.[0-9]+)*)/", $httpagent, $matches))
return "BitTorrent/$matches[1]";
elseif (preg_match("/^BitTorrent\/brst(.+)/", $httpagent, $matches))
return "Burst";
elseif (preg_match("/^RAZA (.+)$/", $httpagent, $matches))
return "Shareaza/$matches[1]";
elseif (preg_match("/Rufus\/([0-9]+\.[0-9]+\.[0-9]+)/", $httpagent, $matches))
return "Rufus/$matches[1]";
elseif (preg_match("/^Python-urllib\\/([0-9]+\\.[0-9]+(\\.[0-9]+)*)/", $httpagent, $matches))
return "G3 Torrent";
elseif (preg_match("/MLDonkey\/([0-9]+).([0-9]+).([0-9]+)*/", $httpagent, $matches))
return "MLDonkey/$matches[1].$matches[2].$matches[3]";
elseif (preg_match("/ed2k_plugin v([0-9]+\\.[0-9]+).*/", $httpagent, $matches))
return "eDonkey/$matches[1]";
elseif (preg_match("/uTorrent\/([0-9]+)([0-9]+)([0-9]+)([0-9A-Z]+)/", $httpagent, $matches))
return "uTorrent/$matches[1].$matches[2].$matches[3].$matches[4]";
elseif (preg_match("/CT([0-9]+)([0-9]+)([0-9]+)([0-9]+)/", $peer_id, $matches))
return "cTorrent/$matches[1].$matches[2].$matches[3].$matches[4]";
elseif (preg_match("/Transmission\/([0-9]+).([0-9]+)/", $httpagent, $matches))
return "Transmission/$matches[1].$matches[2]";
elseif (preg_match("/KT([0-9]+)([0-9]+)([0-9]+)([0-9]+)/", $peer_id, $matches))
return "KTorrent/$matches[1].$matches[2].$matches[3].$matches[4]";
elseif (preg_match("/rtorrent\/([0-9]+\\.[0-9]+(\\.[0-9]+)*)/", $httpagent, $matches))
return "rTorrent/$matches[1]";
elseif (preg_match("/^ABC\/Tribler_ABC-([0-9]+\.[0-9]+(\.[0-9]+)*)/", $httpagent, $matches))
return "Tribler/$matches[1]";
elseif (preg_match("/^BitsOnWheels( |\/)([0-9]+\\.[0-9]+).*/", $httpagent, $matches))
return "BitsOnWheels/$matches[2]";
elseif (preg_match("/BitTorrentPlus\/(.+)$/", $httpagent, $matches))
return "BitTorrent Plus!/$matches[1]";
elseif (ereg("^Deadman Walking", $httpagent))
return "Deadman Walking";
elseif (preg_match("/^eXeem( |\/)([0-9]+\\.[0-9]+).*/", $httpagent, $matches))
return "eXeem$matches[1]$matches[2]";
elseif (preg_match("/^libtorrent\/(.+)$/", $httpagent, $matches))
return "libtorrent/$matches[1]";
elseif (substr($peer_id, 0, 12) == "d0c")
return "Mainline";
elseif (substr($peer_id, 0, 1) == "M")
return "Mainline/Decoded";
elseif (substr($peer_id, 0, 3) == "-BB")
return "BitBuddy";
elseif (substr($peer_id, 0, 8) == "-AR1001-")
return "Arctic Torrent/1.2.3";
elseif (substr($peer_id, 0, 6) == "exbc\08")
return "BitComet/0.56";
elseif (substr($peer_id, 0, 6) == "exbc\09")
return "BitComet/0.57";
elseif (substr($peer_id, 0, 6) == "exbc\0:")
return "BitComet/0.58";
elseif (substr($peer_id, 0,4) == "-BC0")
return "BitComet/0.".substr($peer_id,5,2);
elseif (substr($peer_id, 0, 7) == "exbc\0L")
return "BitLord/1.0";
elseif (substr($peer_id, 0, 7) == "exbcL")
return "BitLord/1.1";
elseif (substr($peer_id, 0, 3) == "346")
return "TorrenTopia";
elseif (substr($peer_id, 0, 8) == "-MP130n-")
return "MooPolice";
elseif (substr($peer_id, 0, 8) == "-SZ2210-")
return "Shareaza/2.2.1.0";
elseif (ereg("^0P3R4H", $httpagent))
return "Opera BT Client";
elseif (substr($peer_id, 0, 6) == "A310--")
return "ABC/3.1";
elseif (ereg("^XBT Client", $httpagent))
return "XBT Client";
elseif (ereg("^BitTorrent\/BitSpirit$", $httpagent))
return "BitSpirit";
elseif (ereg("^DansClient", $httpagent))
return "XanTorrent";
else
return "Unknow";
}
function dltable($name, $arr, $torrent)
{
global $CURUSER;
$s = "" . count($arr) . " $name\n";
if (!count($arr))
return $s;
$s .= "\n";
$s .= "\n";
$s .= "User/IP | " .
"Connectable | ".
"Uploaded | ".
"Rate | ".
"Downloaded | " .
"Rate | " .
"Ratio | " .
"Complete | " .
"Connected | " .
"Idle | " .
"Client | \n";
$now = time();
$moderator = (isset($CURUSER) && get_user_class() >= UC_MODERATOR);
$mod = get_user_class() >= UC_MODERATOR;
foreach ($arr as $e) {
// user/ip/port
// check if anyone has this ip
($unr = mysql_query("SELECT id, username, privacy, warned, donor FROM users WHERE id=$e[userid] ORDER BY last_access DESC LIMIT 1")) or die;
$una = mysql_fetch_array($unr);
if ($una["privacy"] == "strong") continue;
++$num;
$highlight = $CURUSER["id"] == $una["id"] ? " bgcolor=#BBAF9B" : "";
$s .= "\n";
//$s .= " \n";
if ($una["username"]) {
if (get_user_class() >= UC_MODERATOR || $torrent['anonymous'] != 'yes' || $e['userid'] != $torrent['owner']) {
// $s .= "$una[username] | \n";
$s .= "$una[username]" . ($una["donor"] == "yes" ? "" : "") . ($una["enabled"] == "no" ? "" : ($una["warned"] == "yes" ? "" : ""));
}
elseif (get_user_class() >= UC_MODERATOR || $torrent['anonymous'] = 'yes') {
$s .= " | Anonymous | \n";
}
}
else
$s .= "(unknown) | \n";
$secs = max(1, ($now - $e["st"]) - ($now - $e["la"]));
$revived = $e["revived"] == "yes";
$s .= "" . ($e[connectable] == "yes" ? "Yes" : "No") . " | \n";
$s .= "" . mksize($e["uploaded"]) . " | \n";
$s .= "" . mksize(($e["uploaded"] - $e["uploadoffset"]) / $secs) . "/s | \n";
$s .= "" . mksize($e["downloaded"]) . " | \n";
if ($e["seeder"] == "no")
$s .= "" . mksize(($e["downloaded"] - $e["downloadoffset"]) / $secs) . "/s | \n";
else
$s .= "" . mksize(($e["downloaded"] - $e["downloadoffset"]) / max(1, $e["finishedat"] - $e[st])) . "/s | \n";
if ($e["downloaded"])
{
$ratio = floor(($e["uploaded"] / $e["downloaded"]) * 1000) / 1000;
$s .= "" . number_format($ratio, 3) . " | \n";
}
else
if ($e["uploaded"])
$s .= "Inf. | \n";
else
$s .= "--- | \n";
$s .= "" . sprintf("%.2f%%", 100 * (1 - ($e["to_go"] / $torrent["size"]))) . " | \n";
$s .= "" . mkprettytime($now - $e["st"]) . " | \n";
$s .= "" . mkprettytime($now - $e["la"]) . " | \n";
$s .= "" . htmlspecialchars(getagent($e["agent"], $e["peer_id"])) . " | \n";
$s .= " \n";
}
$s .= " \n";
return $s;
}
dbconn(false);
loggedinorreturn();
$id = 0 + $_GET["id"];
if (!isset($id) || !$id)
die();
$res = mysql_query("SELECT torrents.seeders, torrents.banned, torrents.leechers, torrents.info_hash, torrents.filename, LENGTH(torrents.nfo) AS nfosz, UNIX_TIMESTAMP() - UNIX_TIMESTAMP(torrents.last_action) AS lastseed, torrents.numratings, torrents.name, torrents.description, IF(torrents.numratings < $minvotes, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating, torrents.owner, torrents.save_as, torrents.descr, torrents.visible, torrents.size, torrents.added, torrents.views, torrents.hits, torrents.times_completed, torrents.id, torrents.type, torrents.numfiles, torrents.anonymous, categories.name AS cat_name, users.username FROM torrents LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN users ON torrents.owner = users.id WHERE torrents.id = $id")
or sqlerr();
$row = mysql_fetch_array($res);
$owned = $moderator = 0;
if (get_user_class() >= UC_MODERATOR)
$owned = $moderator = 1;
elseif ($CURUSER["id"] == $row["owner"])
$owned = 1;
//}
if (!$row || ($row["banned"] == "yes" && !$moderator))
stderr("Error", "No torrent with ID $id.");
else {
if ($_GET["hit"]) {
mysql_query("UPDATE torrents SET views = views + 1 WHERE id = $id");
if ($_GET["tocomm"])
header("Location: $BASEURL/details.php?id=$id&page=0#startcomments");
elseif ($_GET["filelist"])
header("Location: $BASEURL/details.php?id=$id&filelist=1#filelist");
elseif ($_GET["toseeders"])
header("Location: $BASEURL/details.php?id=$id&dllist=1#seeders");
elseif ($_GET["todlers"])
header("Location: $BASEURL/details.php?id=$id&dllist=1#leechers");
else
header("Location: $BASEURL/details.php?id=$id");
exit();
}
if (!isset($_GET["page"])) {
stdhead("Details for torrent \"" . $row["name"] . "\"");
if ($CURUSER["id"] == $row["owner"] || get_user_class() >= UC_MODERATOR)
$owned = 1;
else
$owned = 0;
$spacer = " ";
if ($_GET["uploaded"]) {
print("Successfully uploaded!\n");
print("Torrent is changed to tracker standarts \n");
print("Please redownload the torrent to start seeding. \n");
}
elseif ($_GET["edited"]) {
print(" Successfully edited!\n");
if (isset($_GET["returnto"]))
print("Go back to whence you came. \n");
}
elseif (isset($_GET["searched"])) {
print("Your search for \"" . htmlspecialchars($_GET["searched"]) . "\" gave a single result:\n");
}
elseif ($_GET["rated"])
print("Rating added!\n");
$s=$row["name"];
$descrs = $row["description"];
print("$s\n");
print("\n");
$url = "edit.php?id=" . $row["id"];
if (isset($_GET["returnto"])) {
$addthis = "&returnto=" . urlencode($_GET["returnto"]);
$url .= $addthis;
$keepget .= $addthis;
}
$editlink = "a href=\"$url\" class=\"sublink\"";
// $s = "" . htmlspecialchars($row["name"]) . "";
// if ($owned)
// $s .= " $spacer<$editlink>[Edit torrent]";
// tr("Name", $s, 1);
print("Download | " . htmlspecialchars($row["filename"]) . " | ");
if (!empty($row["description"]))
print("Small Description | $descrs | ");
// tr("Downloads as", $row["save_as"]);
function hex_esc($matches) {
return sprintf("%02x", ord($matches[0]));
}
tr("Info hash", preg_replace_callback('/./s', "hex_esc", hash_pad($row["info_hash"])));
if (!empty($row["descr"]))
tr("Description", str_replace(array("\n", " ", "?", " ", "U^", " ", "^(2)", " ",
"U", " ", "?", " ", "Y", " ", "°", " ", "±", " ", "?", " ", "U'", " ", "A", " ", "?", " ", "^(3)",
" ", "A`", " ", "U`", " ", "A~", " ", "?", " ", "^(o)", " ", "E`", " ", "I'", " ", "1/4", " ",
"i`", " ", "E'", " ", "»", " ", "y", " ", "u`", " ", "O~", " ", "?", " "), array("\n", " "),
format_urls(htmlspecialchars($row["descr"]))), 1);
if (get_user_class() >= UC_POWER_USER && $row["nfosz"] > 0)
print("NFO | View NFO (" .
mksize($row["nfosz"]) . ") | \n");
if ($row["visible"] == "no")
tr("Visible", "no (dead)", 1);
if ($moderator)
tr("Banned", $row["banned"]);
if (isset($row["cat_name"]))
tr("Type", $row["cat_name"]);
else
tr("Type", "(none selected)");
tr("Last seeder", "Last activity " . mkprettytime($row["lastseed"]) . " ago");
tr("Size",mksize($row["size"]) . " (" . number_format($row["size"]) . " bytes)");
/*
$s = "";
$s .= "";
if (!isset($row["rating"])) {
if ($minvotes > 1) {
$s .= "none yet (needs at least $minvotes votes and has got ";
if ($row["numratings"])
$s .= "only " . $row["numratings"];
else
$s .= "none";
$s .= ")";
}
else
$s .= "No votes yet";
}
else {
$rpic = ratingpic($row["rating"]);
if (!isset($rpic))
$s .= "invalid?";
else
$s .= "$rpic (" . $row["rating"] . " out of 5 with " . $row["numratings"] . " vote(s) total)";
}
$s .= "\n";
$s .= " | $spacer | ";
if (!isset($CURUSER))
$s .= "(Log in to rate it)";
else {
$ratings = array(
5 => "Kewl!",
4 => "Pretty good",
3 => "Decent",
2 => "Pretty bad",
1 => "Sucks!",
);
if (!$owned || $moderator) {
$xres = mysql_query("SELECT rating, added FROM ratings WHERE torrent = $id AND user = " . $CURUSER["id"]);
$xrow = mysql_fetch_array($xres);
if ($xrow)
$s .= "(you rated this torrent as \"" . $xrow["rating"] . " - " . $ratings[$xrow["rating"]] . "\")";
else {
$s .= "\n";
}
}
}
$s .= " | ";
tr("Rating", $s, 1);
*/
tr("Added", $row["added"]);
tr("Views", $row["views"]);
tr("Hits", $row["hits"]);
tr("Snatched", $row["times_completed"] . " time(s)");
$keepget = "";
if($row['anonymous'] == 'yes') {
if (get_user_class() < UC_UPLOADER)
$uprow = "Anonymous";
else
$uprow = "Anonymous ($row[username])";
}
else {
$uprow = (isset($row["username"]) ? ("" . htmlspecialchars($row["username"]) . "") : "(unknown)");
}
if ($owned)
$uprow .= " $spacer<$editlink>[Edit this torrent]";
tr("Upped by", $uprow, 1);
if ($row["type"] == "multi") {
if (!$_GET["filelist"])
tr("Num files[See full list]", $row["numfiles"] . " files", 1);
else {
tr("Num files", $row["numfiles"] . " files", 1);
$s = "\n";
$subres = mysql_query("SELECT * FROM files WHERE torrent = $id ORDER BY id");
$s.="Path | Size | \n";
while ($subrow = mysql_fetch_array($subres)) {
$s .= "" . $subrow["filename"] .
" | " . mksize($subrow["size"]) . " | \n";
}
$s .= " \n";
tr("File list[Hide list]", $s, 1);
}
}
if (!$_GET["dllist"]) {
/*
$subres = mysql_query("SELECT seeder, COUNT(*) FROM peers WHERE torrent = $id GROUP BY seeder");
$resarr = array(yes => 0, no => 0);
$sum = 0;
while ($subrow = mysql_fetch_array($subres)) {
$resarr[$subrow[0]] = $subrow[1];
$sum += $subrow[1];
}
tr("Peers[See full list]", $resarr["yes"] . " seeder(s), " . $resarr["no"] . " leecher(s) = $sum peer(s) total", 1);
*/
tr("Peers[See full list]", $row["seeders"] . " seeder(s), " . $row["leechers"] . " leecher(s) = " . ($row["seeders"] + $row["leechers"]) . " peer(s) total", 1);
}
else {
$downloaders = array();
$seeders = array();
$subres = mysql_query("SELECT seeder, finishedat, downloadoffset, uploadoffset, ip, port, uploaded, downloaded, to_go, UNIX_TIMESTAMP(started) AS st, connectable, agent, peer_id, UNIX_TIMESTAMP(last_action) AS la, userid FROM peers WHERE torrent = $id") or sqlerr();
while ($subrow = mysql_fetch_array($subres)) {
if ($subrow["seeder"] == "yes")
$seeders[] = $subrow;
else
$downloaders[] = $subrow;
}
function leech_sort($a,$b) {
if ( isset( $_GET["usort"] ) ) return seed_sort($a,$b);
$x = $a["to_go"];
$y = $b["to_go"];
if ($x == $y)
return 0;
if ($x < $y)
return -1;
return 1;
}
function seed_sort($a,$b) {
$x = $a["uploaded"];
$y = $b["uploaded"];
if ($x == $y)
return 0;
if ($x < $y)
return 1;
return -1;
}
usort($seeders, "seed_sort");
usort($downloaders, "leech_sort");
tr("Seeders[Hide list]", dltable("Seeder(s)", $seeders, $row), 1);
tr("Leechers[Hide list]", dltable("Leecher(s)", $downloaders, $row), 1);
}
//.torrent file info link
if (get_user_class() >= UC_MODERATOR)
{
tr("Torrent Info", "Torrent Info", 1);
}
print(" \n");
}
else {
stdhead("Comments for torrent \"" . $row["name"] . "\"");
print("\n");
// print("Back to full details \n");
}
print(" \n");
$commentbar = "Add a comment \n";
$subres = mysql_query("SELECT COUNT(*) FROM comments WHERE torrent = $id");
$subrow = mysql_fetch_array($subres);
$count = $subrow[0];
if (!$count) {
print("No comments yet\n");
}
else {
list($pagertop, $pagerbottom, $limit) = pager(20, $count, "details.php?id=$id&", array(lastpagedefault => 1));
$subres = mysql_query("SELECT comments.id, text, user, comments.added, editedby, editedat, avatar, warned, ".
"username, title, class, donor FROM comments LEFT JOIN users ON comments.user = users.id WHERE torrent = " .
"$id ORDER BY comments.id $limit") or sqlerr(__FILE__, __LINE__);
$allrows = array();
while ($subrow = mysql_fetch_array($subres))
$allrows[] = $subrow;
print($commentbar);
print($pagertop);
commenttable($allrows);
print($pagerbottom);
}
print($commentbar);
}
stdfoot();
?>
|