Browse Source

Merge pull request #705 from Arantor/release-2.1

+ Allow users to turn off whether bans go into the error log or not. And...
Arantor 11 years ago
parent
commit
3ce452362d

+ 1 - 0
Sources/Errors.php

@@ -79,6 +79,7 @@ function log_error($error_message, $error_type = 'general', $file = null, $line
 		'database',
 		'undefined_vars',
 		'user',
+		'ban',
 		'template',
 		'debug',
 	);

+ 1 - 0
Sources/ManageSettings.php

@@ -2144,6 +2144,7 @@ function ModifyLogSettings($return_config = false)
 	$config_vars = array(
 			array('check', 'enableErrorLogging'),
 			array('check', 'enableErrorQueryLogging'),
+			array('check', 'log_ban_hits'),
 			// Even do the pruning?
 			array('title', 'pruning_title'),
 			array('desc', 'pruning_desc'),

+ 2 - 2
Sources/Security.php

@@ -364,7 +364,7 @@ function is_not_banned($forceCheck = false)
 		writeLog(true);
 
 		// You banned, sucka!
-		fatal_error(sprintf($txt['your_ban'], $old_name) . (empty($_SESSION['ban']['cannot_access']['reason']) ? '' : '<br />' . $_SESSION['ban']['cannot_access']['reason']) . '<br />' . (!empty($_SESSION['ban']['expire_time']) ? sprintf($txt['your_ban_expires'], timeformat($_SESSION['ban']['expire_time'], false)) : $txt['your_ban_expires_never']), 'user');
+		fatal_error(sprintf($txt['your_ban'], $old_name) . (empty($_SESSION['ban']['cannot_access']['reason']) ? '' : '<br />' . $_SESSION['ban']['cannot_access']['reason']) . '<br />' . (!empty($_SESSION['ban']['expire_time']) ? sprintf($txt['your_ban_expires'], timeformat($_SESSION['ban']['expire_time'], false)) : $txt['your_ban_expires_never']), !empty($modSettings['log_ban_hits']) ? 'ban' : false);
 
 		// If we get here, something's gone wrong.... but let's try anyway.
 		trigger_error('Hacking attempt...', E_USER_ERROR);
@@ -410,7 +410,7 @@ function is_not_banned($forceCheck = false)
 		require_once($sourcedir . '/LogInOut.php');
 		Logout(true, false);
 
-		fatal_error(sprintf($txt['your_ban'], $old_name) . (empty($_SESSION['ban']['cannot_login']['reason']) ? '' : '<br />' . $_SESSION['ban']['cannot_login']['reason']) . '<br />' . (!empty($_SESSION['ban']['expire_time']) ? sprintf($txt['your_ban_expires'], timeformat($_SESSION['ban']['expire_time'], false)) : $txt['your_ban_expires_never']) . '<br />' . $txt['ban_continue_browse'], 'user');
+		fatal_error(sprintf($txt['your_ban'], $old_name) . (empty($_SESSION['ban']['cannot_login']['reason']) ? '' : '<br />' . $_SESSION['ban']['cannot_login']['reason']) . '<br />' . (!empty($_SESSION['ban']['expire_time']) ? sprintf($txt['your_ban_expires'], timeformat($_SESSION['ban']['expire_time'], false)) : $txt['your_ban_expires_never']) . '<br />' . $txt['ban_continue_browse'], !empty($modSettings['log_ban_hits']) ? 'ban' : false);
 	}
 
 	// Fix up the banning permissions.

+ 1 - 0
Themes/default/languages/Admin.english.php

@@ -656,6 +656,7 @@ $txt['custom_profile_shorttitle'] = 'Profile Fields';
 $txt['pruning_title'] = 'Log Pruning';
 $txt['pruning_desc'] = 'The following options are useful for keeping your logs from growing too big, because most of the time older entries are not really of that much use.';
 $txt['log_settings'] = 'Log Settings';
+$txt['log_ban_hits'] = 'Log ban hits in the error log?';
 
 $txt['core_settings_activation_message'] = 'The feature {core_feature} has been activated, click on the title to configure it';
 $txt['core_settings_deactivation_message'] = 'The feature {core_feature} has been deactivated';

