<?php
include("config.php");

if ($purgedays>0){
	$purgeseconds = $purgedays * 86400;
	$olddate = strftime("%Y-%m-%d %H:%M:%S", time() - $purgeseconds);
	
$getid = mysql_query("SELECT * FROM uglymonkey_toplist where lastin < '$olddate' and total='0'");

while($get = mysql_fetch_array($getid)){
$lastin = $get['lastin'];
$total = $get['total'];
$name = $get['name'];
$id = $get['id'];
$sendto = $get['mail'];
$subject = "flaremobile.co.za toplist\n";   
$message = "flaremobile.co.za, \n\nAs you did not send us any hits for the last $purgedays days, \nyour site, '$name', has been removed from the cult.toddywap.com top list.\nYou may register your site details again if you wish.\nYou need to send at least 1 hit every $purgedays days to keep your site active.";
mail($sendto, $subject, $message);
} 
	$sql = "delete from uglymonkey_toplist where lastin < '$olddate' and total='0'";
$result = mysql_query($sql) or die("Failed: $sql");
}

////////////////RESET COUNTERS////////////////


echo("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>FLaReMoBiLe.Co.Za</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style type="text/css">
body{color:#0000FF;} 
a{color:#0000FF;} 
a:link{color:#000000;} 
a:visited{color:#000000;} 
a:hover{color:#FFFFFF;background:#222222;} 
a:active{color:#FFFFFF;background:#222222;} 
a:focus{color:#FFFFFF;background:#222222;} 
div{clear:both;width:100%;}
table{width:100%;}
img:focus{border-color:#222222;} 
input{border-color:#222222;border-width:1px;color:#222222;} 
input:focus{background-color:#222222;color:#FFFFFF;} 
input.BF6:focus{background-color:#222222;color:#FFFFFF;} 
select:focus{background-color:#222222;color:#FFFFFF;}
div.HTAB{padding-top:2px;margin-bottom:4px;} 
img.H1{width:160px;height:30px;} 
img.H1I{width:160px;height:64px;} 
table.TAB{margin-left:1px;margin-top:2px;width:169px;} 
td.TAB{vertical-align:bottom;width:38px;} 
img.TAB{border-top:2px;border-bottom:0px;border-left:2px;border-right:2px;margin:0px;} 
a.TAB{margin:0px;} 
div.MH{font-weight:bold;border-top:1px solid #FFFFFF;border-bottom-width:1px;border-bottom-style:solid;margin-bottom:0px;} 
td.IL-L{width:22px;vertical-align:top;} 
img.IL{width:16px;height:16px;vertical-align:top;margin-right:1px;margin-top:2px;} 
td.IL-R{width:147;} 
td.BP{vertical-align:top;padding-right:1px;padding-left:1px;}
td.BH{vertical-align:top;} 
span.BH3{font-weight:bold;} 
div.BP1{text-align:center;} 
div.BT{margin-top:4px;} 
div.F0{color:#FFFFFF;background-color:#808080;padding-bottom:2px;margin-top:1px;border-top:1px solid #FF0000;} 
a.F0{color:#FFFFFF;}
input{background-color:#FFFFFF color:#000000; border: 1px solid #F99F2B}
select{background-color:#FFFFFF; color:#000000; border: 1px solid #F99F2B}
</style>
</head>
<body>
<div class="HTAB" style="background:#00FF00">
<center>
<? 


$total = mysql_num_rows(mysql_query("select * from uglymonkey_toplist"));

$active = mysql_num_rows(mysql_query("select * from uglymonkey_toplist WHERE incoming>=2"));

$count1 = mysql_num_rows(mysql_query("select * from uglymonkey_toplist WHERE incoming>=2 AND cat = '1'"));

$count2 = mysql_num_rows(mysql_query("select * from uglymonkey_toplist WHERE incoming>=2 AND cat = '2'"));

$count3 = mysql_num_rows(mysql_query("select * from uglymonkey_toplist WHERE incoming>=2 AND cat = '3'"));

$count4 = mysql_num_rows(mysql_query("select * from uglymonkey_toplist WHERE incoming>=2 AND cat = '4'"));

$count5 = mysql_num_rows(mysql_query("select * from uglymonkey_toplist WHERE incoming>=2 AND cat = '5'"));
?>
<div class="HTAB" style="background:#000000">
<img src="http://top.flaremobile.co.za/LOWtop.gif" alt ="L.O.W.top"/><br/>
</center><div class="MH" style="color:#000000; background-color:#3984d8; border-top: solid 1px;border-top-color:#FFFFFF;border-bottom: solid 1px;border-bottom-color:#1c5089"><center><small>
<?php
if ($Hour <= 4) { echo 'Hello night owl!'; } 

else if ($Hour <= 11) { echo 'Good morning!'; } 

else if ($Hour <= 12) { echo 'Enjoy your lunch!'; }

else if ($Hour <= 17) { echo 'Good afternoon!'; } 

else if ($Hour <= 23) { echo 'Good Evening!'; }

echo "<font color=\"#000000\"><i> al ViSiToRz</i></font></a>!</small></center></div>";
echo "<div class=\"MB\" style=\"background-color:#7daee5; border-top: solid 1px;border-top-color:#FFFFFF;border-bottom: solid 1px;border-bottom-color:#3984d8\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"169\"><tr><td class=\"IL-R\"><small></td><tr>";
echo "<td class=\"IL-R\">&#187;<a href=\"submit.php\">Add site</a></td></tr>";
echo "<td class=\"IL-R\">&#187;<a href=\"popular.php\">Popular sites</a></td></tr>";
echo "<td class=\"IL-R\">&#187;<a href=\"newest.php\">NeW Sites</a></td></tr>";


$sql = mysql_query("SELECT * FROM uglymonkey_toplist WHERE incoming>=2 ORDER BY incoming desc LIMIT 1"); 
while($row = mysql_fetch_array($sql)){ 
    $go = $row['name'];
$id = $row['id'];
    echo "top site:<small><b><a href=\"viewsite.php?id=".$id."\">".$row['name']."</a></b></small></td></tr><tr>";}
echo "<div class=\"MH\" style=\"color:#000000; background-color:#FFD170; border-top: solid 1px;border-top-color:#FFFFFF;border-bottom: solid 1px;border-bottom-color:#E2A74A\"><center><u>CaTeGoRiEs</u></center></div><div class=\"MB\" style=\"background-color:#FEE0A1; border-top: solid 1px;border-top-color:#FFFFFF;border-bottom: solid 1px;border-bottom-color:#FFD170\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>
</p><p align=\"left\">
<a href=\"viewcat.php?cat=1\">
<img src=\"folder.gif\" alt=\"*\"/>Adult ($count1)</a><br/><a href=\"viewcat.php?cat=2\">
<img src=\"folder.gif\" alt=\"*\"/>Downloads ($count2)</a><br/><a href=\"viewcat.php?cat=3\">
<img src=\"folder.gif\" alt=\"*\"/>Portal ($count3)</a><br /><a href=\"viewcat.php?cat=4\">
<img src=\"folder.gif\" alt=\"*\"/>Chat/Forum ($count4)</a><br /><a href=\"viewcat.php?cat=5\">
<img src=\"folder.gif\" alt=\"*\"/>Other ($count5)</a><br/><a href=\"allsites.php\"><img src=\"folder.gif\" alt=\"*\"/>All Sites ($active)</a><br/>---<br/>
<center>
<div class=\"MH\" style=\"color:#000000; background-color:#FF33FF; border-top: solid 1px;border-top-color:#FFFFFF;border-bottom: solid 1px;border-bottom-color:#E2A74A\"><center><u>GeNeRaTe MoRe Traffic NoW</u></center></div>
<div class=\"MB\" style=\"color:#000000; background-color:#FF99FF; border-top: solid 1px;border-top-color:#FFFFFF;border-bottom: solid 1px;border-bottom-color:#FFD170\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>
<a href=\"rules.wml\"><img src=\"http://top.flaremobile.co.za/add.gif\" alt=\"*\"/>Add Your Site</a><br/>
<img src=\"http://top.flaremobile.co.za/log.gif\" alt=\"*\"/><a href=\"edit.php\">-Login/Edit</a><br />
<a href=\"searchbox.php\"><img src=\"search.gif\" alt=\"*\"/>Search Engine</a></td></tr><tr>
<div class=\"MH\" style=\"color:#ffffff; background-color:#CC0099; border-top: solid 1px;border-top-color:#FFFFFF;border-bottom: solid 1px;border-bottom-color:#E2A74A\"><center><u>Extra'Z</u></center></div>
<div class=\"MB\" style=\"color:#000000; background-color:#CC00FF; border-top: solid 1px;border-top-color:#FFFFFF;border-bottom: solid 1px;border-bottom-color:#FFD170\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>
<a href=\"newest.php\">-Newest sites</a><br /><a href=\"worst20.php\">-Worst sites</a><br />
<a href=\"popular.php\">-Popular sites</a><br />
<a href=\"about.wml\">-Information</a></a></td></tr><tr>
<div class=\"MH\" style=\"color:#000000; background-color:#9ECA47; border-top: solid 1px;border-top-color:#FFFFFF;border-bottom: solid 1px;border-bottom-color:#6A980D\"><center><u>Site Stats</u></center></div>

<div class=\"MB\" style=\"background-color:#C1DD85; border-top: solid 1px;border-top-color:#FFFFFF;border-bottom: solid 1px;border-bottom-color:#9ECA47\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"169\"><tr>

</small><small>registered sites: <b>$total</b>
</small><br/><small>active sites: <b>$active</b><br/>---<br/>sites sending no hits will be deleted after: <b>$purgedays days</b></small><small>
<br/>---<br/><a href=\"http://top.flaremobile.co.za\">FLaReMoBiLe.Co.Za</center></small>";

echo "<br/>---<br/>&#169; FLaReMoBiLe.Co.Za 2006-2010";
echo "
</small></p></body></html>></td></tr></table></div></div><div>";
?>
