require_once("include/bittorrent.php");
dbconn();
loggedinorreturn();
$id = 0 + $_GET["id"];
stdhead("Snatches");
if(!is_valid_id($id))
stderr("Error", "Invalid id.");
//// complex snatchlist mod by rightthere, oink and thebrass recreated by cue ////
$r = mysql_query("SELECT snatched.torrentid, snatched.uploaded, snatched.downloaded, snatched.complete_date, snatched.last_action, torrents.seeders, torrents.leechers, UNIX_TIMESTAMP(snatched.start_date) AS st, UNIX_TIMESTAMP(snatched.last_action) AS lt, UNIX_TIMESTAMP(snatched.complete_date) AS ct, snatched.start_date FROM snatched JOIN torrents ON torrents.id = snatched.torrentid WHERE snatched.finished='yes' AND userid=$id ORDER BY last_action") or sqlerr();
$user1 = mysql_query("SELECT id, username FROM users WHERE id = ".$id."") or sqlerr(__FILE__, __LINE__);
$aser1 = mysql_fetch_assoc($user1);
$completed = "
\n" .
"" .
"\n" .
"| Type | \n" .
"Torrent | \n" .
"Se. | \n" .
"Le. | \n" .
"Upl. | \n" .
"Down. | \n" .
"Ratio | \n" .
"Last action | \n" .
"Seed | \n".
"
\n";
while ($a = mysql_fetch_assoc($r)) {
$res3 = mysql_query("SELECT userid, seeder FROM peers WHERE torrent=". $a["torrentid"] ." AND userid=".$id."") or sqlerr(__FILE__, __LINE__);
$arr3 = mysql_fetch_assoc($res3);
$r1 = mysql_query("SELECT * FROM torrents WHERE id = ". $a[torrentid] ."") or sqlerr(__FILE__, __LINE__);
$a1 = mysql_fetch_assoc($r1);
$r2 = mysql_query("SELECT name FROM categories WHERE id = ". $a1[category] ."") or sqlerr(__FILE__, __LINE__);
$a2 = mysql_fetch_assoc($r2);
if ($a["downloaded"] > 0) {
$ratio = number_format($a["uploaded"] / $a["downloaded"], 3);
$ratio = "$ratio";
}
else
if ($a["uploaded"] > 0)
$ratio = "Inf.";
else
$ratio = "---";
$uploaded =mksize($a["uploaded"]);
$downloaded = mksize($a["downloaded"]);
$cat = "$a2[name]";
$endtime = $a['complete_date'];
$last_action = $a['last_action'];
$seedtime = mkprettytime($a[lt] - $a[ct]);
$td = mysql_query("SELECT * FROM torrents WHERE id = ". $a[torrentid] ."");
while ($tdl = mysql_fetch_assoc($td)) {
$timesdownloaded = $a["downloaded"] / $tdl["size"];
}
/// smallname completed torrents
$smallname3 =substr(htmlspecialchars($a1["name"]) , 0, 26);
if ($smallname3 != htmlspecialchars($a1["name"])) {
$smallname3 .= '...';
}
#$smallname3 = htmlspecialchars($a1["name"]);
// smallname completed torrents end
$completed .= "\n" .
"| $cat | \n" .
"$smallname3 | \n" .
"". $a[seeders] ." | \n" .
"". $a[leechers] ." | \n" .
"$uploaded | \n" .
"$downloaded | \n" .
"$ratio | \n" .
"$last_action | \n" .
"" . ($arr3["seeder"] == "yes" ? "Yes" : "No") . " | \n".
"
\n";
}
$completed .= "
";
//// end ////
print("$completed\n");
stdfoot();
?>