6 * @copyright (c) 2005 phpBB Group
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 if (!defined('IN_PHPBB'))
26 function main($id, $mode)
28 global $db, $user, $auth, $template, $cache;
29 global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
31 include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
33 $user->add_lang('acp/posting');
35 // Set up general vars
36 $this->tpl_name = 'acp_disallow';
37 $this->page_title = 'ACP_DISALLOW_USERNAMES';
39 $form_key = 'acp_disallow';
40 add_form_key($form_key);
42 $disallow = (isset($_POST['disallow'])) ? true : false;
43 $allow = (isset($_POST['allow'])) ? true : false;
45 if (($allow || $disallow) && !check_form_key($form_key))
47 trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
52 $disallowed_user = str_replace('*', '%', utf8_normalize_nfc(request_var('disallowed_user', '', true)));
54 if (!$disallowed_user)
56 trigger_error($user->lang['NO_USERNAME_SPECIFIED'] . adm_back_link($this->u_action), E_USER_WARNING);
59 $sql = 'SELECT disallow_id
60 FROM ' . DISALLOW_TABLE . "
61 WHERE disallow_username = '" . $db->sql_escape($disallowed_user) . "'";
62 $result = $db->sql_query($sql);
63 $row = $db->sql_fetchrow($result);
64 $db->sql_freeresult($result);
68 trigger_error($user->lang['DISALLOWED_ALREADY'] . adm_back_link($this->u_action), E_USER_WARNING);
71 $sql = 'INSERT INTO ' . DISALLOW_TABLE . ' ' . $db->sql_build_array('INSERT', array('disallow_username' => $disallowed_user));
74 $cache->destroy('_disallowed_usernames');
76 $message = $user->lang['DISALLOW_SUCCESSFUL'];
77 add_log('admin', 'LOG_DISALLOW_ADD', str_replace('%', '*', $disallowed_user));
79 trigger_error($message . adm_back_link($this->u_action));
83 $disallowed_id = request_var('disallowed_id', 0);
87 trigger_error($user->lang['NO_USERNAME_SPECIFIED'] . adm_back_link($this->u_action), E_USER_WARNING);
90 $sql = 'DELETE FROM ' . DISALLOW_TABLE . '
91 WHERE disallow_id = ' . $disallowed_id;
94 $cache->destroy('_disallowed_usernames');
96 add_log('admin', 'LOG_DISALLOW_DELETE');
98 trigger_error($user->lang['DISALLOWED_DELETED'] . adm_back_link($this->u_action));
101 // Grab the current list of disallowed usernames...
103 FROM ' . DISALLOW_TABLE;
104 $result = $db->sql_query($sql);
106 $disallow_select = '';
107 while ($row = $db->sql_fetchrow($result))
109 $disallow_select .= '<option value="' . $row['disallow_id'] . '">' . str_replace('%', '*', $row['disallow_username']) . '</option>';
111 $db->sql_freeresult($result);
113 $template->assign_vars(array(
114 'U_ACTION' => $this->u_action,
115 'S_DISALLOWED_NAMES' => $disallow_select)