root / branches / phpBB-3_0_0 / phpBB / includes / acp / acp_disallow.php
History | View | Annotate | Download (3 kB)
| 1 | 5323 | acydburn | <?php
|
|---|---|---|---|
| 2 | 8147 | acydburn | /**
|
| 3 | 5323 | acydburn | * |
| 4 | 5323 | acydburn | * @package acp |
| 5 | 5323 | acydburn | * @version $Id$ |
| 6 | 8147 | acydburn | * @copyright (c) 2005 phpBB Group |
| 7 | 8147 | acydburn | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
| 8 | 5323 | acydburn | * |
| 9 | 5323 | acydburn | */ |
| 10 | 5323 | acydburn | |
| 11 | 5323 | acydburn | /**
|
| 12 | 8147 | acydburn | * @ignore |
| 13 | 8147 | acydburn | */ |
| 14 | 8147 | acydburn | if (!defined('IN_PHPBB')) |
| 15 | 8147 | acydburn | {
|
| 16 | 8147 | acydburn | exit;
|
| 17 | 8147 | acydburn | } |
| 18 | 8147 | acydburn | |
| 19 | 8147 | acydburn | /**
|
| 20 | 5323 | acydburn | * @package acp |
| 21 | 5323 | acydburn | */ |
| 22 | 5323 | acydburn | class acp_disallow |
| 23 | 5323 | acydburn | {
|
| 24 | 5558 | acydburn | var $u_action; |
| 25 | 5558 | acydburn | |
| 26 | 5323 | acydburn | function main($id, $mode) |
| 27 | 5323 | acydburn | {
|
| 28 | 5323 | acydburn | global $db, $user, $auth, $template, $cache; |
| 29 | 6015 | acydburn | global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; |
| 30 | 5323 | acydburn | |
| 31 | 5323 | acydburn | include($phpbb_root_path . 'includes/functions_user.' . $phpEx); |
| 32 | 5323 | acydburn | |
| 33 | 5323 | acydburn | $user->add_lang('acp/posting'); |
| 34 | 5323 | acydburn | |
| 35 | 5323 | acydburn | // Set up general vars
|
| 36 | 5323 | acydburn | $this->tpl_name = 'acp_disallow'; |
| 37 | 6698 | acydburn | $this->page_title = 'ACP_DISALLOW_USERNAMES'; |
| 38 | 5323 | acydburn | |
| 39 | 8120 | kellanved | $form_key = 'acp_disallow'; |
| 40 | 8120 | kellanved | add_form_key($form_key);
|
| 41 | 8120 | kellanved | |
| 42 | 5323 | acydburn | $disallow = (isset($_POST['disallow'])) ? true : false; |
| 43 | 5323 | acydburn | $allow = (isset($_POST['allow'])) ? true : false; |
| 44 | 5323 | acydburn | |
| 45 | 8120 | kellanved | if (($allow || $disallow) && !check_form_key($form_key)) |
| 46 | 8120 | kellanved | {
|
| 47 | 8120 | kellanved | trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); |
| 48 | 8120 | kellanved | } |
| 49 | 8120 | kellanved | |
| 50 | 5323 | acydburn | if ($disallow) |
| 51 | 5323 | acydburn | {
|
| 52 | 7920 | acydburn | $disallowed_user = str_replace('*', '%', utf8_normalize_nfc(request_var('disallowed_user', '', true))); |
| 53 | 5323 | acydburn | |
| 54 | 5694 | acydburn | if (!$disallowed_user) |
| 55 | 5323 | acydburn | {
|
| 56 | 6320 | acydburn | trigger_error($user->lang['NO_USERNAME_SPECIFIED'] . adm_back_link($this->u_action), E_USER_WARNING); |
| 57 | 5323 | acydburn | } |
| 58 | 5323 | acydburn | |
| 59 | 11076 | git-gate | $sql = 'SELECT disallow_id |
| 60 | 11076 | git-gate | FROM ' . DISALLOW_TABLE . " |
| 61 | 11076 | git-gate | WHERE disallow_username = '" . $db->sql_escape($disallowed_user) . "'"; |
| 62 | 11076 | git-gate | $result = $db->sql_query($sql); |
| 63 | 11076 | git-gate | $row = $db->sql_fetchrow($result); |
| 64 | 11076 | git-gate | $db->sql_freeresult($result); |
| 65 | 11076 | git-gate | |
| 66 | 11076 | git-gate | if ($row) |
| 67 | 11076 | git-gate | {
|
| 68 | 11076 | git-gate | trigger_error($user->lang['DISALLOWED_ALREADY'] . adm_back_link($this->u_action), E_USER_WARNING); |
| 69 | 11076 | git-gate | } |
| 70 | 11076 | git-gate | |
| 71 | 5694 | acydburn | $sql = 'INSERT INTO ' . DISALLOW_TABLE . ' ' . $db->sql_build_array('INSERT', array('disallow_username' => $disallowed_user)); |
| 72 | 5694 | acydburn | $db->sql_query($sql); |
| 73 | 5694 | acydburn | |
| 74 | 6590 | acydburn | $cache->destroy('_disallowed_usernames'); |
| 75 | 6571 | davidmj | |
| 76 | 5694 | acydburn | $message = $user->lang['DISALLOW_SUCCESSFUL']; |
| 77 | 5694 | acydburn | add_log('admin', 'LOG_DISALLOW_ADD', str_replace('%', '*', $disallowed_user)); |
| 78 | 5694 | acydburn | |
| 79 | 5558 | acydburn | trigger_error($message . adm_back_link($this->u_action)); |
| 80 | 5323 | acydburn | } |
| 81 | 5323 | acydburn | else if ($allow) |
| 82 | 5323 | acydburn | {
|
| 83 | 5323 | acydburn | $disallowed_id = request_var('disallowed_id', 0); |
| 84 | 5323 | acydburn | |
| 85 | 5323 | acydburn | if (!$disallowed_id) |
| 86 | 5323 | acydburn | {
|
| 87 | 6320 | acydburn | trigger_error($user->lang['NO_USERNAME_SPECIFIED'] . adm_back_link($this->u_action), E_USER_WARNING); |
| 88 | 5323 | acydburn | } |
| 89 | 5323 | acydburn | |
| 90 | 6533 | acydburn | $sql = 'DELETE FROM ' . DISALLOW_TABLE . ' |
| 91 | 6533 | acydburn | WHERE disallow_id = ' . $disallowed_id; |
| 92 | 5323 | acydburn | $db->sql_query($sql); |
| 93 | 5323 | acydburn | |
| 94 | 6590 | acydburn | $cache->destroy('_disallowed_usernames'); |
| 95 | 6571 | davidmj | |
| 96 | 5323 | acydburn | add_log('admin', 'LOG_DISALLOW_DELETE'); |
| 97 | 5323 | acydburn | |
| 98 | 7258 | acydburn | trigger_error($user->lang['DISALLOWED_DELETED'] . adm_back_link($this->u_action)); |
| 99 | 5323 | acydburn | } |
| 100 | 5323 | acydburn | |
| 101 | 5323 | acydburn | // Grab the current list of disallowed usernames...
|
| 102 | 5323 | acydburn | $sql = 'SELECT * |
| 103 | 5323 | acydburn | FROM ' . DISALLOW_TABLE; |
| 104 | 5323 | acydburn | $result = $db->sql_query($sql); |
| 105 | 5323 | acydburn | |
| 106 | 5323 | acydburn | $disallow_select = ''; |
| 107 | 5323 | acydburn | while ($row = $db->sql_fetchrow($result)) |
| 108 | 5323 | acydburn | {
|
| 109 | 5323 | acydburn | $disallow_select .= '<option value="' . $row['disallow_id'] . '">' . str_replace('%', '*', $row['disallow_username']) . '</option>'; |
| 110 | 5323 | acydburn | } |
| 111 | 5323 | acydburn | $db->sql_freeresult($result); |
| 112 | 5323 | acydburn | |
| 113 | 5323 | acydburn | $template->assign_vars(array( |
| 114 | 5558 | acydburn | 'U_ACTION' => $this->u_action, |
| 115 | 5323 | acydburn | 'S_DISALLOWED_NAMES' => $disallow_select) |
| 116 | 5323 | acydburn | ); |
| 117 | 5323 | acydburn | } |
| 118 | 5323 | acydburn | } |
| 119 | 5323 | acydburn | |
| 120 | 5323 | acydburn | ?> |

