1 |
596
|
thorn
|
<?php
|
2 |
1753
|
Luisehahne
|
/**
|
3 |
|
|
*
|
4 |
|
|
* @category captcha
|
5 |
|
|
* @package include
|
6 |
|
|
* @subpackage
|
7 |
|
|
* @author Ryan Djurovich,WebsiteBaker Project
|
8 |
1898
|
Luisehahne
|
* @copyright 2009-2013, WebsiteBaker Org. e.V.
|
9 |
|
|
* @link http://www.websitebaker.org/
|
10 |
1753
|
Luisehahne
|
* @license http://www.gnu.org/licenses/gpl.html
|
11 |
|
|
* @platform WebsiteBaker 2.8.x
|
12 |
|
|
* @requirements PHP 5.2.2 and higher
|
13 |
|
|
* @version $Id$
|
14 |
|
|
* @filesource $HeadURL$
|
15 |
|
|
* @lastmodified $Date$
|
16 |
|
|
*
|
17 |
|
|
*/
|
18 |
596
|
thorn
|
|
19 |
858
|
thorn
|
// displays the image or text inside an <iframe>
|
20 |
1371
|
Luisehahne
|
if(!function_exists('display_captcha_real')) {
|
21 |
|
|
function display_captcha_real($kind='image') {
|
22 |
|
|
$t = time();
|
23 |
1443
|
Luisehahne
|
$output = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" ";
|
24 |
|
|
$output .= "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
|
25 |
|
|
$output .= "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"";
|
26 |
|
|
$output .= strtolower(LANGUAGE)."\" lang=\"".strtolower(LANGUAGE)."\">\n";
|
27 |
|
|
$output .= "\t<head>\n\t\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n";
|
28 |
|
|
$output .= "\t\t<title>captcha</title>\n\t</head>\n\t<body>\n";
|
29 |
1371
|
Luisehahne
|
$_SESSION['captcha_time'] = $t;
|
30 |
|
|
if($kind=='image') {
|
31 |
1444
|
Luisehahne
|
$output .= "\t\t<a title=\"reload\" href=\"".WB_URL."/include/captcha/captcha.php?display_captcha_X986E21=2\">";
|
32 |
|
|
$output .= "<img style=\"border: none;\" src=\"".WB_URL."/include/captcha/captchas/";
|
33 |
1443
|
Luisehahne
|
$output .= CAPTCHA_TYPE.".php?t=".$t."\" alt=\"Captcha\" /></a>\n";
|
34 |
1371
|
Luisehahne
|
} else {
|
35 |
1443
|
Luisehahne
|
$output .= "\t\t<h2>error</h2>";
|
36 |
1371
|
Luisehahne
|
}
|
37 |
1443
|
Luisehahne
|
$output .= "\t</body>\n</html>";
|
38 |
|
|
echo $output;
|
39 |
858
|
thorn
|
}
|
40 |
|
|
}
|
41 |
|
|
|
42 |
|
|
// called from an <iframe>
|
43 |
|
|
if(isset($_GET['display_captcha_X986E21'])) {
|
44 |
|
|
require('../../config.php');
|
45 |
|
|
switch(CAPTCHA_TYPE) {
|
46 |
|
|
case 'calc_image':
|
47 |
|
|
case 'calc_ttf_image':
|
48 |
|
|
case 'ttf_image':
|
49 |
|
|
case 'old_image':
|
50 |
|
|
display_captcha_real('image');
|
51 |
|
|
break;
|
52 |
|
|
}
|
53 |
|
|
exit(0);
|
54 |
|
|
}
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
// Make sure page cannot be accessed directly
|
58 |
596
|
thorn
|
if(!defined('WB_PATH')) { exit("Cannot access this file directly"); }
|
59 |
|
|
|
60 |
|
|
// check if module language file exists for the language set by the user (e.g. DE, EN)
|
61 |
|
|
global $MOD_CAPTCHA;
|
62 |
|
|
if(!file_exists(WB_PATH.'/modules/captcha_control/languages/'.LANGUAGE .'.php')) {
|
63 |
|
|
// no module language file exists for the language set by the user, include default module language file EN.php
|
64 |
|
|
require_once(WB_PATH.'/modules/captcha_control/languages/EN.php');
|
65 |
|
|
} else {
|
66 |
|
|
// a module language file exists for the language defined by the user, load it
|
67 |
|
|
require_once(WB_PATH.'/modules/captcha_control/languages/'.LANGUAGE .'.php');
|
68 |
|
|
}
|
69 |
|
|
|
70 |
|
|
// output-handler for image-captchas to determine size of image
|
71 |
|
|
if(!function_exists('captcha_header')) {
|
72 |
|
|
function captcha_header() {
|
73 |
|
|
header("Expires: Mon, 1 Jan 1990 05:00:00 GMT");
|
74 |
|
|
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
75 |
|
|
header("Cache-Control: no-store, no-cache, must-revalidate, proxy-revalidate");
|
76 |
|
|
header("Pragma: no-cache");
|
77 |
|
|
header("Content-type: image/png");
|
78 |
|
|
return;
|
79 |
|
|
}
|
80 |
|
|
}
|
81 |
|
|
|
82 |
|
|
// get list of available CAPTCHAS for the dropdown-listbox in admin-tools
|
83 |
|
|
if(extension_loaded('gd') && function_exists('imagepng') && function_exists('imagettftext')) {
|
84 |
|
|
$useable_captchas = array(
|
85 |
|
|
'calc_text'=>$MOD_CAPTCHA_CONTROL['CALC_TEXT'],
|
86 |
|
|
'calc_image'=>$MOD_CAPTCHA_CONTROL['CALC_IMAGE'],
|
87 |
615
|
thorn
|
'calc_ttf_image'=>$MOD_CAPTCHA_CONTROL['CALC_TTF_IMAGE'],
|
88 |
596
|
thorn
|
'ttf_image'=>$MOD_CAPTCHA_CONTROL['TTF_IMAGE'],
|
89 |
624
|
thorn
|
'old_image'=>$MOD_CAPTCHA_CONTROL['OLD_IMAGE'],
|
90 |
|
|
'text'=>$MOD_CAPTCHA_CONTROL['TEXT']
|
91 |
596
|
thorn
|
);
|
92 |
|
|
} elseif(extension_loaded('gd') && function_exists('imagepng')) {
|
93 |
|
|
$useable_captchas = array(
|
94 |
|
|
'calc_text'=>$MOD_CAPTCHA_CONTROL['CALC_TEXT'],
|
95 |
|
|
'calc_image'=>$MOD_CAPTCHA_CONTROL['CALC_IMAGE'],
|
96 |
624
|
thorn
|
'old_image'=>$MOD_CAPTCHA_CONTROL['OLD_IMAGE'],
|
97 |
|
|
'text'=>$MOD_CAPTCHA_CONTROL['TEXT']
|
98 |
596
|
thorn
|
);
|
99 |
|
|
} else {
|
100 |
|
|
$useable_captchas = array(
|
101 |
624
|
thorn
|
'calc_text'=>$MOD_CAPTCHA_CONTROL['CALC_TEXT'],
|
102 |
|
|
'text'=>$MOD_CAPTCHA_CONTROL['TEXT']
|
103 |
596
|
thorn
|
);
|
104 |
|
|
}
|
105 |
|
|
|
106 |
|
|
if(!function_exists('call_captcha')) {
|
107 |
1371
|
Luisehahne
|
function call_captcha($action='all', $style='', $sec_id='') {
|
108 |
596
|
thorn
|
global $MOD_CAPTCHA;
|
109 |
609
|
thorn
|
$t = time();
|
110 |
|
|
$_SESSION['captcha_time'] = $t;
|
111 |
858
|
thorn
|
|
112 |
867
|
thorn
|
// get width and height of captcha image for use in <iframe>
|
113 |
858
|
thorn
|
switch(CAPTCHA_TYPE) {
|
114 |
|
|
case 'calc_image':
|
115 |
1898
|
Luisehahne
|
$captcha_width = 160;
|
116 |
|
|
$captcha_height = 55;
|
117 |
858
|
thorn
|
break;
|
118 |
|
|
case 'calc_ttf_image':
|
119 |
1898
|
Luisehahne
|
$captcha_width = 175;
|
120 |
|
|
$captcha_height = 55;
|
121 |
858
|
thorn
|
break;
|
122 |
|
|
case 'ttf_image':
|
123 |
1898
|
Luisehahne
|
$captcha_width = 175;
|
124 |
|
|
$captcha_height = 55;
|
125 |
858
|
thorn
|
break;
|
126 |
|
|
case 'old_image':
|
127 |
1898
|
Luisehahne
|
$captcha_width = 160;
|
128 |
|
|
$captcha_height = 55;
|
129 |
858
|
thorn
|
break;
|
130 |
|
|
default:
|
131 |
|
|
$captcha_width = 250;
|
132 |
|
|
$captcha_height = 100;
|
133 |
|
|
}
|
134 |
|
|
|
135 |
747
|
thorn
|
if($action=='all') {
|
136 |
|
|
switch(CAPTCHA_TYPE) {
|
137 |
867
|
thorn
|
case 'text': // text-captcha
|
138 |
1753
|
Luisehahne
|
?><table class="captcha_table"><tr>
|
139 |
858
|
thorn
|
<td class="text_captcha">
|
140 |
|
|
<?php include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php'); ?>
|
141 |
|
|
</td>
|
142 |
|
|
<td></td>
|
143 |
756
|
thorn
|
<td><input type="text" name="captcha" maxlength="50" style="width:150px;" /></td>
|
144 |
747
|
thorn
|
<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_QUEST']; ?></td>
|
145 |
|
|
</tr></table><?php
|
146 |
|
|
break;
|
147 |
|
|
case 'calc_text': // calculation as text
|
148 |
1753
|
Luisehahne
|
?><table class="captcha_table"><tr>
|
149 |
858
|
thorn
|
<td class="text_captcha">
|
150 |
|
|
<?php include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php'); ?>
|
151 |
|
|
</td>
|
152 |
|
|
<td> = </td>
|
153 |
1898
|
Luisehahne
|
<td><input type="text" name="captcha" maxlength="10" style="width:30px;" /></td>
|
154 |
747
|
thorn
|
<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_RES']; ?></td>
|
155 |
|
|
</tr></table><?php
|
156 |
|
|
break;
|
157 |
|
|
case 'calc_image': // calculation with image (old captcha)
|
158 |
|
|
case 'calc_ttf_image': // calculation with varying background and ttf-font
|
159 |
1898
|
Luisehahne
|
?><table class="captcha_table" style="font-size: 100%;"><tr>
|
160 |
858
|
thorn
|
<td class="image_captcha">
|
161 |
1898
|
Luisehahne
|
<?php echo "<iframe class=\"captcha_iframe\" width=\"$captcha_width\" height=\"$captcha_height\" style=\"overflow:hidden;border: 1px solid #999;\" name=\"captcha_iframe_$sec_id\" src=\"". WB_URL ."/include/captcha/captcha.php?display_captcha_X986E21=1&s=$sec_id"; ?>">
|
162 |
|
|
<img src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t&s=$sec_id"; ?>" alt="Captcha" style="margin: 0;padding: 0;" />
|
163 |
858
|
thorn
|
</iframe>
|
164 |
|
|
</td>
|
165 |
|
|
<td> = </td>
|
166 |
1898
|
Luisehahne
|
<td><input type="text" name="captcha" maxlength="10" style="width:30px;" /></td>
|
167 |
747
|
thorn
|
<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_RES']; ?></td>
|
168 |
|
|
</tr></table><?php
|
169 |
|
|
break;
|
170 |
|
|
// normal images
|
171 |
|
|
case 'ttf_image': // captcha with varying background and ttf-font
|
172 |
|
|
case 'old_image': // old captcha
|
173 |
1753
|
Luisehahne
|
?><table class="captcha_table"><tr>
|
174 |
858
|
thorn
|
<td class="image_captcha">
|
175 |
1898
|
Luisehahne
|
<?php echo "<iframe class=\"captcha_iframe\" width=\"$captcha_width\" height=\"$captcha_height\" style=\"overflow:hidden;border: 1px solid #999;\" name=\"captcha_iframe_$sec_id\" src=\"". WB_URL ."/include/captcha/captcha.php?display_captcha_X986E21=1&s=$sec_id"; ?> " >
|
176 |
|
|
<img src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t&s=$sec_id"; ?>" alt="Captcha" style="margin: 0;padding: 0;" />
|
177 |
858
|
thorn
|
</iframe>
|
178 |
|
|
</td>
|
179 |
|
|
<td></td>
|
180 |
756
|
thorn
|
<td><input type="text" name="captcha" maxlength="10" style="width:50px;" /></td>
|
181 |
747
|
thorn
|
<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_TEXT']; ?></td>
|
182 |
|
|
</tr></table><?php
|
183 |
|
|
break;
|
184 |
|
|
}
|
185 |
|
|
} elseif($action=='image') {
|
186 |
|
|
switch(CAPTCHA_TYPE) {
|
187 |
|
|
case 'text': // text-captcha
|
188 |
|
|
case 'calc_text': // calculation as text
|
189 |
756
|
thorn
|
echo ($style?"<span $style>":'');
|
190 |
747
|
thorn
|
include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php');
|
191 |
756
|
thorn
|
echo ($style?'</span>':'');
|
192 |
747
|
thorn
|
break;
|
193 |
|
|
case 'calc_image': // calculation with image (old captcha)
|
194 |
|
|
case 'calc_ttf_image': // calculation with varying background and ttf-font
|
195 |
|
|
case 'ttf_image': // captcha with varying background and ttf-font
|
196 |
|
|
case 'old_image': // old captcha
|
197 |
1371
|
Luisehahne
|
echo "<img $style src=\"".WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t&s=$sec_id\" />";
|
198 |
747
|
thorn
|
break;
|
199 |
|
|
}
|
200 |
858
|
thorn
|
} elseif($action=='image_iframe') {
|
201 |
|
|
switch(CAPTCHA_TYPE) {
|
202 |
|
|
case 'text': // text-captcha
|
203 |
|
|
echo ($style?"<span $style>":'');
|
204 |
|
|
include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php');
|
205 |
|
|
echo ($style?'</span>':'');
|
206 |
|
|
break;
|
207 |
|
|
case 'calc_text': // calculation as text
|
208 |
|
|
include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php');
|
209 |
|
|
break;
|
210 |
|
|
case 'calc_image': // calculation with image (old captcha)
|
211 |
|
|
case 'calc_ttf_image': // calculation with varying background and ttf-font
|
212 |
|
|
case 'ttf_image': // captcha with varying background and ttf-font
|
213 |
|
|
case 'old_image': // old captcha
|
214 |
1371
|
Luisehahne
|
?>
|
215 |
|
|
<?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"; ?>">
|
216 |
|
|
<?php
|
217 |
858
|
thorn
|
echo "<img $style alt=\"Captcha\" src=\"".WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t\" />";
|
218 |
|
|
?></iframe><?php
|
219 |
|
|
break;
|
220 |
|
|
}
|
221 |
747
|
thorn
|
} elseif($action=='input') {
|
222 |
|
|
switch(CAPTCHA_TYPE) {
|
223 |
|
|
case 'text': // text-captcha
|
224 |
756
|
thorn
|
echo '<input type="text" name="captcha" '.($style?$style:'style="width:150px;" maxlength="50"').' />';
|
225 |
747
|
thorn
|
break;
|
226 |
|
|
case 'calc_text': // calculation as text
|
227 |
|
|
case 'calc_image': // calculation with image (old captcha)
|
228 |
|
|
case 'calc_ttf_image': // calculation with varying background and ttf-font
|
229 |
756
|
thorn
|
echo '<input type="text" name="captcha" '.($style?$style:'style="width:20px;" maxlength="10"').' />';
|
230 |
747
|
thorn
|
break;
|
231 |
|
|
case 'ttf_image': // captcha with varying background and ttf-font
|
232 |
|
|
case 'old_image': // old captcha
|
233 |
756
|
thorn
|
echo '<input type="text" name="captcha" '.($style?$style:'style="width:50px;" maxlength="10"').' />';
|
234 |
747
|
thorn
|
break;
|
235 |
|
|
}
|
236 |
|
|
} elseif($action=='text') {
|
237 |
756
|
thorn
|
echo ($style?"<span $style>":'');
|
238 |
747
|
thorn
|
switch(CAPTCHA_TYPE) {
|
239 |
|
|
case 'text': // text-captcha
|
240 |
|
|
echo $MOD_CAPTCHA['VERIFICATION_INFO_QUEST'];
|
241 |
|
|
break;
|
242 |
|
|
case 'calc_text': // calculation as text
|
243 |
|
|
case 'calc_image': // calculation with image (old captcha)
|
244 |
|
|
case 'calc_ttf_image': // calculation with varying background and ttf-font
|
245 |
|
|
echo $MOD_CAPTCHA['VERIFICATION_INFO_RES'];
|
246 |
|
|
break;
|
247 |
|
|
case 'ttf_image': // captcha with varying background and ttf-font
|
248 |
|
|
case 'old_image': // old captcha
|
249 |
|
|
echo $MOD_CAPTCHA['VERIFICATION_INFO_TEXT'];
|
250 |
|
|
break;
|
251 |
|
|
}
|
252 |
756
|
thorn
|
echo ($style?'</span>':'');
|
253 |
596
|
thorn
|
}
|
254 |
|
|
}
|
255 |
|
|
}
|