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