<?php

$top = 300;

require "include/bittorrent.php";

dbconn();

loggedinorreturn();

if (get_user_class() < UC_MODERATOR) stderr("Error", "Zugriff verboten.");

stdhead("S&L Liste");

$res1 = mysql_query("select * from sluser") or die(mysql_error());
$count=mysql_num_rows($res1);
if (!$count)
{
print("<center><b><font color=#FF0000>Keine User auf der S&L Liste</font></b></center>");
}
else
{

begin_frame("S&L Liste", true);
begin_table();
print("<tr><td class=\"left\" width=\"20%\"><b>User name</td><td width=\"20%\"><b>Torrent</td><td width=\"20%\"><b>Zeit bis</td><td width=\"20%\"><b>Löschen</td></tr>\n");

$res2 = mysql_query("select id, torrentid, sluserid, pntime from sluser ORDER BY pntime ASC") or die(mysql_error());
while($arr2 = mysql_fetch_assoc($res2))
{
$res4=mysql_query("SELECT name FROM torrents WHERE id=$arr2[torrentid]");
$arr4=mysql_fetch_array($res4);

$res5=mysql_query("SELECT username FROM users WHERE id=$arr2[sluserid]");
$arr5=mysql_fetch_array($res5);

$res6=mysql_query("SELECT seeder FROM peers WHERE userid=$arr2[sluserid] && torrent=$arr2[torrentid] ");
$arr6=mysql_fetch_array($res6);

 if ($arr6["seeder"] == 'yes')
 $color="green";

 if($arr6["seeder"] == '' && get_date_time(time()) < $arr2["pntime"])
 $color="blue";

 if($arr6["seeder"] == '' && get_date_time(time()) > $arr2["pntime"])
 $color="red";

echo '<tr><td style="background-color: ' . $color. '"><a href="userdetails.php?id='.$arr2['sluserid'].'"><font color=black>'.$arr5['username'].'</font></a></td>';
echo '<td style="background-color: ' . $color. '"><a href="details.php?id='.$arr2['torrentid'].'"><font color=black>' .$arr4['name']. '</font></a></td>';
echo '<td style="background-color: ' . $color. '"><font color=black>' .$arr2['pntime']. '</font></a></td>';
echo '<td style="background-color: ' . $color. '"><a href="delslliste.php?id='.$arr2['id'].'"><font color=black>Löschen</font></a></td>';
}

end_table();
end_frame();
}

stdfoot();
?>