[ Index ] |
PHP Cross Reference of phpBB-3.1.12-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * 4 * This file is part of the phpBB Forum Software package. 5 * 6 * @copyright (c) phpBB Limited <https://www.phpbb.com> 7 * @license GNU General Public License, version 2 (GPL-2.0) 8 * 9 * For full copyright and license information, please see 10 * the docs/CREDITS.txt file. 11 * 12 */ 13 14 /** 15 * @ignore 16 */ 17 if (!defined('IN_PHPBB')) 18 { 19 exit; 20 } 21 22 class acp_captcha 23 { 24 var $u_action; 25 26 function main($id, $mode) 27 { 28 global $request, $user, $auth, $template; 29 global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx, $phpbb_container; 30 31 $user->add_lang('acp/board'); 32 33 $factory = $phpbb_container->get('captcha.factory'); 34 $captchas = $factory->get_captcha_types(); 35 36 $selected = request_var('select_captcha', $config['captcha_plugin']); 37 $selected = (isset($captchas['available'][$selected]) || isset($captchas['unavailable'][$selected])) ? $selected : $config['captcha_plugin']; 38 $configure = request_var('configure', false); 39 40 // Oh, they are just here for the view 41 if (isset($_GET['captcha_demo'])) 42 { 43 $this->deliver_demo($selected); 44 } 45 46 // Delegate 47 if ($configure) 48 { 49 $config_captcha = $factory->get_instance($selected); 50 $config_captcha->acp_page($id, $this); 51 } 52 else 53 { 54 $config_vars = array( 55 'enable_confirm' => array( 56 'tpl' => 'REG_ENABLE', 57 'default' => false, 58 'validate' => 'bool', 59 'lang' => 'VISUAL_CONFIRM_REG', 60 ), 61 'enable_post_confirm' => array( 62 'tpl' => 'POST_ENABLE', 63 'default' => false, 64 'validate' => 'bool', 65 'lang' => 'VISUAL_CONFIRM_POST', 66 ), 67 'confirm_refresh' => array( 68 'tpl' => 'CONFIRM_REFRESH', 69 'default' => false, 70 'validate' => 'bool', 71 'lang' => 'VISUAL_CONFIRM_REFRESH', 72 ), 73 'max_reg_attempts' => array( 74 'tpl' => 'REG_LIMIT', 75 'default' => 0, 76 'validate' => 'int:0:99999', 77 'lang' => 'REG_LIMIT', 78 ), 79 'max_login_attempts' => array( 80 'tpl' => 'MAX_LOGIN_ATTEMPTS', 81 'default' => 0, 82 'validate' => 'int:0:99999', 83 'lang' => 'MAX_LOGIN_ATTEMPTS', 84 ), 85 ); 86 87 $this->tpl_name = 'acp_captcha'; 88 $this->page_title = 'ACP_VC_SETTINGS'; 89 $form_key = 'acp_captcha'; 90 add_form_key($form_key); 91 92 $submit = request_var('main_submit', false); 93 $error = $cfg_array = array(); 94 95 if ($submit) 96 { 97 foreach ($config_vars as $config_var => $options) 98 { 99 $cfg_array[$config_var] = $request->variable($config_var, $options['default']); 100 } 101 validate_config_vars($config_vars, $cfg_array, $error); 102 103 if (!check_form_key($form_key)) 104 { 105 $error[] = $user->lang['FORM_INVALID']; 106 } 107 if ($error) 108 { 109 $submit = false; 110 } 111 } 112 113 if ($submit) 114 { 115 foreach ($cfg_array as $key => $value) 116 { 117 $config->set($key, $value); 118 } 119 120 if ($selected !== $config['captcha_plugin']) 121 { 122 // sanity check 123 if (isset($captchas['available'][$selected])) 124 { 125 $old_captcha = $factory->get_instance($config['captcha_plugin']); 126 $old_captcha->uninstall(); 127 128 set_config('captcha_plugin', $selected); 129 $new_captcha = $factory->get_instance($config['captcha_plugin']); 130 $new_captcha->install(); 131 132 add_log('admin', 'LOG_CONFIG_VISUAL'); 133 } 134 else 135 { 136 trigger_error($user->lang['CAPTCHA_UNAVAILABLE'] . adm_back_link($this->u_action), E_USER_WARNING); 137 } 138 } 139 trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action)); 140 } 141 else 142 { 143 $captcha_select = ''; 144 foreach ($captchas['available'] as $value => $title) 145 { 146 $current = ($selected !== false && $value == $selected) ? ' selected="selected"' : ''; 147 $captcha_select .= '<option value="' . $value . '"' . $current . '>' . $user->lang($title) . '</option>'; 148 } 149 150 foreach ($captchas['unavailable'] as $value => $title) 151 { 152 $current = ($selected !== false && $value == $selected) ? ' selected="selected"' : ''; 153 $captcha_select .= '<option value="' . $value . '"' . $current . ' class="disabled-option">' . $user->lang($title) . '</option>'; 154 } 155 156 $demo_captcha = $factory->get_instance($selected); 157 158 foreach ($config_vars as $config_var => $options) 159 { 160 $template->assign_var($options['tpl'], (isset($_POST[$config_var])) ? request_var($config_var, $options['default']) : $config[$config_var]) ; 161 } 162 163 $template->assign_vars(array( 164 'CAPTCHA_PREVIEW_TPL' => $demo_captcha->get_demo_template($id), 165 'S_CAPTCHA_HAS_CONFIG' => $demo_captcha->has_config(), 166 'CAPTCHA_SELECT' => $captcha_select, 167 'ERROR_MSG' => implode('<br />', $error), 168 169 'U_ACTION' => $this->u_action, 170 )); 171 } 172 } 173 } 174 175 /** 176 * Entry point for delivering image CAPTCHAs in the ACP. 177 */ 178 function deliver_demo($selected) 179 { 180 global $db, $user, $config, $phpbb_container; 181 182 $captcha = $phpbb_container->get('captcha.factory')->get_instance($selected); 183 $captcha->init(CONFIRM_REG); 184 $captcha->execute_demo(); 185 186 garbage_collection(); 187 exit_handler(); 188 } 189 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Jan 11 00:25:41 2018 | Cross-referenced by PHPXref 0.7.1 |