<h2>Admin Access Log</h2>
<?php
if(isset($_GET) && is_array($_GET) && count($_GET) > 0 && array_key_exists('page', $_GET) && ctype_digit($_GET['page']))
{
$page = $_GET['page'];
}
else
{
$page = 1;
}
$e->page = $page;
$e->page *= $pagelimit;
$e->page -= $pagelimit;
$accessLogCountQuery = dbcom('SELECT COUNT(id) AS theCount FROM admin_logins;');
$accessLogCountArray = mysql_fetch_array($accessLogCountQuery);
$e->total = $accessLogCountArray['theCount'];
if($accessLogCountArray['theCount'] > 999)
{
dbcom('DELETE FROM admin_logins LIMIT 999;');
}
$accessLogQuery = dbcom("SELECT ip, UNIX_TIMESTAMP(loginTime) AS theTime, loginType FROM admin_logins ORDER BY id DESC LIMIT $e->page, $pagelimit;");
if(mysql_num_rows($accessLogQuery) > 0)
{
echo '<table border="0" cellpadding="0" cellspacing="0" width="500">
<thead>
<tr height="30">
<td colspan="3">Last 999 login attempts to this Admin Panel:</td>
</tr>
<tr height="30">
<td width="200"><b>Date</b></td>
<td width="200"><b>Remote IP</b></td>
<td width="100" align="right"><b>Access </b></td>
</tr>
</thead>
<tbody>' . "\n";
while($accessLogArray = mysql_fetch_array($accessLogQuery))
{
echo "<tr onmouseover=\"this.style.backgroundColor='$hovercolor'; window.status='$title'; return true;\" onmouseout=\"this.style.backgroundColor=''; window.status=''\">" . "\n" .
'<td width="200">' . date("F j, Y, g:i a", $accessLogArray['theTime']) . '</td>' . "\n" .
'<td width="200">' . $accessLogArray['ip'] . '</td>' . "\n";
if($accessLogArray['loginType'] == 0)
{
echo '<td width="100" align="right"><span style="color: #ff0000;">Fail </span></td>';
}
elseif($accessLogArray['loginType'] == 1)
{
echo '<td width="100" align="right"><span style="color: #008000;">Success </span></td>';
}
elseif($accessLogArray['loginType'] == 2)
{
echo '<td width="100" align="right"><span>Lock </span></td>';
}
echo '</tr>' . "\n";
}
echo '</tbody>' . "\n" .
'</table><br />' . "\n";
$e->paginate('ddl.php?go=accesslog&page=');
}
else
{
echo '<p>No access attempts!</p>' . "\n";
}
?>