<?
require_once("include/bittorrent.php");
dbconn(false);
loggedinorreturn();
stdhead();


$orderby = "ORDER BY torrents.id DESC";

$date_time=get_date_time(time()-(3600*24)); // the 72 is the hours you want listed
$result= mysql_query("SELECT id FROM categories");
$catcount=1;
$noofcats=mysql_num_rows($result);
while($catcount <> $noofcats and $_GET["cat"] == 0) {
$result= mysql_query("SELECT * FROM torrents where category ='$catcount' AND visible = 'yes' AND added>='$date_time'");
$nooftor=mysql_num_rows($result);
$result= mysql_query("SELECT name FROM categories where id=$catcount");
$temp=mysql_fetch_assoc($result);
$catname=$temp["name"];
if ($nooftor <> 0) {
begin_frame("$catname", center);
$dead=1;
if ($_GET["incldead"] == 1) {
$addparam .= "incldead=1&";
if (!isset($CURUSER) || get_user_class < UC_ADMINISTRATOR)
$wherea[] = "banned != 'yes'";
}
else
if ($_GET["incldead"] == 2)
$wherea[] = "seeders = '0'";
else
$wherea[] = "seeders >= '1'";
$where = "WHERE seeders >= '1' AND category = '$catcount'";
$query = "SELECT torrents.id, torrents.category, torrents.leechers, torrents.seeders, torrents.name, torrents.times_completed, torrents.size, torrents.added, torrents.comments,torrents.numfiles,torrents.filename,torrents.nfo,torrents.owner,IF(torrents.nfo <> '', 1, 0) as nfoav, categories.name AS cat_name, categories.image AS cat_pic, users.username FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id $where AND torrents.added>='$date_time' $orderby $limit";
$res = mysql_query($query)
or die(mysql_error());

if ($CURUSER != ""){
if ($nooftor) {
list($pagertop, $pagerbottom, $limit) = pager(1000, $count, "index.php?" . $addparam);
echo '<br>';
torrenttable($res);
echo '<br>';
}
if (!$nooftor){
begin_frame("Nothing Found");
echo"<BR><BR> No new torrents added today<BR><BR>";
end_frame();
}
}
else
bark2("You Must Login to See Torrents", "Please Register and Login");

end_frame();
}
$catcount=$catcount+1;
}
stdfoot();
?>