1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-30 19:30:25 +02:00

System logging updates

This commit is contained in:
e107steved
2007-12-29 22:07:49 +00:00
parent 1991680e36
commit b2642bf3b3
4 changed files with 108 additions and 67 deletions

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_admin/admin_log.php,v $
| $Revision: 1.6 $
| $Date: 2007-12-26 15:12:59 $
| $Revision: 1.7 $
| $Date: 2007-12-29 22:07:42 $
| $Author: e107steved $
|
| Preferences:
@@ -32,7 +32,8 @@ Todo:
require_once("../class2.php");
if (!getperms("S"))
{
header("location:".e_BASE."index.php");
header("location:".e_BASE."index.php");
exit;
}
// Main language file should automatically be loaded
@@ -69,17 +70,30 @@ $action = varset($qs[0],'adminlog');
include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_log_messages.php');
// ****************** MAINTENANCE ******************
unset($back_count);
if (isset($_POST['deleteoldadmin']) && isset($_POST['rolllog_clearadmin']))
{
$back_count = $_POST['rolllog_clearadmin'];
$next_action = 'confdel';
}
elseif (isset($_POST['deleteoldaudit']) && isset($_POST['rolllog_clearaudit']))
{
$back_count = $_POST['rolllog_clearaudit'];
$next_action = 'auditdel';
}
if (isset($back_count) && isset($next_action))
{
if (($back_count >= 1) && ($back_count <= 90))
{
$temp_date = getdate();
$old_date = intval(mktime(0,0,0,$temp_date['mon'],$temp_date['mday']-$back_count,$temp_date['year']));
$old_string = strftime("%d %B %Y",$old_date);
// $message = "Back delete ".$back_count." days. Oldest date = ".$old_string;
$action = "confdel";
$action = $next_action;
$qs[1] = $old_date;
$qs[2] = $back_count;
}
@@ -87,23 +101,40 @@ if (isset($_POST['deleteoldadmin']) && isset($_POST['rolllog_clearadmin']))
$message = RL_LAN_050;
}
if (!isset($admin_log)) $message .= " Admin Log not valid";
// Actually delete back events
if ($action == "backdel")
// Actually delete back events - admin or user audit log
if (($action == "backdel") && isset($_POST['backdeltype']))
{
if (isset($_POST['confirmdeleteold']))
if (isset($_POST['confirmdeleteold']))
{
$old_date = intval($qs[1]);
$old_string = strftime("%d %B %Y",$old_date);
$qry = "dblog_datestamp < ".$old_date;
$qry = "dblog_datestamp < ".$old_date; // Same field for both logs
switch ($_POST['backdeltype'])
{
case 'confdel' :
$db_table = 'admin_log';
$db_name = RL_LAN_052;
$db_msg = 'LAN_ADMIN_LOG_002';
break;
case 'auditdel' :
$db_table = 'audit_log';
$db_name = RL_LAN_053;
$db_msg = 'LAN_ADMIN_LOG_003';
break;
default :
exit; // Someone fooling around!
}
// $message = "Back delete, oldest date = {$old_string} Query = {$qry}";
if ($del_count = $sql -> db_Delete("admin_log",$qry))
if ($del_count = $sql -> db_Delete($db_table,$qry))
{
// Add in a log event
$admin_log->log_event ("db_Delete - earlier than {$old_string} (past {$qs[2]} days)", $qry, 4);
$message = RL_LAN_052.$old_string.RL_LAN_057.$del_count.RL_LAN_053;
$message = $db_name.str_replace(array('--OLD--','--NUM--'),array($old_string,$del_count),RL_LAN_057);
$admin_log->log_event($db_msg,"db_Delete - earlier than {$old_string} (past {$qs[2]} days)<br />".$message.'<br />'.$db_table.' '.$qry, 4,'LOG_01');
}
else
{
@@ -140,15 +171,19 @@ if (varsettrue($message))
$ns->tablerender("", "<div style='text-align:center'><b>$message</b></div>");
}
// Prompt to delete back events
if($action == "confdel")
if (($action == "confdel") || ($action == "auditdel"))
{
$old_string = strftime("%d %B %Y",$qs[1]);
$text = "<div style='text-align:center'>
<form method='post' action='".e_SELF."?backdel.{$qs[1]}.{$qs[2]}'>
<input type='hidden' name='backdeltype' value='{$action}' />
<table style='width:97%' class='fborder'>
<tr>
<td class='forumheader3' colspan='2' style='width:100%;vertical-align:top;rext-align:center;'><br /><strong>".RL_LAN_047.$old_string." </strong><br /><br /></td>
<td class='forumheader3' colspan='2' style='width:100%;vertical-align:top;rext-align:center;'><br /><strong>";
$text .= (($action == "confdel") ? RL_LAN_047 : RL_LAN_065).$old_string." </strong><br /><br /></td>
</tr>
<tr><td style='text-align:center' class='fcaption'><input class='button' type='submit' name='confirmdeleteold' value='".RL_LAN_049."' /></td>
<td style='text-align:center' class='fcaption'><input class='button' type='submit' name='confirmcancelold' value='".RL_LAN_055."' /></td></tr>
@@ -157,6 +192,8 @@ if($action == "confdel")
$ns->tablerender("<div style='text-align:center'>".RL_LAN_051."</div>", $text);
}
// Arrays of options for the various logs
$log_db_table = array('adminlog' => 'admin_log', 'auditlog' => 'audit_log', 'rolllog' => 'dblog');
$back_day_count = array('adminlog' => 30, 'auditlog' => 30, 'rolllog' => max(intval($pref['roll_log_days']),1));
@@ -281,6 +318,20 @@ if($action == "config")
$ns->tablerender("<div style='text-align:center'>".RL_LAN_064."</div>", $text);
function gen_log_delete($selectname)
{
$values = array(90,60,30,21,20,14,10,7,6,5,4,3,2,1);
$ret = "<select name='{$selectname}' class='tbox'>\n";
$selected = " selected='selected'"; // Always select the first (highest) value
foreach ($values as $v)
{
$ret .= "<option value='{$v}'{$selected}>{$v}</option>\n";
$selected = '';
}
$ret .= "</select>\n";
return $ret;
}
// Admin log options
//==================
@@ -289,24 +340,7 @@ if($action == "config")
<table style='width:97%' class='fborder'>
<tr>
<td style='width:40%;vertical-align:top;' class='forumheader3'>".RL_LAN_045." </td>
<td style='width:60%;vertical-align:top;' class='forumheader3'>
<select name='rolllog_clearadmin' class='tbox'>
<option value='90' selected='selected'>90</option>
<option value='60'>60</option>
<option value='30'>30</option>
<option value='21'>21</option>
<option value='20'>20</option>
<option value='14'>14</option>
<option value='10'>10</option>
<option value='7'>7</option>
<option value='6'>6</option>
<option value='5'>5</option>
<option value='4'>4</option>
<option value='3'>3</option>
<option value='2'>2</option>
<option value='1'>1</option>
</select>
".RL_LAN_046."
<td style='width:60%;vertical-align:top;' class='forumheader3'>".gen_log_delete('rolllog_clearadmin').RL_LAN_046."
</td>
</tr>\n
<tr><td colspan='2' style='text-align:center' class='fcaption'>
@@ -383,6 +417,23 @@ $audit_checkboxes = array(
$ns->tablerender("<div style='text-align:center'>".RL_LAN_007."</div>", $text);
// Audit Trail maintenance
$text = "
<form method='post' action='".e_SELF."?config'>
<table style='width:97%' class='fborder'>
<tr>
<td style='width:40%;vertical-align:top;' class='forumheader3'>".RL_LAN_066." </td>
<td style='width:60%;vertical-align:top;' class='forumheader3'>".gen_log_delete('rolllog_clearaudit').RL_LAN_046."
</td>
</tr>\n
<tr><td colspan='2' style='text-align:center' class='fcaption'>
<input class='button' type='submit' name='deleteoldaudit' value='".RL_LAN_049."' />
</td></tr>\n
</table></form>\n<br />";
$ns->tablerender("<div style='text-align:center'>".RL_LAN_003."</div>", $text);
// Rolling log options
//====================
$text = "<div style='text-align:center'>

View File

@@ -12,8 +12,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/admin_log_class.php,v $
| $Revision: 1.6 $
| $Date: 2007-12-18 20:57:37 $
| $Revision: 1.7 $
| $Date: 2007-12-29 22:07:42 $
| $Author: e107steved $
To do:
@@ -77,7 +77,7 @@ class e_admin_log {
define('USER_AUDIT_NEW_PW',16); // User changed password
define('USER_AUDIT_NEW_EML',17); // User changed email
define('USER_AUDIT_PW_RES',18); // Password reset
define('USER_AUDIT_NEW_SET',19); // User changed other settings (intentional gap in numbering)
define('USER_AUDIT_NEW_SET',19); // User changed other settings
}
/**
@@ -87,23 +87,22 @@ class e_admin_log {
* @param string $event_detail
* @param int $event_type Log level
*/
// Legacy entry point (not used by much) - retained for completeness.
// (Should really only be used for admin events anyway - not debugging)
function log_event($event_title, $event_detail, $event_type = E_LOG_INFORMATIVE)
// Alternative admin log entry point - compatible with legacy calls, and a bit simpler to use than the generic entry point.
// ($eventcode has been added - give it a reference to identify the source module, such as 'NEWS_12' or 'ECAL_03')
// We also log everything (unlike 0.7, where admin log and debug stuff were all mixed up together)
function log_event($event_title, $event_detail, $event_type = E_LOG_INFORMATIVE, $eventcode='ADMIN')
{
global $e107, $tp;
if($event_type >= $this->_options['log_level'])
{
if($this->_options['backtrace'] == true)
{
$event_detail .= "\n\n".debug_backtrace();
}
$this->e_log_event($event_type,-1,"ADMIN",$event_title,$event_detail,FALSE,LOG_TO_ADMIN);
}
$this->e_log_event($event_type,-1,$eventcode,$event_title,$event_detail,FALSE,LOG_TO_ADMIN);
}
// ***************************** START OF ADDITIONS **************************
/*
Generic log entry point
-----------------------
Example call: (Deliberately pick separators that shouldn't be in file names)
e_log_event(E_LOG_NOTICE,__FILE__."|".__FUNCTION__."@".__LINE__,"ECODE","Event Title","explanatory message",FALSE,LOG_TO_ADMIN);
or:

View File

@@ -1,10 +1,10 @@
<?php
// e107 Language File.
// $Id: lan_admin_log.php,v 1.2 2007-12-15 15:06:40 e107steved Exp $
// $Id: lan_admin_log.php,v 1.3 2007-12-29 22:07:49 e107steved Exp $
define('RL_LAN_001', 'System Logs');
define('RL_LAN_002', "Rolling Log");
//define('RL_LAN_003', "Admin/Rolling Log Installed.");
define('RL_LAN_003', 'User Audit Trail Maintenance');
//define('RL_LAN_004', "Admin/Rolling Log Upgraded");
define('RL_LAN_005', "Configure/View system logs");
define('RL_LAN_006', "Options Updated");
@@ -12,7 +12,7 @@ define('RL_LAN_007', "User Audit Trail Options");
define('RL_LAN_008', "Rolling Log is active:");
define('RL_LAN_009', "Rolling Log History length in days");
define('RL_LAN_010', "Update Options");
define('RL_LAN_011', 'Rolling Log Configuration and Maintenance Options');
define('RL_LAN_011', 'Rolling Log Configuration');
define('RL_LAN_012', "Filter Options");
define('RL_LAN_013', "Start date/time");
define('RL_LAN_014', "End date/time");
@@ -43,12 +43,12 @@ define('RL_LAN_048', "Admin log maintenance");
define('RL_LAN_049', "Delete old entries");
define('RL_LAN_050', "Parameter error - nothing deleted");
define('RL_LAN_051', "Confirm Delete");
define('RL_LAN_052', "Admin log events older than ");
define('RL_LAN_053', " entries) deleted");
define('RL_LAN_052', "Admin log");
define('RL_LAN_053', "User Audit Log");
define('RL_LAN_054', "Nothing to delete, or database error");
define('RL_LAN_055', "Cancel");
define('RL_LAN_056', "Nothing deleted");
define('RL_LAN_057', " (");
define('RL_LAN_057', " - events older than --OLD-- (--NUM-- entries) deleted");
define('RL_LAN_058', "Priority Filter:");
define('RL_LAN_059', "Caller Filter:");
define('RL_LAN_060', "IP Address Filter:");
@@ -56,9 +56,11 @@ define('RL_LAN_061', "Wildcard (*) at end acceptable");
define('RL_LAN_062', 'User Audit Log');
define('RL_LAN_063', 'User audit settings updated');
define('RL_LAN_064', 'Applicable to all logs');
define('RL_LAN_065', "Confirm delete user audit log events older than ");
define('RL_LAN_066', "Delete user audit trail log events older than ");
// Messages for checkbox options in audit log - correspond to audit log event codes
// Messages for checkbox options in audit log - correspond to audit log event codes (20 consecutive values reserved)
define('RL_LAN_071', 'User registration (ignores class setting above)');
define('RL_LAN_072', 'Signup email acknowledgement (ignores class setting above)');
define('RL_LAN_073', 'Login/Logout');

View File

@@ -1,6 +1,6 @@
<?php
// e107 Language File.
// $Id: lan_log_messages.php,v 1.3 2007-12-26 13:21:34 e107steved Exp $
// $Id: lan_log_messages.php,v 1.4 2007-12-29 22:07:49 e107steved Exp $
/*
The definitions in this file are for standard 'explanatory' messages which might be entered
@@ -37,8 +37,8 @@ define('LAN_AUDIT_LOG_020', "");
// Admin log events
//-----------------
define('LAN_ADMIN_LOG_001', 'Admin edited user data');
define('LAN_ADMIN_LOG_002', '');
define('LAN_ADMIN_LOG_003', '');
define('LAN_ADMIN_LOG_002', 'Admin log - delete old data');
define('LAN_ADMIN_LOG_003', 'User Audit log - delete old data');
define('LAN_ADMIN_LOG_004', '');
define('LAN_ADMIN_LOG_005', '');
define('LAN_ADMIN_LOG_006', '');
@@ -48,6 +48,8 @@ define('LAN_ADMIN_LOG_009', '');
define('LAN_ADMIN_LOG_010', '');
define('LAN_ADMIN_LOG_011', '');
// Userclass events
//------------------
define('AL_UC_LAN_00',"Unknown userclass-related event");
define('AL_UC_LAN_01',"Userclass created");
define('AL_UC_LAN_02',"Userclass deleted");
@@ -56,6 +58,8 @@ define('AL_UC_LAN_04',"Class membership updated");
define('AL_UC_LAN_05',"Initial userclass settings edited");
define('AL_UC_LAN_06',"Class membership emptied");
// Banlist events
//----------------
define('AL_BAN_LAN_00','Unknown ban-related event');
define('AL_BAN_LAN_01','Manual ban added');
define('AL_BAN_LAN_02','Ban deleted');
@@ -69,20 +73,5 @@ define('AL_BAN_LAN_09','Banlist entry edited');
define('AL_BAN_LAN_10','Whitelist entry edited');
define('AL_BAN_LAN_11','Whitelist hit for ban entry');
// Rolling log events
//-------------------
define('LAN_ROLL_LOG_001', "Access by banned user");
define('LAN_ROLL_LOG_002', "Flood protection activated");
define('LAN_ROLL_LOG_003', "Invalid page access");
define('LAN_ROLL_LOG_004', "");
define('LAN_ROLL_LOG_005', "");
define('LAN_ROLL_LOG_006', "");
define('LAN_ROLL_LOG_007', "");
define('LAN_ROLL_LOG_008', "");
define('LAN_ROLL_LOG_009', "");
define('LAN_ROLL_LOG_010', "");
define('LAN_ROLL_LOG_011', "");
define('LAN_ROLL_LOG_012', "");
define('LAN_ROLL_LOG_013', "");
?>