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

