1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/includes/acp/acp_disallow.php Wed Mar 07 16:41:10 2012 +0400
1.3 @@ -0,0 +1,120 @@
1.4 +<?php
1.5 +/**
1.6 +*
1.7 +* @package acp
1.8 +* @version $Id$
1.9 +* @copyright (c) 2005 phpBB Group
1.10 +* @license http://opensource.org/licenses/gpl-license.php GNU Public License
1.11 +*
1.12 +*/
1.13 +
1.14 +/**
1.15 +* @ignore
1.16 +*/
1.17 +if (!defined('IN_PHPBB'))
1.18 +{
1.19 + exit;
1.20 +}
1.21 +
1.22 +/**
1.23 +* @package acp
1.24 +*/
1.25 +class acp_disallow
1.26 +{
1.27 + var $u_action;
1.28 +
1.29 + function main($id, $mode)
1.30 + {
1.31 + global $db, $user, $auth, $template, $cache;
1.32 + global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
1.33 +
1.34 + include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
1.35 +
1.36 + $user->add_lang('acp/posting');
1.37 +
1.38 + // Set up general vars
1.39 + $this->tpl_name = 'acp_disallow';
1.40 + $this->page_title = 'ACP_DISALLOW_USERNAMES';
1.41 +
1.42 + $form_key = 'acp_disallow';
1.43 + add_form_key($form_key);
1.44 +
1.45 + $disallow = (isset($_POST['disallow'])) ? true : false;
1.46 + $allow = (isset($_POST['allow'])) ? true : false;
1.47 +
1.48 + if (($allow || $disallow) && !check_form_key($form_key))
1.49 + {
1.50 + trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
1.51 + }
1.52 +
1.53 + if ($disallow)
1.54 + {
1.55 + $disallowed_user = str_replace('*', '%', utf8_normalize_nfc(request_var('disallowed_user', '', true)));
1.56 +
1.57 + if (!$disallowed_user)
1.58 + {
1.59 + trigger_error($user->lang['NO_USERNAME_SPECIFIED'] . adm_back_link($this->u_action), E_USER_WARNING);
1.60 + }
1.61 +
1.62 + $sql = 'SELECT disallow_id
1.63 + FROM ' . DISALLOW_TABLE . "
1.64 + WHERE disallow_username = '" . $db->sql_escape($disallowed_user) . "'";
1.65 + $result = $db->sql_query($sql);
1.66 + $row = $db->sql_fetchrow($result);
1.67 + $db->sql_freeresult($result);
1.68 +
1.69 + if ($row)
1.70 + {
1.71 + trigger_error($user->lang['DISALLOWED_ALREADY'] . adm_back_link($this->u_action), E_USER_WARNING);
1.72 + }
1.73 +
1.74 + $sql = 'INSERT INTO ' . DISALLOW_TABLE . ' ' . $db->sql_build_array('INSERT', array('disallow_username' => $disallowed_user));
1.75 + $db->sql_query($sql);
1.76 +
1.77 + $cache->destroy('_disallowed_usernames');
1.78 +
1.79 + $message = $user->lang['DISALLOW_SUCCESSFUL'];
1.80 + add_log('admin', 'LOG_DISALLOW_ADD', str_replace('%', '*', $disallowed_user));
1.81 +
1.82 + trigger_error($message . adm_back_link($this->u_action));
1.83 + }
1.84 + else if ($allow)
1.85 + {
1.86 + $disallowed_id = request_var('disallowed_id', 0);
1.87 +
1.88 + if (!$disallowed_id)
1.89 + {
1.90 + trigger_error($user->lang['NO_USERNAME_SPECIFIED'] . adm_back_link($this->u_action), E_USER_WARNING);
1.91 + }
1.92 +
1.93 + $sql = 'DELETE FROM ' . DISALLOW_TABLE . '
1.94 + WHERE disallow_id = ' . $disallowed_id;
1.95 + $db->sql_query($sql);
1.96 +
1.97 + $cache->destroy('_disallowed_usernames');
1.98 +
1.99 + add_log('admin', 'LOG_DISALLOW_DELETE');
1.100 +
1.101 + trigger_error($user->lang['DISALLOWED_DELETED'] . adm_back_link($this->u_action));
1.102 + }
1.103 +
1.104 + // Grab the current list of disallowed usernames...
1.105 + $sql = 'SELECT *
1.106 + FROM ' . DISALLOW_TABLE;
1.107 + $result = $db->sql_query($sql);
1.108 +
1.109 + $disallow_select = '';
1.110 + while ($row = $db->sql_fetchrow($result))
1.111 + {
1.112 + $disallow_select .= '<option value="' . $row['disallow_id'] . '">' . str_replace('%', '*', $row['disallow_username']) . '</option>';
1.113 + }
1.114 + $db->sql_freeresult($result);
1.115 +
1.116 + $template->assign_vars(array(
1.117 + 'U_ACTION' => $this->u_action,
1.118 + 'S_DISALLOWED_NAMES' => $disallow_select)
1.119 + );
1.120 + }
1.121 +}
1.122 +
1.123 +?>
1.124 \ No newline at end of file