las7h0p3

details.php

May 28th, 2013
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 28.19 KB | None | 0 0
  1. <?
  2.  
  3. ob_start("ob_gzhandler");
  4.  
  5. require_once("include/bittorrent.php");
  6.  
  7.  
  8. function getagent($httpagent, $peer_id="")
  9. {
  10. if (preg_match("/^Azureus ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]\_B([0-9][0-9|*])(.+)$)/", $httpagent, $matches))
  11. return "Azureus/$matches[1]";
  12. elseif (preg_match("/^Azureus ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]\_CVS)/", $httpagent, $matches))
  13. return "Azureus/$matches[1]";
  14. elseif (preg_match("/^Java\/([0-9]+\.[0-9]+\.[0-9]+)/", $httpagent, $matches))
  15. return "Azureus/<2.0.7.0";
  16. elseif (preg_match("/^Azureus ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/", $httpagent, $matches))
  17. return "Azureus/$matches[1]";
  18. elseif (preg_match("/BitTorrent\/S-([0-9]+\.[0-9]+(\.[0-9]+)*)/", $httpagent, $matches))
  19. return "Shadow's/$matches[1]";
  20. elseif (preg_match("/BitTorrent\/U-([0-9]+\.[0-9]+\.[0-9]+)/", $httpagent, $matches))
  21. return "UPnP/$matches[1]";
  22. elseif (preg_match("/^BitTor(rent|nado)\\/T-(.+)$/", $httpagent, $matches))
  23. return "BitTornado/$matches[2]";
  24. elseif (preg_match("/^BitTornado\\/T-(.+)$/", $httpagent, $matches))
  25. return "BitTornado/$matches[1]";
  26. elseif (preg_match("/^BitTorrent\/ABC-([0-9]+\.[0-9]+(\.[0-9]+)*)/", $httpagent, $matches))
  27. return "ABC/$matches[1]";
  28. elseif (preg_match("/^ABC ([0-9]+\.[0-9]+(\.[0-9]+)*)\/ABC-([0-9]+\.[0-9]+(\.[0-9]+)*)/", $httpagent, $matches))
  29. return "ABC/$matches[1]";
  30. if(substr($peer_id, 0, 6) == "A310--")
  31. return "ABC/3.1";
  32. elseif (preg_match("/^Python-urllib\/.+?, BitTorrent\/([0-9]+\.[0-9]+(\.[0-9]+)*)/", $httpagent, $matches))
  33. return "BitTorrent/$matches[1]";
  34. elseif (ereg("^BitTorrent\/BitSpirit$", $httpagent))
  35. return "BitSpirit";
  36. elseif (ereg("^DansClient", $httpagent))
  37. return "XanTorrent";
  38. elseif (preg_match("/^BitTorrent\/brst(.+)/", $httpagent, $matches))
  39. return "Burst/$matches[1]";
  40. elseif (preg_match("/^RAZA (.+)$/", $httpagent, $matches))
  41. return "Shareaza/$matches[1]";
  42. if(substr($peer_id, 0, 8) == "-SZ2210-")
  43. return "Shareaza/2.2.1.0";
  44. elseif (preg_match("/Rufus\/([0-9]+\.[0-9]+\.[0-9]+)/", $httpagent, $matches))
  45. return "Rufus/$matches[1]";
  46. elseif (preg_match("/^BitTorrent\\/([0-9]+\\.[0-9]+(\\.[0-9]+)*)/", $httpagent, $matches))
  47. {
  48. if(substr($peer_id, 0, 6) == "exbc\08")
  49. return "BitComet/0.56";
  50. elseif(substr($peer_id, 0, 6) == "exbc\09")
  51. return "BitComet/0.57";
  52. elseif(substr($peer_id, 0, 6) == "exbc\0:")
  53. return "BitComet/0.58";
  54. if (substr($peer_id, 0,4) == "-BC0")
  55. return "BitComet/0.".substr($peer_id,5,2);
  56. elseif(substr($peer_id, 0, 7) == "exbc\0L")
  57. return "BitLord/1.0";
  58. elseif(substr($peer_id, 0, 7) == "exbcL")
  59. return "BitLord/1.1";
  60. else
  61. return "Unknow";
  62. }
  63. elseif (preg_match("/^Python-urllib\\/([0-9]+\\.[0-9]+(\\.[0-9]+)*)/", $httpagent, $matches))
  64. return "G3 Torrent";
  65. elseif (preg_match("/MLDonkey\/([0-9]+).([0-9]+).([0-9]+)*/", $httpagent, $matches))
  66. return "MLDonkey/$matches[1].$matches[2].$matches[3]";
  67. elseif (preg_match("/ed2k_plugin v([0-9]+\\.[0-9]+).*/", $httpagent, $matches))
  68. return "eDonkey/$matches[1]";
  69. elseif (preg_match("/uTorrent\/([0-9]+)([0-9]+)([0-9]+)([0-9A-Z]+)/", $httpagent, $matches))
  70. return "µTorrent/$matches[1].$matches[2].$matches[3].$matches[4]";
  71. elseif (ereg("^0P3R4H", $httpagent))
  72. return "Opera BT Client";
  73. elseif (preg_match("/CT([0-9]+)([0-9]+)([0-9]+)([0-9]+)/", $peer_id, $matches))
  74. return "cTorrent/$matches[1].$matches[2].$matches[3].$matches[4]";
  75. elseif (preg_match("/Transmission\/([0-9]+).([0-9]+)/", $httpagent, $matches))
  76. return "Transmission/$matches[1].$matches[2]";
  77. elseif (preg_match("/KT([0-9]+)([0-9]+)([0-9]+)([0-9]+)/", $peer_id, $matches))
  78. return "KTorrent/$matches[1].$matches[2].$matches[3].$matches[4]";
  79. elseif (preg_match("/rtorrent\/([0-9]+\\.[0-9]+(\\.[0-9]+)*)/", $httpagent, $matches))
  80. return "rTorrent/$matches[1]";
  81. elseif(substr($peer_id, 0, 12) == "d0c")
  82. return "Mainline";
  83. elseif(substr($peer_id, 0, 1) == "M")
  84. return "Mainline/Decoded";
  85. elseif(substr($peer_id, 0, 3) == "-BB")
  86. return "BitBuddy";
  87.  
  88.  
  89. else
  90. return "Unknow";
  91. }
  92.  
  93. function dltable($name, $arr, $torrent)
  94. {
  95.  
  96. global $CURUSER;
  97. $s = "<b>" . count($arr) . " $name</b>\n";
  98. if (!count($arr))
  99. return $s;
  100. $s .= "\n";
  101. $s .= "<table width=100% class=main border=1 cellspacing=0 cellpadding=5>\n";
  102. $s .= "<tr><td class=colhead>Flag</td>" .
  103. "<td class=colhead>User/IP</td>" .
  104. "<td class=colhead align=center>Connectable</td>".
  105. "<td class=colhead align=right>Uploaded</td>".
  106. "<td class=colhead align=right>Rate</td>".
  107. "<td class=colhead align=right>Downloaded</td>" .
  108. "<td class=colhead align=right>Rate</td>" .
  109. "<td class=colhead align=right>Ratio</td>" .
  110. "<td class=colhead align=right>Complete</td>" .
  111. "<td class=colhead align=right>Connected</td>" .
  112. "<td class=colhead align=right>Idle</td>" .
  113. "<td class=colhead align=left>Client</td></tr>\n";
  114. $now = time();
  115. $moderator = (isset($CURUSER) && get_user_class() >= UC_MODERATOR);
  116. $mod = get_user_class() >= UC_MODERATOR;
  117. foreach ($arr as $e) {
  118.  
  119.  
  120. // user/ip/port
  121. // check if anyone has this ip
  122. ($unr = mysql_query("SELECT u.username, u.privacy, u.class, IF(u.country, c.flagpic, 'question.gif') as countryflag FROM users as u LEFT OUTER JOIN countries as c ON u.country = c.id WHERE u.id=$e[userid] ORDER BY last_access DESC LIMIT 1")) or sqlerr();
  123. $una = mysql_fetch_array($unr);
  124. if ($una["privacy"] == "strong") continue;
  125. $s .= "<tr>\n";
  126. if ($una["username"])
  127. $s .= "<td$tdclass align=center><center><img src=/pic/flag/$una[countryflag]></center></td><td$tdclass><a href=userdetails.php?id=$e[userid]><b>" .$country. $una["username"] . "</b></a></td>\n";
  128. else
  129. $s .= "<td>" . ($mod ? $e["ip"] : preg_replace('/\.\d+$/', ".xxx", $e["ip"])) . "</td>\n";
  130. $secs = max(1, ($now - $e["st"]) - ($now - $e["la"]));
  131. $revived = $e["revived"] == "yes";
  132. $s .= "<td align=center>" . ($e[connectable] == "yes" ? "Yes" : "<font color=red>No</font>") . "</td>\n";
  133. $s .= "<td align=right>" . mksize($e["uploaded"]) . "</td>\n";
  134. $s .= "<td align=right><nobr>" . mksize(($e["uploaded"] - $e["uploadoffset"]) / $secs) . "/s</nobr></td>\n";
  135. $s .= "<td align=right>" . mksize($e["downloaded"]) . "</td>\n";
  136. if ($e["seeder"] == "no")
  137. $s .= "<td align=right><nobr>" . mksize(($e["downloaded"] - $e["downloadoffset"]) / $secs) . "/s</nobr></td>\n";
  138. else
  139. $s .= "<td align=right><nobr>" . mksize(($e["downloaded"] - $e["downloadoffset"]) / max(1, $e["finishedat"] - $e[st])) . "/s</nobr></td>\n";
  140. if ($e["downloaded"])
  141. {
  142.  
  143. $ratio = floor(($e["uploaded"] / $e["downloaded"]) * 1000) / 1000;
  144. $s .= "<td align=\"right\"><font color=" . get_ratio_color($ratio) . ">" . number_format($ratio, 3) . "</font></td>\n";
  145. }
  146. else
  147. if ($e["uploaded"])
  148. $s .= "<td align=right>Inf.</td>\n";
  149. else
  150. $s .= "<td align=right>---</td>\n";
  151. $s .= "<td align=right>" . sprintf("%.2f%%", 100 * (1 - ($e["to_go"] / $torrent["size"]))) . "</td>\n";
  152. $s .= "<td align=right>" . mkprettytime($now - $e["st"]) . "</td>\n";
  153. $s .= "<td align=right>" . mkprettytime($now - $e["la"]) . "</td>\n";
  154. $s .= "<td align=left>" . htmlspecialchars(getagent($e["agent"], $e["peer_id"])) . "</td>\n";
  155. $s .= "</tr>\n";
  156. }
  157. $s .= "</table>\n";
  158. return $s;
  159. }
  160.  
  161. dbconn(false);
  162.  
  163. loggedinorreturn();
  164.  
  165. $id = 0 + $_GET["id"];
  166.  
  167. if (!isset($id) || !$id)
  168. die();
  169.  
  170. $res = mysql_query("SELECT torrents.seeders, categories.id AS cat_id, 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, torrents.poster, torrents.nlsubs, torrents.bgaudio, torrents.nfo, torrents.tube, torrents.image1, torrents.image2, torrents.category, 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();
  171. $row = mysql_fetch_array($res);
  172.  
  173.  
  174.  
  175. if ($row["category"] == 42 && $user["age"] < 18) {
  176. // Too young to view
  177. } else {
  178. // Show regular content
  179. }
  180.  
  181.  
  182.  
  183.  
  184.  
  185. $owned = $moderator = 0;
  186. if (get_user_class() >= UC_MODERATOR)
  187. $owned = $moderator = 1;
  188. elseif ($CURUSER["id"] == $row["owner"])
  189. $owned = 1;
  190. //}
  191.  
  192. if (!$row || ($row["banned"] == "yes" && !$moderator))
  193. stderr("Error", "No torrent with ID.");
  194. else {
  195. if ($_GET["hit"]) {
  196. mysql_query("UPDATE torrents SET views = views + 1 WHERE id = $id");
  197. if ($_GET["tocomm"])
  198. header("Location: $BASEURL/details.php?id=$id&page=0#startcomments");
  199. elseif ($_GET["filelist"])
  200. header("Location: $BASEURL/details.php?id=$id&filelist=1#filelist");
  201. elseif ($_GET["toseeders"])
  202. header("Location: $BASEURL/details.php?id=$id&dllist=1#seeders");
  203. elseif ($_GET["todlers"])
  204. header("Location: $BASEURL/details.php?id=$id&dllist=1#leechers");
  205. else
  206. header("Location: $BASEURL/details.php?id=$id");
  207. exit();
  208. }
  209.  
  210. if (!isset($_GET["page"])) {
  211. stdhead("Details for torrent \"" . $row["name"] . "\"");
  212.  
  213. if ($CURUSER["id"] == $row["owner"] || get_user_class() >= UC_MODERATOR)
  214. $owned = 1;
  215. else
  216. $owned = 0;
  217.  
  218. $spacer = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  219.  
  220. if ($_GET["uploaded"]) {
  221. print("<h2>Успешно качване!</h2>\n");
  222. print("<p>Успешно качихте торента.</b> Преди да почнете да сийдвате свалете торента пак!</p>\n");
  223. }
  224. elseif ($_GET["edited"]) {
  225. print("<h2>Успешно редактиране!</h2>\n");
  226. if (isset($_GET["returnto"]))
  227. print("<p><b>Go back to <a href=\"" . htmlspecialchars($_GET["returnto"]) . "\">whence you came</a>.</b></p>\n");
  228. }
  229. elseif (isset($_GET["searched"])) {
  230. print("<h2>Your search for \"" . htmlspecialchars($_GET["searched"]) . "\" gave a single result:</h2>\n");
  231. }
  232. elseif ($_GET["rated"]) {
  233. print("<h2>Rating added!</h2>\n");
  234. }
  235. elseif ($_GET["thanks"])
  236. print("<h2>Thanks added!</h2>\n");
  237.  
  238. $s=$row["name"];
  239. print("<h1>$s</h1>\n");
  240. print("<table width=750 border=\"1\" cellspacing=\"0\" cellpadding=\"5\">\n");
  241.  
  242. $url = "edit.php?id=" . $row["id"];
  243. if (isset($_GET["returnto"])) {
  244. $addthis = "&amp;returnto=" . urlencode($_GET["returnto"]);
  245. $url .= $addthis;
  246. $keepget .= $addthis;
  247. }
  248. $editlink = "a href=\"$url\" class=\"sublink\"";
  249.  
  250. // $s = "<b>" . htmlspecialchars($row["name"]) . "</b>";
  251. // if ($owned)
  252. // $s .= " $spacer<$editlink>[Edit torrent]</a>";
  253. tr("Название", $s, 1);
  254.  
  255.  
  256. print("<tr><td class=rowhead width=1%>Download</td><td width=99% align=left>");
  257. if ($CURUSER["warned"] == 'yes' )
  258. {
  259. print("<FONT COLOR=RED><b><i>!!!Не можете да теглите щото сте предупреден!!!</i></b></FONT>");
  260. }
  261. else
  262. {
  263. print("<a class=\"index\" href=\"download.php/$id/" . rawurlencode($row["filename"]) . "\">" . htmlspecialchars($row["filename"]) . "</a>");
  264. }
  265. print("</td></tr>");
  266.  
  267.  
  268. tr("Сваляне&nbsp;на", $row["save_as"]);
  269.  
  270.  
  271. function hex_esc($matches) {
  272. return sprintf("%02x", ord($matches[0]));
  273. }
  274. tr("Info hash", preg_replace_callback('/./s', "hex_esc", hash_pad($row["info_hash"])));
  275.  
  276.  
  277.  
  278. if ($row["nlsubs"] == "Nee")
  279. tr("Субтитри", "Няма субтитри", 1);
  280. else
  281. tr("Субтитри", "<img src=/pic/bgsubs.gif>", 1);
  282.  
  283.  
  284. if ($row["bgaudio"] == "Nee")
  285. tr("Аудио", "Няма аудио", 1);
  286. else
  287. tr("Аудио", "<img src=/pic/bgaudio.gif>", 1);
  288.  
  289.  
  290. if (!empty($row["poster"]))
  291. tr("Обложка:", "<img src='".$row["poster"]."'>", 1);
  292. else
  293. tr("Обложка:", "<img src=poster.jpg>", 1);
  294.  
  295. if (!empty($row["descr"]))
  296. tr("Описание", str_replace(array("\n", " "), array("<br>\n", "&nbsp; "), format_comment(htmlspecialchars($row["descr"]))), 1);
  297. if (get_user_class() >= UC_POWER_USER && $row["nfosz"] > 0)
  298. print("<tr><td class=rowhead>NFO</td><td align=left><a href=viewnfo.php?id=$row[id]><b>Виж NFO</b></a> (" .
  299. mksize($row["nfosz"]) . ")</td></tr>\n");
  300. if ($row["visible"] == "no")
  301.  
  302. tr("Visible", "<b>no</b> (dead)", 1);
  303. if ($moderator)
  304. if ($row["image1"] != "" OR $row["image2"] != "") {
  305. if ($row["image1"] != "")
  306. $img1 = "<a href='viewimage.php?pic=$row[image1]'><img border='0' src='thumbnail.php?$row[image1]'></a>";
  307. if ($row["image2"] != "")
  308. $img2 = "<a href='viewimage.php?pic=$row[image2]'><img border='0' src='thumbnail.php?$row[image2]'></a>";
  309. tr("Изображения", $img1 . "&nbsp&nbsp" . $img2, 1);
  310. }
  311.  
  312.  
  313. if (!empty($row["tube"]))
  314. tr("Sample:", "<embed src='". str_replace("watch?v=", "v/", htmlspecialchars($row["tube"])) ."' type=\"application/x-shockwave-flash\" width=\"500\" height=\"410\"></embed>", 1);
  315. else
  316. tr("YouTube:", "<img src=pic/nosamp.jpg>", 1);
  317.  
  318.  
  319.  
  320.  
  321.  
  322. if (isset($row["cat_name"]))
  323. tr("Категория", $row["cat_name"]);
  324. else
  325. tr("Type", "(none selected)");
  326.  
  327. tr("Последен&nbsp;сийдър", "Last activity " . mkprettytime($row["lastseed"]) . " ago");
  328. tr("Размер",mksize($row["size"]) . " (" . number_format($row["size"]) . " bytes)");
  329.  
  330. $s = "";
  331. $s .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"top\" class=embedded>";
  332. if (!isset($row["rating"])) {
  333. if ($minvotes > 1) {
  334. $s .= "none yet (needs at least $minvotes votes and has got ";
  335. if ($row["numratings"])
  336. $s .= "only " . $row["numratings"];
  337. else
  338. $s .= "none";
  339. $s .= ")";
  340. }
  341. else
  342. $s .= "Още няма гласували";
  343. }
  344. else {
  345. $rpic = ratingpic($row["rating"]);
  346. if (!isset($rpic))
  347. $s .= "invalid?";
  348. else
  349. $s .= "$rpic (" . $row["rating"] . " от " . $row["numratings"] . " глас(а) общо)";
  350. }
  351. $s .= "\n";
  352. $s .= "</td><td class=embedded>$spacer</td><td valign=\"top\" class=embedded>";
  353. if (!isset($CURUSER))
  354. $s .= "(<a href=\"login.php?returnto=" . urlencode($_SERVER["REQUEST_URI"]) . "&amp;nowarn=1\">Log in</a> to rate it)";
  355. else {
  356. $ratings = array(
  357. 5 => "Суперско",
  358. 4 => "Добре",
  359. 3 => "Средно",
  360. 2 => "Нестава",
  361. 1 => "Много зле",
  362. );
  363. if (!$owned || $moderator) {
  364. $xres = mysql_query("SELECT rating, added FROM ratings WHERE torrent = $id AND user = " . $CURUSER["id"]);
  365. $xrow = mysql_fetch_array($xres);
  366. if ($xrow)
  367. $s .= "(вие гласувахте за тоя торент със \"" . $xrow["rating"] . " - " . $ratings[$xrow["rating"]] . "\")";
  368. else {
  369. $s .= "<form method=\"post\" action=\"takerate.php\"><input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
  370. $s .= "<select name=\"rating\">\n";
  371. $s .= "<option value=\"0\">(гласувай)</option>\n";
  372. foreach ($ratings as $k => $v) {
  373. $s .= "<option value=\"$k\">$k - $v</option>\n";
  374. }
  375. $s .= "</select>\n";
  376. $s .= "<input type=\"submit\" value=\"Оцени\" />";
  377. $s .= "</form>\n";
  378. }
  379. }
  380. }
  381. $s .= "</td></tr></table>";
  382. tr("Рейтинг", $s, 1);
  383. tr("Добавено на", $row["added"]);
  384. tr("Видян", $row["views"]);
  385. tr("Свален", $row["hits"]);
  386. //print("<tr><td class=rowhead>Snatched</td><td align=left><b><a href=viewsnatches.php?id=$id>".$row["times_completed"]." x</a></b> - Click here to view all snatches</td></tr>\n");
  387. // Totaltraffic mod
  388. $data = mysql_query("SELECT (t.size * t.times_completed + SUM(p.downloaded)) AS data FROM torrents AS t LEFT JOIN peers AS p ON t.id = p.torrent WHERE p.seeder = 'no' AND p.torrent = '$id' AND times_completed > 0 GROUP BY t.id ORDER BY added ASC LIMIT 15") or sqlerr(__FILE__, __LINE__);
  389. $a = mysql_fetch_assoc($data);
  390. $data = mksize($a["data"]) . "";
  391. tr("Общ трафик", $data);
  392. if ($row[seeders] == 0) {
  393.  
  394. }
  395. if ($row["times_completed"] != 0)
  396. {
  397.  
  398. $res3 = mysql_query("SELECT snatched.userid,users.username,users.uploaded,users.downloaded FROM snatched inner
  399.  
  400. join users on snatched.userid = users.id inner join torrents on snatched.torrentid = torrents.id WHERE torrentid
  401.  
  402. =$id order by snatched.id desc LIMIT 10") or sqlerr();
  403. $num = mysql_num_rows($res3);
  404.  
  405. for ($i = 0; $i < $num; ++$i)
  406. {
  407. $arr3 = mysql_fetch_assoc($res3);
  408. if ($arr3["downloaded"] > 0)
  409. {
  410. $ratio = number_format($arr3["uploaded"] / $arr3["downloaded"], 2);
  411. $ratio = "<font color=" . get_ratio_color($ratio) . ">" . $arr3["username"] . " (" . $ratio . ")</font>";
  412. }
  413. echo("<b><a href=userdetails.php?id=" . $arr3["userid"] . ">" . $ratio . "</a></b>&nbsp;&nbsp;");
  414. }
  415. echo ("</td></tr>");
  416. }
  417.  
  418. $seedersProgressbar = array();
  419. $leechersProgressbar = array();
  420. $resProgressbar = mysql_query("SELECT p.seeder, p.to_go, t.size FROM torrents AS t LEFT JOIN peers AS p ON t.id = p.torrent WHERE p.torrent = '$id'") or sqlerr();
  421. $progressPerTorrent = 0;
  422. $iProgressbar = 0;
  423. while ($rowProgressbar = mysql_fetch_array($resProgressbar)) {
  424. $progressPerTorrent += sprintf("%.2f", 100 * (1 - ($rowProgressbar["to_go"] / $rowProgressbar["size"])));
  425. $iProgressbar++;
  426. }
  427. if ($iProgressbar == 0)
  428. $iProgressbar = 1;
  429. $progressTotal = sprintf("%.2f", $progressPerTorrent / $iProgressbar);
  430. //tr("Progress", get_percent_completed_image(floor($progressTotal))." (".round($progressTotal)."%)", 1);
  431.  
  432. $keepget = "";
  433. $uprow = (isset($row["username"]) ? ("<a href=userdetails.php?id=" . $row["owner"] . "><b>" . htmlspecialchars($row["username"]) . "</b></a>") : "<i>unknown</i>");
  434. if ($owned)
  435. $uprow .= " $spacer<$editlink><b>[Редактирай]</b></a>";
  436. if ($owned)
  437. tr("Качено от", $uprow, 1);
  438.  
  439. if ($row["type"] == "multi") {
  440. if (!$_GET["filelist"])
  441. tr("Файлове<br /><a href=\"details.php?id=$id&amp;filelist=1$keepget#filelist\" class=\"sublink\">[See full list]</a>", $row["numfiles"] . " files", 1);
  442. else {
  443. tr("Файлове", $row["numfiles"] . " files", 1);
  444.  
  445. $s = "<table class=main border=\"1\" cellspacing=0 cellpadding=\"5\">\n";
  446.  
  447. $subres = mysql_query("SELECT * FROM files WHERE torrent = $id ORDER BY id");
  448. $s.="<tr><td class=colhead>Path</td><td class=colhead align=right>Size</td></tr>\n";
  449. while ($subrow = mysql_fetch_array($subres)) {
  450. $s .= "<tr><td>" . $subrow["filename"] .
  451. "</td><td align=\"right\">" . mksize($subrow["size"]) . "</td></tr>\n";
  452. }
  453.  
  454. $s .= "</table>\n";
  455. tr("<a name=\"filelist\">File list</a><br /><a href=\"details.php?id=$id$keepget\" class=\"sublink\">[Hide list]</a>", $s, 1);
  456. }
  457. }
  458.  
  459. if (!$_GET["dllist"]) {
  460. /*
  461. $subres = mysql_query("SELECT seeder, COUNT(*) FROM peers WHERE torrent = $id GROUP BY seeder");
  462. $resarr = array(yes => 0, no => 0);
  463. $sum = 0;
  464. while ($subrow = mysql_fetch_array($subres)) {
  465. $resarr[$subrow[0]] = $subrow[1];
  466. $sum += $subrow[1];
  467. }
  468. tr("Peers<br /><a href=\"details.php?id=$id&amp;dllist=1$keepget#seeders\" class=\"sublink\"></a>", $resarr["yes"] . " seeder(s), " . $resarr["no"] . " leecher(s) = $sum peer(s) total", 1);
  469. */
  470. tr("Peers<br /><a href=\"details.php?id=$id&amp;dllist=1$keepget#seeders\" class=\"sublink\"></a>", $row["seeders"] . " seeder(s), " . $row["leechers"] . " leecher(s) = " . ($row["seeders"] + $row["leechers"]) . " peer(s) total", 1);
  471. }
  472. else {
  473. $downloaders = array();
  474. $seeders = array();
  475. $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();
  476. while ($subrow = mysql_fetch_array($subres)) {
  477. if ($subrow["seeder"] == "yes")
  478. $seeders[] = $subrow;
  479. else
  480. $downloaders[] = $subrow;
  481. }
  482.  
  483. function leech_sort($a,$b) {
  484. if ( isset( $_GET["usort"] ) ) return seed_sort($a,$b);
  485. $x = $a["to_go"];
  486. $y = $b["to_go"];
  487. if ($x == $y)
  488. return 0;
  489. if ($x < $y)
  490. return -1;
  491. return 1;
  492. }
  493. function seed_sort($a,$b) {
  494. $x = $a["uploaded"];
  495. $y = $b["uploaded"];
  496. if ($x == $y)
  497. return 0;
  498. if ($x < $y)
  499. return 1;
  500. return -1;
  501. }
  502.  
  503. usort($seeders, "seed_sort");
  504. usort($downloaders, "leech_sort");
  505.  
  506. tr("<a name=\"seeders\">Seeders</a><br /><a href=\"details.php?id=$id$keepget\" class=\"sublink\"></a>", dltable("Seeder(s)", $seeders, $row), 1);
  507. tr("<a name=\"leechers\">Leechers</a><br /><a href=\"details.php?id=$id$keepget\" class=\"sublink\"></a>", dltable("Leecher(s)", $downloaders, $row), 1);
  508.  
  509. }
  510. //.torrent file info link
  511. if (get_user_class() >= UC_MODERATOR)
  512. {
  513. //tr("Torrent Info", "<a href=\"torrent_info.php?id=$id\">Torrent Info</a>", 1);
  514. }
  515. $torrentid = $_GET["id"];
  516. $thanks_sql = mysql_query("SELECT * FROM thanks where torrentid=$torrentid");
  517. $thanks_all = mysql_numrows($thanks_sql);
  518. if ($thanks_all) {
  519. while($rows_t = mysql_fetch_array($thanks_sql)) {
  520. $thanks_userid = $rows_t["userid"];
  521. $user_sql = mysql_query("SELECT * FROM users where id=$thanks_userid");
  522. $rows_a = mysql_fetch_array($user_sql);
  523. $username_t = $rows_a["username"];
  524. $thanksby = $thanksby."<a href='userdetails.php?id=$thanks_userid'>$username_t</a>, ";
  525. }
  526. $t_userid = $CURUSER["id"];
  527. $tsql = mysql_query("SELECT COUNT(*) FROM thanks where torrentid=$torrentid and userid=$t_userid");
  528. $trows = mysql_fetch_array($tsql);
  529. $t_ab = $trows[0];
  530. if ($t_ab == "0") {
  531. $thanksby = $thanksby." <form action=\"thanks.php\" method=\"post\">
  532. <input type=\"submit\" name=\"submit\" value=\"Thanks!\">
  533. <input type=\"hidden\" name=\"torrentid\" value=\"$torrentid\">
  534. </form>";
  535. }
  536. else {
  537. $thanksby = $thanksby." <form action=\"thanks.php\" method=\"post\">
  538. <input type=\"submit\" name=\"submit\" value=\"Thanks!\" disabled>
  539. <input type=\"hidden\" name=\"torrentid\" value=\"$torrentid\">
  540. </form>";
  541. }
  542. }
  543. else {
  544. $thanksby = "None yet.
  545. <form action=\"thanks.php\" method=\"post\">
  546. <input type=\"submit\" name=\"submit\" value=\"Thanks!\">
  547. <input type=\"hidden\" name=\"torrentid\" value=\"$torrentid\">
  548. </form>
  549. ";
  550. }
  551.  
  552. print("</table></p>\n");
  553. }
  554. else {
  555. stdhead("Comments for torrent \"" . $row["name"] . "\"");
  556. print("<h1>Comments for <a href=details.php?id=$id>" . $row["name"] . "</a></h1>\n");
  557. // print("<p><a href=\"details.php?id=$id\">Back to full details</a></p>\n");
  558. }
  559.  
  560. print("<p><a name=\"startcomments\"></a></p>\n");
  561.  
  562. $commentbar = "<p align=\"center\"><a class=\"index\" href=\"comment.php?action=add&amp;tid=$id\">Добави коментар</a></p>\n";
  563.  
  564. $subres = mysql_query("SELECT COUNT(*) FROM comments WHERE torrent = $id");
  565. $subrow = mysql_fetch_array($subres);
  566. $count = $subrow[0];
  567.  
  568. if (!$count) {
  569. print("<h2>Още няма коментари</h2>\n");
  570. }
  571. else {
  572. list($pagertop, $pagerbottom, $limit) = pager(20, $count, "details.php?id=$id&", array(lastpagedefault => 1));
  573.  
  574. $subres = mysql_query("SELECT comments.id, text, user, comments.added, editedby, editedat, avatar, warned, ".
  575. "username, title, class, donor FROM comments LEFT JOIN users ON comments.user = users.id WHERE torrent = " .
  576. "$id ORDER BY comments.id $limit") or sqlerr(__FILE__, __LINE__);
  577. $allrows = array();
  578. while ($subrow = mysql_fetch_array($subres))
  579. $allrows[] = $subrow;
  580.  
  581. print($commentbar);
  582. print($pagertop);
  583.  
  584. commenttable($allrows);
  585.  
  586. print($pagerbottom);
  587. }
  588.  
  589. print($commentbar);
  590. }
  591.  
  592. stdfoot();
  593.  
  594. ?>
Advertisement
Add Comment
Please, Sign In to add comment