" . count($arr) . " $name\n"; if (!count($arr)) return $s; //$s .= "\n"; $s .= "\n"; $s .= "" . "". "". "". "" . "" . "" . "" . "" . "" . "\n"; $now = gmtime(); $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 = do_mysql_query("SELECT username, privacy, anonymous FROM users WHERE id=".$e['userid'])) or die; $una = mysql_fetch_assoc($unr); if ($una["privacy"] == "strong") continue; $s .= "\n"; if (get_user_class() >= UC_MODERATOR OR $CURUSER["id"] == $e["userid"] OR $una["anonymous"] == "no"){ if ($una["username"]) $s .= "\n"; else $s .= "\n"; } elseif ($una["anonymous"] == "yes") $s .= "\n"; $secs = max(1, ($now - $e["st"]) - ($now - $e["la"])); $revived = $e["revived"] == "yes"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; if ($e["seeder"] == "no") $s .= "\n"; else $s .= "\n"; if ($e["downloaded"]) { $ratio = floor(($e["uploaded"] / $e["downloaded"]) * 1000) / 1000; $s .= "\n"; } else if ($e["uploaded"]) $s .= "\n"; else $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; } $s .= "
"._('User/IP').""._('Connectable').""._('Uploaded').""._('Rate').""._('Downloaded').""._('Rate').""._('Ratio').""._('Complete').""._('Connected').""._('Idle').""._('Client')."
$una[username]" . ($mod ? $e["ip"] : preg_replace('/\.\d+$/', ".xxx", $e["ip"])) . "Anonymous" . ($e[connectable] == "yes" ? "Yes" : "No") . "" . mksize($e["uploaded"]) . "" . mksize(($e["uploaded"] - $e["uploadoffset"]) / $secs) . "/s" . mksize($e["downloaded"]) . "" . mksize(($e["downloaded"] - $e["downloadoffset"]) / $secs) . "/s" . mksize(($e["downloaded"] - $e["downloadoffset"]) / max(1, $e["finishedat"] - $e[st])) . "/s" . number_format($ratio, 3) . "Inf.---" . sprintf("%.2f%%", 100 * (1 - ($e["to_go"] / $torrent["size"]))) . "" . mkprettytime($now - $e["st"]) . "" . mkprettytime($now - $e["la"]) . "" . htmlspecialchars(getagent($e["agent"])) . "
\n"; return $s; } dbconn(false); loggedinorreturn(); $id = (int) $_GET["id"]; if (!is_valid_id($id)) stderr( _("Error"), _("Invalid ID")); $res = do_mysql_query("SELECT UNIX_TIMESTAMP(torrents.added) AS ts, torrents.descr_parsed, torrents.completed_by, torrents.seeders, torrents.banned, torrents.leechers, torrents.info_hash, torrents.filename, torrents.description, torrents.comments, 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.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, users.anonymous 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"]) { do_mysql_query("UPDATE LOW_PRIORITY torrents SET views = views + 1 WHERE id = $id"); if ($_GET["tocomm"]) header("Location: details.php?id=$id&page=0#startcomments"); elseif ($_GET["filelist"]) header("Location: details.php?id=$id&filelist=1#filelist"); elseif ($_GET["toseeders"]) header("Location: details.php?id=$id&dllist=1#seeders"); elseif ($_GET["todlers"]) header("Location: details.php?id=$id&dllist=1#leechers"); else header("Location: 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("

"._('You can start seeding now. Note that the torrent won\'t be visible until you do that!')."

\n"); } elseif ($_GET["edited"]) { print("

"._('Successfully edited!')."

