Code:
<?php
ob_start("ob_gzhandler");
require_once("include/bittorrent.php");
require ("imdb/imdb.class.php");
include("include/rating_functions.php");
function getagent($httpagent)
{
if (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("/^BitTorrent\\/T-(.+)$/", $httpagent, $matches))
return "BitTornado/$matches[1]";
elseif (preg_match("/^BitTorrent\\/([0-9]+\\.[0-9]+(\\.[0-9]+)*)/", $httpagent, $matches))
return "BitTorrent/$matches[1]";
elseif (preg_match("/^Python-urllib\\/.+?, BitTorrent\\/([0-9]+\\.[0-9]+(\\.[0-9]+)*)/", $httpagent, $matches))
return "BitTorrent/$matches[1]";
elseif (ereg("^BitTorrent\\/BitSpirit$", $httpagent))
return "BitSpirit";
elseif (preg_match("/^BitTorrent\\/brst(.+)/", $httpagent, $matches))
return "Burst/$matches[1]";
elseif (preg_match("/^RAZA (.+)$/", $httpagent, $matches))
return "Shareaza/$matches[1]";
else
return "---";
}
function dltable($name, $arr, $torrent)
{
global $CURUSER;
$s = "" . count($arr) . " $name\n";
if (!count($arr))
return $s;
$s .= "\n";
$s .= "<table width=100% class=main border=1 cellspacing=0 cellpadding=5>\n";
$s .= "<tr><td class=colhead>User/IP</td>" .
"<td class=colhead align=center>Connectable</td>".
"<td class=colhead align=right>Uploaded</td>".
"<td class=colhead align=right>Rate</td>".
"<td class=colhead align=right>Downloaded</td>" .
"<td class=colhead align=right>Rate</td>" .
"<td class=colhead align=right>Ratio</td>" .
"<td class=colhead align=right>Complete</td>" .
"<td class=colhead align=right>Connected</td>" .
"<td class=colhead align=right>Idle</td>" .
"<td class=colhead align=left>Client</td></tr>\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 username, privacy FROM users WHERE id=$e[userid] ORDER BY last_access DESC LIMIT 1")) or die;
$una = mysql_fetch_assoc($unr);
if ($una["privacy"] == "strong") continue;
$s .= "<tr>\n";
if ($una["username"])
$s .= "<td><a href=userdetails.php?id=$e[userid]>$una[username]</a></td>\n";
else
$s .= "<td>" . ($mod ? $e["ip"] : preg_replace('/\.\d+$/', ".xxx", $e["ip"])) . "</td>\n";
$secs = max(1, ($now - $e["st"]) - ($now - $e["la"]));
$revived = $e["revived"] == "yes";
$s .= "<td align=center>" . ($e[connectable] == "yes" ? "Yes" : "<font color=red>No</font>") . "</td>\n";
$s .= "<td align=right>" . mksize($e["uploaded"]) . "</td>\n";
$s .= "<td align=right><nobr>" . mksize(($e["uploaded"] - $e["uploadoffset"]) / $secs) . "/s</nobr></td>\n";
$s .= "<td align=right>" . mksize($e["downloaded"]) . "</td>\n";
if ($e["seeder"] == "no")
$s .= "<td align=right><nobr>" . mksize(($e["downloaded"] - $e["downloadoffset"]) / $secs) . "/s</nobr></td>\n";
else
$s .= "<td align=right><nobr>" . mksize(($e["downloaded"] - $e["downloadoffset"]) / max(1, $e["finishedat"] - $e[st])) . "/s</nobr></td>\n";
if ($e["downloaded"])
{
$ratio = floor(($e["uploaded"] / $e["downloaded"]) * 1000) / 1000;
$s .= "<td align=\"right\"><font color=" . get_ratio_color($ratio) . ">" . number_format($ratio, 3) . "</font></td>\n";
}
else
if ($e["uploaded"])
$s .= "<td align=right>Inf.</td>\n";
else
$s .= "<td align=right>---</td>\n";
$s .= "<td align=right>" . sprintf("%.2f%%", 100 * (1 - ($e["to_go"] / $torrent["size"]))) . "</td>\n";
$s .= "<td align=right>" . mkprettytime($now - $e["st"]) . "</td>\n";
$s .= "<td align=right>" . mkprettytime($now - $e["la"]) . "</td>\n";
$s .= "<td align=left>" . htmlspecialchars(getagent($e["agent"])) . "</td>\n";
$s .= "</tr>\n";
}
$s .= "</table>\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, torrents.points, LENGTH(torrents.nfo) AS nfosz, UNIX_TIMESTAMP() - UNIX_TIMESTAMP(torrents.last_action) AS lastseed, torrents.numratings, torrents.name, IF(torrents.numratings < $minvotes, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating, torrents.owner, torrents.save_as, torrents.descr, torrents.url, torrents.poster, torrents.tube, torrents.visible, torrents.size, torrents.added, torrents.views, torrents.hits, torrents.times_completed, torrents.id, torrents.type, torrents.numfiles, 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_assoc($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.");
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("<h2>Successfully uploaded!</h2>\n");
print("
You can start seeding now. Note that the torrent won't be visible until you do that!</p>\n");
}
elseif ($_GET["edited"]) {
print("<h2>Successfully edited!</h2>\n");
if (isset($_GET["returnto"]))
print("
Go back to <a href=\"" . htmlspecialchars("{$BASEURL}/{$_GET['returnto']}") . "\">whence you came</a>.</p>\n");
}
elseif (isset($_GET["searched"])) {
print("<h2>Your search for \"" . htmlspecialchars($_GET["searched"]) . "\" gave a single result:</h2>\n");
}
elseif ($_GET["rated"]) {
print("<h2>Rating added!</h2>\n");
}
elseif ($_GET["thanks"])
print("<h2>Thanks added!</h2>\n");
$s=$row["name"];
print("<h1>$s</h1>\n");
print("<table width=750 border=\"1\" cellspacing=\"0\" cellpadding=\"5\">\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]</a>";
// tr("Name", $s, 1);
if ($CURUSER["id"] == $row["owner"]) $CURUSER["downloadpos"] = "yes";
if ($CURUSER["downloadpos"] != "no")
{
print("<tr><td class=rowhead width=1%><img src=pic/download.jpg></td><td width=99% align=left><a class=\"index\" href=\"download.php/$id/" . rawurlencode($row["filename"]) . "\">" . htmlspecialchars($row["filename"]) . "</a></td></tr>");
// tr("Downloadsas", $row["save_as"]);
/// Mod by dokty - tbdev.net
$blasd = mysql_query("SELECT points FROM coins WHERE torrentid=$id AND userid=".$CURUSER["id"]);
$sdsa = mysql_fetch_assoc($blasd) or $sdsa["points"] = 0;
tr("Points","In total ".$row["points"]." Points given to this torrent of which ".$sdsa["points"]." from you.
By clicking on the coins you can give points to the uploader of this torrent.
", 1);
function hex_esc($matches) {
return sprintf("%02x", ord($matches[0]));
}
tr("Info hash", preg_replace_callback('/./s', "hex_esc", hash_pad($row["info_hash"])));
}
else {
tr("Download", "You are not allowed to download");
}
print("<tr valign=top><td class=rowhead>Description<a href=\"javascript: klappe_news('a1')\">
<img border=\"0\"src=\"pic/show.gif\" id=\"pica".$array['id']."\" alt=\"[Hide/Show]\"></td><td align=left><div id=\"ka1\" style=\"display: none;\">" . str_replace(array("\n", " "), array("
\n", " "), format_comment(htmlspecialchars($row["descr"]))) . "</div></td></tr>\n");
#if (!empty($row["descr"]))
#tr("Description", str_replace(array("\n", " "), array("
\n", " "), format_comment(htmlspecialchars($row["descr"]))), 1);
if (!empty($row["tube"]))
tr("Sample:", "<embed src='". str_replace("watch?v=", "v/", htmlspecialchars($row["tube"])) ."' type=\"application/x-shockwave-flash\" width=\"500\" height=\"410\"></embed>", 1);
else
tr("YouTube", "<img src=pic/nosamp.jpg>", 1);
if (!empty($row["poster"]))
tr("Picture", "[img]".$row["poster"]."[/img]
Click For Full Picture", 1);
//tr("Picture", "[img]".$row["poster"]."[/img]", 1);
else
tr("Picture", "<img src=poster.jpg>", 1);
//auto imdb mod
if (($row["url"] != "")AND(strpos($row["url"], imdb))AND(strpos($row["url"], title)))
echo "<script type=\"text/javascript\" src=\"imdb/swfobject.js\"></script>";
{
$thenumbers = ltrim(strrchr($row["url"],'tt'),'tt');
$thenumbers = ereg_replace("[^A-Za-z0-9]", "", $thenumbers);
$movie = new imdb ($thenumbers);
$movieid = $thenumbers;
$movie->setid ($movieid);
$country = $movie->country ();
$director = $movie->director();
$write = $movie->writing();
$produce = $movie->producer();
$cast = $movie->cast();
$plot = $movie->plot ();
$compose = $movie->composer();
$gen = $movie->genres();
$trailer = $movie->trailer();
if (($photo_url = $movie->photo_localurl() ) != FALSE) {
$smallth = '[img]'.$photo_url.'[/img]';
}
$autodata = "<font color=\"navy\">#######################################################################</font>
\n";
$autodata .= "<font color=\"darkred\" size=\"3\">Information:</font>
\n";
$autodata .= "<font color=\"navy\">#######################################################################</font>
\n";
$autodata .= "<font color=\"DarkRed\"> Title: </font>" . "".$movie->title ()."
\n";
$autodata .= "<font color=\"DarkRed\"> Also known as: </font>";
foreach ( $movie->alsoknow() as $ak){
$autodata .= "".$ak["title"]."" . "".$ak["year"]."" . "".$ak["country"]."" . " (" . "".$ak["comment"]."" . ")" . ", ";
}
$autodata .= "
\n<font color=\"DarkRed\"> Year: </font>" . "".$movie->year ()."
\n";
$autodata .= "<font color=\"DarkRed\"> Runtime: </font>" . "".$movie->runtime ()."" . " mins
\n";
$autodata .= "<font color=\"DarkRed\"> Votes: </font>" . "".$movie->votes ()."
\n";
$autodata .= "<font color=\"DarkRed\"> Rating: </font>" . "".$movie->rating ()."
\n";
$autodata .= "<font color=\"DarkRed\"> Language: </font>" . "".$movie->language ()."
\n";
$autodata .= "<font color=\"DarkRed\"> Country: </font>";
for ($i = 0; $i + 1 < count ($country); $i++) {
$autodata .="$country[$i], ";
}
$autodata .= "$country[$i]";
$autodata .= "
\n<font color=\"DarkRed\"> All Genres: </font>";
for ($i = 0; $i + 1 < count($gen); $i++) {
$autodata .= "$gen[$i], ";
}
$autodata .= "$gen[$i]";
$autodata .= "
\n<font color=\"DarkRed\"> Tagline: </font>" . "".$movie->tagline ()."
\n";
$autodata .= "<font color=\"DarkRed\"> Director: </font>";
for ($i = 0; $i < count ($director); $i++) {
$autodata .= "<a target=\"_blank\" href=\"http://us.imdb.com/Name?" . "".$director[$i]["imdb"]."" ."\">" . "".$director[$i]["name"]."" . "</a> ";
}
$autodata .= "
\n<font color=\"DarkRed\"> Writing By: </font>";
for ($i = 0; $i < count ($write); $i++) {
$autodata .= "<a target=\"_blank\" href=\"http://us.imdb.com/Name?" . "".$write[$i]["imdb"]."" ."\">" . "".$write[$i]["name"]."" . "</a> ";
}
$autodata .= "
\n<font color=\"DarkRed\"> Produced By: </font>";
for ($i = 0; $i < count ($produce); $i++) {
$autodata .= "<a target=\"_blank\" href=\"http://us.imdb.com/Name?" . "".$produce[$i]["imdb"]."" ." \">" . "".$produce[$i]["name"]."" . "</a> ";
}
$autodata .= "
\n<font color=\"DarkRed\"> Music: </font>";
for ($i = 0; $i < count($compose); $i++) {
$autodata .= "<a target=\"_blank\" href=\"http://us.imdb.com/Name?" . "".$compose[$i]["imdb"]."" ." \">" . "".$compose[$i]["name"]."" . "</a> ";
}
$autodata .= "
\n\n<font color=\"navy\">#######################################################################</font>
\n";
$autodata .= "<font color=\"darkred\" size=\"3\"> Description:</font>
\n";
$autodata .= "<font color=\"navy\">#######################################################################</font>";
for ($i = 0; $i < count ($plot); $i++) {
$autodata .= "
\n<font color=\"DarkRed\">