Commit 5ebb1854 by Scott

Add option to prevent certain usernames

Defaults to ‘anonymous’
parent e2529b61
...@@ -436,6 +436,10 @@ function qa_default_option($name) ...@@ -436,6 +436,10 @@ function qa_default_option($name)
$value = qa_lang_html_sub('options/default_terms', qa_html(qa_opt('site_title'))); $value = qa_lang_html_sub('options/default_terms', qa_html(qa_opt('site_title')));
break; break;
case 'block_bad_usernames':
$value = qa_lang_html('main/anonymous');
break;
case 'custom_sidebar': case 'custom_sidebar':
$value = qa_lang_html_sub('options/default_sidebar', qa_html(qa_opt('site_title'))); $value = qa_lang_html_sub('options/default_sidebar', qa_html(qa_opt('site_title')));
break; break;
......
...@@ -45,6 +45,7 @@ return array( ...@@ -45,6 +45,7 @@ return array(
'avatar_q_page_q_size' => 'Avatar size on questions:', 'avatar_q_page_q_size' => 'Avatar size on questions:',
'avatar_store_size' => 'Maximum size for storing avatars:', 'avatar_store_size' => 'Maximum size for storing avatars:',
'avatar_users_size' => 'Avatar size on top users page:', 'avatar_users_size' => 'Avatar size on top users page:',
'block_bad_usernames' => 'Disallowed usernames - separate by spaces or commas:',
'block_bad_words' => 'Censored words - separate by spaces or commas:', 'block_bad_words' => 'Censored words - separate by spaces or commas:',
'block_ips_write' => 'Blocked IP addresses - separate by spaces or commas:', 'block_ips_write' => 'Blocked IP addresses - separate by spaces or commas:',
'caching_catwidget_time' => 'Cache category widget for:', 'caching_catwidget_time' => 'Cache category widget for:',
......
...@@ -63,6 +63,7 @@ return array( ...@@ -63,6 +63,7 @@ return array(
'email_required' => 'Email address required - not public', 'email_required' => 'Email address required - not public',
'forgot_link' => 'I forgot my password', 'forgot_link' => 'I forgot my password',
'full_name' => 'Full name', 'full_name' => 'Full name',
'handle_blocked' => 'Username is disallowed - please try another',
'handle_empty' => 'Username must not be empty', 'handle_empty' => 'Username must not be empty',
'handle_exists' => 'Username is taken - please try another', 'handle_exists' => 'Username is taken - please try another',
'handle_has_bad' => 'Username may not contain: ^', 'handle_has_bad' => 'Username may not contain: ^',
......
...@@ -322,7 +322,7 @@ switch ($adminsection) { ...@@ -322,7 +322,7 @@ switch ($adminsection) {
require_once QA_INCLUDE_DIR . 'util/image.php'; require_once QA_INCLUDE_DIR . 'util/image.php';
array_push($showoptions, 'show_custom_register', 'custom_register', 'show_register_terms', 'register_terms', 'show_notice_welcome', 'notice_welcome', 'show_custom_welcome', 'custom_welcome', array_push($showoptions, 'show_custom_register', 'custom_register', 'show_register_terms', 'register_terms', 'show_notice_welcome', 'notice_welcome', 'show_custom_welcome', 'custom_welcome',
'', 'allow_login_email_only', 'allow_change_usernames', 'register_notify_admin', 'suspend_register_users', '', 'allow_login_email_only', 'allow_change_usernames', 'register_notify_admin', 'suspend_register_users', '', 'block_bad_usernames',
'', 'allow_private_messages', 'show_message_history', 'page_size_pms', 'allow_user_walls', 'page_size_wall', '', 'allow_private_messages', 'show_message_history', 'page_size_pms', 'allow_user_walls', 'page_size_wall',
'', 'avatar_allow_gravatar'); '', 'avatar_allow_gravatar');
...@@ -747,6 +747,7 @@ else { ...@@ -747,6 +747,7 @@ else {
break; break;
case 'block_bad_words': case 'block_bad_words':
case 'block_bad_usernames':
require_once QA_INCLUDE_DIR . 'util/string.php'; require_once QA_INCLUDE_DIR . 'util/string.php';
$optionvalue = implode(' , ', qa_block_words_explode($optionvalue)); $optionvalue = implode(' , ', qa_block_words_explode($optionvalue));
break; break;
...@@ -1243,6 +1244,7 @@ foreach ($showoptions as $optionname) { ...@@ -1243,6 +1244,7 @@ foreach ($showoptions as $optionname) {
break; break;
case 'block_bad_words': case 'block_bad_words':
case 'block_bad_usernames':
$optionfield['style'] = 'tall'; $optionfield['style'] = 'tall';
$optionfield['rows'] = 4; $optionfield['rows'] = 4;
$optionfield['note'] = qa_lang_html('admin/block_words_note'); $optionfield['note'] = qa_lang_html('admin/block_words_note');
......
...@@ -52,6 +52,12 @@ class qa_filter_basic ...@@ -52,6 +52,12 @@ class qa_filter_basic
if (qa_strlen($handle) > QA_DB_MAX_HANDLE_LENGTH) { if (qa_strlen($handle) > QA_DB_MAX_HANDLE_LENGTH) {
return qa_lang_sub('main/max_length_x', QA_DB_MAX_HANDLE_LENGTH); return qa_lang_sub('main/max_length_x', QA_DB_MAX_HANDLE_LENGTH);
} }
// check for banned usernames (e.g. "anonymous")
$wordspreg = qa_block_words_to_preg(qa_opt('block_bad_usernames'));
$blocked = qa_block_words_match_all($handle, $wordspreg);
if (!empty($blocked)) {
return qa_lang('users/handle_blocked');
}
} }
public function filter_question(&$question, &$errors, $oldquestion) public function filter_question(&$question, &$errors, $oldquestion)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment