<?
require "include/bittorrent.php";
dbconn();
loggedinorreturn();
stdhead("Alle Zeit-Only Uploads");

if (get_user_class() < UC_MODERATOR)
        stderr("Error", "Permission denied.");

begin_frame ("Alle Zeit-Only Uploads", FALSE, "47%");
begin_table ();

$page=(int)$_GET['page'];
$perpage=50;

$arr=mysql_fetch_row(mysql_query("SELECT COUNT(*) FROM torrents WHERE timeou = 'yes' OR freetime = 'yes'"));
$pages=($pp=floor($arr[0] / $perpage))+($pp*$perpage < $arr[0]?1:0);
$page=($page<1?1:$page>$pages?$pages:$page);
for ($i=1;$i<=$pages;++$i)
$pagemenu.=($i!=$page?"<a href=?page=$i>":'')."<b>$i</b>".($i!=$page?'</a>':'')."\n";
$browsemenu.=($page>1?'<a href=?page='.($page-1).'>':'').'<b>&lt;&lt; Zurueck</b>'.($page>1?'</a>':'');
$browsemenu.= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
$browsemenu.=($page<$pages?'<a href=?page='.($page+1).'>':'').'<b>Weiter &gt;&gt;</b>'.($page<$pages?'</a>':'');

$offset=($page*$perpage)-$perpage;

print("<tr><td class=tablea><b>ID</td><td class=tablea><b>Torrent</td><td class=tablea><b>OU Bis</td></tr>\n");

$res7 = mysql_query("SELECT id, torrents.name as torrentname, freeuntil FROM torrents WHERE timeou = 'yes' OR freetime = 'yes' ORDER BY freeuntil DESC LIMIT $offset,$perpage");
while ($arr7 = mysql_fetch_assoc($res7)) {

$res8 = mysql_query("SELECT outage FROM outime WHERE aktiv ='yes'");
$arr8 = mysql_fetch_array($res8);

echo '<tr><td class=tablea>'.$arr7["id"].'</td>';
echo '<td class=tablea><a href=details.php?id='.$arr7["id"].'>'.$arr7["torrentname"].'</a></td>';
if (mysql_num_rows($res8) > 0){
echo '<td class=tablea>Noch '.$arr8["outage"].' Tage</td></tr>';
}else{
echo '<td class=tablea>'.$arr7["freeuntil"].'</td></tr>';
}
}

?>
<td class=tableb colspan="3" align="center" valign="middle" class="bottom">
<?=$browsemenu?><br><?=$pagemenu?></td>
<?
end_table();
end_frame();
stdfoot();

?>