+ 1 - 0
Themes/default/languages/Help.english.php

@@ -291,6 +291,7 @@ $helptxt['cache_memcached'] = 'If you are using memcached you need to provide th
 $helptxt['cache_cachedir'] = 'This setting is only for the smf file based cache system. It specifies the path to the cache directory.  It is recommended that you place this in /tmp/ if you are going to use this, although it will work in any directory';
 $helptxt['enableErrorLogging'] = 'This will log any errors, like a failed login, so you can see what went wrong.';
 $helptxt['enableErrorQueryLogging'] = 'This will include the full query sent to the database in the error log.  Requires error logging to be turned on.<br /><br /><strong>Note:  This will affect the ability to filter the error log by the error message.</strong>';
+$helptxt['log_ban_hits'] = 'If enabled, every time a banned user tries to access the site, this will be logged in the error log. If you do not care whether, or how often, banned users attempt to access the site, you can turn this off for a performance boost.';
 $helptxt['allow_disableAnnounce'] = 'This will allow users to opt out of notification of topics you announce by checking the &quot;announce topic&quot; checkbox when posting.';
 $helptxt['disallow_sendBody'] = 'This option removes the option to receive the text of replies, posts and personal messages in notification emails.<br /><br />Often, members will reply to the notification email, which in most cases means the webmaster receives the reply.';
 $helptxt['jquery_source'] = 'This will determine the source used to load the jQuery Library.  Auto will use the CDN first and if not available fall back to the local source.  Local will only use the local source, CDN will only load it from Googles CDN network';

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

@@ -118,6 +118,8 @@ $txt['errortype_database'] = 'Database';
 $txt['errortype_database_desc'] = 'Errors caused by faulty queries.  These should be looked at and reported to the SMF team.';
 $txt['errortype_undefined_vars'] = 'Undefined';
 $txt['errortype_undefined_vars_desc'] = 'Errors caused by the use of undefined variables, indexes, or offsets.';
+$txt['errortype_ban'] = 'Bans';
+$txt['errortype_ban_desc'] = 'A log of banned users trying to access your forum.';
 $txt['errortype_template'] = 'Template';
 $txt['errortype_template_desc'] = 'Errors related to the loading of templates.';
 $txt['errortype_user'] = 'User';

+ 1 - 0
other/install_2-1_mysql.sql

@@ -1726,6 +1726,7 @@ VALUES ('smfVersion', '{$smf_version}'),
 	('titlesEnable', '1'),
 	('topicSummaryPosts', '15'),
 	('enableErrorLogging', '1'),
+	('log_ban_hits', '1'),
 	('max_image_width', '0'),
 	('max_image_height', '0'),
 	('onlineEnable', '0'),

+ 1 - 0
other/install_2-1_postgresql.sql

@@ -2226,6 +2226,7 @@ INSERT INTO {$db_prefix}settings (variable, value) VALUES ('userLanguage', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('titlesEnable', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('topicSummaryPosts', '15');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enableErrorLogging', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('log_ban_hits', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('max_image_width', '0');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('max_image_height', '0');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('onlineEnable', '0');

+ 1 - 0
other/install_2-1_sqlite.sql

@@ -1872,6 +1872,7 @@ INSERT INTO {$db_prefix}settings (variable, value) VALUES ('userLanguage', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('titlesEnable', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('topicSummaryPosts', '15');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enableErrorLogging', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('log_ban_hits', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('max_image_width', '0');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('max_image_height', '0');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('onlineEnable', '0');

+ 1 - 0
other/install_2-1_sqlite3.sql

@@ -1872,6 +1872,7 @@ INSERT INTO {$db_prefix}settings (variable, value) VALUES ('userLanguage', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('titlesEnable', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('topicSummaryPosts', '15');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enableErrorLogging', '1');
+INSERT INTO {$db_prefix}settings (variable, value) VALUES ('log_ban_hits', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('max_image_width', '0');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('max_image_height', '0');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('onlineEnable', '0');