|
indvdum@0
|
1 |
<?php
|
|
indvdum@0
|
2 |
/**
|
|
indvdum@0
|
3 |
*
|
|
indvdum@0
|
4 |
* @package acp
|
|
indvdum@0
|
5 |
* @version $Id$
|
|
indvdum@0
|
6 |
* @copyright (c) 2005 phpBB Group
|
|
indvdum@0
|
7 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
indvdum@0
|
8 |
*/
|
|
indvdum@0
|
9 |
|
|
indvdum@0
|
10 |
/**
|
|
indvdum@0
|
11 |
* @ignore
|
|
indvdum@0
|
12 |
*/
|
|
indvdum@0
|
13 |
if (!defined('IN_PHPBB'))
|
|
indvdum@0
|
14 |
{
|
|
indvdum@0
|
15 |
exit;
|
|
indvdum@0
|
16 |
}
|
|
indvdum@0
|
17 |
|
|
indvdum@0
|
18 |
/**
|
|
indvdum@0
|
19 |
* @package acp
|
|
indvdum@0
|
20 |
*/
|
|
indvdum@0
|
21 |
class acp_captcha
|
|
indvdum@0
|
22 |
{
|
|
indvdum@0
|
23 |
var $u_action;
|
|
indvdum@0
|
24 |
|
|
indvdum@0
|
25 |
function main($id, $mode)
|
|
indvdum@0
|
26 |
{
|
|
indvdum@0
|
27 |
global $db, $user, $auth, $template;
|
|
indvdum@0
|
28 |
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
|
|
indvdum@0
|
29 |
|
|
indvdum@0
|
30 |
$user->add_lang('acp/board');
|
|
indvdum@0
|
31 |
|
|
indvdum@0
|
32 |
include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx);
|
|
indvdum@0
|
33 |
$captchas = phpbb_captcha_factory::get_captcha_types();
|
|
indvdum@0
|
34 |
|
|
indvdum@0
|
35 |
$selected = request_var('select_captcha', $config['captcha_plugin']);
|
|
indvdum@0
|
36 |
$selected = (isset($captchas['available'][$selected]) || isset($captchas['unavailable'][$selected])) ? $selected : $config['captcha_plugin'];
|
|
indvdum@0
|
37 |
$configure = request_var('configure', false);
|
|
indvdum@0
|
38 |
|
|
indvdum@0
|
39 |
|
|
indvdum@0
|
40 |
// Oh, they are just here for the view
|
|
indvdum@0
|
41 |
if (isset($_GET['captcha_demo']))
|
|
indvdum@0
|
42 |
{
|
|
indvdum@0
|
43 |
$this->deliver_demo($selected);
|
|
indvdum@0
|
44 |
}
|
|
indvdum@0
|
45 |
|
|
indvdum@0
|
46 |
// Delegate
|
|
indvdum@0
|
47 |
if ($configure)
|
|
indvdum@0
|
48 |
{
|
|
indvdum@0
|
49 |
$config_captcha =& phpbb_captcha_factory::get_instance($selected);
|
|
indvdum@0
|
50 |
$config_captcha->acp_page($id, $this);
|
|
indvdum@0
|
51 |
}
|
|
indvdum@0
|
52 |
else
|
|
indvdum@0
|
53 |
{
|
|
indvdum@0
|
54 |
$config_vars = array(
|
|
indvdum@0
|
55 |
'enable_confirm' => array('tpl' => 'REG_ENABLE', 'default' => false),
|
|
indvdum@0
|
56 |
'enable_post_confirm' => array('tpl' => 'POST_ENABLE', 'default' => false),
|
|
indvdum@0
|
57 |
'confirm_refresh' => array('tpl' => 'CONFIRM_REFRESH', 'default' => false),
|
|
indvdum@0
|
58 |
'max_reg_attempts' => array('tpl' => 'REG_LIMIT', 'default' => 0),
|
|
indvdum@0
|
59 |
'max_login_attempts' => array('tpl' => 'MAX_LOGIN_ATTEMPTS', 'default' => 0),
|
|
indvdum@0
|
60 |
);
|
|
indvdum@0
|
61 |
|
|
indvdum@0
|
62 |
$this->tpl_name = 'acp_captcha';
|
|
indvdum@0
|
63 |
$this->page_title = 'ACP_VC_SETTINGS';
|
|
indvdum@0
|
64 |
$form_key = 'acp_captcha';
|
|
indvdum@0
|
65 |
add_form_key($form_key);
|
|
indvdum@0
|
66 |
|
|
indvdum@0
|
67 |
$submit = request_var('main_submit', false);
|
|
indvdum@0
|
68 |
|
|
indvdum@0
|
69 |
if ($submit && check_form_key($form_key))
|
|
indvdum@0
|
70 |
{
|
|
indvdum@0
|
71 |
foreach ($config_vars as $config_var => $options)
|
|
indvdum@0
|
72 |
{
|
|
indvdum@0
|
73 |
set_config($config_var, request_var($config_var, $options['default']));
|
|
indvdum@0
|
74 |
}
|
|
indvdum@0
|
75 |
|
|
indvdum@0
|
76 |
if ($selected !== $config['captcha_plugin'])
|
|
indvdum@0
|
77 |
{
|
|
indvdum@0
|
78 |
// sanity check
|
|
indvdum@0
|
79 |
if (isset($captchas['available'][$selected]))
|
|
indvdum@0
|
80 |
{
|
|
indvdum@0
|
81 |
$old_captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']);
|
|
indvdum@0
|
82 |
$old_captcha->uninstall();
|
|
indvdum@0
|
83 |
|
|
indvdum@0
|
84 |
set_config('captcha_plugin', $selected);
|
|
indvdum@0
|
85 |
$new_captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']);
|
|
indvdum@0
|
86 |
$new_captcha->install();
|
|
indvdum@0
|
87 |
|
|
indvdum@0
|
88 |
add_log('admin', 'LOG_CONFIG_VISUAL');
|
|
indvdum@0
|
89 |
}
|
|
indvdum@0
|
90 |
else
|
|
indvdum@0
|
91 |
{
|
|
indvdum@0
|
92 |
trigger_error($user->lang['CAPTCHA_UNAVAILABLE'] . adm_back_link($this->u_action), E_USER_WARNING);
|
|
indvdum@0
|
93 |
}
|
|
indvdum@0
|
94 |
}
|
|
indvdum@0
|
95 |
trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
|
|
indvdum@0
|
96 |
}
|
|
indvdum@0
|
97 |
else if ($submit)
|
|
indvdum@0
|
98 |
{
|
|
indvdum@0
|
99 |
trigger_error($user->lang['FORM_INVALID'] . adm_back_link(), E_USER_WARNING);
|
|
indvdum@0
|
100 |
}
|
|
indvdum@0
|
101 |
else
|
|
indvdum@0
|
102 |
{
|
|
indvdum@0
|
103 |
$captcha_select = '';
|
|
indvdum@0
|
104 |
foreach ($captchas['available'] as $value => $title)
|
|
indvdum@0
|
105 |
{
|
|
indvdum@0
|
106 |
$current = ($selected !== false && $value == $selected) ? ' selected="selected"' : '';
|
|
indvdum@0
|
107 |
$captcha_select .= '<option value="' . $value . '"' . $current . '>' . $user->lang[$title] . '</option>';
|
|
indvdum@0
|
108 |
}
|
|
indvdum@0
|
109 |
|
|
indvdum@0
|
110 |
foreach ($captchas['unavailable'] as $value => $title)
|
|
indvdum@0
|
111 |
{
|
|
indvdum@0
|
112 |
$current = ($selected !== false && $value == $selected) ? ' selected="selected"' : '';
|
|
indvdum@0
|
113 |
$captcha_select .= '<option value="' . $value . '"' . $current . ' class="disabled-option">' . $user->lang[$title] . '</option>';
|
|
indvdum@0
|
114 |
}
|
|
indvdum@0
|
115 |
|
|
indvdum@0
|
116 |
$demo_captcha =& phpbb_captcha_factory::get_instance($selected);
|
|
indvdum@0
|
117 |
|
|
indvdum@0
|
118 |
foreach ($config_vars as $config_var => $options)
|
|
indvdum@0
|
119 |
{
|
|
indvdum@0
|
120 |
$template->assign_var($options['tpl'], (isset($_POST[$config_var])) ? request_var($config_var, $options['default']) : $config[$config_var]) ;
|
|
indvdum@0
|
121 |
}
|
|
indvdum@0
|
122 |
|
|
indvdum@0
|
123 |
$template->assign_vars(array(
|
|
indvdum@0
|
124 |
'CAPTCHA_PREVIEW_TPL' => $demo_captcha->get_demo_template($id),
|
|
indvdum@0
|
125 |
'S_CAPTCHA_HAS_CONFIG' => $demo_captcha->has_config(),
|
|
indvdum@0
|
126 |
'CAPTCHA_SELECT' => $captcha_select,
|
|
indvdum@0
|
127 |
));
|
|
indvdum@0
|
128 |
}
|
|
indvdum@0
|
129 |
}
|
|
indvdum@0
|
130 |
}
|
|
indvdum@0
|
131 |
|
|
indvdum@0
|
132 |
/**
|
|
indvdum@0
|
133 |
* Entry point for delivering image CAPTCHAs in the ACP.
|
|
indvdum@0
|
134 |
*/
|
|
indvdum@0
|
135 |
function deliver_demo($selected)
|
|
indvdum@0
|
136 |
{
|
|
indvdum@0
|
137 |
global $db, $user, $config;
|
|
indvdum@0
|
138 |
|
|
indvdum@0
|
139 |
$captcha =& phpbb_captcha_factory::get_instance($selected);
|
|
indvdum@0
|
140 |
$captcha->init(CONFIRM_REG);
|
|
indvdum@0
|
141 |
$captcha->execute_demo();
|
|
indvdum@0
|
142 |
|
|
indvdum@0
|
143 |
garbage_collection();
|
|
indvdum@0
|
144 |
exit_handler();
|
|
indvdum@0
|
145 |
}
|
|
indvdum@0
|
146 |
}
|
|
indvdum@0
|
147 |
|
|
indvdum@0
|
148 |
?> |