From 7208ea330483d42b0fc722bfdda2c3cbf0c52369 Mon Sep 17 00:00:00 2001 From: e107steved Date: Sat, 17 May 2008 15:00:41 +0000 Subject: [PATCH] Comment viewing/delete with by-user option --- e107_admin/admin_log.php | 292 ++++++++++++++---- .../English/admin/help/admin_log.php | 12 +- .../English/admin/lan_admin_log.php | 32 +- .../English/admin/lan_log_messages.php | 11 +- 4 files changed, 274 insertions(+), 73 deletions(-) diff --git a/e107_admin/admin_log.php b/e107_admin/admin_log.php index 6291d9d9c..d8935ce6a 100644 --- a/e107_admin/admin_log.php +++ b/e107_admin/admin_log.php @@ -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.12 $ -| $Date: 2008-01-11 21:53:33 $ +| $Revision: 1.13 $ +| $Date: 2008-05-17 15:00:32 $ | $Author: e107steved $ | | Preferences: @@ -71,6 +71,29 @@ include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_log_messages.php'); +// Delete comments if appropriate +if (isset($_POST['deleteitems']) && ($action == 'comments')) +{ + $c_list = array(); + foreach ($_POST['del_item'] as $di) + { + if (intval($di) > 0) $c_list[] = '`comment_id`='.intval($di); + } + 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,''); + } + else + { + $text = RL_LAN_113; + } + $ns -> tablerender(LAN_DELETE, "
".$text."
"); + unset($c_list); +} + + + // ****************** MAINTENANCE ****************** unset($back_count); if (isset($_POST['deleteoldadmin']) && isset($_POST['rolllog_clearadmin'])) @@ -193,11 +216,10 @@ if (($action == "confdel") || ($action == "auditdel")) -// Arrays of options for the various logs -$log_db_table = array('adminlog' => 'admin_log', 'auditlog' => 'audit_log', 'rolllog' => 'dblog', 'downlog' => 'download_requests'); -$back_day_count = array('adminlog' => 30, 'auditlog' => 30, 'rolllog' => max(intval($pref['roll_log_days']),1), 'downlog' => 60); -$page_title = array('adminlog' => RL_LAN_030, 'auditlog' => RL_LAN_062, 'rolllog' => RL_LAN_002, 'downlog' => RL_LAN_067); -$col_count = array('adminlog' => 8, 'auditlog' => 8, 'rolllog' => 9); +// 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'); +$back_day_count = array('adminlog' => 30, 'auditlog' => 30, 'rolllog' => max(intval($pref['roll_log_days']),1), 'downlog' => 60, 'detailed' => 20, 'comments' => 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); @@ -214,14 +236,26 @@ $sort_field = "dblog_id"; $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'])) +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 S_POST[] if 'clear filters' not active $start_time = $_POST['starttimedate'] + $_POST['starttimehours']*3600 + $_POST['starttimemins']*60; $start_enabled = isset($_POST['start_enabled']); - $end_time = $_POST['endtimedate'] + $_POST['endtimehours']*3600 + $_POST['endtimemins']*60; + if (isset($_POST['timelength'])) + { + $end_time = intval($_POST['timelength'])*60 + $start_time; + } + else + { + $end_time = $_POST['endtimedate'] + $_POST['endtimehours']*3600 + $_POST['endtimemins']*60; + } $end_enabled = isset($_POST['end_enabled']); $user_filter = $_POST['roll_user_filter']; $event_filter = $_POST['roll_event_filter']; @@ -230,6 +264,7 @@ if (isset($_POST['updatefilters'])) $caller_filter = $_POST['roll_caller_filter']; $ipaddress_filter = $_POST['roll_ipaddress_filter']; $downloadid_filter = $_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 @@ -240,11 +275,16 @@ 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)) + { + $user_filter = intval($qs[2]); + } } +$timelength = 5; +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) +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 @@ -276,7 +316,7 @@ function time_box($boxname, $this_time, $day_count, $inc_tomorrow = FALSE) // Minutes $ret .= " \n"; +// for ($i = 1; $i <= 10; $i++) + foreach (array(1,2,3,4,5,7,10,15,20,30) as $i) + { + $selected = ($timelength == $i) ? " selected='selected'" : ''; + $text .= "\n"; + } + $text .= "\n".RL_LAN_093.""; + $filter_cols = 4; + break; case 'priority' : $text .= " ".RL_LAN_058." + + +
"; + + // 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 .= "
-
+ "; foreach($col_widths[$action] as $i) @@ -712,10 +826,9 @@ $map_filters = array( } $text .= "\n"; - if (!$sql->db_Select_gen($qry)) + if ($num_entry == 0) { $text .= ""; - $num_entry = 0; } else {// Start with header @@ -744,6 +857,7 @@ function log_process($matches) } } // Now put up the events + $delete_button = FALSE; while ($row = $sql->db_Fetch()) { $text .= ''; @@ -754,6 +868,17 @@ function log_process($matches) case 'cf_datestring' : $val = date("d-m-y H:i:s",$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; @@ -780,6 +905,24 @@ function log_process($matches) // Look for pseudo-code for newlines, link insertion $val = preg_replace_callback("#\[!(\w+?)(=.+?){0,1}!]#",'log_process',$row['dblog_remarks']); break; + case 'comment_author' : + list(,$val) = explode('.',$row['comment_author'],2); + break; + case 'comment_ip' : + $val = $row['comment_ip']; + if (strlen($val) == 8) + { + $hexip = explode('.', chunk_split($val, 2, '.')); + $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 'del_check' : // Put up a 'delete' checkbox + $val = ""; + $delete_button = TRUE; + break; default : $val = $row[$cf]; } @@ -789,7 +932,10 @@ function log_process($matches) } } $text .= " - +
".RL_LAN_017."
+ "; + if ($delete_button) $text .= "     "; + $text .= "
"; @@ -829,8 +975,20 @@ function admin_log_adminmenu() $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 ($action == 'comments') + { + $var['users']['text'] = RL_LAN_115; + $var['users']['link'] ="users.php"; + } show_admin_menu(RL_LAN_005, $action, $var); } diff --git a/e107_languages/English/admin/help/admin_log.php b/e107_languages/English/admin/help/admin_log.php index 1461df125..c056fb407 100644 --- a/e107_languages/English/admin/help/admin_log.php +++ b/e107_languages/English/admin/help/admin_log.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_languages/English/admin/help/admin_log.php,v $ -| $Revision: 1.2 $ -| $Date: 2008-01-11 21:53:39 $ +| $Revision: 1.3 $ +| $Date: 2008-05-17 15:00:40 $ | $Author: e107steved $ +----------------------------------------------------------------------------+ */ @@ -61,6 +61,14 @@ case 'downlog' : $text = "This page displays user downloads.

"; $text .= common_filters(); break; +case 'comments' : + $text = "This page displays user comments, with options to select by user ID, type and date. Unwanted comments can be deleted."; + break; +case 'detailed' : + $text = "The main system logs record time to a high degree of precision (if the underlying server supports it), and this page allows you to inspect entries + occuring within a relatively small time window. Entries from the admin log, audit log and rolling log are merged, so that you can see the precise + relationships between events."; + break; case 'adminlog' : default : $text = "This page displays administrator activity.

diff --git a/e107_languages/English/admin/lan_admin_log.php b/e107_languages/English/admin/lan_admin_log.php index 0be6d22b4..cc717252d 100644 --- a/e107_languages/English/admin/lan_admin_log.php +++ b/e107_languages/English/admin/lan_admin_log.php @@ -1,6 +1,6 @@ \ No newline at end of file diff --git a/e107_languages/English/admin/lan_log_messages.php b/e107_languages/English/admin/lan_log_messages.php index 67dac7248..19bc0bd2d 100644 --- a/e107_languages/English/admin/lan_log_messages.php +++ b/e107_languages/English/admin/lan_log_messages.php @@ -1,6 +1,6 @@