source: trunk/forum/includes/acp/acp_captcha.php

Last change on this file was 702, checked in by george, 15 years ago
  • Upraveno: Aktualizace fóra.
File size: 4.0 KB
RevLine 
[400]1<?php
2/**
3*
4* @package acp
[702]5* @version $Id$
[400]6* @copyright (c) 2005 phpBB Group
7* @license http://opensource.org/licenses/gpl-license.php GNU Public License
8*/
9
10/**
11* @ignore
12*/
13if (!defined('IN_PHPBB'))
14{
15 exit;
16}
17
18/**
19* @package acp
20*/
21class acp_captcha
22{
23 var $u_action;
24
25 function main($id, $mode)
26 {
27 global $db, $user, $auth, $template;
28 global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
29
30 $user->add_lang('acp/board');
31
[702]32 include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx);
33 $captchas = phpbb_captcha_factory::get_captcha_types();
[400]34
[702]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);
[400]38
[702]39
40 // Oh, they are just here for the view
41 if (isset($_GET['captcha_demo']))
[400]42 {
[702]43 $this->deliver_demo($selected);
[400]44 }
45
[702]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 );
[400]61
[702]62 $this->tpl_name = 'acp_captcha';
63 $this->page_title = 'ACP_VC_SETTINGS';
64 $form_key = 'acp_captcha';
65 add_form_key($form_key);
[400]66
[702]67 $submit = request_var('main_submit', false);
[400]68
[702]69 if ($submit && check_form_key($form_key))
[400]70 {
[702]71 foreach ($config_vars as $config_var => $options)
[400]72 {
[702]73 set_config($config_var, request_var($config_var, $options['default']));
[400]74 }
75
[702]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));
[400]96 }
[702]97 else if ($submit)
[400]98 {
[702]99 trigger_error($user->lang['FORM_INVALID'] . adm_back_link());
[400]100 }
[702]101 else
[400]102 {
[702]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 ));
[400]128 }
129 }
130 }
[702]131
132 /**
133 * Entry point for delivering image CAPTCHAs in the ACP.
134 */
135 function deliver_demo($selected)
136 {
137 global $db, $user, $config;
138
139 $captcha =& phpbb_captcha_factory::get_instance($selected);
140 $captcha->init(CONFIRM_REG);
141 $captcha->execute_demo();
142
143 garbage_collection();
144 exit_handler();
145 }
[400]146}
147
148?>
Note: See TracBrowser for help on using the repository browser.