<?php
require "include/bittorrent.php";
dbconn(true);
loggedinorreturn();
if (get_user_class() >= UC_TEAMLEITUNG) {
///
//$res = mysql_query("SELECT id, name, owner, last_action FROM torrents WHERE last_action < $dt and seeders = '0' and visible = 'no'");
//$row = mysql_fetch_array($res);
//$count = $row[0];

//$perpage = 100;
stdhead("Tote Torrents");
//if (mysql_num_rows($res) == 0)
begin_main_frame();
// ===================================

$days = 4;
$dt = sqlesc(get_date_time(gmtime() - ($days * 86400)));
$dto = number_format(get_row_count("torrents", "WHERE last_action < $dt and visible = 'no'"));

begin_frame("$dto Tote Torrents (seit 4 Tagen oder mehr)", true);
begin_table();
//echo $pagertop;
?>


<tr><td class="tabletitle">ID</td><td class="tabletitle" align="left">Name</td><td class="tabletitle" align="left">Upper</td><td class="tabletitle" align="left">Letzte Aktivität</td><td class="tabletitle">Löschen?</td></tr>
<?
$days = 4;
$dt = sqlesc(get_date_time(gmtime() - ($days * 86400)));
$res = mysql_query("SELECT id, name, owner, last_action FROM torrents WHERE last_action < $dt and visible = 'no' ORDER BY last_action");

// ------------------

?><form method="post" action="/deloldtorrent.php"><?
//echo "<tr><td colspan=\"7\" align=\"right\"><input type=\"checkbox\" name=\"mark\" value=\"1\"></td></tr>";
?><tr><td class="tabletitle" colspan="7" align="right"><input type="submit" name="mark" value="Alle markieren!" /></td></tr></form><?

?><form method="post" action="/takedeloldtorrent.php"><tr><td class="tabletitle" colspan="7" align="right"><input type="submit" value="Und Wech!" /></td></tr><?

while ($arr = @mysql_fetch_assoc($res)) {
$res12 = mysql_query("SELECT username FROM users WHERE id=$arr[owner]");
$row12 = mysql_fetch_assoc($res12);
$mark=$_POST["mark"];
if ($mark == 'Alle markieren!')
{
echo "<tr><td>" . $arr[id] . "</td><td align=\"left\"><b><a href=details.php?id=" . $arr[id] . ">". $arr[name] . "</a></b></td><td align=\"left\"><a href=userdetails.php?id=" . $arr[owner] . ">". $row12[username] . "</a></td><td align=\"left\">" . $arr[last_action] . "</td><td align=center><input type=\"checkbox\" name=\"deltor[]\" value=\"" . $arr[id] . "\" checked /></td></tr>";
}
else
{
echo "<tr><td class=tablea align=\"left\"><b><a href=details.php?id=" . $arr[id] . ">" . $arr[id] . "</a></b></td><td class=tablea align=\"left\"><b><a href=details.php?id=" . $arr[id] . ">". $arr[name] . "</a></b></td><td class=tablea align=\"left\"><a href=userdetails.php?id=" . $arr[owner] . ">". $row12[username] . "</a></td><td class=tablea align=\"left\">" . $arr[last_action] . "</td><td class=tablea align=center><input type=\"checkbox\" name=\"deltor[]\" value=\"" . $arr[id] . "\" /></td></tr>";
}
}
?>
<tr><td class=tableb colspan="7" align="right"><input type="submit" value="Und Wech!" /></td></tr>
</form>
<?
// ------------------
  end_table();
  end_frame();
// ===================================
end_main_frame();
stdfoot();
}
else {
stderr("Sorry", "Access denied!");
}
?>