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