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 |
|
|
// Must include code to stop this file being accessed directly
|
27 |
|
|
if(!defined('WB_PATH')) { exit("Cannot access this file directly"); }
|
28 |
|
|
|
29 |
|
|
if(!isset($admin)) {
|
30 |
|
|
require_once(WB_PATH.'/framework/class.wb.php');
|
31 |
|
|
$admin = new wb;
|
32 |
|
|
}
|
33 |
|
|
|
34 |
|
|
// check if module language file exists for the language set by the user (e.g. DE, EN)
|
35 |
|
|
global $MOD_CAPTCHA;
|
36 |
|
|
if(!file_exists(WB_PATH.'/modules/captcha_control/languages/'.LANGUAGE .'.php')) {
|
37 |
|
|
// no module language file exists for the language set by the user, include default module language file EN.php
|
38 |
|
|
require_once(WB_PATH.'/modules/captcha_control/languages/EN.php');
|
39 |
|
|
} else {
|
40 |
|
|
// a module language file exists for the language defined by the user, load it
|
41 |
|
|
require_once(WB_PATH.'/modules/captcha_control/languages/'.LANGUAGE .'.php');
|
42 |
|
|
}
|
43 |
|
|
|
44 |
|
|
// output-handler for image-captchas to determine size of image
|
45 |
|
|
if(!function_exists('captcha_header')) {
|
46 |
|
|
function captcha_header() {
|
47 |
|
|
header("Expires: Mon, 1 Jan 1990 05:00:00 GMT");
|
48 |
|
|
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
49 |
|
|
header("Cache-Control: no-store, no-cache, must-revalidate, proxy-revalidate");
|
50 |
|
|
header("Cache-Control: post-check=0, pre-check=0", false); // MS made there own headers :-(
|
51 |
|
|
header("Pragma: no-cache");
|
52 |
|
|
header("Content-type: image/png");
|
53 |
|
|
return;
|
54 |
|
|
}
|
55 |
|
|
}
|
56 |
|
|
|
57 |
|
|
// get list of available CAPTCHAS for the dropdown-listbox in admin-tools
|
58 |
|
|
if(extension_loaded('gd') && function_exists('imagepng') && function_exists('imagettftext')) {
|
59 |
|
|
$useable_captchas = array(
|
60 |
|
|
'calc_text'=>$MOD_CAPTCHA_CONTROL['CALC_TEXT'],
|
61 |
|
|
'calc_image'=>$MOD_CAPTCHA_CONTROL['CALC_IMAGE'],
|
62 |
615
|
thorn
|
'calc_ttf_image'=>$MOD_CAPTCHA_CONTROL['CALC_TTF_IMAGE'],
|
63 |
596
|
thorn
|
'ttf_image'=>$MOD_CAPTCHA_CONTROL['TTF_IMAGE'],
|
64 |
624
|
thorn
|
'old_image'=>$MOD_CAPTCHA_CONTROL['OLD_IMAGE'],
|
65 |
|
|
'text'=>$MOD_CAPTCHA_CONTROL['TEXT']
|
66 |
596
|
thorn
|
);
|
67 |
|
|
} elseif(extension_loaded('gd') && function_exists('imagepng')) {
|
68 |
|
|
$useable_captchas = array(
|
69 |
|
|
'calc_text'=>$MOD_CAPTCHA_CONTROL['CALC_TEXT'],
|
70 |
|
|
'calc_image'=>$MOD_CAPTCHA_CONTROL['CALC_IMAGE'],
|
71 |
624
|
thorn
|
'old_image'=>$MOD_CAPTCHA_CONTROL['OLD_IMAGE'],
|
72 |
|
|
'text'=>$MOD_CAPTCHA_CONTROL['TEXT']
|
73 |
596
|
thorn
|
);
|
74 |
|
|
} else {
|
75 |
|
|
$useable_captchas = array(
|
76 |
624
|
thorn
|
'calc_text'=>$MOD_CAPTCHA_CONTROL['CALC_TEXT'],
|
77 |
|
|
'text'=>$MOD_CAPTCHA_CONTROL['TEXT']
|
78 |
596
|
thorn
|
);
|
79 |
|
|
}
|
80 |
|
|
|
81 |
|
|
if(!function_exists('call_captcha')) {
|
82 |
|
|
function call_captcha() {
|
83 |
|
|
global $MOD_CAPTCHA;
|
84 |
609
|
thorn
|
$t = time();
|
85 |
|
|
$_SESSION['captcha_time'] = $t;
|
86 |
|
|
|
87 |
596
|
thorn
|
switch(CAPTCHA_TYPE) {
|
88 |
624
|
thorn
|
// one special case
|
89 |
|
|
case 'text': // text-captcha
|
90 |
|
|
?><table class="captcha_table"><tr>
|
91 |
|
|
<td class="text_captcha"><?php include(WB_PATH.'/include/captcha/captchas/text.php'); ?></td>
|
92 |
647
|
doc
|
<td><input type="text" name="captcha" maxlength="50" style="width:150px" /></td>
|
93 |
624
|
thorn
|
<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_QUEST']; ?></td>
|
94 |
|
|
</tr></table><?php
|
95 |
|
|
break;
|
96 |
596
|
thorn
|
// two special cases
|
97 |
|
|
case 'calc_text': // calculation as text
|
98 |
615
|
thorn
|
?><table class="captcha_table"><tr>
|
99 |
624
|
thorn
|
<td class="text_captcha"><?php include(WB_PATH.'/include/captcha/captchas/calc_text.php'); ?> = </td>
|
100 |
615
|
thorn
|
<td><input type="text" name="captcha" maxlength="5" style="width:20px" /></td>
|
101 |
|
|
<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_RES']; ?></td>
|
102 |
|
|
</tr></table><?php
|
103 |
596
|
thorn
|
break;
|
104 |
|
|
case 'calc_image': // calculation with image (old captcha)
|
105 |
615
|
thorn
|
?><table class="captcha_table"><tr>
|
106 |
624
|
thorn
|
<td class="image_captcha"><img src="<?php echo WB_URL."/include/captcha/captchas/calc_image.php?t=$t"; ?>" alt="Captcha" /></td><td> = </td>
|
107 |
615
|
thorn
|
<td><input type="text" name="captcha" maxlength="5" style="width:20px" /></td>
|
108 |
|
|
<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_RES']; ?></td>
|
109 |
|
|
</tr></table><?php
|
110 |
596
|
thorn
|
break;
|
111 |
|
|
// normal images
|
112 |
|
|
case 'ttf_image': // captcha with varying background and ttf-font
|
113 |
615
|
thorn
|
case 'calc_ttf_image': // calculation with varying background and ttf-font
|
114 |
596
|
thorn
|
case 'old_image': // old captcha
|
115 |
615
|
thorn
|
?><table class="captcha_table"><tr>
|
116 |
624
|
thorn
|
<td class="image_captcha"><img src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t"; ?>" alt="Captcha" /></td>
|
117 |
615
|
thorn
|
<td><input type="text" name="captcha" maxlength="5" style="width:50px" /></td>
|
118 |
|
|
<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_TEXT']; ?></td>
|
119 |
|
|
</tr></table><?php
|
120 |
596
|
thorn
|
break;
|
121 |
|
|
}
|
122 |
|
|
}
|
123 |
|
|
}
|
124 |
615
|
thorn
|
?>
|