" . count($arr) . " $name\n"; if (!count($arr)) return $s; $s .= "\n"; $s .= "\n"; $s .= "" . "". "". "". "" . "" . "" . "" . "" . "" . "\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_array($unr); if ($una["privacy"] == "strong") continue; $s .= "\n"; if (get_user_class() >= UC_VIP && $una["username"]) { $s .= "\n"; } if (get_user_class() <= UC_MODERATOR && $una["username"]) { if ($una["username"]) $s .= "\n"; else $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/IPConnectableUploadedRateDownloadedRateRatioCompleteConnectedIdleClient
Anonymous$una[username]" . ($mod ? $e["ip"] : preg_replace('/\.\d+$/', ".xxx", $e["ip"])) . "" . ($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 = 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, 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 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."); 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("

You can start seeding now. Note that the torrent won't be visible until you do that!

\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"]; 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("");// 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", format_comment($row["descr"]), 1); //DESCRIPTION if (!empty($row["descr"])){ include 'include\strip.php'; $row["descr"] = preg_replace("/[^\\x20-\\x7e\\x0a\\x0d]/", " ", $row["descr"]); strip( $row["descr"]); print("\n");} //END DESCRIPTION //AUTO NFO LOADUP if (empty($row["descr"])){ $nfo = htmlspecialchars($row["nfo"]); include 'include/strip.php'; $nfo = preg_replace("/[^\\x20-\\x7e\\x0a\\x0d]/", " ", $nfo); strip( $nfo); print("\n");} //AUTO NFO LOADUP if (get_user_class() >= UC_POWER_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)"); /* $s = ""; $s .= "
Download" . htmlspecialchars($row["filename"]) . "
Description
" . str_replace(array("\n", " "), array("
\n", " "), format_comment(htmlspecialchars($row["descr"]))) . "
Description
" . str_replace(array("\n", " "), array("
\n", " "), format_comment($nfo)) . "
NFOView NFO (" . mksize($row["nfosz"]) . ")
"; 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 .= "\n"; $s .= ""; $s .= "
\n"; } } } $s .= "
"; tr("Rating", $s, 1); */ tr("Added", $row["added"]); tr("Views", $row["views"]); tr("Hits", $row["hits"]); tr("Snatched", ($row["times_completed"] > 0 ? "$row[times_completed] time(s)" : "0 times"), 1); $keepget = ""; $uprow = (isset($row["username"]) ? ("" . htmlspecialchars($row["username"]) . "") : "unknown"); if ($owned){ // Ciphex - moved the row printer inside the condition. This way only the uploader or a mod can see the uploader of a torrent. $uprow .= " $spacer<$editlink>[Edit this torrent]"; tr("Upped by", $uprow, 1); } else tr("Upped by", "(hidden)", 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.="\n"; while ($subrow = mysql_fetch_array($subres)) { $s .= "\n"; } $s .= "
PathSize
" . $subrow["filename"] . "" . mksize($subrow["size"]) . "
\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, 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); } print("

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

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

\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(); ?>