phpBB

Code Changes

File: includes/acp/acp_captcha.php

  Unmodified   Added   Modified   Removed
Line 25Line 25

function main($id, $mode)
{


function main($id, $mode)
{

		global $db, $user, $auth, $template;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx, $phpbb_container;

		global $user, $template, $phpbb_log, $request;
global $config, $phpbb_container;


$user->add_lang('acp/board');



$user->add_lang('acp/board');


 
		/* @var $factory \phpbb\captcha\factory */

		$factory = $phpbb_container->get('captcha.factory');
$captchas = $factory->get_captcha_types();


		$factory = $phpbb_container->get('captcha.factory');
$captchas = $factory->get_captcha_types();


		$selected = request_var('select_captcha', $config['captcha_plugin']);

		$selected = $request->variable('select_captcha', $config['captcha_plugin']);

		$selected = (isset($captchas['available'][$selected]) || isset($captchas['unavailable'][$selected])) ? $selected : $config['captcha_plugin'];

		$selected = (isset($captchas['available'][$selected]) || isset($captchas['unavailable'][$selected])) ? $selected : $config['captcha_plugin'];

		$configure = request_var('configure', false);

		$configure = $request->variable('configure', false);


// Oh, they are just here for the view
if (isset($_GET['captcha_demo']))


// Oh, they are just here for the view
if (isset($_GET['captcha_demo']))

Line 52Line 53
		else
{
$config_vars = array(

		else
{
$config_vars = array(

				'enable_confirm'		=> array('tpl' => 'REG_ENABLE', 'default' => false),
'enable_post_confirm' => array('tpl' => 'POST_ENABLE', 'default' => false),
'confirm_refresh' => array('tpl' => 'CONFIRM_REFRESH', 'default' => false),
'max_reg_attempts' => array('tpl' => 'REG_LIMIT', 'default' => 0),
'max_login_attempts' => array('tpl' => 'MAX_LOGIN_ATTEMPTS', 'default' => 0),


























				'enable_confirm'		=> array(
'tpl' => 'REG_ENABLE',
'default' => false,
'validate' => 'bool',
'lang' => 'VISUAL_CONFIRM_REG',
),
'enable_post_confirm' => array(
'tpl' => 'POST_ENABLE',
'default' => false,
'validate' => 'bool',
'lang' => 'VISUAL_CONFIRM_POST',
),
'confirm_refresh' => array(
'tpl' => 'CONFIRM_REFRESH',
'default' => false,
'validate' => 'bool',
'lang' => 'VISUAL_CONFIRM_REFRESH',
),
'max_reg_attempts' => array(
'tpl' => 'REG_LIMIT',
'default' => 0,
'validate' => 'int:0:99999',
'lang' => 'REG_LIMIT',
),
'max_login_attempts' => array(
'tpl' => 'MAX_LOGIN_ATTEMPTS',
'default' => 0,
'validate' => 'int:0:99999',
'lang' => 'MAX_LOGIN_ATTEMPTS',
),

			);

$this->tpl_name = 'acp_captcha';

			);

$this->tpl_name = 'acp_captcha';

Line 64Line 90
			$form_key = 'acp_captcha';
add_form_key($form_key);


			$form_key = 'acp_captcha';
add_form_key($form_key);


			$submit = request_var('main_submit', false);


			$submit = $request->variable('main_submit', false);
$error = $cfg_array = array();





			if ($submit && check_form_key($form_key))

			if ($submit)

			{
foreach ($config_vars as $config_var => $options)
{

			{
foreach ($config_vars as $config_var => $options)
{

					set_config($config_var, request_var($config_var, $options['default']));



















					$cfg_array[$config_var] = $request->variable($config_var, $options['default']);
}
validate_config_vars($config_vars, $cfg_array, $error);

if (!check_form_key($form_key))
{
$error[] = $user->lang['FORM_INVALID'];
}
if ($error)
{
$submit = false;
}
}

if ($submit)
{
foreach ($cfg_array as $key => $value)
{
$config->set($key, $value);

				}

if ($selected !== $config['captcha_plugin'])

				}

if ($selected !== $config['captcha_plugin'])

Line 81Line 126
						$old_captcha = $factory->get_instance($config['captcha_plugin']);
$old_captcha->uninstall();


						$old_captcha = $factory->get_instance($config['captcha_plugin']);
$old_captcha->uninstall();


						set_config('captcha_plugin', $selected);

						$config->set('captcha_plugin', $selected);

						$new_captcha = $factory->get_instance($config['captcha_plugin']);
$new_captcha->install();


						$new_captcha = $factory->get_instance($config['captcha_plugin']);
$new_captcha->install();


						add_log('admin', 'LOG_CONFIG_VISUAL');

						$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_CONFIG_VISUAL');

					}
else
{

					}
else
{

Line 93Line 138
					}
}
trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));

					}
}
trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));

			}
else if ($submit)
{
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);

 
			}
else
{

			}
else
{

Line 117Line 158

foreach ($config_vars as $config_var => $options)
{


foreach ($config_vars as $config_var => $options)
{

					$template->assign_var($options['tpl'], (isset($_POST[$config_var])) ? request_var($config_var, $options['default']) : $config[$config_var]) ;

					$template->assign_var($options['tpl'], (isset($_POST[$config_var])) ? $request->variable($config_var, $options['default']) : $config[$config_var]) ;

				}

$template->assign_vars(array(
'CAPTCHA_PREVIEW_TPL' => $demo_captcha->get_demo_template($id),
'S_CAPTCHA_HAS_CONFIG' => $demo_captcha->has_config(),
'CAPTCHA_SELECT' => $captcha_select,

				}

$template->assign_vars(array(
'CAPTCHA_PREVIEW_TPL' => $demo_captcha->get_demo_template($id),
'S_CAPTCHA_HAS_CONFIG' => $demo_captcha->has_config(),
'CAPTCHA_SELECT' => $captcha_select,

 
					'ERROR_MSG'				=> implode('<br />', $error),


'U_ACTION' => $this->u_action,
));


'U_ACTION' => $this->u_action,
));

Line 136Line 178
	*/
function deliver_demo($selected)
{

	*/
function deliver_demo($selected)
{

		global $db, $user, $config, $phpbb_container;

		global $phpbb_container;


$captcha = $phpbb_container->get('captcha.factory')->get_instance($selected);
$captcha->init(CONFIRM_REG);


$captcha = $phpbb_container->get('captcha.factory')->get_instance($selected);
$captcha->init(CONFIRM_REG);