Blame Identity/Webenv/phpBB/3.0.4/includes/acp/acp_disallow.php

ef5584
ef5584
/**
ef5584
*
ef5584
* @package acp
ef5584
* @version $Id: acp_disallow.php 8479 2008-03-29 00:22:48Z naderman $
ef5584
* @copyright (c) 2005 phpBB Group
ef5584
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
ef5584
*
ef5584
*/
ef5584
ef5584
/**
ef5584
* @ignore
ef5584
*/
ef5584
if (!defined('IN_PHPBB'))
ef5584
{
ef5584
	exit;
ef5584
}
ef5584
ef5584
/**
ef5584
* @package acp
ef5584
*/
ef5584
class acp_disallow
ef5584
{
ef5584
	var $u_action;
ef5584
ef5584
	function main($id, $mode)
ef5584
	{
ef5584
		global $db, $user, $auth, $template, $cache;
ef5584
		global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
ef5584
ef5584
		include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
ef5584
ef5584
		$user->add_lang('acp/posting');
ef5584
ef5584
		// Set up general vars
ef5584
		$this->tpl_name = 'acp_disallow';
ef5584
		$this->page_title = 'ACP_DISALLOW_USERNAMES';
ef5584
ef5584
		$form_key = 'acp_disallow';
ef5584
		add_form_key($form_key);
ef5584
ef5584
		$disallow = (isset($_POST['disallow'])) ? true : false;
ef5584
		$allow = (isset($_POST['allow'])) ? true : false;
ef5584
ef5584
		if (($allow || $disallow) && !check_form_key($form_key))
ef5584
		{
ef5584
			trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
ef5584
		}
ef5584
ef5584
		if ($disallow)
ef5584
		{
ef5584
			$disallowed_user = str_replace('*', '%', utf8_normalize_nfc(request_var('disallowed_user', '', true)));
ef5584
ef5584
			if (!$disallowed_user)
ef5584
			{
ef5584
				trigger_error($user->lang['NO_USERNAME_SPECIFIED'] . adm_back_link($this->u_action), E_USER_WARNING);
ef5584
			}
ef5584
ef5584
			$sql = 'INSERT INTO ' . DISALLOW_TABLE . ' ' . $db->sql_build_array('INSERT', array('disallow_username' => $disallowed_user));
ef5584
			$db->sql_query($sql);
ef5584
ef5584
			$cache->destroy('_disallowed_usernames');
ef5584
ef5584
			$message = $user->lang['DISALLOW_SUCCESSFUL'];
ef5584
			add_log('admin', 'LOG_DISALLOW_ADD', str_replace('%', '*', $disallowed_user));
ef5584
ef5584
			trigger_error($message . adm_back_link($this->u_action));
ef5584
		}
ef5584
		else if ($allow)
ef5584
		{
ef5584
			$disallowed_id = request_var('disallowed_id', 0);
ef5584
ef5584
			if (!$disallowed_id)
ef5584
			{
ef5584
				trigger_error($user->lang['NO_USERNAME_SPECIFIED'] . adm_back_link($this->u_action), E_USER_WARNING);
ef5584
			}
ef5584
ef5584
			$sql = 'DELETE FROM ' . DISALLOW_TABLE . '
ef5584
				WHERE disallow_id = ' . $disallowed_id;
ef5584
			$db->sql_query($sql);
ef5584
ef5584
			$cache->destroy('_disallowed_usernames');
ef5584
ef5584
			add_log('admin', 'LOG_DISALLOW_DELETE');
ef5584
ef5584
			trigger_error($user->lang['DISALLOWED_DELETED'] . adm_back_link($this->u_action));
ef5584
		}
ef5584
ef5584
		// Grab the current list of disallowed usernames...
ef5584
		$sql = 'SELECT *
ef5584
			FROM ' . DISALLOW_TABLE;
ef5584
		$result = $db->sql_query($sql);
ef5584
ef5584
		$disallow_select = '';
ef5584
		while ($row = $db->sql_fetchrow($result))
ef5584
		{
ef5584
			$disallow_select .= '<option value="' . $row['disallow_id'] . '">' . str_replace('%', '*', $row['disallow_username']) . '</option>';
ef5584
		}
ef5584
		$db->sql_freeresult($result);
ef5584
ef5584
		$template->assign_vars(array(
ef5584
			'U_ACTION'				=> $this->u_action,
ef5584
			'S_DISALLOWED_NAMES'	=> $disallow_select)
ef5584
		);
ef5584
	}
ef5584
}
ef5584
ef5584
?>