From 3c5b71f736e830ccd85d0fbf18c45ed0c3b75b11 Mon Sep 17 00:00:00 2001 From: secretr Date: Tue, 16 Dec 2008 14:22:01 +0000 Subject: [PATCH] Admin Log Administration ready --- e107_admin/admin_log.php | 1667 +++++++++-------- e107_files/jslib/core/admin.js | 57 +- e107_handlers/form_handler.php | 68 +- .../English/admin/lan_admin_log.php | 11 +- e107_themes/_blank/admin_style.css | 10 +- 5 files changed, 939 insertions(+), 874 deletions(-) diff --git a/e107_admin/admin_log.php b/e107_admin/admin_log.php index dc82e6ce6..ca1211e27 100644 --- a/e107_admin/admin_log.php +++ b/e107_admin/admin_log.php @@ -1,258 +1,242 @@ $file) { - $file = str_replace('--LAN--',e_LANGUAGE,$file); + $file = str_replace('--LAN--', e_LANGUAGE, $file); include_lan(e_PLUGIN.$path.'/'.$file); } } - unset($qs); -require_once(e_ADMIN."auth.php"); +require_once (e_ADMIN."auth.php"); +require_once (e_HANDLER."message_handler.php"); +require_once (e_HANDLER."form_handler.php"); +$emessage = &eMessage::getInstance(); +$frm = new e_form(false); -define ('AL_DATE_TIME_FORMAT', 'y-m-d H:i:s'); +define('AL_DATE_TIME_FORMAT', 'y-m-d H:i:s'); -if (isset($_POST['setoptions'])) +if(isset($_POST['setoptions'])) { unset($temp); - $temp['roll_log_active'] = intval($_POST['roll_log_active']); - $temp['roll_log_days'] = intval($_POST['roll_log_days']); - if ($admin_log->logArrayDiffs($temp, $pref, 'ADLOG_01')) - { - save_prefs(); // Only save if changes - $message = RL_LAN_006 ; // "Options updated."; - } -} - -if (isset($_POST['setcommonoptions'])) -{ - unset($temp); - $temp['sys_log_perpage'] = intval($_POST['sys_log_perpage']); - if ($admin_log->logArrayDiffs($temp, $pref, 'ADLOG_01')) - { - save_prefs(); // Only save if changes - $message = RL_LAN_006 ; // "Options updated."; - } -} - - -// User audit prefs -if (isset($_POST['setauditoptions'])) -{ - unset($temp); - $message = RL_LAN_063; - if (in_array((string)USER_AUDIT_LOGIN,$_POST['user_audit_opts'])) + if(in_array((string) USER_AUDIT_LOGIN, $_POST['user_audit_opts'])) { $_POST['user_audit_opts'][] = USER_AUDIT_LOGOUT; } - foreach ($_POST['user_audit_opts'] as $k => $v) + foreach($_POST['user_audit_opts'] as $k => $v) { - if (!is_numeric($v)) + if(! is_numeric($v)) { unset($_POST['user_audit_opts'][$k]); } } - $temp['user_audit_opts'] = implode(',',$_POST['user_audit_opts']); + $temp['roll_log_active'] = intval($_POST['roll_log_active']); + $temp['roll_log_days'] = intval($_POST['roll_log_days']); + $temp['sys_log_perpage'] = intval($_POST['sys_log_perpage']); + $temp['user_audit_opts'] = implode(',', $_POST['user_audit_opts']); $temp['user_audit_class'] = intval($_POST['user_audit_class']); - if ($admin_log->logArrayDiffs($temp, $pref, 'ADLOG_04')) + + if($admin_log->logArrayDiffs($temp, $pref, 'ADLOG_01') || $admin_log->logArrayDiffs($temp, $pref, 'ADLOG_04')) { - save_prefs(); // Only save if changes + save_prefs(); // Only save if changes + $emessage->add(RL_LAN_006, E_MESSAGE_SUCCESS); } + else + { + $emessage->add(LAN_NO_CHANGE); + } + } - -if (e_QUERY) -{ // Must explode after calling auth.php +if(e_QUERY) +{ // Must explode after calling auth.php $qs = explode(".", e_QUERY); } -$action = varset($qs[0],'adminlog'); - - - +$action = varset($qs[0], 'adminlog'); // Delete comments if appropriate -if (isset($_POST['deleteitems']) && ($action == 'comments')) +if(isset($_POST['deleteitems']) && ($action == 'comments')) { $c_list = array(); - foreach ($_POST['del_item'] as $di) + foreach($_POST['del_item'] as $di) { - if (intval($di) > 0) $c_list[] = '`comment_id`='.intval($di); + if(intval($di) > 0) + $c_list[] = '`comment_id`='.intval($di); } - if ($count = $sql->db_Delete('comments',implode(' OR ',$c_list))) + if($count = $sql->db_Delete('comments', implode(' OR ', $c_list))) { - $text = str_replace('--NUMBER--', $count,RL_LAN_112); - $admin_log->log_event('COMMENT_01','ID: '.implode(',',$_POST['del_item']),E_LOG_INFORMATIVE,''); + //$text = str_replace('--NUMBER--', $count,RL_LAN_112); + $emessage->add(str_replace('--NUMBER--', $count, RL_LAN_112), E_MESSAGE_SUCCESS); + $admin_log->log_event('COMMENT_01', 'ID: '.implode(',', $_POST['del_item']), E_LOG_INFORMATIVE, ''); } else { - $text = RL_LAN_113; + //$text = RL_LAN_113; + $emessage->add(RL_LAN_113, E_MESSAGE_WARNING); } - $ns -> tablerender(LAN_DELETE, "
".$text."
"); + //$ns -> tablerender(LAN_DELETE, "
".$text."
"); unset($c_list); } - - // ****************** MAINTENANCE ****************** unset($back_count); -if (isset($_POST['deleteoldadmin']) && isset($_POST['rolllog_clearadmin'])) +if(isset($_POST['deleteoldadmin']) && isset($_POST['rolllog_clearadmin'])) { - $back_count = intval($_POST['rolllog_clearadmin']); - $next_action = 'confdel'; + $back_count = intval($_POST['rolllog_clearadmin']); + $next_action = 'confdel'; } -elseif (isset($_POST['deleteoldaudit']) && isset($_POST['rolllog_clearaudit'])) +elseif(isset($_POST['deleteoldaudit']) && isset($_POST['rolllog_clearaudit'])) { - $back_count = intval($_POST['rolllog_clearaudit']); - $next_action = 'auditdel'; + $back_count = intval($_POST['rolllog_clearaudit']); + $next_action = 'auditdel'; } -if (isset($back_count) && isset($next_action)) +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 = $next_action; - $qs[1] = $old_date; - $qs[2] = $back_count; - } - else - $message = RL_LAN_050; + 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 = $next_action; + $qs[1] = $old_date; + $qs[2] = $back_count; + } + else $emessage->add(RL_LAN_050, E_MESSAGE_WARNING); + //$message = RL_LAN_050; } - - -if (!isset($admin_log)) $message .= " Admin Log not valid"; - +if(!isset($admin_log)) + $emessage->add("Admin Log not valid", E_MESSAGE_WARNING); + //$message .= " Admin Log not valid"; // Actually delete back events - admin or user audit log -if (($action == "backdel") && isset($_POST['backdeltype'])) +if(($action == "backdel") && isset($_POST['backdeltype'])) { - if (isset($_POST['confirmdeleteold'])) - { - $old_date = intval($qs[1]); - $old_string = strftime("%d %B %Y",$old_date); - $qry = "dblog_datestamp < ".$old_date; // Same field for both logs - switch ($_POST['backdeltype']) + if(isset($_POST['confirmdeleteold'])) { - case 'confdel' : - $db_table = 'admin_log'; - $db_name = RL_LAN_052; - $db_msg = "ADLOG_02"; - break; - case 'auditdel' : - $db_table = 'audit_log'; - $db_name = RL_LAN_053; - $db_msg = "ADLOG_03"; - break; - default : - exit; // Someone fooling around! - } -// $message = "Back delete, oldest date = {$old_string} Query = {$qry}"; - if ($del_count = $sql -> db_Delete($db_table,$qry)) - { - // Add in a log event - $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, E_LOG_INFORMATIVE,''); - } - else - { - $message = RL_LAN_054." : ".$sql->mySQLresult; - } - } + $old_date = intval($qs[1]); + $old_string = strftime("%d %B %Y", $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 = "ADLOG_02"; + break; + case 'auditdel': + $db_table = 'audit_log'; + $db_name = RL_LAN_053; + $db_msg = "ADLOG_03"; + break; + default: + exit(); // Someone fooling around! + } + // $message = "Back delete, oldest date = {$old_string} Query = {$qry}"; + if($del_count = $sql->db_Delete($db_table, $qry)) + { + // Add in a log event + $message = $db_name.str_replace(array('--OLD--', '--NUM--'), array($old_string, $del_count), RL_LAN_057); + $emessage->add($message, E_MESSAGE_SUCCESS); + $admin_log->log_event($db_msg, "db_Delete - earlier than {$old_string} (past {$qs[2]} days)[!br!]".$message.'[!br!]'.$db_table.' '.$qry, E_LOG_INFORMATIVE, ''); + } + else + { + //$message = RL_LAN_054." : ".$sql->mySQLresult; + $emessage->add(RL_LAN_054." : ".$sql->mySQLresult, E_MESSAGE_WARNING); + } + } else + $emessage->add(RL_LAN_056); //info - - if (isset($_POST['confirmcancelold'])) - { - $message = RL_LAN_056; - } - $action = "config"; - unset($qs[1]); - unset($qs[2]); + $action = "config"; + unset($qs[1]); + unset($qs[2]); } - - -if (varsettrue($message)) +/* +if(varsettrue($message)) { $ns->tablerender("", "
$message
"); } - - +*/ // Prompt to delete back events -if (($action == "confdel") || ($action == "auditdel")) +if(($action == "confdel") || ($action == "auditdel")) { - $old_string = strftime("%d %B %Y",$qs[1]); - $text = "
-
- - - - - - - -

"; - $text .= (($action == "confdel") ? RL_LAN_047 : RL_LAN_065).$old_string."

"; - - $ns->tablerender("
".RL_LAN_051."
", $text); + $old_string = strftime("%d %B %Y", $qs[1]); + $text = " +
+
+ ".RL_LAN_051." + + + + +
+ ".(($action == "confdel") ? RL_LAN_047 : RL_LAN_065).$old_string." +
+
+ + + +
+
+
+ + "; + + $ns->tablerender(RL_LAN_051, $text); } - - // Arrays of options for the various logs - the $page_title array is used to determine the allowable values for $action ('options' is a special case) -$log_db_table = array('adminlog' => 'admin_log', 'auditlog' => 'audit_log', 'rolllog' => 'dblog', 'downlog' => 'download_requests', 'comments' => 'comments', 'online'=>'online'); -$back_day_count = array('adminlog' => 30, 'auditlog' => 30, 'rolllog' => max(intval($pref['roll_log_days']),1), 'downlog' => 60, 'detailed' => 20, 'comments' => 30, 'online' => 30); +$log_db_table = array('adminlog' => 'admin_log', 'auditlog' => 'audit_log', 'rolllog' => 'dblog', 'downlog' => 'download_requests', 'comments' => 'comments', 'online' => 'online'); +$back_day_count = array('adminlog' => 30, 'auditlog' => 30, 'rolllog' => max(intval($pref['roll_log_days']), 1), 'downlog' => 60, 'detailed' => 20, 'comments' => 30, 'online' => 30); $page_title = array('adminlog' => RL_LAN_030, 'auditlog' => RL_LAN_062, 'rolllog' => RL_LAN_002, 'downlog' => RL_LAN_067, 'detailed' => RL_LAN_094, 'comments' => RL_LAN_099, 'online' => RL_LAN_120); - - // Set all the defaults for the data filter $start_enabled = FALSE; $end_enabled = FALSE; @@ -261,782 +245,833 @@ $end_time = 0; $user_filter = ''; $event_filter = ''; $pri_filter_cond = "xx"; -$pri_filter_val = ""; -$sort_order = "DESC"; +$pri_filter_val = ""; +$sort_order = "DESC"; $downloadid_filter = ''; $last_noted_time = 0; - - // Maintain the log view filter across pages $rl_cookiename = $pref['cookie_name']."_rl_admin"; -if (isset($_POST['updatefilters']) || isset($_POST['clearfilters'])) -{ // Need to put the filter values into the cookie - if (!isset($_POST['clearfilters'])) - { // Only update filter values from $_POST[] if 'clear filters' not active - $start_time = intval($_POST['starttimedate'] + $_POST['starttimehours']*3600 + $_POST['starttimemins']*60); +if(isset($_POST['updatefilters']) || isset($_POST['clearfilters'])) +{ // Need to put the filter values into the cookie + if(! isset($_POST['clearfilters'])) + { // Only update filter values from $_POST[] if 'clear filters' not active + $start_time = intval($_POST['starttimedate'] + $_POST['starttimehours'] * 3600 + $_POST['starttimemins'] * 60); $start_enabled = isset($_POST['start_enabled']); - if (isset($_POST['timelength'])) + if(isset($_POST['timelength'])) { - $end_time = intval($_POST['timelength'])*60 + $start_time; + $end_time = intval($_POST['timelength']) * 60 + $start_time; } else { - $end_time = intval($_POST['endtimedate'] + $_POST['endtimehours']*3600 + $_POST['endtimemins']*60); + $end_time = intval($_POST['endtimedate'] + $_POST['endtimehours'] * 3600 + $_POST['endtimemins'] * 60); } $end_enabled = isset($_POST['end_enabled']); - $user_filter = trim(varset($_POST['roll_user_filter'],'')); - if ($user_filter != '') $user_filter = intval($user_filter); + $user_filter = trim(varset($_POST['roll_user_filter'], '')); + if($user_filter != '') + $user_filter = intval($user_filter); $event_filter = $tp->toDB($_POST['roll_event_filter']); $pri_filter_cond = $tp->toDB($_POST['roll_pri_cond']); - $pri_filter_val = $tp->toDB($_POST['roll_pri_val']); - $caller_filter = $tp->toDB($_POST['roll_caller_filter']); + $pri_filter_val = $tp->toDB($_POST['roll_pri_val']); + $caller_filter = $tp->toDB($_POST['roll_caller_filter']); $ipaddress_filter = $e107->ipEncode($tp->toDB($_POST['roll_ipaddress_filter'])); $downloadid_filter = $tp->toDB($_POST['roll_downloadid_filter']); } - $cookie_string = implode("|",array($start_time,$start_enabled,$end_time,$end_enabled,$user_filter,$event_filter,$pri_filter_cond,$pri_filter_val,$caller_filter,$ipaddress_filter,$downloadid_filter)); -// echo $cookie_string."
"; -// Create session cookie to store values - cookie($rl_cookiename,$cookie_string,0); // Use session cookie + $cookie_string = implode("|", array($start_time, $start_enabled, $end_time, $end_enabled, $user_filter, $event_filter, $pri_filter_cond, $pri_filter_val, $caller_filter, $ipaddress_filter, $downloadid_filter)); + // echo $cookie_string."
"; + // Create session cookie to store values + cookie($rl_cookiename, $cookie_string, 0); // Use session cookie } else { -// Now try and get the filters from the cookie - if (isset($_COOKIE[$rl_cookiename])) - list($start_time,$start_enabled,$end_time,$end_enabled,$user_filter,$event_filter,$pri_filter_cond,$pri_filter_val, $caller_filter,$ipaddress_filter,$downloadid_filter) = explode("|",$_COOKIE[$rl_cookiename]); - if (isset($qs[1]) && isset($qs[2]) && ($qs[1] == 'user') && ctype_digit($qs[2]) && (intval($qs[2]) > 0)) + // Now try and get the filters from the cookie + if(isset($_COOKIE[$rl_cookiename])) + list($start_time, $start_enabled, $end_time, $end_enabled, $user_filter, $event_filter, $pri_filter_cond, $pri_filter_val, $caller_filter, $ipaddress_filter, $downloadid_filter) = explode("|", $_COOKIE[$rl_cookiename]); + if(isset($qs[1]) && isset($qs[2]) && ($qs[1] == 'user') && ctype_digit($qs[2]) && (intval($qs[2]) > 0)) { $user_filter = intval($qs[2]); } } $timelength = 5; -if ($start_time != 0 && $end_time != 0) $timelength = intval(($end_time - $start_time)/60); +if($start_time != 0 && $end_time != 0) + $timelength = intval(($end_time - $start_time) / 60); function time_box($boxname, $this_time, $day_count, $inc_tomorrow = FALSE, $all_mins = FALSE) -{ // Generates boxes for date and time for today and the preceding days - // Appends 'date', 'hours', 'mins' to the specified boxname - - $all_time = getdate(); // Date/time now - $sel_time = getdate($this_time); // Currently selected date/time - $sel_day = mktime(0,0,0,$sel_time['mon'],$sel_time['mday'],$sel_time['year']); - $today = mktime(0,0,0,$all_time['mon'],$all_time['mday'] + ($inc_tomorrow ? 1 : 0),$all_time['year']); - -// Start with day - $ret = "\n"; - -// Hours - $ret .= " \n"; +{ // Generates boxes for date and time for today and the preceding days + // Appends 'date', 'hours', 'mins' to the specified boxname -// Minutes - $ret .= " \n"; - return $ret; + $all_time = getdate(); // Date/time now + $sel_time = getdate($this_time); // Currently selected date/time + $sel_day = mktime(0, 0, 0, $sel_time['mon'], $sel_time['mday'], $sel_time['year']); + $today = mktime(0, 0, 0, $all_time['mon'], $all_time['mday'] + ($inc_tomorrow ? 1 : 0), $all_time['year']); + + // Start with day + $ret = ""; + + // Hours + $ret .= " "; + + // Minutes + $ret .= " "; + + return $ret; } - -if(!defined("USER_WIDTH")) { define("USER_WIDTH","width:97%"); } +if(! defined("USER_WIDTH")) +{ + define("USER_WIDTH", "width:97%"); +} //==================================================================== // CONFIGURATION OPTIONS MENU //==================================================================== + if($action == "config") { - -// Common to all logs - $text = "
-
- - - - - - - - -
".RL_LAN_044."
- -

"; - $ns->tablerender("
".RL_LAN_064."
", $text); + // User Audit log options (for info) + //======================= + // define('USER_AUDIT_SIGNUP',11); // User signed up + // define('USER_AUDIT_EMAILACK',12); // User responded to registration email + // define('USER_AUDIT_LOGIN',13); // User logged in + // define('USER_AUDIT_LOGOUT',14); // User logged out + // define('USER_AUDIT_NEW_DN',15); // User changed display name + // define('USER_AUDIT_NEW_PW',16); // User changed password + // define('USER_AUDIT_NEW_EML',17); // User changed email + // define('USER_AUDIT_NEW_SET',19); // User changed other settings (intentional gap in numbering) -function gen_log_delete($selectname) -{ - $values = array(90,60,30,21,20,14,10,7,6,5,4,3,2,1); - $ret = "\n"; - return $ret; -} + $audit_checkboxes = array(USER_AUDIT_SIGNUP => RL_LAN_071, USER_AUDIT_EMAILACK => RL_LAN_072, USER_AUDIT_LOGIN => RL_LAN_073, // USER_AUDIT_LOGOUT => RL_LAN_074, // Logout is lumped in with login + USER_AUDIT_NEW_DN => RL_LAN_075, USER_AUDIT_NEW_PW => RL_LAN_076, USER_AUDIT_PW_RES => RL_LAN_078, USER_AUDIT_NEW_EML => RL_LAN_077, USER_AUDIT_NEW_SET => RL_LAN_079, USER_AUDIT_ADD_ADMIN => RL_LAN_080); - -// Admin log options -//================== - $text = " -
- - - - - \n - \n -
".RL_LAN_045." ".gen_log_delete('rolllog_clearadmin').RL_LAN_046." -
- -
\n
"; - - $ns->tablerender("
".RL_LAN_048."
", $text); - - -// User Audit log options (for info) -//======================= -// define('USER_AUDIT_SIGNUP',11); // User signed up -// define('USER_AUDIT_EMAILACK',12); // User responded to registration email -// define('USER_AUDIT_LOGIN',13); // User logged in -// define('USER_AUDIT_LOGOUT',14); // User logged out -// define('USER_AUDIT_NEW_DN',15); // User changed display name -// define('USER_AUDIT_NEW_PW',16); // User changed password -// define('USER_AUDIT_NEW_EML',17); // User changed email -// define('USER_AUDIT_NEW_SET',19); // User changed other settings (intentional gap in numbering) - -$audit_checkboxes = array( - USER_AUDIT_SIGNUP => RL_LAN_071, - USER_AUDIT_EMAILACK => RL_LAN_072, - USER_AUDIT_LOGIN => RL_LAN_073, -// USER_AUDIT_LOGOUT => RL_LAN_074, // Logout is lumped in with login - USER_AUDIT_NEW_DN => RL_LAN_075, - USER_AUDIT_NEW_PW => RL_LAN_076, - USER_AUDIT_PW_RES => RL_LAN_078, - USER_AUDIT_NEW_EML => RL_LAN_077, - USER_AUDIT_NEW_SET => RL_LAN_079, - USER_AUDIT_ADD_ADMIN => RL_LAN_080 -); - - - if (!isset($e_userclass) && !is_object($e_userclass)) + if(! isset($e_userclass) && ! is_object($e_userclass)) { - require_once(e_HANDLER."userclass_class.php"); - $e_userclass = new user_class; + require_once (e_HANDLER."userclass_class.php"); + $e_userclass = new user_class(); } - $user_signup_opts = array_flip(explode(',',varset($pref['user_audit_opts'],''))); - $text = "
+ $user_signup_opts = array_flip(explode(',', varset($pref['user_audit_opts'], ''))); + + // Common to all logs + $text = " +
+ ".RL_LAN_121."
- - - - + + "; + + // Rolling log options + //==================== -// Audit Trail maintenance - $text = " + $text .= " + + + + + + + + + +
".RL_LAN_026.""; +
+ ".RL_LAN_122." + + + + + + + + + + + "; - - $text .= "\n"; - $text .= " - - - - - + + + + + + - - - -
".RL_LAN_044." + +
".RL_LAN_064."
+
".RL_LAN_031.""; - $spacer = ''; - foreach ($audit_checkboxes as $k => $t) + // User Audit Trail Options + $text .= " +
".RL_LAN_123." + +
".RL_LAN_026."
+
".RL_LAN_124." + ".RL_LAN_031." + "; + foreach($audit_checkboxes as $k => $t) { - $text .= $spacer." - ".$t; - $spacer = '
'; + $text .= " +
+ "; } $text .= " -
-
"; - $ns->tablerender("
".RL_LAN_007."
", $text); +
".$frm->admin_button('check_all', 'jstarget:user_audit_opts', 'action', 'Check All').$frm->admin_button('uncheck_all', 'jstarget:user_audit_opts', 'action', 'Uncheck All')."
+
".RL_LAN_008." +
+ +
+
".RL_LAN_009." + +
+
+ +
+
+ + "; + + // Admin log maintenance + //================== + $text .= "
- - - - - \n - \n -
".RL_LAN_066." ".gen_log_delete('rolllog_clearaudit').RL_LAN_046." -
- -
\n
"; +
+ ".RL_LAN_125." + + + + + + + + + + + "; - $ns->tablerender("
".RL_LAN_003."
", $text); + // User log maintenance + //==================== + $text .= " + + + + + +
".RL_LAN_045." + ".gen_log_delete('rolllog_clearadmin').RL_LAN_046." +
".RL_LAN_066." + ".gen_log_delete('rolllog_clearaudit').RL_LAN_046." +
+
+ + + "; -// Rolling log options -//==================== - $text = "
-
- - - - - - - - - - \n - - \n -
".RL_LAN_008." - -
".RL_LAN_009." - -
-
\n
"; - $ns->tablerender("
".RL_LAN_011."
", $text); - + $ns->tablerender(RL_LAN_121, $emessage->render().$text); } - - - //==================================================================== // LOG VIEW MENU //==================================================================== -if (isset($page_title[$action])) +if(isset($page_title[$action])) { -$from = intval(varset($qs[1], 0)); // First entry to display -$amount = max(varset($pref['sys_log_perpage'], 20),5); // Number of entries per page + $from = intval(varset($qs[1], 0)); // First entry to display + $amount = max(varset($pref['sys_log_perpage'], 20), 5); // Number of entries per page -// Array decides which filters are active for each log. There are 4 columns total. All but 'datetimes' occupy 2. Must specify multiple of 4 columns - add 'blank' if necessary -$active_filters = array('adminlog' => array('datetimes'=>0,'ipfilter'=>0,'userfilter'=>0,'eventfilter'=>0,'priority'=>0), - 'auditlog' => array('datetimes'=>0,'ipfilter'=>0,'userfilter'=>0,'eventfilter'=>0,'blank'=>2), - 'rolllog' => array('datetimes'=>0,'ipfilter'=>0,'userfilter'=>0,'eventfilter'=>0,'priority'=>0,'callerfilter'=>0,'blank'=>2), - 'downlog' => array('datetimes'=>0,'ipfilter'=>0,'userfilter'=>0,'downloadidfilter'=>0,'blank'=>2), - 'detailed' => array('datestart'=>0, 'ipfilter'=>0,'userfilter'=>0,'eventfilter'=>0,'blank'=>2), - 'comments' => array('datetimes'=>1, 'ipfilter'=>0,'userfilter'=>0,'eventfilter'=>0,'blank'=>2), - 'online' => array('ipfilter'=>0,'userfilter'=>0) - ); -// Arrays determine column widths, headings, displayed fields for each log -$col_fields = array('adminlog' => array('cf_datestring','dblog_type','dblog_ip','dblog_user_id','user_name','dblog_eventcode','dblog_title','dblog_remarks'), - 'auditlog' => array('cf_datestring','dblog_ip','dblog_user_id','dblog_user_name','dblog_eventcode','dblog_title','dblog_remarks'), - 'rolllog' => array('cf_datestring','dblog_type','dblog_ip','dblog_user_id','dblog_user_name','dblog_eventcode','dblog_caller','dblog_title','dblog_remarks'), - 'downlog' => array('cf_datestring','dblog_ip','dblog_user_id','user_name','download_request_download_id','download_name'), - 'detailed' => array('cf_microtime','cf_microtimediff','source','dblog_type','dblog_ip','dblog_user_id','user_name','dblog_eventcode','dblog_title','dblog_remarks'), - 'comments' => array('cf_datestring', 'comment_id', 'comment_pid', 'comment_item_id', 'comment_subject', 'comment_author_id', 'comment_author_name', 'comment_ip', 'comment_type', 'comment_comment', 'comment_blocked', 'comment_lock', 'del_check'), - 'online' => array('cf_datestring', 'dblog_ip', 'dblog_user_id', 'user_name', 'online_location', 'online_pagecount', 'online_flag', 'online_active') - ); -$col_widths = array('adminlog' => array(18,4,14,7,15,8,14,20), // Date - Pri - IP - UID - User - Code - Event - Info - 'auditlog' => array(18,14,7,15,8,14,24), - 'rolllog' => array(15,4,12,6,12,7,13,13,18), // Date - Pri - IP - UID - User - Code - Caller - Event - Info - 'downlog' => array(18,14,7,15,8,38), - 'detailed' => array(10,8,6,4,14,6,17,7,17,21), - 'comments' => array(14,7,7,7,14,3,10,12,5,17,1,1,1), - 'online' => array(18,15,7,14,32,6,4,4) - ); -$col_titles = array('adminlog' => array(RL_LAN_019,RL_LAN_032,RL_LAN_020,RL_LAN_104,RL_LAN_022,RL_LAN_023,RL_LAN_025,RL_LAN_033), - 'auditlog' => array(RL_LAN_019,RL_LAN_020,RL_LAN_104,RL_LAN_022,RL_LAN_023,RL_LAN_025,RL_LAN_033), - 'rolllog' => array(RL_LAN_019,RL_LAN_032,RL_LAN_020,RL_LAN_104,RL_LAN_022,RL_LAN_023,RL_LAN_024,RL_LAN_025,RL_LAN_033), - 'downlog' => array(RL_LAN_019,RL_LAN_020,RL_LAN_104,RL_LAN_022,RL_LAN_068,RL_LAN_069), - 'detailed' => array(RL_LAN_097,RL_LAN_096,RL_LAN_098,RL_LAN_032,RL_LAN_020,RL_LAN_104,RL_LAN_022,RL_LAN_023,RL_LAN_025,RL_LAN_033), - 'comments' => array(RL_LAN_019, RL_LAN_100, RL_LAN_101, RL_LAN_102, RL_LAN_103, RL_LAN_104, RL_LAN_105, RL_LAN_020, RL_LAN_106, RL_LAN_107, RL_LAN_108, RL_LAN_109, RL_LAN_110), - 'online' => array(RL_LAN_019, RL_LAN_020,RL_LAN_021,RL_LAN_022,RL_LAN_116, RL_LAN_117, RL_LAN_118, RL_LAN_116) - ); + // Array decides which filters are active for each log. There are 4 columns total. All but 'datetimes' occupy 2. Must specify multiple of 4 columns - add 'blank' if necessary + $active_filters = array('adminlog' => array('datetimes' => 0, 'ipfilter' => 0, 'userfilter' => 0, 'eventfilter' => 0, 'priority' => 0), 'auditlog' => array('datetimes' => 0, 'ipfilter' => 0, 'userfilter' => 0, 'eventfilter' => 0, 'blank' => 2), 'rolllog' => array('datetimes' => 0, 'ipfilter' => 0, 'userfilter' => 0, 'eventfilter' => 0, 'priority' => 0, 'callerfilter' => 0, 'blank' => 2), 'downlog' => array('datetimes' => 0, 'ipfilter' => 0, 'userfilter' => 0, 'downloadidfilter' => 0, 'blank' => 2), 'detailed' => array('datestart' => 0, 'ipfilter' => 0, 'userfilter' => 0, 'eventfilter' => 0, 'blank' => 2), 'comments' => array('datetimes' => 1, 'ipfilter' => 0, 'userfilter' => 0, 'eventfilter' => 0, 'blank' => 2), 'online' => array('ipfilter' => 0, 'userfilter' => 0)); -// For DB where the delete option is available, specifies the ID field -$delete_field = array( - 'comments' => 'comment_id' - ); + // Arrays determine column widths, headings, displayed fields for each log + $col_fields = array('adminlog' => array('cf_datestring', 'dblog_type', 'dblog_ip', 'dblog_user_id', 'user_name', 'dblog_eventcode', 'dblog_title', 'dblog_remarks'), 'auditlog' => array('cf_datestring', 'dblog_ip', 'dblog_user_id', 'dblog_user_name', 'dblog_eventcode', 'dblog_title', 'dblog_remarks'), 'rolllog' => array('cf_datestring', 'dblog_type', 'dblog_ip', 'dblog_user_id', 'dblog_user_name', 'dblog_eventcode', 'dblog_caller', 'dblog_title', 'dblog_remarks'), 'downlog' => array('cf_datestring', 'dblog_ip', 'dblog_user_id', 'user_name', 'download_request_download_id', 'download_name'), 'detailed' => array('cf_microtime', 'cf_microtimediff', 'source', 'dblog_type', 'dblog_ip', 'dblog_user_id', 'user_name', 'dblog_eventcode', 'dblog_title', 'dblog_remarks'), 'comments' => array('cf_datestring', 'comment_id', 'comment_pid', 'comment_item_id', 'comment_subject', 'comment_author_id', 'comment_author_name', 'comment_ip', 'comment_type', 'comment_comment', 'comment_blocked', 'comment_lock', 'del_check'), 'online' => array('cf_datestring', 'dblog_ip', 'dblog_user_id', 'user_name', 'online_location', 'online_pagecount', 'online_flag', 'online_active')); + $col_widths = array('adminlog' => array(18, 4, 14, 7, 15, 8, 14, 20), // Date - Pri - IP - UID - User - Code - Event - Info +'auditlog' => array(18, 14, 7, 15, 8, 14, 24), 'rolllog' => array(15, 4, 12, 6, 12, 7, 13, 13, 18), // Date - Pri - IP - UID - User - Code - Caller - Event - Info +'downlog' => array(18, 14, 7, 15, 8, 38), 'detailed' => array(10, 8, 6, 4, 14, 6, 17, 7, 17, 21), 'comments' => array(14, 7, 7, 7, 14, 3, 10, 12, 5, 17, 1, 1, 1), 'online' => array(18, 15, 7, 14, 32, 6, 4, 4)); + $col_titles = array('adminlog' => array(RL_LAN_019, RL_LAN_032, RL_LAN_020, RL_LAN_104, RL_LAN_022, RL_LAN_023, RL_LAN_025, RL_LAN_033), 'auditlog' => array(RL_LAN_019, RL_LAN_020, RL_LAN_104, RL_LAN_022, RL_LAN_023, RL_LAN_025, RL_LAN_033), 'rolllog' => array(RL_LAN_019, RL_LAN_032, RL_LAN_020, RL_LAN_104, RL_LAN_022, RL_LAN_023, RL_LAN_024, RL_LAN_025, RL_LAN_033), 'downlog' => array(RL_LAN_019, RL_LAN_020, RL_LAN_104, RL_LAN_022, RL_LAN_068, RL_LAN_069), 'detailed' => array(RL_LAN_097, RL_LAN_096, RL_LAN_098, RL_LAN_032, RL_LAN_020, RL_LAN_104, RL_LAN_022, RL_LAN_023, RL_LAN_025, RL_LAN_033), 'comments' => array(RL_LAN_019, RL_LAN_100, RL_LAN_101, RL_LAN_102, RL_LAN_103, RL_LAN_104, RL_LAN_105, RL_LAN_020, RL_LAN_106, RL_LAN_107, RL_LAN_108, RL_LAN_109, RL_LAN_110), 'online' => array(RL_LAN_019, RL_LAN_020, RL_LAN_021, RL_LAN_022, RL_LAN_116, RL_LAN_117, RL_LAN_118, RL_LAN_116)); -// Only need to define entries in this array if the base DB query is non-standard (i.e. different field names and/or joins) -$base_query = array( - 'downlog' => "SELECT SQL_CALC_FOUND_ROWS + // For DB where the delete option is available, specifies the ID field + $delete_field = array('comments' => 'comment_id'); + + // Only need to define entries in this array if the base DB query is non-standard (i.e. different field names and/or joins) + $base_query = array('downlog' => "SELECT SQL_CALC_FOUND_ROWS dbl.download_request_id as dblog_id, dbl.download_request_userid as dblog_user_id, dbl.download_request_ip as dblog_ip, dbl.download_request_download_id, dbl.download_request_datestamp as dblog_datestamp, d.download_name, - u.user_name - FROM #download_requests AS dbl - LEFT JOIN #user AS u ON dbl.download_request_userid=u.user_id + u.user_name + FROM #download_requests AS dbl + LEFT JOIN #user AS u ON dbl.download_request_userid=u.user_id LEFT JOIN #download AS d ON dbl.download_request_download_id=d.download_id - ", - 'detailed' => "SELECT SQL_CALC_FOUND_ROWS cl.*, u.* FROM ( + ", 'detailed' => "SELECT SQL_CALC_FOUND_ROWS cl.*, u.* FROM ( SELECT dblog_datestamp + (dblog_microtime/1000000) AS dblog_time, dblog_user_id, dblog_eventcode, dblog_title, dblog_remarks, dblog_type, dblog_ip, 'roll' AS source FROM `#dblog` UNION SELECT dblog_datestamp + (dblog_microtime/1000000) AS dblog_time, dblog_user_id, dblog_eventcode, dblog_title, dblog_remarks, '-' AS dblog_type, dblog_ip, 'audit' AS source FROM `#audit_log` UNION SELECT dblog_datestamp + (dblog_microtime/1000000) AS dblog_time, dblog_user_id, dblog_eventcode, dblog_title, dblog_remarks, dblog_type, dblog_ip, 'admin' AS source FROM `#admin_log`) AS cl - LEFT JOIN `#user` AS u ON cl.dblog_user_id=u.user_id ", - 'comments' => "SELECT SQL_CALC_FOUND_ROWS *, comment_datestamp AS dblog_datestamp FROM `#comments` AS c", - 'online' => "SELECT SQL_CALC_FOUND_ROWS online_timestamp AS dblog_datestamp, - online_ip AS dblog_ip, - SUBSTRING_INDEX(online_user_id,'.',1) AS dblog_user_id, - SUBSTRING(online_user_id FROM LOCATE('.',online_user_id)+1) AS user_name, + LEFT JOIN `#user` AS u ON cl.dblog_user_id=u.user_id ", 'comments' => "SELECT SQL_CALC_FOUND_ROWS *, comment_datestamp AS dblog_datestamp FROM `#comments` AS c", 'online' => "SELECT SQL_CALC_FOUND_ROWS online_timestamp AS dblog_datestamp, + online_ip AS dblog_ip, + SUBSTRING_INDEX(online_user_id,'.',1) AS dblog_user_id, + SUBSTRING(online_user_id FROM LOCATE('.',online_user_id)+1) AS user_name, `online_location`, `online_pagecount`, `online_flag`, `online_active` - FROM `#online`" - ); + FROM `#online`"); -// The filters have to use the 'actual' db field names. So the following table sets the defaults and the exceptions which vary across the range of tables supported -$map_filters = array( - 'default' => array('datetimes' => '`dblog_datestamp`', 'ipfilter' => '`dblog_ip`', 'userfilter' => '`dblog_user_id`', 'eventfilter' => '`dblog_eventcode`'), - 'downlog' => array('datetimes' => '`download_request_datestamp`', 'ipfilter' => '`download_request_ip`', 'userfilter' => '`download_request_userid`'), - 'detailed' => array('datestart' => '`dblog_time`'), - 'comments' => array('datetimes' => '`comment_datestamp`', 'ipfilter' => '`comment_ip`', 'eventfilter' => 'comment_type', 'userfilter' => '`comment_author_id`'), - 'online' => array('online_ip' => '`dblog_ip`', 'online_user_id' => '`dblog_user_id`') - ); + // The filters have to use the 'actual' db field names. So the following table sets the defaults and the exceptions which vary across the range of tables supported + $map_filters = array('default' => array('datetimes' => '`dblog_datestamp`', 'ipfilter' => '`dblog_ip`', 'userfilter' => '`dblog_user_id`', 'eventfilter' => '`dblog_eventcode`'), 'downlog' => array('datetimes' => '`download_request_datestamp`', 'ipfilter' => '`download_request_ip`', 'userfilter' => '`download_request_userid`'), 'detailed' => array('datestart' => '`dblog_time`'), 'comments' => array('datetimes' => '`comment_datestamp`', 'ipfilter' => '`comment_ip`', 'eventfilter' => 'comment_type', 'userfilter' => '`comment_author_id`'), 'online' => array('online_ip' => '`dblog_ip`', 'online_user_id' => '`dblog_user_id`')); -// Field to sort table on -$sort_fields = array( - 'default' => 'dblog_id', - 'detailed' => 'dblog_time', - 'comments' => 'comment_datestamp', - 'online' => 'online_timestamp' - ); + // Field to sort table on + $sort_fields = array('default' => 'dblog_id', 'detailed' => 'dblog_time', 'comments' => 'comment_datestamp', 'online' => 'online_timestamp'); - - -// Check things - if ($start_time >= $end_time) - { // Make end time beginning of tomorrow - $tempdate = getdate(); - $end_time = mktime(0,0,0,$tempdate['mon'],$tempdate['mday']+1,$tempdate['year']); // Seems odd, but mktime will work this out OK - // (or so the manual says) - } - - - -// Now work out the query - only use those filters which are displayed - $qry = ''; - $and_array = array(); - foreach ($active_filters[$action] as $fname=>$fpars) - { - $filter_field = varset($map_filters[$action][$fname],$map_filters['default'][$fname]); - switch ($fname) - { - case 'datetimes' : - if ($start_enabled && ($start_time > 0)) $and_array[] = "{$filter_field} >= ".intval($start_time); - if ($end_enabled && ($end_time > 0)) $and_array[] = "{$filter_field} <= ".intval($end_time); - break; - case 'datestart' : - if ($start_time == 0) - { - $end_time = time(); - $start_time = $end_time - 300; // Default to last 5 mins - } - $and_array[] = "{$filter_field} >= ".intval($start_time); - $and_array[] = "{$filter_field} <= ".intval($end_time); - break; - case 'ipfilter' : - if ($ipaddress_filter != "") - { - if (substr($ipaddress_filter,-1) == '*') - { // Wildcard to handle - mySQL uses % - $and_array[] = "{$filter_field} LIKE '".substr($ipaddress_filter,0,-1)."%' "; - } - else - { - $and_array[] = "{$filter_field}= '".$ipaddress_filter."' "; - } - } - break; - case 'userfilter' : - if ($user_filter != '') $and_array[] = "{$filter_field} = ".intval($user_filter); - break; - case 'eventfilter' : - if ($event_filter != '') - { - if (substr($event_filter,-1) == '*') - { // Wildcard to handle - mySQL uses % - $and_array[] = " {$filter_field} LIKE '".substr($event_filter,0,-1)."%' "; - } - else - { - $and_array[] = "{$filter_field}= '".$event_filter."' "; - } - } - break; - case 'callerfilter' : - if ($caller_filter != '') - { - if (substr($caller_filter,-1) == '*') - { // Wildcard to handle - mySQL uses % - $and_array[] = "dblog_caller LIKE '".substr($caller_filter,0,-1)."%' "; - } - else - { - $and_array[] = "dblog_caller= '".$caller_filter."' "; - } - } - break; - case 'priority' : - if (($pri_filter_val != "") && ($pri_filter_cond != "") && ($pri_filter_cond != "xx")) - { - switch ($pri_filter_cond) - { - case "lt" : - $and_array[] = "dblog_type <= '{$pri_filter_val}' "; - break; - case "eq" : - $and_array[] = "dblog_type = '{$pri_filter_val}' "; - break; - case "gt" : - $and_array[] = "dblog_type >= '{$pri_filter_val}' "; - break; - } - } - break; - case 'downloadidfilter' : - if ($downloadid_filter != '') $and_array[] = "download_request_download_id = ".intval($downloadid_filter); - break; - } + // Check things + if($start_time >= $end_time) + { // Make end time beginning of tomorrow + $tempdate = getdate(); + $end_time = mktime(0, 0, 0, $tempdate['mon'], $tempdate['mday'] + 1, $tempdate['year']); // Seems odd, but mktime will work this out OK + // (or so the manual says) } + // Now work out the query - only use those filters which are displayed + $qry = ''; + $and_array = array(); + foreach($active_filters[$action] as $fname => $fpars) + { + $filter_field = varset($map_filters[$action][$fname], $map_filters['default'][$fname]); + switch($fname) + { + case 'datetimes': + if($start_enabled && ($start_time > 0)) + $and_array[] = "{$filter_field} >= ".intval($start_time); + if($end_enabled && ($end_time > 0)) + $and_array[] = "{$filter_field} <= ".intval($end_time); + break; + case 'datestart': + if($start_time == 0) + { + $end_time = time(); + $start_time = $end_time - 300; // Default to last 5 mins + } + $and_array[] = "{$filter_field} >= ".intval($start_time); + $and_array[] = "{$filter_field} <= ".intval($end_time); + break; + case 'ipfilter': + if($ipaddress_filter != "") + { + if(substr($ipaddress_filter, - 1) == '*') + { // Wildcard to handle - mySQL uses % + $and_array[] = "{$filter_field} LIKE '".substr($ipaddress_filter, 0, - 1)."%' "; + } + else + { + $and_array[] = "{$filter_field}= '".$ipaddress_filter."' "; + } + } + break; + case 'userfilter': + if($user_filter != '') + $and_array[] = "{$filter_field} = ".intval($user_filter); + break; + case 'eventfilter': + if($event_filter != '') + { + if(substr($event_filter, - 1) == '*') + { // Wildcard to handle - mySQL uses % + $and_array[] = " {$filter_field} LIKE '".substr($event_filter, 0, - 1)."%' "; + } + else + { + $and_array[] = "{$filter_field}= '".$event_filter."' "; + } + } + break; + case 'callerfilter': + if($caller_filter != '') + { + if(substr($caller_filter, - 1) == '*') + { // Wildcard to handle - mySQL uses % + $and_array[] = "dblog_caller LIKE '".substr($caller_filter, 0, - 1)."%' "; + } + else + { + $and_array[] = "dblog_caller= '".$caller_filter."' "; + } + } + break; + case 'priority': + if(($pri_filter_val != "") && ($pri_filter_cond != "") && ($pri_filter_cond != "xx")) + { + switch($pri_filter_cond) + { + case "lt": + $and_array[] = "dblog_type <= '{$pri_filter_val}' "; + break; + case "eq": + $and_array[] = "dblog_type = '{$pri_filter_val}' "; + break; + case "gt": + $and_array[] = "dblog_type >= '{$pri_filter_val}' "; + break; + } + } + break; + case 'downloadidfilter': + if($downloadid_filter != '') + $and_array[] = "download_request_download_id = ".intval($downloadid_filter); + break; + } + } - if (count($and_array)) $qry = " WHERE ".implode(' AND ',$and_array); - + if(count($and_array)) + $qry = " WHERE ".implode(' AND ', $and_array); $limit_clause = " LIMIT {$from}, {$amount} "; - $sort_field = varset($sort_fields[$action],$sort_fields['default']); + $sort_field = varset($sort_fields[$action], $sort_fields['default']); - if (isset($base_query[$action])) + if(isset($base_query[$action])) { - $qry = $base_query[$action].$qry." ORDER BY {$sort_field} ".$sort_order; + $qry = $base_query[$action].$qry." ORDER BY {$sort_field} ".$sort_order; } else { - $qry = "SELECT SQL_CALC_FOUND_ROWS dbl.*,u.user_name FROM #".$log_db_table[$action]." AS dbl LEFT JOIN #user AS u ON dbl.dblog_user_id=u.user_id".$qry." ORDER BY {$sort_field} ".$sort_order; + $qry = "SELECT SQL_CALC_FOUND_ROWS dbl.*,u.user_name FROM #".$log_db_table[$action]." AS dbl LEFT JOIN #user AS u ON dbl.dblog_user_id=u.user_id".$qry." ORDER BY {$sort_field} ".$sort_order; } $num_entry = 0; - if ($sql->db_Select_gen($qry.$limit_clause)) + if($sql->db_Select_gen($qry.$limit_clause)) { - $num_entry = $sql->total_results; + $num_entry = $sql->total_results; } - if ($from > $num_entry) + if($from > $num_entry) { - $from = 0; // We may be on a later page - $limit_clause = " LIMIT {$from}, {$amount} "; - $sql->db_Select_gen($qry.$limit_clause); // Re-run query with new value of $from - $num_entry = $sql->total_results; + $from = 0; // We may be on a later page + $limit_clause = " LIMIT {$from}, {$amount} "; + $sql->db_Select_gen($qry.$limit_clause); // Re-run query with new value of $from + $num_entry = $sql->total_results; } -// Start by putting up the filter boxes - $text = "
-
- - - - - - - - "; + // Start by putting up the filter boxes + $text = " + +
+ ".RL_LAN_012." +
".RL_LAN_012."
+ + + + + + + "; $filter_cols = 0; - foreach ($active_filters[$action] as $fname=>$fpars) + foreach($active_filters[$action] as $fname => $fpars) { - if ($filter_cols == 0) $text .= ''; - switch ($fname) - { - case 'datetimes' : - $text .= " - - "; - $filter_cols = 4; - break; - case 'datestart' : - $text .= " - - - "; - $filter_cols = 4; - break; - case 'priority' : - $text .= " - "; - $filter_cols += 2; - break; - case 'ipfilter' : - $text .= " - "; - $filter_cols += 2; - break; - case 'userfilter' : - $text .= " - "; - $filter_cols += 2; - break; - case 'eventfilter' : - $text .= " - "; - $filter_cols += 2; - break; - case 'callerfilter' : - $text .= " - "; - $filter_cols += 2; - break; - case 'downloadidfilter' : - $text .= " - "; - $filter_cols += 2; - break; - case 'blank' : // Any number of blank cells - $text .= Str_repeat("",$fpars); - $filter_cols += $fpars; - break; - } - if ($filter_cols >= 4) { $text .= ''; $filter_cols = 0; } + if($filter_cols == 0) + $text .= ''; + switch($fname) + { + case 'datetimes': + $text .= " + + + + + "; + $filter_cols = 4; + break; + case 'datestart': + $text .= " + + + + "; + $filter_cols = 4; + break; + case 'priority': + $text .= " + + + "; + $filter_cols += 2; + break; + case 'ipfilter': + $text .= " + + + "; + $filter_cols += 2; + break; + case 'userfilter': + $text .= " + + + "; + $filter_cols += 2; + break; + case 'eventfilter': + $text .= " + + + "; + $filter_cols += 2; + break; + case 'callerfilter': + $text .= " + + + "; + $filter_cols += 2; + break; + case 'downloadidfilter': + $text .= " + + "; + $filter_cols += 2; + break; + case 'blank': // Any number of blank cells + $text .= str_repeat("", $fpars); + $filter_cols += $fpars; + break; + } + if($filter_cols >= 4) + { + $text .= ''; + $filter_cols = 0; + } } -// $text .= ""; + // $text .= ""; $text .= " - - - -
 ".RL_LAN_013."".time_box("starttime",$start_time,$back_day_count[$action],FALSE)." ".RL_LAN_014."".time_box("endtime",$end_time,$back_day_count[$action],TRUE). - "".RL_LAN_013."".time_box("starttime",$start_time,$back_day_count[$action],FALSE,TRUE)."".RL_LAN_092."\n".RL_LAN_093."".RL_LAN_058." -   - ".RL_LAN_060."
".RL_LAN_061."
".RL_LAN_015."
".RL_LAN_016."
".RL_LAN_029."
".RL_LAN_061."
".RL_LAN_059."
".RL_LAN_061."
".RL_LAN_090." 
+ + + ".time_box("starttime", $start_time, $back_day_count[$action], FALSE)." + + + ".time_box("endtime", $end_time, $back_day_count[$action], TRUE)." + ".RL_LAN_013."".time_box("starttime", $start_time, $back_day_count[$action], FALSE, TRUE)."".RL_LAN_092." + ".RL_LAN_093." + ".RL_LAN_058." + + + ".RL_LAN_060." + +
".RL_LAN_061."
+
".RL_LAN_015." + +
".RL_LAN_016."
+
".RL_LAN_029." + +
".RL_LAN_061."
+
".RL_LAN_059." + +
".RL_LAN_061."
+
".RL_LAN_090." + +  
Query = ".$qry.$limit_clause."
{$_COOKIE[$rl_cookiename]}
Query = ".$qry.$limit_clause."
{$_COOKIE[$rl_cookiename]}
-
-

"; + +
+ + +
+ + + "; - - - -// Next bit is the actual log display - the arrays define column widths, titles, fields etc for each log + // Next bit is the actual log display - the arrays define column widths, titles, fields etc for each log $column_count = count($col_widths[$action]); - $text .= "
-
- - "; + $text .= " + +
+ {$page_title[$action]} +
+ + "; + foreach($col_widths[$action] as $i) { - $text .= "\n"; + $text .= " + + "; } - $text .= "\n"; - if ($num_entry == 0) + $text .= " + + + "; + + if($num_entry == 0) { - $text .= ""; + $text .= " + + + + "; } else - {// Start with header - $text .= ''; - foreach ($col_titles[$action] as $ct) - { - $text .= " "; - } - $text .= "\n"; - - -// Routine to handle the simple bbcode-like codes for log body text -function log_process($matches) -{ - switch ($matches[1]) - { - case 'br' : - return '
'; - case 'link' : - $temp = substr($matches[2],1); - return "{$temp}"; - case 'test' : - return '----TEST----'; - default : - return $matches[0]; // No change - } -} -// Now put up the events - $delete_button = FALSE; - while ($row = $sql->db_Fetch()) - { - $text .= ''; - foreach ($col_fields[$action] as $cf) + { // Start with header + $text .= ' + + + '; + $count = 1; + foreach($col_titles[$action] as $ct) { - switch ($cf) - { - case 'cf_datestring' : - $val = date(AL_DATE_TIME_FORMAT,$row['dblog_datestamp']); - break; - case 'cf_microtime' : - $val = date("H:i:s",intval($row['dblog_time']) % 86400).'.'.str_pad(100000*round($row['dblog_time']-floor($row['dblog_time']),6),6,'0'); - break; - case 'cf_microtimediff' : - $val = ' '; - if ($last_noted_time > 0) + count($col_titles[$action]); + $text .= " + {$ct} + "; + $count ++; + } + $text .= " + + + + "; + + // Routine to handle the simple bbcode-like codes for log body text + function log_process($matches) + { + switch($matches[1]) { - $val = number_format($last_noted_time - $row['dblog_time'],6,'.',''); + case 'br': + return '
'; + case 'link': + $temp = substr($matches[2], 1); + return "{$temp}"; + case 'test': + return '----TEST----'; + default: + return $matches[0]; // No change } - $last_noted_time = $row['dblog_time']; - break; - case 'cf_eventcode' : - $val = 'ADMIN'.$row['dblog_eventcode']; - break; - case 'dblog_title' : // Look up constants to give multi-language viewing - $val = trim($row['dblog_title']); - if (defined($val)) $val = constant($val); - break; - case 'dblog_user_name' : - $val = $row['dblog_user_id'] ? $row['dblog_user_name'] : LAN_ANONYMOUS; - break; - case 'user_name' : - $val = $row['dblog_user_id'] ? $row['user_name'] : LAN_ANONYMOUS; - break; - case 'dblog_caller' : - $val = $row['dblog_caller']; - if ((strpos($val,'|') !== FALSE) && (strpos($val,'@') !== FALSE)) + } + // Now put up the events + $delete_button = FALSE; + while($row = $sql->db_Fetch()) + { + $text .= ''; + foreach($col_fields[$action] as $cf) { - list($file,$rest) = explode('|',$val); - list($routine,$rest) = explode('@',$rest); - $val = $file.'
Function: '.$routine.'
Line: '.$rest; - } - break; - case 'dblog_remarks' : - // Look for pseudo-code for newlines, link insertion - $val = preg_replace_callback("#\[!(\w+?)(=.+?){0,1}!]#",'log_process',$row['dblog_remarks']); - break; - case 'dblog_ip' : - $val = $e107->ipDecode($row['dblog_ip']); - break; - case 'comment_ip' : - $val = $e107->ipDecode($row['comment_ip']); -/* if (strlen($val) == 8) // New decoder should handle this automatically + switch($cf) + { + case 'cf_datestring': + $val = date(AL_DATE_TIME_FORMAT, $row['dblog_datestamp']); + break; + case 'cf_microtime': + $val = date("H:i:s", intval($row['dblog_time']) % 86400).'.'.str_pad(100000 * round($row['dblog_time'] - floor($row['dblog_time']), 6), 6, '0'); + break; + case 'cf_microtimediff': + $val = ' '; + if($last_noted_time > 0) + { + $val = number_format($last_noted_time - $row['dblog_time'], 6, '.', ''); + } + $last_noted_time = $row['dblog_time']; + break; + case 'cf_eventcode': + $val = 'ADMIN'.$row['dblog_eventcode']; + break; + case 'dblog_title': // Look up constants to give multi-language viewing + $val = trim($row['dblog_title']); + if(defined($val)) + $val = constant($val); + break; + case 'dblog_user_name': + $val = $row['dblog_user_id'] ? $row['dblog_user_name'] : LAN_ANONYMOUS; + break; + case 'user_name': + $val = $row['dblog_user_id'] ? $row['user_name'] : LAN_ANONYMOUS; + break; + case 'dblog_caller': + $val = $row['dblog_caller']; + if((strpos($val, '|') !== FALSE) && (strpos($val, '@') !== FALSE)) + { + list($file, $rest) = explode('|', $val); + list($routine, $rest) = explode('@', $rest); + $val = $file.'
Function: '.$routine.'
Line: '.$rest; + } + break; + case 'dblog_remarks': + // Look for pseudo-code for newlines, link insertion + $val = preg_replace_callback("#\[!(\w+?)(=.+?){0,1}!]#", 'log_process', $row['dblog_remarks']); + break; + case 'dblog_ip': + $val = $e107->ipDecode($row['dblog_ip']); + break; + case 'comment_ip': + $val = $e107->ipDecode($row['comment_ip']); + /* if (strlen($val) == 8) // New decoder should handle this automatically { $hexip = explode('.', chunk_split($val, 2, '.')); - $val = hexdec($hexip[0]). '.' . hexdec($hexip[1]) . '.' . hexdec($hexip[2]) . '.' . hexdec($hexip[3]); + $val = hexdec($hexip[0]). '.'.hexdec($hexip[1]).'.'.hexdec($hexip[2]).'.'.hexdec($hexip[3]); } */ - break; - case 'comment_comment' : - $val =$tp->text_truncate($row['comment_comment'],100,'...'); // Just display first bit of comment - break; - case 'online_location' : - $val = str_replace($e107->base_path,'',$row['online_location']); // Just display site-specific bit of path - break; - case 'del_check' : // Put up a 'delete' checkbox - $val = ""; - $delete_button = TRUE; - break; - default : - $val = $row[$cf]; - } - $text .= ""; + break; + case 'comment_comment': + $val = $tp->text_truncate($row['comment_comment'], 100, '...'); // Just display first bit of comment + break; + case 'online_location': + $val = str_replace($e107->base_path, '', $row['online_location']); // Just display site-specific bit of path + break; + case 'del_check': // Put up a 'delete' checkbox + $val = ""; + $delete_button = TRUE; + break; + default: + $val = $row[$cf]; + } + $text .= ""; + } + $text .= ""; } - $text .= "\n"; - } } $text .= " - -
".RL_LAN_017."
".RL_LAN_017."
{$ct}
{$val}{$val}
- "; - if ($delete_button) $text .= "     "; - $text .= "
-
-
"; - - -// Next-Previous. ========================== - - if ($num_entry > $amount) + + +
+ + "; + if($delete_button) { - $parms = "{$num_entry},{$amount},{$from},".e_SELF."?".$action.".[FROM]"; - $text .= "
".$tp->parseTemplate("{NEXTPREV={$parms}}"); + $text .= " + + "; + } + $text .= " +
+ + + "; + + // Next-Previous. ========================== + + $text .= sprintf(RL_LAN_126, $num_entry); + if($num_entry > $amount) + { + $parms = "{$num_entry},{$amount},{$from},".e_SELF."?".$action.".[FROM]"; + $text .= "
".$tp->parseTemplate("{NEXTPREV={$parms}}")."
"; } - $text .= "   Total {$num_entry} entries matching search condition"; - $ns->tablerender("
{$page_title[$action]}
", $text); + $ns->tablerender("{$page_title[$action]}", $emessage->render().$text); } - function admin_log_adminmenu() { - if (e_QUERY) { - $tmp = explode(".", e_QUERY); - $action = $tmp[0]; - } - if ($action == "") { - $action = "adminlog"; - } - $var['adminlog']['text'] = RL_LAN_030; - $var['adminlog']['link'] = "admin_log.php?adminlog"; - - $var['auditlog']['text'] = RL_LAN_062; - $var['auditlog']['link'] = "admin_log.php?auditlog"; - - $var['rolllog']['text'] = RL_LAN_002; - $var['rolllog']['link'] = "admin_log.php?rolllog"; - - $var['downlog']['text'] = RL_LAN_067; - $var['downlog']['link'] = "admin_log.php?downlog"; - - $var['detailed']['text'] = RL_LAN_091; - $var['detailed']['link'] = "admin_log.php?detailed"; - - $var['comments']['text'] = 'Comments'; - $var['comments']['link'] = "admin_log.php?comments"; - - $var['config']['text'] = RL_LAN_027; - $var['config']['link'] ="admin_log.php?config"; + if(e_QUERY) + { + $tmp = explode(".", e_QUERY); + $action = $tmp[0]; + } + if($action == "") + { + $action = "adminlog"; + } + $var['adminlog']['text'] = RL_LAN_030; + $var['adminlog']['link'] = "admin_log.php?adminlog"; - if ($action == 'comments') - { - $var['users']['text'] = RL_LAN_115; - $var['users']['link'] ="users.php"; - } - - show_admin_menu(RL_LAN_005, $action, $var); + $var['auditlog']['text'] = RL_LAN_062; + $var['auditlog']['link'] = "admin_log.php?auditlog"; + + $var['rolllog']['text'] = RL_LAN_002; + $var['rolllog']['link'] = "admin_log.php?rolllog"; + + $var['downlog']['text'] = RL_LAN_067; + $var['downlog']['link'] = "admin_log.php?downlog"; + + $var['detailed']['text'] = RL_LAN_091; + $var['detailed']['link'] = "admin_log.php?detailed"; + + $var['comments']['text'] = 'Comments'; + $var['comments']['link'] = "admin_log.php?comments"; + + $var['config']['text'] = RL_LAN_027; + $var['config']['link'] = "admin_log.php?config"; + + /* XXX - why?! + if($action == 'comments') + { + $var['users']['text'] = RL_LAN_115; + $var['users']['link'] = "users.php"; + } + */ + show_admin_menu(RL_LAN_005, $action, $var); } +require_once (e_ADMIN."footer.php"); -require_once(e_ADMIN."footer.php"); +function gen_log_delete($selectname) +{ + $values = array(90, 60, 30, 21, 20, 14, 10, 7, 6, 5, 4, 3, 2, 1); + $ret = ""; + return $ret; +} + +/** + * Handle page DOM within the page header + * + * @return string JS source + */ +function headerjs() +{ + require_once(e_HANDLER.'js_helper.php'); + $ret = " + + + "; + + return $ret; +} ?> \ No newline at end of file diff --git a/e107_files/jslib/core/admin.js b/e107_files/jslib/core/admin.js index a81567ece..51908e785 100644 --- a/e107_files/jslib/core/admin.js +++ b/e107_files/jslib/core/admin.js @@ -8,8 +8,8 @@ * e107 Admin Helper * * $Source: /cvs_backup/e107_0.8/e107_files/jslib/core/admin.js,v $ - * $Revision: 1.4 $ - * $Date: 2008-12-15 17:03:25 $ + * $Revision: 1.5 $ + * $Date: 2008-12-16 14:22:01 $ * $Author: secretr $ * */ @@ -33,7 +33,8 @@ e107Admin.Helper = { $$('.autocheck').invoke('observe', 'click', this.toggleCheckedHandler); $$('button.action[name=check_all]').invoke('observe', 'click', this.allCheckedEventHandler); $$('button.action[name=uncheck_all]').invoke('observe', 'click', this.allUncheckedEventHandler); - $$('button.delete', 'input.delete[type=image]').invoke('observe', 'click', function(e) { + $$('button.delete', 'input.delete[type=image]', 'a.delete').invoke('observe', 'click', function(e) { + if(e.element().hasClassName('no-confirm') || (e.element().readAttribute('rel') && e.element().readAttribute('rel').toLowerCase == 'no-confirm')) return; var msg = e.element().readAttribute('title') || e107.getModLan('delete_confirm'); if( !e107Helper.confirm(msg) ) e.stop(); }); @@ -84,53 +85,71 @@ e107Admin.Helper = { /** * Event listener - * Check all checkboxes in the current form, having - * name attribute value starting with 'multiaction' - * This method is auto-attached to every button having name=check_all - * if init() method is executed + * Check all checkboxes in the current form, having name attribute value starting with 'multiaction' + * by default or any value set by button's value(special command 'jstarget:') + * This method is auto-attached to every button having name=check_all if init() method is executed * * Examples of valid inputbox markup: * * OR * + * OR + * (see the button example below) + * OR + * (see the button example below) * * Example of button being auto-observed (see e107Admin.Helper#init) - * + * // default selector - multiaction + * OR + * // checkboxes names starting with - some_checkbox_arary * - * Demo: e107_admin/image.php + * Demo: e107_admin/image.php, admin_log.php * */ allChecked: function(event) { event.stop(); - var form = event.element().up('form'); + var form = event.element().up('form'), selector = 'multiaction'; + if(event.element().readAttribute('value').startsWith('jstarget:')) { + selector = event.element().readAttribute('value').replace(/jstarget:/, '').strip(); + } + if(form) { - form.toggleChecked(true, 'name^=multiaction'); + form.toggleChecked(true, 'name^=' + selector); } }, /** * Event listener - * Uncheck all checkboxes in the current form, having - * name attribute value starting with 'multiaction' - * This method is auto-attached to every button having name=uncheck_all - * if init() method is executed + * Uncheck all checkboxes in the current form, having name attribute value starting with 'multiaction' + * by default or any value set by button's value(special command 'jstarget:') + * This method is auto-attached to every button having name=uncheck_all if init() method is executed * * Examples of valid inputbox markup: * * OR * + * OR + * (see the button example below) + * OR + * (see the button example below) * * Example of button being auto-observed (see e107Admin.Helper#init) - * + * // default selector - multiaction + * OR + * // checkboxes names starting with - some_checkbox_arary * - * Demo: e107_admin/image.php + * Demo: e107_admin/image.php, admin_log.php * */ allUnchecked: function(event) { event.stop(); - var form = event.element().up('form'); + var form = event.element().up('form'), selector = 'multiaction'; + if(event.element().readAttribute('value').startsWith('jstarget:')) { + selector = event.element().readAttribute('value').replace(/jstarget:/, '').strip(); + } + if(form) { - form.toggleChecked(false, 'name^=multiaction'); + form.toggleChecked(false, 'name^=' + selector); } } } diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index a66768edd..80ade466f 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -9,8 +9,8 @@ * Form Handler * * $Source: /cvs_backup/e107_0.8/e107_handlers/form_handler.php,v $ - * $Revision: 1.7 $ - * $Date: 2008-12-15 21:16:32 $ + * $Revision: 1.8 $ + * $Date: 2008-12-16 14:22:01 $ * $Author: secretr $ * */ @@ -38,16 +38,16 @@ if (!defined('e107_INIT')) { exit; } * * - size => (int) size attribute value (used when needed) * default: 40 - * + * * - title (string) title attribute * default: empty string (omitted) * * - readonly => (bool) readonly attribute * default: false - * + * * - selected => (bool) selected attribute (used when needed) * default: false - * + * * checked => (bool) checked attribute (used when needed) * default: false * - disabled => (bool) disabled attribute @@ -77,12 +77,12 @@ class e_form return "get_attributes($options, $name, $value)." />"; } - function file($name, $options = array()) + function file($name, $options = array()) { $options = $this->format_options('text', $name, $options); return "get_attributes($options, $name, $value)." />"; } - + function password($name, $maxlength = 50, $options = array()) { @@ -95,41 +95,41 @@ class e_form $options = $this->format_options('textarea', $name, $options); return ""; } - - function checkbox($name, $value, $checked = false, $options = array()) + + function checkbox($name, $value, $checked = false, $options = array()) { $options['checked'] = $checked; //comes as separate argument just for convenience $options = $this->format_options('checkbox', $name, $options); return "get_attributes($options, $name, $value)." />"; } - - function radio($name, $value, $checked = false, $options = array()) + + function radio($name, $value, $checked = false, $options = array()) { $options['checked'] = $checked; //comes as separate argument just for convenience $options = $this->format_options('radio', $name, $options); return "get_attributes($options, $name, $value)." />"; } - - function label($text, $name = '', $value = '') + + function label($text, $name = '', $value = '') { $for_id = $this->_format_id('', $name, $value, 'for'); return "{$text}"; } - function select_open($name, $options = array()) + function select_open($name, $options = array()) { $options = $this->format_options('select', $name, $options); return ""; } - function hidden($name, $value, $options = array()) + function hidden($name, $value, $options = array()) { $options = $this->format_options('hidden', $name, $options); return "get_attributes($options, $name, $value)." />"; } - - function submit($name, $value, $options = array()) + + function submit($name, $value, $options = array()) { $options = $this->format_options('submit', $name, $options); return "get_attributes($options, $name, $value)." />"; } - - function submit_image($name, $value, $image, $options = array()) + + function submit_image($name, $value, $image, $options = array()) { $options = $this->format_options('submit', $name, $options); return "get_attributes($options, $name, $value)." />"; } - + function admin_button($name, $value, $action = 'submit', $label = '', $options = array()) { $options['class'] = $action; //additional classes in options not allowed @@ -172,14 +172,12 @@ class e_form if($action == 'action') $btype = 'button'; $options = $this->format_options('admin_button', $name, $options); if(empty($label)) $label = $value; - + return " - + "; } - + function get_attributes($options, $name = '', $value = '') { $ret = ''; @@ -199,7 +197,7 @@ class e_form case 'size': if($optval) $ret .= " size='{$optval}'"; break; - + case 'title': if($optval) $ret .= " title='{$optval}'"; break; @@ -217,7 +215,7 @@ class e_form case 'selected': if($optval) $ret .= " selected='selected'"; break; - + case 'checked': if($optval) $ret .= " checked='checked'"; break; @@ -249,7 +247,7 @@ class e_form //format the name first $name = str_replace(array('[]', '[', ']', '_'), array('', '-', '', '-'), $name); - + if(empty($id_value) ) return " {$return_attribute}='{$name}".($value ? "-{$value}" : '')."'";// also useful when name is e.g. name='my_name[some_id]' elseif(is_numeric($id_value) && $name) return " {$return_attribute}='{$name}-{$id_value}'";// also useful when name is e.g. name='my_name[]' else return " {$return_attribute}='{$id_value}'"; diff --git a/e107_languages/English/admin/lan_admin_log.php b/e107_languages/English/admin/lan_admin_log.php index 5c766b337..2ec5628e5 100644 --- a/e107_languages/English/admin/lan_admin_log.php +++ b/e107_languages/English/admin/lan_admin_log.php @@ -1,7 +1,7 @@ %d entries matching search condition'); +define('RL_LAN_JS_CONFIRM', 'Are you sure?'); ?> \ No newline at end of file diff --git a/e107_themes/_blank/admin_style.css b/e107_themes/_blank/admin_style.css index d4c44f5d1..794bd3541 100644 --- a/e107_themes/_blank/admin_style.css +++ b/e107_themes/_blank/admin_style.css @@ -89,6 +89,9 @@ ul,ol { list-style:none; } .adminlist { width:100%; border:1px solid #ddd;} .adminlist th { padding: 5px; border-bottom:1px solid #ddd; border-right: 1px solid #ddd; font-weight: bold; white-space:nowrap; } .adminlist td { padding: 5px; border-bottom:1px solid #ddd; border-right: 1px solid #ddd; } + +.adminlist td div.field-spacer { clear: both; margin-bottom: 3px; } /* multi-fields per row separator */ + .adminlist th.last, .adminlist td.last { border-right: 0px solid;} .adminlist tr.last td{ border-bottom: 0px solid;} @@ -113,7 +116,7 @@ select, .tbox, .helpbox { } option { padding-right: 10px;} input.input-text, textarea, .tbox, .helpbox { padding:2px; } -select.tbox { min-height:17px; padding: 0px; /* to set the height for empty selects */ } +select.tbox { min-height:17px; padding: 0px; /* setting the height of empty selects */ } .select.order { width: 40px !important; } .select.time-offset { width: 60px !important; } input.radio { margin-right: 3px; } @@ -129,6 +132,7 @@ label { cursor: pointer; } .adminform { width:100%; border:1px solid #ddd;} .adminform td { padding: 5px; text-align: left} +.adminform td div.field-spacer { clear: both; margin-bottom: 3px; } /* multi-fields per row separator */ .adminform .select { width: 280px;} .adminform .input-text { width: 274px;} @@ -143,6 +147,7 @@ label { cursor: pointer; } /* form used for content edit */ .adminedit { width:100%; border:1px solid #ddd;} .adminedit td { padding: 5px; text-align: left} +.adminedit td div.field-spacer { clear: both; margin-bottom: 3px; } /* multi-fields per row separator */ .adminedit .select { width: 280px; } .adminedit .input-text { width: 274px;} @@ -298,6 +303,7 @@ input.action.edit {} /********** Misc */ .e-pointer { cursor: pointer; } /* Pointer Hand */ .expand-container { padding: 10px; } /* Block with expandable items */ +.nextprev-bar { clear: both; padding: 5px; font-size: 14px; margin: 5px; border:1px solid #ddd; } /* Page NextPrev nabigation block */ /*******************************************************************************************************************/ @@ -309,7 +315,7 @@ input.action.edit {} .admin-header-content { border: 1px solid #DDDDDD; } .admin-page-body { padding: 20px 15px 0; } .admin-footer {} -legend { font-size: 16px; font-weight: bold; padding: 5px; } +legend { font-size: 14px; font-weight: bold; padding: 5px; } /******** Layout */ .main-table { width: 100%; border: 0 none; }