Browse Source

! Clearing the admin/mod logs no longer has the 24 window. Instead, a message is left that the log was cleared. To discourage tampering, that message cannot be deleted on its own, only as part of the log being cleared... but a message is still left saying it was cleared, if that makes sense.

Signed-off-by: Peter Spicer <[email protected]>
Peter Spicer 10 years ago
parent
commit
8f69b76c84
2 changed files with 12 additions and 13 deletions
  1. 10 13
      Sources/Modlog.php
  2. 2 0
      Themes/default/languages/Modlog.english.php

+ 10 - 13
Sources/Modlog.php

@@ -20,7 +20,7 @@ if (!defined('SMF'))
 /**
  * Prepares the information from the moderation log for viewing.
  * Show the moderation log.
- * Disallows the deletion of events within twenty-four hours of now.
+ * If clearing the log, leaves a message in the log to indicate it was cleared, by whom and when.
  * Requires the admin_forum permission.
  * Accessed via ?action=moderate;area=modlog.
  *
@@ -49,8 +49,6 @@ function ViewModlog()
 
 	// The number of entries to show per page of log file.
 	$context['displaypage'] = 30;
-	// Amount of hours that must pass before allowed to delete file.
-	$context['hoursdisable'] = 24;
 
 	// Handle deletion...
 	if (isset($_POST['removeall']) && $context['can_delete'])
@@ -60,28 +58,31 @@ function ViewModlog()
 
 		$smcFunc['db_query']('', '
 			DELETE FROM {db_prefix}log_actions
-			WHERE id_log = {int:moderate_log}
-				AND log_time < {int:twenty_four_hours_wait}',
+			WHERE id_log = {int:moderate_log}',
 			array(
-				'twenty_four_hours_wait' => time() - $context['hoursdisable'] * 3600,
 				'moderate_log' => $context['log_type'],
 			)
 		);
+
+		$log_type = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 'admin' : 'moderate';
+		logAction('clearlog_' . $log_type, array(), $log_type);
+		
 	}
 	elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete'])
 	{
 		checkSession();
 		validateToken('mod-ml');
 
+		// No sneaky removing the 'cleared the log' entries.
 		$smcFunc['db_query']('', '
 			DELETE FROM {db_prefix}log_actions
 			WHERE id_log = {int:moderate_log}
 				AND id_action IN ({array_string:delete_actions})
-				AND log_time < {int:twenty_four_hours_wait}',
+				AND action NOT LIKE {string:clearlog}',
 			array(
-				'twenty_four_hours_wait' => time() - $context['hoursdisable'] * 3600,
 				'delete_actions' => array_unique($_POST['delete']),
 				'moderate_log' => $context['log_type'],
+				'clearlog' => 'clearlog_%',
 			)
 		);
 	}
@@ -357,10 +358,6 @@ function list_getModLogEntries($start, $items_per_page, $sort, $query_string = '
 
 	$modlog_query = allowedTo('admin_forum') || $user_info['mod_cache']['bq'] == '1=1' ? '1=1' : ($user_info['mod_cache']['bq'] == '0=1' ? 'lm.id_board = 0 AND lm.id_topic = 0' : (strtr($user_info['mod_cache']['bq'], array('id_board' => 'b.id_board')) . ' AND ' . strtr($user_info['mod_cache']['bq'], array('id_board' => 't.id_board'))));
 
-	// Do a little bit of self protection.
-	if (!isset($context['hoursdisable']))
-		$context['hoursdisable'] = 24;
-
 	// Can they see the IP address?
 	$seeIP = allowedTo('moderate_forum');
 
@@ -473,7 +470,7 @@ function list_getModLogEntries($start, $items_per_page, $sort, $query_string = '
 			'moderator_link' => $row['id_member'] ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>' : (empty($row['real_name']) ? ($txt['guest'] . (!empty($row['extra']['member_acted']) ? ' (' . $row['extra']['member_acted'] . ')' : '')) : $row['real_name']),
 			'time' => timeformat($row['log_time']),
 			'timestamp' => forum_time(true, $row['log_time']),
-			'editable' => time() > $row['log_time'] + $context['hoursdisable'] * 3600,
+			'editable' => substr($row['action'], 0, 8) !== 'clearlog',
 			'extra' => $row['extra'],
 			'action' => $row['action'],
 			'action_text' => isset($row['action_text']) ? $row['action_text'] : '',

+ 2 - 0
Themes/default/languages/Modlog.english.php

@@ -29,6 +29,8 @@ $txt['modlog_ac_move'] = 'Moved &quot;{topic}&quot; from &quot;{board_from}&quot
 $txt['modlog_ac_profile'] = 'Edit the profile of &quot;{member}&quot;';
 $txt['modlog_ac_pruned'] = 'Pruned some posts older than {days} days';
 $txt['modlog_ac_news'] = 'Edited the news';
+$txt['modlog_ac_clearlog_moderate'] = 'Cleared the moderation log';
+$txt['modlog_ac_clearlog_admin'] = 'Cleared the administration log';
 $txt['modlog_enter_comment'] = 'Enter Moderation Comment';
 $txt['modlog_moderation_log'] = 'Moderation Log';
 $txt['modlog_moderation_log_desc'] = 'Below is a list of all the moderation actions that have been carried out by moderators of the forum.<br /><strong>Please note:</strong> Entries cannot be removed from this log until they are at least twenty-four hours old.';