<?

require "include/bittorrent.php";

dbconn(false);

loggedinorreturn();

ob_start("ob_gzhandler");


stdhead("Snatch Details");

begin_main_frame();


		  

$res3 = mysql_query("select count(completed.id) from completed inner join users on completed.user_id = users.id inner join

torrents on completed.torrent_id = torrents.id where completed.torrent_id =" . $_GET[id]) or die(mysql_error());
$row = mysql_fetch_array($res3);

$count = $row[0];
$perpage = 10;list($pagertop, $pagerbottom, $limit) = pager($perpage, $count, $_SERVER["PHP_SELF"] . "?id=" . $_GET[id] . "&" );


$res2 = mysql_query("select name from torrents where id = $_GET[id]");
$arr2 = mysql_fetch_assoc($res2);
$dt = gmtime() - 180;
$dt = sqlesc(get_date_time($dt));


begin_frame("<width=\"15\" height=\"15\" alt=\"\" style=\"vertical-align: middle;\">Snatcher Liste für <a href=details.php?id=$_GET[id]><b>$arr2[name]</b></a></h3>\n");
print("<p class=tablecat align=center><font color=red>Mitglieder die dieses Torrent gedownloadet haben</font></p>");

echo $pagertop;

print("<table border=3 cellspacing=0 cellpadding=0 align=center class=tableb width=92%>\n");
print("<tr><td class=tabletitle align=left>Mitglied</td><td class=tabletitle align=left>Hochgeladen</td><td class=tabletitle align=left>Runtergeladen</td><td class=tabletitle align=left>Ratio</td><td class=tabletitle align=left>Fertiggestellt</td><td class=tabletitle align=left>Torrent gestoppt</td><td class=tabletitle align=left>PM Mitglied</td><td class=tabletitle align=left><font color=red>Melde Mitglied</font></td><td class=tabletitle align=left>On/Off</td><td align=left class=tabletitle>Seedet</td></tr>");

$res = mysql_query("select users.id, users.username, users.uploaded, users.downloaded,completed.complete_time, completed.user_id from completed inner

join users on completed.user_id = users.id inner join torrents on completed.torrent_id = torrents.id where

completed.torrent_id =" . $_GET[id] . " ORDER BY completed.id desc $limit");
while ($arr = mysql_fetch_assoc($res))
{
//_______SNATCH LISTE WANN LETZTEMAL AKTIV BY STIFFA START______
$res1= mysql_query("SELECT datetime, event FROM startstoplog WHERE torrent=" . $_GET[id] . " AND userid=$arr[user_id] ORDER BY datetime desc LIMIT 1") or sqlerr(__FILE__,__LINE__); 
$arr1 = mysql_fetch_assoc($res1);
//_______SNATCH LISTE WANN LETZTEMAL AKTIV BY STIFFA ENDE______

$res2 = mysql_query("SELECT id,donor,title,enabled,warned,last_access FROM users WHERE id=$arr[user_id]") or sqlerr(__FILE__,

__LINE__);
$arr2 = mysql_fetch_assoc($res2);

$res3 = mysql_query("SELECT * FROM peers WHERE torrent=$_GET[id] AND userid=$arr[user_id]");
$arr3 = mysql_fetch_assoc($res3);

$res4 = mysql_query("SELECT userid,torrentid,downloaded,uploaded FROM traffic WHERE torrentid=$_GET[id] AND

userid=$arr[user_id]") or sqlerr(__FILE__, __LINE__);
$arr4 = mysql_fetch_assoc($res4);

if ($arr["downloaded"] > 0)
{
      $ratio = number_format($arr["uploaded"] / $arr["downloaded"], 2);
      $ratio = "<font color=" . get_ratio_color($ratio) . ">$ratio</font>";
   }
   else
      if ($arr["uploaded"] > 0)
        $ratio = "Inf.";
else
 $ratio = "---";
if ($arr4["downloaded"] > 0)
{
      $ratio4 = number_format($arr4["uploaded"] / $arr4["downloaded"], 2);
      $ratio4 = "<font color=" . get_ratio_color($ratio4) . ">$ratio4</font>";
   }
   else
      if ($arr4["uploaded"] > 0)
        $ratio4 = "Inf.";
else
 $ratio4 = "---";

$uploaded4 =mksize($arr4["uploaded"]);
$downloaded4 = mksize($arr4["downloaded"]);
$uploaded =mksize($arr["uploaded"]);
$downloaded = mksize($arr["downloaded"]);



$rt_uploaded = 0;
$rt_downloaded = 0;
$rt_uploaded += $ars["uploaded"];
$rt_downloaded += $ars["downloaded"];



$supload =mksize($ars["uploaded"]);
$sdownload = mksize($ars["downloaded"]);

//_______SNATCH LISTE WANN LETZTEMAL AKTIV BY STIFFA START______
$completetime = $arr["complete_time"];
$laction = $arr1["datetime"];

if ($arr1["event"] == "start")
print("<tr><td class=tableb><a href=userdetails.php?id=$arr[id]><b>$arr[username]". get_user_icons($arr2, true) ."</b></a></td><td class=tablea align=left><b>Torrent: $uploaded4</b><br>Gesamt: $uploaded</td><td class=tablea align=left><b>Torrent: $downloaded4</b><br>Total: $downloaded</td><td class=tablea align=left><b>Torrent: $ratio4</b><br>Gesamt: $ratio</td><td class=tablea align=left><b>$completetime</b></td><td class=tablea align=center><font color=green>Seedet im Moment</font></td><td class=tablea><form method=get action=messages.php style=display:inline><input type=hidden name=action value=send><input type=hidden name=receiver value=" . $arr[user_id] . "><input type=submit value=PM style=height: 23px style=width:90%></form><form method=post action=report.php?user=$arr[user_id]></td><td class=tablea align=left><input type=submit value=\"Report\" style=height: 23px style=width:90%></form></td><td class=tablea align=center>".("'".$arr2['last_access']."'">$dt?"<img src=".$GLOBALS["PIC_BASE_URL"]."button_online.gif border=0 alt=\"Online\">":"<img src=".$GLOBALS["PIC_BASE_URL"]."button_offline.gif border=0 alt=\"Offline\">" )."</td>"."<td class=tablea align=center>" . ($arr3["seeder"] == "yes" ? "<b><font color=green>Ja</font></b>" : "<b><font color=red>Nein</font></b>") ."</td></tr>\n");

else if ($arr1["event"] == "stop")
print("<tr><td class=tableb><a href=userdetails.php?id=$arr[id]><b>$arr[username]". get_user_icons($arr2, true) ."</b></a></td><td class=tablea align=left><b>Torrent: $uploaded4</b><br>Gesamt: $uploaded</td><td class=tablea align=left><b>Torrent: $downloaded4</b><br>Total: $downloaded</td><td class=tablea align=left><b>Torrent: $ratio4</b><br>Gesamt: $ratio</td><td class=tablea align=left><b>$completetime</b></td><td class=tablea align=center><font color=red>$laction</font></td><td class=tablea><form method=get action=messages.php style=display:inline><input type=hidden name=action value=send><input type=hidden name=receiver value=" . $arr[user_id] . "><input type=submit value=PM style=height: 23px style=width:90%></form><form method=post action=report.php?user=$arr[user_id]></td><td class=tablea align=left><input type=submit value=\"Report\" style=height: 23px style=width:90%></form></td><td class=tablea align=center>".("'".$arr2['last_access']."'">$dt?"<img src=".$GLOBALS["PIC_BASE_URL"]."button_online.gif border=0 alt=\"Online\">":"<img src=".$GLOBALS["PIC_BASE_URL"]."button_offline.gif border=0 alt=\"Offline\">" )."</td>"."<td class=tablea align=center>" . ($arr3["seeder"] == "yes" ? "<b><font color=green>Ja</font></b>" : "<b><font color=red>Nein</font></b>") ."</td></tr>\n");

if ($arr1["event"] == "")
print("<tr><td class=tableb><a href=userdetails.php?id=$arr[id]><b>$arr[username]". get_user_icons($arr2, true) ."</b></a></td><td class=tablea align=left><b>Torrent: $uploaded4</b><br>Gesamt: $uploaded</td><td class=tablea align=left><b>Torrent: $downloaded4</b><br>Total: $downloaded</td><td class=tablea align=left><b>Torrent: $ratio4</b><br>Gesamt: $ratio</td><td class=tablea align=left><b>$completetime</b></td><td class=tablea align=center><b>Daten wurden gelöscht</b></td><td class=tablea><form method=get action=messages.php style=display:inline><input type=hidden name=action value=send><input type=hidden name=receiver value=" . $arr[user_id] . "><input type=submit value=PM style=height: 23px style=width:90%></form><form method=post action=report.php?user=$arr[user_id]></td><td class=tablea align=left><input type=submit value=\"Report\" style=height: 23px style=width:90%></form></td><td class=tablea align=center>".("'".$arr2['last_access']."'">$dt?"<img src=".$GLOBALS["PIC_BASE_URL"]."button_online.gif border=0 alt=\"Online\">":"<img src=".$GLOBALS["PIC_BASE_URL"]."button_offline.gif border=0 alt=\"Offline\">" )."</td>"."<td class=tablea align=center>" . ($arr3["seeder"] == "yes" ? "<b><font color=green>Ja</font></b>" : "<b><font color=red>Nein</font></b>") ."</td></tr>\n");
//_______SNATCH LISTE WANN LETZTEMAL AKTIV BY STIFFA ENDE______



}
print("</table>\n");

echo $pagerbottom;

end_frame();

?>