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 |
|
|
'old_image'=>$MOD_CAPTCHA_CONTROL['OLD_IMAGE']
|
65 |
|
|
);
|
66 |
|
|
} elseif(extension_loaded('gd') && function_exists('imagepng')) {
|
67 |
|
|
$useable_captchas = array(
|
68 |
|
|
'calc_text'=>$MOD_CAPTCHA_CONTROL['CALC_TEXT'],
|
69 |
|
|
'calc_image'=>$MOD_CAPTCHA_CONTROL['CALC_IMAGE'],
|
70 |
|
|
'old_image'=>$MOD_CAPTCHA_CONTROL['OLD_IMAGE']
|
71 |
|
|
);
|
72 |
|
|
} else {
|
73 |
|
|
$useable_captchas = array(
|
74 |
|
|
'calc_text'=>$MOD_CAPTCHA_CONTROL['CALC_TEXT']
|
75 |
|
|
);
|
76 |
|
|
}
|
77 |
|
|
|
78 |
|
|
if(!function_exists('call_captcha')) {
|
79 |
|
|
function call_captcha() {
|
80 |
|
|
global $MOD_CAPTCHA;
|
81 |
609
|
thorn
|
$t = time();
|
82 |
|
|
$_SESSION['captcha_time'] = $t;
|
83 |
|
|
|
84 |
596
|
thorn
|
switch(CAPTCHA_TYPE) {
|
85 |
|
|
// two special cases
|
86 |
|
|
case 'calc_text': // calculation as text
|
87 |
615
|
thorn
|
?><table class="captcha_table"><tr>
|
88 |
|
|
<td><?php include(WB_PATH.'/include/captcha/captchas/calc_text.php'); ?> = </td>
|
89 |
|
|
<td><input type="text" name="captcha" maxlength="5" style="width:20px" /></td>
|
90 |
|
|
<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_RES']; ?></td>
|
91 |
|
|
</tr></table><?php
|
92 |
596
|
thorn
|
break;
|
93 |
|
|
case 'calc_image': // calculation with image (old captcha)
|
94 |
615
|
thorn
|
?><table class="captcha_table"><tr>
|
95 |
|
|
<td><img src="<?php echo WB_URL."/include/captcha/captchas/calc_image.php?t=$t"; ?>" alt="Captcha" /> = </td>
|
96 |
|
|
<td><input type="text" name="captcha" maxlength="5" style="width:20px" /></td>
|
97 |
|
|
<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_RES']; ?></td>
|
98 |
|
|
</tr></table><?php
|
99 |
596
|
thorn
|
break;
|
100 |
|
|
// normal images
|
101 |
|
|
case 'ttf_image': // captcha with varying background and ttf-font
|
102 |
615
|
thorn
|
case 'calc_ttf_image': // calculation with varying background and ttf-font
|
103 |
596
|
thorn
|
case 'old_image': // old captcha
|
104 |
615
|
thorn
|
?><table class="captcha_table"><tr>
|
105 |
|
|
<td><img src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t"; ?>" alt="Captcha" /></td>
|
106 |
|
|
<td><input type="text" name="captcha" maxlength="5" style="width:50px" /></td>
|
107 |
|
|
<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_TEXT']; ?></td>
|
108 |
|
|
</tr></table><?php
|
109 |
596
|
thorn
|
break;
|
110 |
|
|
}
|
111 |
|
|
}
|
112 |
|
|
}
|
113 |
615
|
thorn
|
?>
|