|
1 <?php |
|
2 /** |
|
3 * |
|
4 * @package VC |
|
5 * @version $Id$ |
|
6 * @copyright (c) 2006, 2008 phpBB Group |
|
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
|
8 * |
|
9 */ |
|
10 |
|
11 /** |
|
12 * @ignore |
|
13 */ |
|
14 if (!defined('IN_PHPBB')) |
|
15 { |
|
16 exit; |
|
17 } |
|
18 |
|
19 /** |
|
20 * Placeholder for autoload |
|
21 */ |
|
22 if (!class_exists('phpbb_default_captcha')) |
|
23 { |
|
24 include($phpbb_root_path . 'includes/captcha/plugins/captcha_abstract.' . $phpEx); |
|
25 } |
|
26 |
|
27 /** |
|
28 * @package VC |
|
29 */ |
|
30 class phpbb_captcha_gd extends phpbb_default_captcha |
|
31 { |
|
32 |
|
33 var $captcha_vars = array( |
|
34 'captcha_gd_x_grid' => 'CAPTCHA_GD_X_GRID', |
|
35 'captcha_gd_y_grid' => 'CAPTCHA_GD_Y_GRID', |
|
36 'captcha_gd_foreground_noise' => 'CAPTCHA_GD_FOREGROUND_NOISE', |
|
37 // 'captcha_gd' => 'CAPTCHA_GD_PREVIEWED', |
|
38 'captcha_gd_wave' => 'CAPTCHA_GD_WAVE', |
|
39 'captcha_gd_3d_noise' => 'CAPTCHA_GD_3D_NOISE', |
|
40 'captcha_gd_fonts' => 'CAPTCHA_GD_FONTS', |
|
41 ); |
|
42 |
|
43 function phpbb_captcha_gd() |
|
44 { |
|
45 global $phpbb_root_path, $phpEx; |
|
46 |
|
47 if (!class_exists('captcha')) |
|
48 { |
|
49 include($phpbb_root_path . 'includes/captcha/captcha_gd.' . $phpEx); |
|
50 } |
|
51 } |
|
52 |
|
53 function &get_instance() |
|
54 { |
|
55 $instance =& new phpbb_captcha_gd(); |
|
56 return $instance; |
|
57 } |
|
58 |
|
59 function is_available() |
|
60 { |
|
61 global $phpbb_root_path, $phpEx; |
|
62 |
|
63 if (@extension_loaded('gd')) |
|
64 { |
|
65 return true; |
|
66 } |
|
67 |
|
68 if (!function_exists('can_load_dll')) |
|
69 { |
|
70 include($phpbb_root_path . 'includes/functions_install.' . $phpEx); |
|
71 } |
|
72 |
|
73 return can_load_dll('gd'); |
|
74 } |
|
75 |
|
76 /** |
|
77 * API function |
|
78 */ |
|
79 function has_config() |
|
80 { |
|
81 return true; |
|
82 } |
|
83 |
|
84 function get_name() |
|
85 { |
|
86 return 'CAPTCHA_GD'; |
|
87 } |
|
88 |
|
89 function get_class_name() |
|
90 { |
|
91 return 'phpbb_captcha_gd'; |
|
92 } |
|
93 |
|
94 function acp_page($id, &$module) |
|
95 { |
|
96 global $db, $user, $auth, $template; |
|
97 global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; |
|
98 |
|
99 $user->add_lang('acp/board'); |
|
100 |
|
101 $config_vars = array( |
|
102 'enable_confirm' => 'REG_ENABLE', |
|
103 'enable_post_confirm' => 'POST_ENABLE', |
|
104 'confirm_refresh' => 'CONFIRM_REFRESH', |
|
105 'captcha_gd' => 'CAPTCHA_GD', |
|
106 ); |
|
107 |
|
108 $module->tpl_name = 'captcha_gd_acp'; |
|
109 $module->page_title = 'ACP_VC_SETTINGS'; |
|
110 $form_key = 'acp_captcha'; |
|
111 add_form_key($form_key); |
|
112 |
|
113 $submit = request_var('submit', ''); |
|
114 |
|
115 if ($submit && check_form_key($form_key)) |
|
116 { |
|
117 $captcha_vars = array_keys($this->captcha_vars); |
|
118 foreach ($captcha_vars as $captcha_var) |
|
119 { |
|
120 $value = request_var($captcha_var, 0); |
|
121 if ($value >= 0) |
|
122 { |
|
123 set_config($captcha_var, $value); |
|
124 } |
|
125 } |
|
126 |
|
127 add_log('admin', 'LOG_CONFIG_VISUAL'); |
|
128 trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($module->u_action)); |
|
129 } |
|
130 else if ($submit) |
|
131 { |
|
132 trigger_error($user->lang['FORM_INVALID'] . adm_back_link($module->u_action)); |
|
133 } |
|
134 else |
|
135 { |
|
136 foreach ($this->captcha_vars as $captcha_var => $template_var) |
|
137 { |
|
138 $var = (isset($_REQUEST[$captcha_var])) ? request_var($captcha_var, 0) : $config[$captcha_var]; |
|
139 $template->assign_var($template_var, $var); |
|
140 } |
|
141 |
|
142 $template->assign_vars(array( |
|
143 'CAPTCHA_PREVIEW' => $this->get_demo_template($id), |
|
144 'CAPTCHA_NAME' => $this->get_class_name(), |
|
145 'U_ACTION' => $module->u_action, |
|
146 )); |
|
147 } |
|
148 } |
|
149 |
|
150 function execute_demo() |
|
151 { |
|
152 global $config; |
|
153 |
|
154 $config_old = $config; |
|
155 foreach ($this->captcha_vars as $captcha_var => $template_var) |
|
156 { |
|
157 $config[$captcha_var] = request_var($captcha_var, (int) $config[$captcha_var]); |
|
158 } |
|
159 parent::execute_demo(); |
|
160 $config = $config_old; |
|
161 } |
|
162 |
|
163 } |
|
164 |
|
165 ?> |