<?php
$query = @mysql_query("SELECT COUNT(*) FROM `chat_logs`;");
$all = @mysql_result($query, 0);

if(isset($_GET['s'])) $s = intval($_GET['s']);
else $s = 0;
if($s < 0) $s = 0;
if($s > $all) $s = 0;
$c = $s + 1;

if ($s > 10)  print "<a href=\"arnab.php?".SID."&amp;pass=$pass&amp;ver=html&amp;mod=logs&amp;s=0\">&lt;&lt;&lt;&lt;</a><br/>";
if ($s > 0)  print "<a href=\"arnab.php?".SID."&amp;pass=$pass&amp;ver=html&amp;mod=logs&amp;s=".($s-10)."\">&lt;&lt;&lt;</a><br/>";

$query = mysql_query("DELETE FROM `chat_logs` WHERE `time` < ".(time() - (3600 * 24 * 3)).";");

$query = mysql_query("SELECT * FROM `chat_logs` ORDER BY `id` DESC LIMIT $s, 10;");

if(mysql_num_rows($query) == 0)
{
echo "Logs are empty.<br/>\n";
}

$actnum = array(1, 2, 3, 4, 5, 6, 7);
$act = array(
"Kicked(a) the user with the nickname",
"banned(a) the nickname",
"banned(a) IP + UA user",
"banned(a) IP user",
"removed(a) of the user",
"Blocked Chat Access(a) of the user",
"Deleted(a) The Room",
);

while($logs = mysql_fetch_array($query))
{
$moder = $logs['moder'];
$action = $logs['action'];
$action = str_replace($actnum, $act, $action);
$object = $logs['object'];
$text = $logs['text'];
$date = $logs['date'];

echo "$c. <u>$moder</u> $action <u>$object</u><br/>\n";
if(!empty($text)) echo "cause: $text<br/>\n";
echo "date: $date<br/>\n";
echo "---<br/>\n";
$c++;
}

if ($all > $s + 5)  print "<a href=\"arnab.php?".SID."&amp;pass=$pass&amp;ver=html&amp;mod=logs&amp;s=".($s+5)."\">&gt;&gt;&gt;</a><br/>";
if (($all > $s + 5) && ($all - $s > 10))  print "<a href=\"arnab.php?".SID."&amp;pass=$pass&amp;ver=html&amp;mod=logs&amp;s=".($all-5)."\">&gt;&gt;&gt;&gt;</a><br/>";
?>