1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category modules
|
5
|
* @package captcha_control
|
6
|
* @author WebsiteBaker Project
|
7
|
* @copyright 2009-2011, Website Baker Org. e.V.
|
8
|
* @link http://www.websitebaker2.org/
|
9
|
* @license http://www.gnu.org/licenses/gpl.html
|
10
|
* @platform WebsiteBaker 2.8.x
|
11
|
* @requirements PHP 5.2.2 and higher
|
12
|
* @version $Id: tool.php 1536 2011-12-10 04:22:29Z Luisehahne $
|
13
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/tags/2.8.3/wb/modules/captcha_control/tool.php $
|
14
|
* @lastmodified $Date: 2011-12-10 05:22:29 +0100 (Sat, 10 Dec 2011) $
|
15
|
*
|
16
|
*/
|
17
|
|
18
|
// prevent this file from being accessed directly
|
19
|
/* -------------------------------------------------------- */
|
20
|
if(defined('WB_PATH') == false)
|
21
|
{
|
22
|
// Stop this file being access directly
|
23
|
die('<head><title>Access denied</title></head><body><h2 style="color:red;margin:3em auto;text-align:center;">Cannot access this file directly</h2></body></html>');
|
24
|
}
|
25
|
/* -------------------------------------------------------- */
|
26
|
|
27
|
// check if module language file exists for the language set by the user (e.g. DE, EN)
|
28
|
if(!file_exists(WB_PATH .'/modules/captcha_control/languages/'.LANGUAGE .'.php')) {
|
29
|
// no module language file exists for the language set by the user, include default module language file EN.php
|
30
|
require_once(WB_PATH .'/modules/captcha_control/languages/EN.php');
|
31
|
} else {
|
32
|
// a module language file exists for the language defined by the user, load it
|
33
|
require_once(WB_PATH .'/modules/captcha_control/languages/'.LANGUAGE .'.php');
|
34
|
}
|
35
|
|
36
|
$table = TABLE_PREFIX.'mod_captcha_control';
|
37
|
$js_back = ADMIN_URL.'/admintools/tool.php?tool=captcha_control';
|
38
|
|
39
|
// check if data was submitted
|
40
|
if(isset($_POST['save_settings'])) {
|
41
|
if (!$admin->checkFTAN())
|
42
|
{
|
43
|
if(!$admin_header) { $admin->print_header(); }
|
44
|
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], $js_back );
|
45
|
}
|
46
|
|
47
|
// get configuration settings
|
48
|
$enabled_captcha = ($_POST['enabled_captcha'] == '1') ? '1' : '0';
|
49
|
$enabled_asp = ($_POST['enabled_asp'] == '1') ? '1' : '0';
|
50
|
$captcha_type = $admin->add_slashes($_POST['captcha_type']);
|
51
|
|
52
|
// update database settings
|
53
|
$database->query("UPDATE $table SET
|
54
|
enabled_captcha = '$enabled_captcha',
|
55
|
enabled_asp = '$enabled_asp',
|
56
|
captcha_type = '$captcha_type'
|
57
|
");
|
58
|
|
59
|
// save text-captchas
|
60
|
if($captcha_type == 'text') { // ct_text
|
61
|
$text_qa=$admin->add_slashes($_POST['text_qa']);
|
62
|
if(!preg_match('/### .*? ###/', $text_qa)) {
|
63
|
$database->query("UPDATE $table SET ct_text = '$text_qa'");
|
64
|
}
|
65
|
}
|
66
|
|
67
|
// check if there is a database error, otherwise say successful
|
68
|
if(!$admin_header) { $admin->print_header(); }
|
69
|
if($database->is_error()) {
|
70
|
$admin->print_error($database->get_error(), $js_back);
|
71
|
} else {
|
72
|
$admin->print_success($MESSAGE['PAGES']['SAVED'], $js_back);
|
73
|
}
|
74
|
|
75
|
} else {
|
76
|
}
|
77
|
|
78
|
// include captcha-file
|
79
|
require_once(WB_PATH .'/include/captcha/captcha.php');
|
80
|
|
81
|
// load text-captchas
|
82
|
$text_qa='';
|
83
|
if($query = $database->query("SELECT ct_text FROM $table")) {
|
84
|
$data = $query->fetchRow();
|
85
|
$text_qa = $data['ct_text'];
|
86
|
}
|
87
|
if($text_qa == '')
|
88
|
$text_qa = $MOD_CAPTCHA_CONTROL['CAPTCHA_TEXT_DESC'];
|
89
|
|
90
|
// script to load image
|
91
|
?>
|
92
|
<script type="text/javascript">
|
93
|
var pics = new Array();
|
94
|
|
95
|
pics["ttf_image"] = new Image();
|
96
|
pics["ttf_image"].src = "<?php echo WB_URL.'/include/captcha/captchas/ttf_image.png'?>";
|
97
|
|
98
|
pics["calc_image"] = new Image();
|
99
|
pics["calc_image"].src = "<?php echo WB_URL.'/include/captcha/captchas/calc_image.png'?>";
|
100
|
|
101
|
pics["calc_ttf_image"] = new Image();
|
102
|
pics["calc_ttf_image"].src = "<?php echo WB_URL.'/include/captcha/captchas/calc_ttf_image.png'?>";
|
103
|
|
104
|
pics["old_image"] = new Image();
|
105
|
pics["old_image"].src = "<?php echo WB_URL.'/include/captcha/captchas/old_image.png'?>";
|
106
|
|
107
|
pics["calc_text"] = new Image();
|
108
|
pics["calc_text"].src = "<?php echo WB_URL.'/include/captcha/captchas/calc_text.png'?>";
|
109
|
|
110
|
pics["text"] = new Image();
|
111
|
pics["text"].src = "<?php echo WB_URL.'/include/captcha/captchas/text.png'?>";
|
112
|
|
113
|
function load_captcha_image() {
|
114
|
document.captcha_example.src = pics[document.store_settings.captcha_type.value].src;
|
115
|
toggle_text_qa();
|
116
|
}
|
117
|
|
118
|
function toggle_text_qa() {
|
119
|
if(document.store_settings.captcha_type.value == 'text' ) {
|
120
|
document.getElementById('text_qa').style.display = '';
|
121
|
} else {
|
122
|
document.getElementById('text_qa').style.display = 'none';
|
123
|
}
|
124
|
}
|
125
|
|
126
|
</script>
|
127
|
<?php
|
128
|
|
129
|
// connect to database and read out captcha settings
|
130
|
if($query = $database->query("SELECT * FROM $table")) {
|
131
|
$data = $query->fetchRow();
|
132
|
$enabled_captcha = $data['enabled_captcha'];
|
133
|
$enabled_asp = $data['enabled_asp'];
|
134
|
$captcha_type = $data['captcha_type'];
|
135
|
} else {
|
136
|
// something went wrong, use dummy value
|
137
|
$enabled_captcha = '1';
|
138
|
$enabled_asp = '1';
|
139
|
$captcha_type = 'calc_text';
|
140
|
}
|
141
|
|
142
|
// write out heading
|
143
|
echo '<h2>' .$MOD_CAPTCHA_CONTROL['HEADING'] .'</h2>';
|
144
|
|
145
|
// output the form with values from the database
|
146
|
echo '<p>' .$MOD_CAPTCHA_CONTROL['HOWTO'] .'</p>';
|
147
|
?>
|
148
|
<form name="store_settings" action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
|
149
|
<?php echo $admin->getFTAN(); ?>
|
150
|
<table width="98%" cellspacing="0" border="0" cellpadding="5px" class="row_a">
|
151
|
<tr><td colspan="2"><strong><?php echo $MOD_CAPTCHA_CONTROL['CAPTCHA_CONF'];?>:</strong></td></tr>
|
152
|
<tr>
|
153
|
<td width="30%"><?php echo $MOD_CAPTCHA_CONTROL['CAPTCHA_TYPE'];?>:</td>
|
154
|
<td>
|
155
|
<select name="captcha_type" id="captcha_type" onchange="load_captcha_image()" style="width: 98%;">
|
156
|
<?php foreach($useable_captchas AS $key=>$text) {
|
157
|
echo "<option value=\"$key\" ".($captcha_type==$key ? ' selected="selected"' : '').">$text</option>";
|
158
|
} ?>
|
159
|
</select>
|
160
|
</td>
|
161
|
</tr>
|
162
|
<tr>
|
163
|
<td> </td>
|
164
|
<td align="left" width="150px">
|
165
|
<img alt="captcha_example" id="captcha_example" src="<?php echo WB_URL.'/include/captcha/captchas/'.$captcha_type.'.png'?>" />
|
166
|
</td>
|
167
|
</tr>
|
168
|
<tr id="text_qa" style="display:<?php if($captcha_type=='text') echo ''; else echo 'none'; ;?>;">
|
169
|
<td valign="top" class="setting_name"><?php echo $MOD_CAPTCHA_CONTROL['CAPTCHA_ENTER_TEXT'];?>:</td>
|
170
|
<td class="setting_value" colspan="2">
|
171
|
<textarea name="text_qa" cols="60" rows="10"><?php echo $text_qa; ?></textarea>
|
172
|
</td>
|
173
|
</tr>
|
174
|
<tr>
|
175
|
<td><?php echo $MOD_CAPTCHA_CONTROL['USE_SIGNUP_CAPTCHA'];?>:</td>
|
176
|
<td>
|
177
|
<input type="radio" <?php echo ($enabled_captcha=='1') ?'checked="checked"' :'';?>
|
178
|
name="enabled_captcha" value="1" /><?php echo $MOD_CAPTCHA_CONTROL['ENABLED'];?>
|
179
|
<input type="radio" <?php echo ($enabled_captcha=='0') ?'checked="checked"' :'';?>
|
180
|
name="enabled_captcha" value="0" /><?php echo $MOD_CAPTCHA_CONTROL['DISABLED'];?>
|
181
|
</td>
|
182
|
</tr>
|
183
|
<tr><td> </td><td style="font-size:smaller;"><?php echo $MOD_CAPTCHA_CONTROL['CAPTCHA_EXP'];?></td></tr>
|
184
|
<tr><td colspan="2"><br /><strong><?php echo $MOD_CAPTCHA_CONTROL['ASP_CONF'];?>:</strong></td></tr>
|
185
|
<tr>
|
186
|
<td><?php echo $MOD_CAPTCHA_CONTROL['ASP_TEXT'];?>:</td>
|
187
|
<td>
|
188
|
<input type="radio" <?php echo ($enabled_asp=='1') ?'checked="checked"' :'';?>
|
189
|
name="enabled_asp" value="1" /><?php echo $MOD_CAPTCHA_CONTROL['ENABLED'];?>
|
190
|
<input type="radio" <?php echo ($enabled_asp=='0') ?'checked="checked"' :'';?>
|
191
|
name="enabled_asp" value="0" /><?php echo $MOD_CAPTCHA_CONTROL['DISABLED'];?>
|
192
|
</td>
|
193
|
</tr>
|
194
|
<tr>
|
195
|
<td> </td>
|
196
|
<td style="font-size:smaller;"><?php echo $MOD_CAPTCHA_CONTROL['ASP_EXP'];?></td>
|
197
|
</tr>
|
198
|
</table>
|
199
|
<input type="submit" name="save_settings" style="margin-top:10px; width:140px;" value="<?php echo $TEXT['SAVE']; ?>" />
|
200
|
</form>
|