Changeset 702 for trunk/forum/includes/acp/acp_captcha.php
- Timestamp:
- Mar 31, 2010, 6:32:40 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/forum/includes/acp/acp_captcha.php
r400 r702 3 3 * 4 4 * @package acp 5 * @version $Id : acp_captcha.php 8722 2008-07-29 15:13:13Z Kellanved$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 30 30 $user->add_lang('acp/board'); 31 31 32 include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); 33 $captchas = phpbb_captcha_factory::get_captcha_types(); 32 34 33 $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 ); 35 $selected = request_var('select_captcha', $config['captcha_plugin']); 36 $selected = (isset($captchas['available'][$selected]) || isset($captchas['unavailable'][$selected])) ? $selected : $config['captcha_plugin']; 37 $configure = request_var('configure', false); 39 38 40 if (isset($_GET['demo'])) 39 40 // Oh, they are just here for the view 41 if (isset($_GET['captcha_demo'])) 41 42 { 42 $captcha_vars = array_keys($captcha_vars); 43 foreach ($captcha_vars as $captcha_var) 43 $this->deliver_demo($selected); 44 } 45 46 // Delegate 47 if ($configure) 48 { 49 $config_captcha =& phpbb_captcha_factory::get_instance($selected); 50 $config_captcha->acp_page($id, $this); 51 } 52 else 53 { 54 $config_vars = array( 55 'enable_confirm' => array('tpl' => 'REG_ENABLE', 'default' => false), 56 'enable_post_confirm' => array('tpl' => 'POST_ENABLE', 'default' => false), 57 'confirm_refresh' => array('tpl' => 'CONFIRM_REFRESH', 'default' => false), 58 'max_reg_attempts' => array('tpl' => 'REG_LIMIT', 'default' => 0), 59 'max_login_attempts' => array('tpl' => 'MAX_LOGIN_ATTEMPTS', 'default' => 0), 60 ); 61 62 $this->tpl_name = 'acp_captcha'; 63 $this->page_title = 'ACP_VC_SETTINGS'; 64 $form_key = 'acp_captcha'; 65 add_form_key($form_key); 66 67 $submit = request_var('main_submit', false); 68 69 if ($submit && check_form_key($form_key)) 44 70 { 45 $config[$captcha_var] = (isset($_REQUEST[$captcha_var])) ? request_var($captcha_var, 0) : $config[$captcha_var]; 71 foreach ($config_vars as $config_var => $options) 72 { 73 set_config($config_var, request_var($config_var, $options['default'])); 74 } 75 76 if ($selected !== $config['captcha_plugin']) 77 { 78 // sanity check 79 if (isset($captchas['available'][$selected])) 80 { 81 $old_captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); 82 $old_captcha->uninstall(); 83 84 set_config('captcha_plugin', $selected); 85 $new_captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); 86 $new_captcha->install(); 87 88 add_log('admin', 'LOG_CONFIG_VISUAL'); 89 } 90 else 91 { 92 trigger_error($user->lang['CAPTCHA_UNAVAILABLE'] . adm_back_link($this->u_action)); 93 } 94 } 95 trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action)); 46 96 } 47 if ($config['captcha_gd'])97 else if ($submit) 48 98 { 49 include($phpbb_root_path . 'includes/captcha/captcha_gd.' . $phpEx);99 trigger_error($user->lang['FORM_INVALID'] . adm_back_link()); 50 100 } 51 101 else 52 102 { 53 include($phpbb_root_path . 'includes/captcha/captcha_non_gd.' . $phpEx); 103 $captcha_select = ''; 104 foreach ($captchas['available'] as $value => $title) 105 { 106 $current = ($selected !== false && $value == $selected) ? ' selected="selected"' : ''; 107 $captcha_select .= '<option value="' . $value . '"' . $current . '>' . $user->lang[$title] . '</option>'; 108 } 109 110 foreach ($captchas['unavailable'] as $value => $title) 111 { 112 $current = ($selected !== false && $value == $selected) ? ' selected="selected"' : ''; 113 $captcha_select .= '<option value="' . $value . '"' . $current . ' class="disabled-option">' . $user->lang[$title] . '</option>'; 114 } 115 116 $demo_captcha =& phpbb_captcha_factory::get_instance($selected); 117 118 foreach ($config_vars as $config_var => $options) 119 { 120 $template->assign_var($options['tpl'], (isset($_POST[$config_var])) ? request_var($config_var, $options['default']) : $config[$config_var]) ; 121 } 122 123 $template->assign_vars(array( 124 'CAPTCHA_PREVIEW_TPL' => $demo_captcha->get_demo_template($id), 125 'S_CAPTCHA_HAS_CONFIG' => $demo_captcha->has_config(), 126 'CAPTCHA_SELECT' => $captcha_select, 127 )); 54 128 } 55 $captcha = new captcha();56 $captcha->execute(gen_rand_string(mt_rand(5, 8)), time());57 exit;58 129 } 130 } 59 131 60 $config_vars = array( 61 'enable_confirm' => 'REG_ENABLE', 62 'enable_post_confirm' => 'POST_ENABLE', 63 'captcha_gd' => 'CAPTCHA_GD', 64 ); 132 /** 133 * Entry point for delivering image CAPTCHAs in the ACP. 134 */ 135 function deliver_demo($selected) 136 { 137 global $db, $user, $config; 65 138 66 $this->tpl_name = 'acp_captcha'; 67 $this->page_title = 'ACP_VC_SETTINGS'; 68 $form_key = 'acp_captcha'; 69 add_form_key($form_key); 139 $captcha =& phpbb_captcha_factory::get_instance($selected); 140 $captcha->init(CONFIRM_REG); 141 $captcha->execute_demo(); 70 142 71 $submit = request_var('submit', ''); 72 73 if ($submit && check_form_key($form_key)) 74 { 75 $config_vars = array_keys($config_vars); 76 foreach ($config_vars as $config_var) 77 { 78 set_config($config_var, request_var($config_var, '')); 79 } 80 $captcha_vars = array_keys($captcha_vars); 81 foreach ($captcha_vars as $captcha_var) 82 { 83 $value = request_var($captcha_var, 0); 84 if ($value >= 0) 85 { 86 set_config($captcha_var, $value); 87 } 88 } 89 trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action)); 90 } 91 else if ($submit) 92 { 93 trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action)); 94 } 95 else 96 { 97 98 $preview_image_src = append_sid(append_sid("{$phpbb_admin_path}index.$phpEx", "i=$id&demo=demo")); 99 if (@extension_loaded('gd')) 100 { 101 $template->assign_var('GD', true); 102 } 103 foreach ($config_vars as $config_var => $template_var) 104 { 105 $template->assign_var($template_var, (isset($_REQUEST[$config_var])) ? request_var($config_var, '') : $config[$config_var]) ; 106 } 107 foreach ($captcha_vars as $captcha_var => $template_var) 108 { 109 $var = (isset($_REQUEST[$captcha_var])) ? request_var($captcha_var, 0) : $config[$captcha_var]; 110 $template->assign_var($template_var, $var); 111 $preview_image_src .= "&$captcha_var=" . $var; 112 } 113 $template->assign_vars(array( 114 'CAPTCHA_PREVIEW' => $preview_image_src, 115 'PREVIEW' => isset($_POST['preview']), 116 )); 117 118 } 143 garbage_collection(); 144 exit_handler(); 119 145 } 120 146 }
Note:
See TracChangeset
for help on using the changeset viewer.