"); 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"); elseif ($_GET["thanks"]) print("

"._('Thanks 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=" . htmlspecialchars($_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(""); // tr("Downloads as", $row["save_as"]); /* if (!empty($row["description"])) print(""); */ 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_parsed"])) tr( _("Description"), $row["descr_parsed"], 1); if (get_user_class() >= UC_USER && $row["nfosz"] > 0) print("\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)"); if($GLOBALS['settings']['mod_rating']) { $s = ""; $s .= "
"._('Download')."" . htmlspecialchars($row["filename"]) . "
Small Description$descrs
"._('NFO').""._('View NFO')." (" . mksize($row["nfosz"]) . ")
"; if (!isset($row["rating"])) { if ($minvotes > 3) { $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 = do_mysql_query("SELECT rating, added FROM ratings WHERE torrent = $id AND user = " . $CURUSER["id"]); $xrow = mysql_fetch_assoc($xres); if ($xrow) $s .= "(you rated this torrent as \"" . $xrow["rating"] . " - " . $ratings[$xrow["rating"]] . "\")"; else { $s .= "
\n"; $s .= "\n"; $s .= ""; $s .= "
\n"; } } } $s .= "
"; tr("Rating", $s, 1); } $timezone = $row['added']; tr("Added", $timezone); tr("Views", $row["views"]); tr("Hits", $row["hits"]); if (get_user_class() >= UC_POWER_USER) { tr("Snatched", $row["times_completed"] . " time(s)"); /////// completed_by hack ///////////// /* $completed_by_sql = 'SELECT u.id, u.name FROM completed_by c LEFT JOIN users u ON c.uid = u.id WHERE c.torrentid='.$row['id'].' ORDER BY torrentid DESC LIMIT 0,10'; if ($row["times_completed"] != 0) { echo("The last 10 downloaders"); $completed_by_run = do_mysql_query($completed_by_sql); while($inf = mysql_fetch_assoc($completed_by_run)) { echo("" . $inf["username"] . "  "); } echo (""); } */ } ///// end ///// $keepget = ""; if($row["anonymous"] == "yes" AND get_user_class() < UC_MODERATOR AND $CURUSER["id"] != $row["owner"]){ $row["owner"] = ""; $row["username"] = "Anonymous"; } else $row["owner"] = ""; $uprow = (isset($row["username"]) ? ("" . $row["owner"] . "" . htmlspecialchars($row["username"]) . "") : "Anonymous"); 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 = do_mysql_query("SELECT * FROM files WHERE torrent = $id ORDER BY id"); $s.="\n"; while ($subrow = mysql_fetch_assoc($subres)) { $s .= "\n"; } $s .= "
PathSize
" . $subrow["filename"] . "" . mksize($subrow["size"]) . "
\n"; tr("File list
[Hide list]", $s, 1); } } if (!$_GET["dllist"]) { /* $subres = do_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); */ if (get_user_class() >= UC_POWER_USER) { 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 = do_mysql_query("SELECT seeder, finishedat, downloadoffset, uploadoffset, ip, port, uploaded, downloaded, to_go, UNIX_TIMESTAMP(started) AS st, connectable, agent, 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"); if (get_user_class() >= UC_POWER_USER) { tr("Seeders
[Hide list]", dltable("Seeder(s)", $seeders, $row), 1); tr("Leechers
[Hide list]", dltable("Leecher(s)", $downloaders, $row), 1); } } if( $GLOBALS['settings']['mod_thanks'] ) { $thanks_sql = do_mysql_query("SELECT users.id, users.username FROM thanks LEFT JOIN users ON users.id = thanks.userid WHERE torrentid=$torrentid") or die(mysql_error()); $thanks_all = mysql_num_rows($thanks_sql); if ($thanks_all > 0) { while($rows_t = mysql_fetch_array($thanks_sql)) { $thanksby .= ''.$rows_t['username'].', '; } // $t_userid = $CURUSER["id"]; // $tsql = mysql_query("SELECT COUNT(*) FROM thanks where torrentid=$torrentid and userid=$t_userid"); // $trows = mysql_fetch_array($tsql); // $t_ab = $trows[0]; $t_ab = (int) $_GET['thanks']; if ($t_ab == 0) { $thanksby .= "
"; } else { $thanksby .= "
"; } } else { $thanksby = "None yet
"; } tr("Report
Torrent", "Click here to report this torrent to staff for violation of the rules", 1); tr("Thanks by:",$thanksby,1); } print("

\n"); } else { stdhead("Comments for torrent \"" . $row["name"] . "\""); print("

Comments for " . $row["name"] . "

\n"); // print("

Back to full details

\n"); } if( $GLOBALS['settings']['mod_snatched'] ) { $page = (int) $_GET['page']; $perpage = 10; $offset = ($page * $perpage); if($offset < 0) $offset = 0; $res = do_mysql_query("SELECT SQL_CALC_FOUND_ROWS users.id, users.username, users.title, users.uploaded as user_uploaded, users.downloaded as user_downloaded, IF( users.downloaded > 0, ROUND(users.uploaded / users.downloaded, 3), '---') as user_ratio, users.donor, users.enabled, users.warned, users.last_access, snatched.uploaded as snatch_uploaded, snatched.downloaded as snatch_downloaded, IF( snatched.downloaded > 0, ROUND(snatched.uploaded / snatched.downloaded, 3), '---') as snatched_ratio, snatched.completedat, snatched.last_action, snatched.seeder, snatched.userid, IF( UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(last_access) <= 180, 'online', 'offline' ) as online FROM snatched LEFT JOIN users ON snatched.userid = users.id WHERE snatched.finished='yes' AND snatched.torrentid =" . $torrentid . " ORDER BY snatched.id DESC LIMIT ".$offset.",".$perpage); $count = mysql_result(mysql_query("SELECT FOUND_ROWS()"), 0); list($pagertop, $pagerbottom, $limit) = pager($perpage, $count, $_SERVER["PHP_SELF"] . "?id=" . $id . "&" ); //$res3 = mysql_query("SELECT name FROM torrents WHERE id = ".$torrentid); //$arr3 = mysql_fetch_assoc($res3); print("

Snatch Details for ".$row['name']."

\n"); print("

The users at the top finished the download most recently

"); echo $pagertop; print("\n"); print(""); while ($arr = mysql_fetch_assoc($res)) { //start Global $ratio = "".$arr['user_ratio'].""; $uploaded =mksize($arr["uploaded"]); $downloaded = mksize($arr["downloaded"]); //start torrent $ratio2 = "".$arr['snatched_ratio'].""; $uploaded2 = mksize($arr["snatch_uploaded"]); $downloaded2 = mksize($arr["snatch_downloaded"]); //end $highlight = $CURUSER["id"] == $arr["id"] ? " bgcolor=#00A527" : ""; print(" \n"); } print("
"._('Username').""._('Uploaded').""._('Downloaded').""._('Ratio').""._('When Completed').""._('Last Action').""._('Seeding').""._('PM User').""._('Report User').""._('On/Off')."
".$arr['username']." ".$uploaded." Global
".$uploaded2." Torrent
".$downloaded." Global
".$downloaded2." Torrent
".$ratio." Global
".$ratio2." Torrent
".$arr['completedat']." ".$arr['last_action']." " .($arr["seeder"] == "yes" ? "Yes" : "No") . " " . get_user_icons($arr, true) . "  \"".$arr['online']."\"
\n"); echo $pagerbottom; } print("

\n"); $commentbar = "

Add a comment

\n"; $count = $row['comments']; if (!$count) { print("

No comments yet

\n"); } else { list($pagertop, $pagerbottom, $limit) = pager(20, $count, "details.php?id=$id&", array('lastpagedefault' => 1)); $subres = do_mysql_query("SELECT comments.id, text_parsed, user, comments.added, UNIX_TIMESTAMP(comments.added) as utadded, UNIX_TIMESTAMP(editedat) as uteditedat, editedby, editedat, avatar, warned, username, title, class, donor FROM comments FORCE INDEX(torrent_id) 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(); ?>