1 |
596
|
thorn
|
<?php
|
2 |
|
|
|
3 |
|
|
// $Id$
|
4 |
|
|
|
5 |
|
|
/*
|
6 |
|
|
|
7 |
|
|
Website Baker Project <http://www.websitebaker.org/>
|
8 |
915
|
Ruebenwurz
|
Copyright (C) 2004-2009, Ryan Djurovich
|
9 |
596
|
thorn
|
|
10 |
|
|
Website Baker is free software; you can redistribute it and/or modify
|
11 |
|
|
it under the terms of the GNU General Public License as published by
|
12 |
|
|
the Free Software Foundation; either version 2 of the License, or
|
13 |
|
|
(at your option) any later version.
|
14 |
|
|
|
15 |
|
|
Website Baker is distributed in the hope that it will be useful,
|
16 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
|
|
GNU General Public License for more details.
|
19 |
|
|
|
20 |
|
|
You should have received a copy of the GNU General Public License
|
21 |
|
|
along with Website Baker; if not, write to the Free Software
|
22 |
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
23 |
|
|
|
24 |
|
|
*/
|
25 |
|
|
|
26 |
858
|
thorn
|
// displays the image or text inside an <iframe>
|
27 |
1371
|
Luisehahne
|
if(!function_exists('display_captcha_real')) {
|
28 |
|
|
function display_captcha_real($kind='image') {
|
29 |
|
|
$t = time();
|
30 |
|
|
$_SESSION['captcha_time'] = $t;
|
31 |
|
|
$sec_id = '';
|
32 |
|
|
if(isset($_GET['s']) && is_numeric($_GET['s'])) $sec_id = $_GET['s'];
|
33 |
|
|
if($kind=='image') {
|
34 |
|
|
?><a title="reload" href="<?php echo WB_URL.'/include/captcha/captcha.php?display_captcha_X986E21=2'; ?>">
|
35 |
|
|
<img style="border: none;" src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t&s=$sec_id"; ?>" alt="Captcha" />
|
36 |
|
|
</a><?php
|
37 |
|
|
} else {
|
38 |
|
|
echo 'error';
|
39 |
|
|
}
|
40 |
858
|
thorn
|
}
|
41 |
|
|
}
|
42 |
|
|
|
43 |
|
|
// called from an <iframe>
|
44 |
|
|
if(isset($_GET['display_captcha_X986E21'])) {
|
45 |
|
|
require('../../config.php');
|
46 |
|
|
switch(CAPTCHA_TYPE) {
|
47 |
|
|
case 'calc_image':
|
48 |
|
|
case 'calc_ttf_image':
|
49 |
|
|
case 'ttf_image':
|
50 |
|
|
case 'old_image':
|
51 |
|
|
display_captcha_real('image');
|
52 |
|
|
break;
|
53 |
|
|
}
|
54 |
|
|
exit(0);
|
55 |
|
|
}
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
// Make sure page cannot be accessed directly
|
59 |
596
|
thorn
|
if(!defined('WB_PATH')) { exit("Cannot access this file directly"); }
|
60 |
|
|
|
61 |
|
|
// check if module language file exists for the language set by the user (e.g. DE, EN)
|
62 |
|
|
global $MOD_CAPTCHA;
|
63 |
|
|
if(!file_exists(WB_PATH.'/modules/captcha_control/languages/'.LANGUAGE .'.php')) {
|
64 |
|
|
// no module language file exists for the language set by the user, include default module language file EN.php
|
65 |
|
|
require_once(WB_PATH.'/modules/captcha_control/languages/EN.php');
|
66 |
|
|
} else {
|
67 |
|
|
// a module language file exists for the language defined by the user, load it
|
68 |
|
|
require_once(WB_PATH.'/modules/captcha_control/languages/'.LANGUAGE .'.php');
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
// output-handler for image-captchas to determine size of image
|
72 |
|
|
if(!function_exists('captcha_header')) {
|
73 |
|
|
function captcha_header() {
|
74 |
|
|
header("Expires: Mon, 1 Jan 1990 05:00:00 GMT");
|
75 |
|
|
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
76 |
|
|
header("Cache-Control: no-store, no-cache, must-revalidate, proxy-revalidate");
|
77 |
|
|
header("Pragma: no-cache");
|
78 |
|
|
header("Content-type: image/png");
|
79 |
|
|
return;
|
80 |
|
|
}
|
81 |
|
|
}
|
82 |
|
|
|
83 |
|
|
// get list of available CAPTCHAS for the dropdown-listbox in admin-tools
|
84 |
|
|
if(extension_loaded('gd') && function_exists('imagepng') && function_exists('imagettftext')) {
|
85 |
|
|
$useable_captchas = array(
|
86 |
|
|
'calc_text'=>$MOD_CAPTCHA_CONTROL['CALC_TEXT'],
|
87 |
|
|
'calc_image'=>$MOD_CAPTCHA_CONTROL['CALC_IMAGE'],
|
88 |
615
|
thorn
|
'calc_ttf_image'=>$MOD_CAPTCHA_CONTROL['CALC_TTF_IMAGE'],
|
89 |
596
|
thorn
|
'ttf_image'=>$MOD_CAPTCHA_CONTROL['TTF_IMAGE'],
|
90 |
624
|
thorn
|
'old_image'=>$MOD_CAPTCHA_CONTROL['OLD_IMAGE'],
|
91 |
|
|
'text'=>$MOD_CAPTCHA_CONTROL['TEXT']
|
92 |
596
|
thorn
|
);
|
93 |
|
|
} elseif(extension_loaded('gd') && function_exists('imagepng')) {
|
94 |
|
|
$useable_captchas = array(
|
95 |
|
|
'calc_text'=>$MOD_CAPTCHA_CONTROL['CALC_TEXT'],
|
96 |
|
|
'calc_image'=>$MOD_CAPTCHA_CONTROL['CALC_IMAGE'],
|
97 |
624
|
thorn
|
'old_image'=>$MOD_CAPTCHA_CONTROL['OLD_IMAGE'],
|
98 |
|
|
'text'=>$MOD_CAPTCHA_CONTROL['TEXT']
|
99 |
596
|
thorn
|
);
|
100 |
|
|
} else {
|
101 |
|
|
$useable_captchas = array(
|
102 |
624
|
thorn
|
'calc_text'=>$MOD_CAPTCHA_CONTROL['CALC_TEXT'],
|
103 |
|
|
'text'=>$MOD_CAPTCHA_CONTROL['TEXT']
|
104 |
596
|
thorn
|
);
|
105 |
|
|
}
|
106 |
|
|
|
107 |
|
|
if(!function_exists('call_captcha')) {
|
108 |
1371
|
Luisehahne
|
function call_captcha($action='all', $style='', $sec_id='') {
|
109 |
596
|
thorn
|
global $MOD_CAPTCHA;
|
110 |
609
|
thorn
|
$t = time();
|
111 |
|
|
$_SESSION['captcha_time'] = $t;
|
112 |
858
|
thorn
|
|
113 |
867
|
thorn
|
// get width and height of captcha image for use in <iframe>
|
114 |
858
|
thorn
|
switch(CAPTCHA_TYPE) {
|
115 |
|
|
case 'calc_image':
|
116 |
|
|
$captcha_width = 142;
|
117 |
|
|
$captcha_height = 30;
|
118 |
|
|
break;
|
119 |
|
|
case 'calc_ttf_image':
|
120 |
|
|
$captcha_width = 162;
|
121 |
|
|
$captcha_height = 40;
|
122 |
|
|
break;
|
123 |
|
|
case 'ttf_image':
|
124 |
|
|
$captcha_width = 162;
|
125 |
|
|
$captcha_height = 40;
|
126 |
|
|
break;
|
127 |
|
|
case 'old_image':
|
128 |
|
|
$captcha_width = 142;
|
129 |
|
|
$captcha_height = 30;
|
130 |
|
|
break;
|
131 |
|
|
default:
|
132 |
|
|
$captcha_width = 250;
|
133 |
|
|
$captcha_height = 100;
|
134 |
|
|
}
|
135 |
|
|
|
136 |
747
|
thorn
|
if($action=='all') {
|
137 |
|
|
switch(CAPTCHA_TYPE) {
|
138 |
867
|
thorn
|
case 'text': // text-captcha
|
139 |
747
|
thorn
|
?><table class="captcha_table"><tr>
|
140 |
858
|
thorn
|
<td class="text_captcha">
|
141 |
|
|
<?php include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php'); ?>
|
142 |
|
|
</td>
|
143 |
|
|
<td></td>
|
144 |
756
|
thorn
|
<td><input type="text" name="captcha" maxlength="50" style="width:150px;" /></td>
|
145 |
747
|
thorn
|
<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_QUEST']; ?></td>
|
146 |
|
|
</tr></table><?php
|
147 |
|
|
break;
|
148 |
|
|
case 'calc_text': // calculation as text
|
149 |
|
|
?><table class="captcha_table"><tr>
|
150 |
858
|
thorn
|
<td class="text_captcha">
|
151 |
|
|
<?php include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php'); ?>
|
152 |
|
|
</td>
|
153 |
|
|
<td> = </td>
|
154 |
756
|
thorn
|
<td><input type="text" name="captcha" maxlength="10" style="width:20px;" /></td>
|
155 |
747
|
thorn
|
<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_RES']; ?></td>
|
156 |
|
|
</tr></table><?php
|
157 |
|
|
break;
|
158 |
|
|
case 'calc_image': // calculation with image (old captcha)
|
159 |
|
|
case 'calc_ttf_image': // calculation with varying background and ttf-font
|
160 |
858
|
thorn
|
?><table class="captcha_table"><tr>
|
161 |
|
|
<td class="image_captcha">
|
162 |
1371
|
Luisehahne
|
<?php echo "<iframe class=\"captcha_iframe\" width=\"$captcha_width\" height=\"$captcha_height\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" frameborder=\"0\" name=\"captcha_iframe_$sec_id\" src=\"". WB_URL ."/include/captcha/captcha.php?display_captcha_X986E21=1&s=$sec_id"; ?>">
|
163 |
|
|
<img src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t&s=$sec_id"; ?>" alt="Captcha" />
|
164 |
858
|
thorn
|
</iframe>
|
165 |
|
|
</td>
|
166 |
|
|
<td> = </td>
|
167 |
756
|
thorn
|
<td><input type="text" name="captcha" maxlength="10" style="width:20px;" /></td>
|
168 |
747
|
thorn
|
<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_RES']; ?></td>
|
169 |
|
|
</tr></table><?php
|
170 |
|
|
break;
|
171 |
|
|
// normal images
|
172 |
|
|
case 'ttf_image': // captcha with varying background and ttf-font
|
173 |
|
|
case 'old_image': // old captcha
|
174 |
|
|
?><table class="captcha_table"><tr>
|
175 |
858
|
thorn
|
<td class="image_captcha">
|
176 |
1371
|
Luisehahne
|
<?php echo "<iframe class=\"captcha_iframe\" width=\"$captcha_width\" height=\"$captcha_height\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" frameborder=\"0\" name=\"captcha_iframe_$sec_id\" src=\"". WB_URL ."/include/captcha/captcha.php?display_captcha_X986E21=1&s=$sec_id"; ?>">
|
177 |
|
|
<img src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t&s=$sec_id"; ?>" alt="Captcha" />
|
178 |
858
|
thorn
|
</iframe>
|
179 |
|
|
</td>
|
180 |
|
|
<td></td>
|
181 |
756
|
thorn
|
<td><input type="text" name="captcha" maxlength="10" style="width:50px;" /></td>
|
182 |
747
|
thorn
|
<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_TEXT']; ?></td>
|
183 |
|
|
</tr></table><?php
|
184 |
|
|
break;
|
185 |
|
|
}
|
186 |
|
|
} elseif($action=='image') {
|
187 |
|
|
switch(CAPTCHA_TYPE) {
|
188 |
|
|
case 'text': // text-captcha
|
189 |
|
|
case 'calc_text': // calculation as text
|
190 |
756
|
thorn
|
echo ($style?"<span $style>":'');
|
191 |
747
|
thorn
|
include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php');
|
192 |
756
|
thorn
|
echo ($style?'</span>':'');
|
193 |
747
|
thorn
|
break;
|
194 |
|
|
case 'calc_image': // calculation with image (old captcha)
|
195 |
|
|
case 'calc_ttf_image': // calculation with varying background and ttf-font
|
196 |
|
|
case 'ttf_image': // captcha with varying background and ttf-font
|
197 |
|
|
case 'old_image': // old captcha
|
198 |
1371
|
Luisehahne
|
echo "<img $style src=\"".WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t&s=$sec_id\" />";
|
199 |
747
|
thorn
|
break;
|
200 |
|
|
}
|
201 |
858
|
thorn
|
} elseif($action=='image_iframe') {
|
202 |
|
|
switch(CAPTCHA_TYPE) {
|
203 |
|
|
case 'text': // text-captcha
|
204 |
|
|
echo ($style?"<span $style>":'');
|
205 |
|
|
include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php');
|
206 |
|
|
echo ($style?'</span>':'');
|
207 |
|
|
break;
|
208 |
|
|
case 'calc_text': // calculation as text
|
209 |
|
|
include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php');
|
210 |
|
|
break;
|
211 |
|
|
case 'calc_image': // calculation with image (old captcha)
|
212 |
|
|
case 'calc_ttf_image': // calculation with varying background and ttf-font
|
213 |
|
|
case 'ttf_image': // captcha with varying background and ttf-font
|
214 |
|
|
case 'old_image': // old captcha
|
215 |
1371
|
Luisehahne
|
?>
|
216 |
|
|
<?php echo "<iframe class=\"captcha_iframe\" width=\"$captcha_width\" height=\"$captcha_height\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" frameborder=\"0\" name=\"captcha_iframe_$sec_id\" src=\"". WB_URL ."/include/captcha/captcha.php?display_captcha_X986E21=1&s=$sec_id"; ?>">
|
217 |
|
|
<?php
|
218 |
858
|
thorn
|
echo "<img $style alt=\"Captcha\" src=\"".WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t\" />";
|
219 |
|
|
?></iframe><?php
|
220 |
|
|
break;
|
221 |
|
|
}
|
222 |
747
|
thorn
|
} elseif($action=='input') {
|
223 |
|
|
switch(CAPTCHA_TYPE) {
|
224 |
|
|
case 'text': // text-captcha
|
225 |
756
|
thorn
|
echo '<input type="text" name="captcha" '.($style?$style:'style="width:150px;" maxlength="50"').' />';
|
226 |
747
|
thorn
|
break;
|
227 |
|
|
case 'calc_text': // calculation as text
|
228 |
|
|
case 'calc_image': // calculation with image (old captcha)
|
229 |
|
|
case 'calc_ttf_image': // calculation with varying background and ttf-font
|
230 |
756
|
thorn
|
echo '<input type="text" name="captcha" '.($style?$style:'style="width:20px;" maxlength="10"').' />';
|
231 |
747
|
thorn
|
break;
|
232 |
|
|
case 'ttf_image': // captcha with varying background and ttf-font
|
233 |
|
|
case 'old_image': // old captcha
|
234 |
756
|
thorn
|
echo '<input type="text" name="captcha" '.($style?$style:'style="width:50px;" maxlength="10"').' />';
|
235 |
747
|
thorn
|
break;
|
236 |
|
|
}
|
237 |
|
|
} elseif($action=='text') {
|
238 |
756
|
thorn
|
echo ($style?"<span $style>":'');
|
239 |
747
|
thorn
|
switch(CAPTCHA_TYPE) {
|
240 |
|
|
case 'text': // text-captcha
|
241 |
|
|
echo $MOD_CAPTCHA['VERIFICATION_INFO_QUEST'];
|
242 |
|
|
break;
|
243 |
|
|
case 'calc_text': // calculation as text
|
244 |
|
|
case 'calc_image': // calculation with image (old captcha)
|
245 |
|
|
case 'calc_ttf_image': // calculation with varying background and ttf-font
|
246 |
|
|
echo $MOD_CAPTCHA['VERIFICATION_INFO_RES'];
|
247 |
|
|
break;
|
248 |
|
|
case 'ttf_image': // captcha with varying background and ttf-font
|
249 |
|
|
case 'old_image': // old captcha
|
250 |
|
|
echo $MOD_CAPTCHA['VERIFICATION_INFO_TEXT'];
|
251 |
|
|
break;
|
252 |
|
|
}
|
253 |
756
|
thorn
|
echo ($style?'</span>':'');
|
254 |
596
|
thorn
|
}
|
255 |
|
|
}
|
256 |
|
|
}
|