From 265cabc30e6b1f708c60bc283d4fb087b17f164b Mon Sep 17 00:00:00 2001 From: the_systech Date: Mon, 15 Oct 2001 20:15:46 +0000 Subject: [PATCH] Username Disallow Admin... git-svn-id: file:///svn/phpbb/trunk@1210 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/admin/admin_disallow.php | 131 ++++++++++++++++++ phpBB/includes/functions.php | 6 +- phpBB/language/lang_english/lang_main.php | 18 ++- phpBB/templates/PSO/admin/disallow_body.tpl | 30 ++++ .../subSilver/admin/disallow_body.tpl | 33 +++++ 5 files changed, 213 insertions(+), 5 deletions(-) create mode 100644 phpBB/admin/admin_disallow.php create mode 100644 phpBB/templates/PSO/admin/disallow_body.tpl create mode 100644 phpBB/templates/subSilver/admin/disallow_body.tpl diff --git a/phpBB/admin/admin_disallow.php b/phpBB/admin/admin_disallow.php new file mode 100644 index 0000000000..b52ee9e769 --- /dev/null +++ b/phpBB/admin/admin_disallow.php @@ -0,0 +1,131 @@ +sql_query($sql); + if( !$result ) + { + message_die(GENERAL_ERROR, "Couldn't removed disallowed user.", "",__LINE__, __FILE__, $sql); + } + $output_info = $lang['disallowed_deleted']; + break; + case $lang['Add']: + $disallowed_user = ( isset($HTTP_POST_VARS['disallowed_user']) ) ? $HTTP_POST_VARS['disallowed_user'] : $HTTP_GET_VARS['disallowed_user']; + $disallowed_user = preg_replace( '/\*/', '%', $disallowed_user ); + if( !validate_username( $disallowed_user ) ) + { + $output_info = $lang['disallowed_already']; + } + else + { + $sql = 'INSERT INTO '.DISALLOW_TABLE."(disallow_username) VALUES('".$disallowed_user."')"; + $result = $db->sql_query( $sql ); + if ( !$result ) + { + message_die(GENERAL_ERROR, "Could not add disallowed user.", "",__LINE__, __FILE__, $sql); + } + $output_info = $lang['disallow_successful']; + } + break; +} +// +// Grab the current list of disallowed usernames... +// +$sql = 'SELECT * FROM '.DISALLOW_TABLE; +$result = $db->sql_query($sql); +if( !$result ) +{ + message_die( GENERAL_ERROR, "Couldn't get disallowed users.", "", __LINE__, __FILE__, $sql ); +} +$disallowed = $db->sql_fetchrowset($result); + +// +// Ok now generate the info for the template, which will be put out no matter +// what mode we are in. +// +$disallow_select = "'; +$template->set_filenames(array( + "body" => "admin/disallow_body.tpl") +); +$template->assign_vars(array( + "S_DISALLOW_SELECT" => $disallow_select, + "L_INFO" => $output_info, + "L_DISALLOW_TITLE" => $lang['Disallow_control'], + "L_DELETE" => $lang['Delete'], + "L_ADD" => $lang['Add'], + "L_RESET" => $lang['Reset'], + "S_FORM_ACTION" => 'admin_disallow.php', + "L_EXPLAIN" => $lang['disallow_instructs'], + "L_DEL_DISALLOW" => $lang['del_disallow'], + "L_DEL_EXPLAIN" => $lang['del_disallow_explain'], + "L_ADD_DISALLOW" => $lang['add_disallow'], + "L_ADD_EXPLAIN" => $lang['add_disallow_explain'], + "L_USERNAME" => $lang['Username']) +); +$template->pparse("body"); +?> diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 0723bbae58..a6c34a4345 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -486,7 +486,7 @@ function validate_username($username) OR LOWER(g.group_name) = '" . strtolower($username) . "' )"; $sql_disallow = "SELECT disallow_username FROM " . DISALLOW_TABLE . " - WHERE disallow_username = '$username'"; + WHERE '$username' LIKE disallow_username"; if($result = $db->sql_query($sql_users)) { if($db->sql_numrows($result) > 0) @@ -513,7 +513,7 @@ function validate_username($username) UNION SELECT disallow_username, NULL FROM " . DISALLOW_TABLE . " - WHERE disallow_username = '$username'"; + WHERE '$username' LIKE disallow_username"; if($result = $db->sql_query($sql)) { if($db->sql_numrows($result) > 0) @@ -1207,4 +1207,4 @@ function message_die($msg_code, $msg_text = "", $msg_title = "", $err_line = "", } -?> \ No newline at end of file +?> diff --git a/phpBB/language/lang_english/lang_main.php b/phpBB/language/lang_english/lang_main.php index a3533116dc..d9c85c778b 100644 --- a/phpBB/language/lang_english/lang_main.php +++ b/phpBB/language/lang_english/lang_main.php @@ -139,7 +139,7 @@ $lang['None'] = "None"; $lang['online'] = "online"; $lang['You_last_visit'] = "You last visited on"; - +$lang['Add'] = "Add"; $lang['Welcome_to'] = "Welcome to"; // Followed by site name $lang['Register'] = "Register"; $lang['Profile'] = "Profile"; @@ -1096,8 +1096,22 @@ $lang['Rank_image'] = "Rank Image"; $lang['Rank_image_explain'] = "This is the place to set a custom image for everyone in the rank. You can specify either a relative or absolute path to the image"; $lang['return_rank_admin'] = "to return to rank admin"; +// +// Disallow Username Admin +// +$lang['disallowed_deleted'] = "The disallowed username has successfully been removed"; +$lang['disallowed_already'] = "The username you are trying to disallow has already been disallowed, or a user currently exists that this would disallow"; +$lang['disallow_successful'] = "The disallowed username has successfully been added"; +$lang['Disallow_control'] = "Username Disallow Control"; +$lang['disallow_instructs'] = "Here you can control usernames which will not be allowed to be used. Disallowed usernames are allowed to contain a wildcard character of '*'. Please note that you will not be allowed to specify a username to disallow if that username has already been registered. You must first delete that username, and then disallow it."; +$lang['del_disallow'] = "Remove a Disallowed Username"; +$lang['del_disallow_explain'] = "You can remove a disallowed username by selecting the username from this list and clicking submit"; +$lang['add_disallow'] = "Add a disallowed username"; +$lang['add_disallow_explain'] = "You can disallow a username using the wildcard character '*' to match any character"; +$lang['no_disallowed'] = "No Disallowed Usernames"; + // // That's all Folks! // ------------------------------------------------- -?> \ No newline at end of file +?> diff --git a/phpBB/templates/PSO/admin/disallow_body.tpl b/phpBB/templates/PSO/admin/disallow_body.tpl new file mode 100644 index 0000000000..e16871e143 --- /dev/null +++ b/phpBB/templates/PSO/admin/disallow_body.tpl @@ -0,0 +1,30 @@ + +
+ +

{L_DISALLOW_TITLE}

+ +

{L_EXPLAIN_EXPLAIN}

+ +
+ + + + + + + + + + + + + + + + + +
{L_DEL_DISALLOW}
{L_USERNAME}: 
{L_DEL_EXPLAIN}
{S_DISALLOW_SELECT} &nbps;
{L_ADD_DISALLOW}
{L_USERNAME}: 
{L_ADD_EXPLAIN}
  
+ +

{L_INFO}

+ +
diff --git a/phpBB/templates/subSilver/admin/disallow_body.tpl b/phpBB/templates/subSilver/admin/disallow_body.tpl new file mode 100644 index 0000000000..8b1e832e67 --- /dev/null +++ b/phpBB/templates/subSilver/admin/disallow_body.tpl @@ -0,0 +1,33 @@ + +

{L_DISALLOW_TITLE}

+

{L_EXPLAIN}

+ +
+ + + + + + + + + + + + + + + + + +
{L_DEL_DISALLOW}
{L_USERNAME}:
+ {L_DEL_EXPLAIN}
{S_DISALLOW_SELECT} 
{L_ADD_DISALLOW}
{L_USERNAME}:
+ {L_ADD_EXPLAIN}>
+ +
+ +    + +
+ +

{L_INFO}