4 * File: Logview.Admin.class.php
5 * This is the LogViewer for the Geeklog Spam-X plugin
7 * Copyright (C) 2004-2006 by the following authors:
8 * Author Tom Willett tomw AT pigstye DOT net
10 * Licensed under GNU General Public License
16 if (strpos(strtolower($_SERVER['PHP_SELF']), 'logview.admin.class.php') !== false) {
17 die('This file can not be used on its own!');
21 * Include Abstract Base Class
23 require_once $_CONF['path'] . 'plugins/spamx/BaseAdmin.class.php';
31 class LogView extends BaseAdmin {
37 global $_CONF, $LANG_SX00;
41 $max_Log_Size = 100000;
43 if (isset ($_POST['action'])) {
44 $action = COM_applyFilter ($_POST['action']);
46 $path = $_CONF['site_admin_url']
47 . '/plugins/spamx/index.php?command=LogView';
49 $display .= "<form method=\"post\" action=\"{$path}\"><div>";
50 $display .= "<input type=\"submit\" name=\"action\" value=\"{$LANG_SX00['clearlog']}\"" . XHTML . ">";
51 $display .= "</div></form>";
52 if ($action == $LANG_SX00['clearlog']) {
53 $timestamp = strftime("%c");
54 $fd = fopen($_CONF['path_log'] . $log, "w");
55 fputs($fd, "$timestamp {$LANG_SX00['logcleared']} \n");
58 $fsize = filesize($_CONF['path_log'] . $log);
59 if ($fsize > $max_Log_Size) {
60 $fd=fopen($_CONF['path_log'] . $log, "r");
61 fseek($fd,-$max_Log_Size,SEEK_END);
63 $data = fread($fd,$max_Log_Size);
65 $fd = fopen($_CONF['path_log'] . $log, "w");
66 fputs($fd, "$timestamp {$LANG_SX00['logcleared']} \n");
70 $display .= "<hr" . XHTML . "><pre>";
71 $display .= implode('', file($_CONF['path_log'] . $log));
80 return $LANG_SX00['viewlog'];