<?
$page = "admin_log.php";
include "admin_header.php";

if(isset($_POST['task'])) { $task = $_POST['task']; } else { $task = "main"; }



if($task == "doclear") {
mysql_query("DELETE FROM bhost_log");
$task = "main";
}



if($task == "main") {
$logs = mysql_query("SELECT * FROM bhost_log ORDER BY l_id DESC LIMIT 300");
$logtotal = mysql_num_rows($logs);
echo $head;
echo "
<h2>$admin_log1</h2>
$admin_log2
<br><br>
";

if($logtotal == 0) {
echo "
<table cellpadding='0' cellspacing='0'>
<tr>
<td class='entry'>
$admin_log3
</td>
</tr>
</table>
";
}

if($logtotal > 0) {
echo "
<form action='admin_log.php' method='POST'>
<input type='submit' class='button' value='$admin_log4'>
<input type='hidden' name='task' value='doclear'>
</form>

<br>

<table cellpadding='0' cellspacing='0'>
<tr>
<td class='header' width='5%' style='padding: 7px; font-size: 9pt;'>#</td>
<td class='header' width='5%' style='padding: 7px; border-left: none;'>$admin_log5</td>
<td class='header' width='40%' style='padding: 7px; border-left: none;'>$admin_log6</td>
<td class='header' width='40%' style='padding: 7px; border-left: none;' NOWRAP>$admin_log8</td>
<td class='header' width='10%' style='padding: 7px; border-left: none;' NOWRAP>$admin_log9</td>
</tr>
";

while($log = mysql_fetch_assoc($logs)) {
$date = cdate("h:i:s A m/d/y", $log[date]);
$result = $log[result];
if($result == "0") { $result = "<font color='#FF0000'>Failure</font>"; } 
elseif($result == "1") { $result = "Success"; }
echo "
<tr>
<td class='list2' NOWRAP>$log[l_id] &nbsp;</td>
<td class='list2' style='border-left: none;' NOWRAP>$date &nbsp;</td>
<td class='list2' style='border-left: none;' NOWRAP>$log[username] &nbsp;</td>
<td class='list2' style='border-left: none;' NOWRAP>$result &nbsp;</td>
<td class='list2' style='border-left: none;' NOWRAP>$log[ipaddress] &nbsp;</td>
</tr>
";
}
echo "</table>";
}

echo $foot;
}

?>