I recently tried to view the log file on a site that gets a lot of comment spam and the log file viewer bombed. I looked at the log file and saw that it was 7MB in size. So I modified the Log viewer to check the size of the log file and resize it to 100Kb (the size is configurable) so it could be viewed. I have included the file below if you are interested.
Replace the contents of the file LogView.Admin.class.php with this:
----------- Cut Here ----------------
/**
* File: Logview.Admin.class.php
* This is the LogViewer for the Geeklog SpamX Plug-in!
*
* Copyright (C) 2004 by the following authors:
* Author Tom Willett tomw@pigstye.net
*
* Licensed under GNU General Public License
*/
require_once($_CONF['path'] . 'plugins/spamx/BaseAdmin.class.php');
class LogView extends BaseAdmin {
/**
* Constructor
*/
function display()
{
global $_CONF, $_POST, $LANG_SX00;
$max_Log_Size = 100000;
$action = COM_applyFilter($_POST['action']);
$path = $_CONF['site_admin_url'] . '/plugins/spamx/index.php?command=LogView';
$log = 'spamx.log';
$display .= "<form method="post" action="">";
$display .= "<input type="submit" name="action" value="">";
$display .= "</form>";
if ($action == $LANG_SX00['clearlog']) {
$timestamp = strftime("%c");
$fd = fopen($_CONF['path_log'] . $log, "w");
fputs($fd, "$timestamp n");
fclose($fd);
}
$fsize = filesize($_CONF['path_log'] . $log);
if ($fsize > $max_Log_Size) {
$fd=fopen($_CONF['path_log'] . $log, "r");
fseek($fd,-$max_Log_Size,SEEK_END);
$data = fgets($fd);
$data = fread($fd,$max_Log_Size);
fclose($fd);
$fd = fopen($_CONF['path_log'] . $log, "w");
fputs($fd, "$timestamp n");
fwrite($fd,$data);
fclose($fd);
}
$display .= "<hr><pre>";
$display .= implode('', file($_CONF['path_log'] . $log));
$display .= "</pre>";
return $display;
}
function link()
{
global $LANG_SX00;
return $LANG_SX00['viewlog'];
}
}
?>