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

ef5584
ef5584
/**
ef5584
*
ef5584
* @package acp
ef5584
* @version $Id: acp_captcha.php 8722 2008-07-29 15:13:13Z Kellanved $
ef5584
* @copyright (c) 2005 phpBB Group
ef5584
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
ef5584
*/
ef5584
ef5584
/**
ef5584
* @ignore
ef5584
*/
ef5584
if (!defined('IN_PHPBB'))
ef5584
{
ef5584
	exit;
ef5584
}
ef5584
ef5584
/**
ef5584
* @package acp
ef5584
*/
ef5584
class acp_captcha
ef5584
{
ef5584
	var $u_action;
ef5584
ef5584
	function main($id, $mode)
ef5584
	{
ef5584
		global $db, $user, $auth, $template;
ef5584
		global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
ef5584
ef5584
		$user->add_lang('acp/board');
ef5584
ef5584
ef5584
		$captcha_vars = array(
ef5584
			'captcha_gd_x_grid'				=> 'CAPTCHA_GD_X_GRID',
ef5584
			'captcha_gd_y_grid'				=> 'CAPTCHA_GD_Y_GRID',
ef5584
			'captcha_gd_foreground_noise'	=> 'CAPTCHA_GD_FOREGROUND_NOISE',
ef5584
			'captcha_gd'					=> 'CAPTCHA_GD_PREVIEWED'
ef5584
		);
ef5584
ef5584
		if (isset($_GET['demo']))
ef5584
		{
ef5584
			$captcha_vars = array_keys($captcha_vars);
ef5584
			foreach ($captcha_vars as $captcha_var)
ef5584
			{
ef5584
				$config[$captcha_var] = (isset($_REQUEST[$captcha_var])) ? request_var($captcha_var, 0) : $config[$captcha_var];
ef5584
			}
ef5584
			if ($config['captcha_gd'])
ef5584
			{
ef5584
				include($phpbb_root_path . 'includes/captcha/captcha_gd.' . $phpEx);
ef5584
			}
ef5584
			else
ef5584
			{
ef5584
				include($phpbb_root_path . 'includes/captcha/captcha_non_gd.' . $phpEx);
ef5584
			}
ef5584
			$captcha = new captcha();
ef5584
			$captcha->execute(gen_rand_string(mt_rand(5, 8)), time());
ef5584
			exit;
ef5584
		}
ef5584
ef5584
		$config_vars = array(
ef5584
			'enable_confirm'		=> 'REG_ENABLE',
ef5584
			'enable_post_confirm'	=> 'POST_ENABLE',
ef5584
			'captcha_gd'			=> 'CAPTCHA_GD',
ef5584
		);
ef5584
ef5584
		$this->tpl_name = 'acp_captcha';
ef5584
		$this->page_title = 'ACP_VC_SETTINGS';
ef5584
		$form_key = 'acp_captcha';
ef5584
		add_form_key($form_key);
ef5584
ef5584
		$submit = request_var('submit', '');
ef5584
ef5584
		if ($submit && check_form_key($form_key))
ef5584
		{
ef5584
			$config_vars = array_keys($config_vars);
ef5584
			foreach ($config_vars as $config_var)
ef5584
			{
ef5584
				set_config($config_var, request_var($config_var, ''));
ef5584
			}
ef5584
			$captcha_vars = array_keys($captcha_vars);
ef5584
			foreach ($captcha_vars as $captcha_var)
ef5584
			{
ef5584
				$value = request_var($captcha_var, 0);
ef5584
				if ($value >= 0)
ef5584
				{
ef5584
					set_config($captcha_var, $value);
ef5584
				}
ef5584
			}
ef5584
			trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
ef5584
		}
ef5584
		else if ($submit)
ef5584
		{
ef5584
				trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action));
ef5584
		}
ef5584
		else
ef5584
		{
ef5584
ef5584
			$preview_image_src = append_sid(append_sid("{$phpbb_admin_path}index.$phpEx", "i=$id&demo=demo"));
ef5584
			if (@extension_loaded('gd'))
ef5584
			{
ef5584
				$template->assign_var('GD', true);
ef5584
			}
ef5584
			foreach ($config_vars as $config_var => $template_var)
ef5584
			{
ef5584
				$template->assign_var($template_var, (isset($_REQUEST[$config_var])) ? request_var($config_var, '') : $config[$config_var]) ;
ef5584
			}
ef5584
			foreach ($captcha_vars as $captcha_var => $template_var)
ef5584
			{
ef5584
				$var = (isset($_REQUEST[$captcha_var])) ? request_var($captcha_var, 0) : $config[$captcha_var];
ef5584
				$template->assign_var($template_var, $var);
ef5584
				$preview_image_src .= "&$captcha_var=" . $var;
ef5584
			}
ef5584
			$template->assign_vars(array(
ef5584
				'CAPTCHA_PREVIEW'	=> $preview_image_src,
ef5584
				'PREVIEW'			=> isset($_POST['preview']),
ef5584
			));
ef5584
ef5584
		}
ef5584
	}
ef5584
}
ef5584
ef5584
?>