1 |
596
|
thorn
|
<?php
|
2 |
|
|
|
3 |
|
|
// $Id$
|
4 |
|
|
|
5 |
|
|
/*
|
6 |
|
|
|
7 |
|
|
Website Baker Project <http://www.websitebaker.org/>
|
8 |
|
|
Copyright (C) 2004-2008, Ryan Djurovich
|
9 |
|
|
|
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 |
|
|
function display_captcha_real($kind='image') {
|
28 |
|
|
$t = time();
|
29 |
|
|
$_SESSION['captcha_time'] = $t;
|
30 |
|
|
if($kind=='image') {
|
31 |
|
|
?><a title="reload" href="<?php echo WB_URL.'/include/captcha/captcha.php?display_captcha_X986E21=2'; ?>">
|
32 |
|
|
<img style="border: none;" src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t"; ?>" alt="Captcha" />
|
33 |
|
|
</a><?php
|
34 |
|
|
} elseif($kind=='text') {
|
35 |
|
|
?><a style="text-decoration:none;" title="reload" href="<?php echo WB_URL.'/include/captcha/captcha.php?display_captcha_X986E21=2'; ?>"><?php
|
36 |
|
|
include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php');
|
37 |
|
|
?></a><?php
|
38 |
|
|
} else {
|
39 |
|
|
echo 'error';
|
40 |
|
|
}
|
41 |
|
|
}
|
42 |
|
|
|
43 |
|
|
// called from an <iframe>
|
44 |
|
|
if(isset($_GET['display_captcha_X986E21'])) {
|
45 |
|
|
require('../../config.php');
|
46 |
|
|
switch(CAPTCHA_TYPE) {
|
47 |
|
|
case 'text':
|
48 |
|
|
case 'calc_text':
|
49 |
|
|
display_captcha_real('text');
|
50 |
|
|
break;
|
51 |
|
|
case 'calc_image':
|
52 |
|
|
case 'calc_ttf_image':
|
53 |
|
|
case 'ttf_image':
|
54 |
|
|
case 'old_image':
|
55 |
|
|
display_captcha_real('image');
|
56 |
|
|
break;
|
57 |
|
|
}
|
58 |
|
|
exit(0);
|
59 |
|
|
}
|
60 |
|
|
|
61 |
|
|
|
62 |
|
|
// Make sure page cannot be accessed directly
|
63 |
596
|
thorn
|
if(!defined('WB_PATH')) { exit("Cannot access this file directly"); }
|
64 |
|
|
|
65 |
|
|
// check if module language file exists for the language set by the user (e.g. DE, EN)
|
66 |
|
|
global $MOD_CAPTCHA;
|
67 |
|
|
if(!file_exists(WB_PATH.'/modules/captcha_control/languages/'.LANGUAGE .'.php')) {
|
68 |
|
|
// no module language file exists for the language set by the user, include default module language file EN.php
|
69 |
|
|
require_once(WB_PATH.'/modules/captcha_control/languages/EN.php');
|
70 |
|
|
} else {
|
71 |
|
|
// a module language file exists for the language defined by the user, load it
|
72 |
|
|
require_once(WB_PATH.'/modules/captcha_control/languages/'.LANGUAGE .'.php');
|
73 |
|
|
}
|
74 |
|
|
|
75 |
|
|
// output-handler for image-captchas to determine size of image
|
76 |
|
|
if(!function_exists('captcha_header')) {
|
77 |
|
|
function captcha_header() {
|
78 |
|
|
header("Expires: Mon, 1 Jan 1990 05:00:00 GMT");
|
79 |
|
|
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
80 |
|
|
header("Cache-Control: no-store, no-cache, must-revalidate, proxy-revalidate");
|
81 |
|
|
header("Cache-Control: post-check=0, pre-check=0", false); // MS made there own headers :-(
|
82 |
|
|
header("Pragma: no-cache");
|
83 |
|
|
header("Content-type: image/png");
|
84 |
|
|
return;
|
85 |
|
|
}
|
86 |
|
|
}
|
87 |
|
|
|
88 |
|
|
// get list of available CAPTCHAS for the dropdown-listbox in admin-tools
|
89 |
|
|
if(extension_loaded('gd') && function_exists('imagepng') && function_exists('imagettftext')) {
|
90 |
|
|
$useable_captchas = array(
|
91 |
|
|
'calc_text'=>$MOD_CAPTCHA_CONTROL['CALC_TEXT'],
|
92 |
|
|
'calc_image'=>$MOD_CAPTCHA_CONTROL['CALC_IMAGE'],
|
93 |
615
|
thorn
|
'calc_ttf_image'=>$MOD_CAPTCHA_CONTROL['CALC_TTF_IMAGE'],
|
94 |
596
|
thorn
|
'ttf_image'=>$MOD_CAPTCHA_CONTROL['TTF_IMAGE'],
|
95 |
624
|
thorn
|
'old_image'=>$MOD_CAPTCHA_CONTROL['OLD_IMAGE'],
|
96 |
|
|
'text'=>$MOD_CAPTCHA_CONTROL['TEXT']
|
97 |
596
|
thorn
|
);
|
98 |
|
|
} elseif(extension_loaded('gd') && function_exists('imagepng')) {
|
99 |
|
|
$useable_captchas = array(
|
100 |
|
|
'calc_text'=>$MOD_CAPTCHA_CONTROL['CALC_TEXT'],
|
101 |
|
|
'calc_image'=>$MOD_CAPTCHA_CONTROL['CALC_IMAGE'],
|
102 |
624
|
thorn
|
'old_image'=>$MOD_CAPTCHA_CONTROL['OLD_IMAGE'],
|
103 |
|
|
'text'=>$MOD_CAPTCHA_CONTROL['TEXT']
|
104 |
596
|
thorn
|
);
|
105 |
|
|
} else {
|
106 |
|
|
$useable_captchas = array(
|
107 |
624
|
thorn
|
'calc_text'=>$MOD_CAPTCHA_CONTROL['CALC_TEXT'],
|
108 |
|
|
'text'=>$MOD_CAPTCHA_CONTROL['TEXT']
|
109 |
596
|
thorn
|
);
|
110 |
|
|
}
|
111 |
|
|
|
112 |
|
|
if(!function_exists('call_captcha')) {
|
113 |
756
|
thorn
|
function call_captcha($action='all', $style='') {
|
114 |
596
|
thorn
|
global $MOD_CAPTCHA;
|
115 |
609
|
thorn
|
$t = time();
|
116 |
|
|
$_SESSION['captcha_time'] = $t;
|
117 |
858
|
thorn
|
|
118 |
|
|
// get width and height of captcha image or text for use in <iframe>
|
119 |
|
|
switch(CAPTCHA_TYPE) {
|
120 |
|
|
case 'text':
|
121 |
|
|
$captcha_width = 250;
|
122 |
|
|
$captcha_height = 100;
|
123 |
|
|
break;
|
124 |
|
|
case 'calc_text':
|
125 |
|
|
$captcha_width = 120;
|
126 |
|
|
$captcha_height = 20;
|
127 |
|
|
break;
|
128 |
|
|
case 'calc_image':
|
129 |
|
|
$captcha_width = 142;
|
130 |
|
|
$captcha_height = 30;
|
131 |
|
|
break;
|
132 |
|
|
case 'calc_ttf_image':
|
133 |
|
|
$captcha_width = 162;
|
134 |
|
|
$captcha_height = 40;
|
135 |
|
|
break;
|
136 |
|
|
case 'ttf_image':
|
137 |
|
|
$captcha_width = 162;
|
138 |
|
|
$captcha_height = 40;
|
139 |
|
|
break;
|
140 |
|
|
case 'old_image':
|
141 |
|
|
$captcha_width = 142;
|
142 |
|
|
$captcha_height = 30;
|
143 |
|
|
break;
|
144 |
|
|
default:
|
145 |
|
|
$captcha_width = 250;
|
146 |
|
|
$captcha_height = 100;
|
147 |
|
|
}
|
148 |
|
|
|
149 |
747
|
thorn
|
if($action=='all') {
|
150 |
|
|
switch(CAPTCHA_TYPE) {
|
151 |
|
|
// one special case
|
152 |
858
|
thorn
|
case 'text': // text-captcha - we don't use an <iframe> in this case
|
153 |
747
|
thorn
|
?><table class="captcha_table"><tr>
|
154 |
858
|
thorn
|
<td class="text_captcha">
|
155 |
|
|
<?php include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php'); ?>
|
156 |
|
|
</td>
|
157 |
|
|
<td></td>
|
158 |
756
|
thorn
|
<td><input type="text" name="captcha" maxlength="50" style="width:150px;" /></td>
|
159 |
747
|
thorn
|
<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_QUEST']; ?></td>
|
160 |
|
|
</tr></table><?php
|
161 |
|
|
break;
|
162 |
|
|
// two special cases
|
163 |
|
|
case 'calc_text': // calculation as text
|
164 |
|
|
?><table class="captcha_table"><tr>
|
165 |
858
|
thorn
|
<td class="text_captcha">
|
166 |
|
|
<iframe class="captcha_iframe" width="<?php echo $captcha_width; ?>" height="<?php echo $captcha_height; ?>" scrolling="no" marginheight="0" marginwidth="0" frameborder="0" name="captcha_iframe" src="<?php echo WB_URL.'/include/captcha/captcha.php?display_captcha_X986E21=1'; ?>">
|
167 |
|
|
<?php include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php'); ?>
|
168 |
|
|
</iframe>
|
169 |
|
|
</td>
|
170 |
|
|
<td> = </td>
|
171 |
756
|
thorn
|
<td><input type="text" name="captcha" maxlength="10" style="width:20px;" /></td>
|
172 |
747
|
thorn
|
<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_RES']; ?></td>
|
173 |
|
|
</tr></table><?php
|
174 |
|
|
break;
|
175 |
|
|
case 'calc_image': // calculation with image (old captcha)
|
176 |
|
|
case 'calc_ttf_image': // calculation with varying background and ttf-font
|
177 |
858
|
thorn
|
?><table class="captcha_table"><tr>
|
178 |
|
|
<td class="image_captcha">
|
179 |
|
|
<iframe class="captcha_iframe" width="<?php echo $captcha_width; ?>" height="<?php echo $captcha_height; ?>" scrolling="no" marginheight="0" marginwidth="0" frameborder="0" name="captcha_iframe" src="<?php echo WB_URL.'/include/captcha/captcha.php?display_captcha_X986E21=1'; ?>">
|
180 |
|
|
<img src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t"; ?>" alt="Captcha" />
|
181 |
|
|
</iframe>
|
182 |
|
|
</td>
|
183 |
|
|
<td> = </td>
|
184 |
756
|
thorn
|
<td><input type="text" name="captcha" maxlength="10" style="width:20px;" /></td>
|
185 |
747
|
thorn
|
<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_RES']; ?></td>
|
186 |
|
|
</tr></table><?php
|
187 |
|
|
break;
|
188 |
|
|
// normal images
|
189 |
|
|
case 'ttf_image': // captcha with varying background and ttf-font
|
190 |
|
|
case 'old_image': // old captcha
|
191 |
|
|
?><table class="captcha_table"><tr>
|
192 |
858
|
thorn
|
<td class="image_captcha">
|
193 |
|
|
<iframe class="captcha_iframe" width="<?php echo $captcha_width; ?>" height="<?php echo $captcha_height; ?>" scrolling="no" marginheight="0" marginwidth="0" frameborder="0" name="captcha_iframe" src="<?php echo WB_URL.'/include/captcha/captcha.php?display_captcha_X986E21=1'; ?>">
|
194 |
|
|
<img src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t"; ?>" alt="Captcha" />
|
195 |
|
|
</iframe>
|
196 |
|
|
</td>
|
197 |
|
|
<td></td>
|
198 |
756
|
thorn
|
<td><input type="text" name="captcha" maxlength="10" style="width:50px;" /></td>
|
199 |
747
|
thorn
|
<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_TEXT']; ?></td>
|
200 |
|
|
</tr></table><?php
|
201 |
|
|
break;
|
202 |
|
|
}
|
203 |
|
|
} elseif($action=='image') {
|
204 |
|
|
switch(CAPTCHA_TYPE) {
|
205 |
|
|
case 'text': // text-captcha
|
206 |
|
|
case 'calc_text': // calculation as text
|
207 |
756
|
thorn
|
echo ($style?"<span $style>":'');
|
208 |
747
|
thorn
|
include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php');
|
209 |
756
|
thorn
|
echo ($style?'</span>':'');
|
210 |
747
|
thorn
|
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 |
756
|
thorn
|
echo "<img $style src=\"".WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t\" />";
|
216 |
747
|
thorn
|
break;
|
217 |
|
|
}
|
218 |
858
|
thorn
|
} elseif($action=='image_iframe') {
|
219 |
|
|
switch(CAPTCHA_TYPE) {
|
220 |
|
|
case 'text': // text-captcha
|
221 |
|
|
echo ($style?"<span $style>":'');
|
222 |
|
|
include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php');
|
223 |
|
|
echo ($style?'</span>':'');
|
224 |
|
|
break;
|
225 |
|
|
case 'calc_text': // calculation as text
|
226 |
|
|
?><iframe class="captcha_iframe" width="<?php echo $captcha_width; ?>" height="<?php echo $captcha_height; ?>" scrolling="no" marginheight="0" marginwidth="0" frameborder="0" name="captcha_iframe" src="<?php echo WB_URL.'/include/captcha/captcha.php?display_captcha_X986E21=1'; ?>"><?php
|
227 |
|
|
include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php');
|
228 |
|
|
?></iframe><?php
|
229 |
|
|
break;
|
230 |
|
|
case 'calc_image': // calculation with image (old captcha)
|
231 |
|
|
case 'calc_ttf_image': // calculation with varying background and ttf-font
|
232 |
|
|
case 'ttf_image': // captcha with varying background and ttf-font
|
233 |
|
|
case 'old_image': // old captcha
|
234 |
|
|
?><iframe class="captcha_iframe" width="<?php echo $captcha_width; ?>" height="<?php echo $captcha_height; ?>" scrolling="no" marginheight="0" marginwidth="0" frameborder="0" name="captcha_iframe" src="<?php echo WB_URL.'/include/captcha/captcha.php?display_captcha_X986E21=1'; ?>"><?php
|
235 |
|
|
echo "<img $style alt=\"Captcha\" src=\"".WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t\" />";
|
236 |
|
|
?></iframe><?php
|
237 |
|
|
break;
|
238 |
|
|
}
|
239 |
747
|
thorn
|
} elseif($action=='input') {
|
240 |
|
|
switch(CAPTCHA_TYPE) {
|
241 |
|
|
case 'text': // text-captcha
|
242 |
756
|
thorn
|
echo '<input type="text" name="captcha" '.($style?$style:'style="width:150px;" maxlength="50"').' />';
|
243 |
747
|
thorn
|
break;
|
244 |
|
|
case 'calc_text': // calculation as text
|
245 |
|
|
case 'calc_image': // calculation with image (old captcha)
|
246 |
|
|
case 'calc_ttf_image': // calculation with varying background and ttf-font
|
247 |
756
|
thorn
|
echo '<input type="text" name="captcha" '.($style?$style:'style="width:20px;" maxlength="10"').' />';
|
248 |
747
|
thorn
|
break;
|
249 |
|
|
case 'ttf_image': // captcha with varying background and ttf-font
|
250 |
|
|
case 'old_image': // old captcha
|
251 |
756
|
thorn
|
echo '<input type="text" name="captcha" '.($style?$style:'style="width:50px;" maxlength="10"').' />';
|
252 |
747
|
thorn
|
break;
|
253 |
|
|
}
|
254 |
|
|
} elseif($action=='text') {
|
255 |
756
|
thorn
|
echo ($style?"<span $style>":'');
|
256 |
747
|
thorn
|
switch(CAPTCHA_TYPE) {
|
257 |
|
|
case 'text': // text-captcha
|
258 |
|
|
echo $MOD_CAPTCHA['VERIFICATION_INFO_QUEST'];
|
259 |
|
|
break;
|
260 |
|
|
case 'calc_text': // calculation as text
|
261 |
|
|
case 'calc_image': // calculation with image (old captcha)
|
262 |
|
|
case 'calc_ttf_image': // calculation with varying background and ttf-font
|
263 |
|
|
echo $MOD_CAPTCHA['VERIFICATION_INFO_RES'];
|
264 |
|
|
break;
|
265 |
|
|
case 'ttf_image': // captcha with varying background and ttf-font
|
266 |
|
|
case 'old_image': // old captcha
|
267 |
|
|
echo $MOD_CAPTCHA['VERIFICATION_INFO_TEXT'];
|
268 |
|
|
break;
|
269 |
|
|
}
|
270 |
756
|
thorn
|
echo ($style?'</span>':'');
|
271 |
596
|
thorn
|
}
|
272 |
|
|
}
|
273 |
|
|
}
|