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