1
|
<?php
|
2
|
|
3
|
// $Id: captcha.php 747 2008-03-12 18:17:15Z 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
|
// 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
|
'calc_ttf_image'=>$MOD_CAPTCHA_CONTROL['CALC_TTF_IMAGE'],
|
63
|
'ttf_image'=>$MOD_CAPTCHA_CONTROL['TTF_IMAGE'],
|
64
|
'old_image'=>$MOD_CAPTCHA_CONTROL['OLD_IMAGE'],
|
65
|
'text'=>$MOD_CAPTCHA_CONTROL['TEXT']
|
66
|
);
|
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
|
'old_image'=>$MOD_CAPTCHA_CONTROL['OLD_IMAGE'],
|
72
|
'text'=>$MOD_CAPTCHA_CONTROL['TEXT']
|
73
|
);
|
74
|
} else {
|
75
|
$useable_captchas = array(
|
76
|
'calc_text'=>$MOD_CAPTCHA_CONTROL['CALC_TEXT'],
|
77
|
'text'=>$MOD_CAPTCHA_CONTROL['TEXT']
|
78
|
);
|
79
|
}
|
80
|
|
81
|
if(!function_exists('call_captcha')) {
|
82
|
function call_captcha($action='all') {
|
83
|
global $MOD_CAPTCHA;
|
84
|
$t = time();
|
85
|
$_SESSION['captcha_time'] = $t;
|
86
|
|
87
|
if($action=='all') {
|
88
|
switch(CAPTCHA_TYPE) {
|
89
|
// one special case
|
90
|
case 'text': // text-captcha
|
91
|
?><table class="captcha_table"><tr>
|
92
|
<td class="text_captcha"><?php include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php'); ?></td>
|
93
|
<td><input type="text" name="captcha" maxlength="50" style="width:150px" /></td>
|
94
|
<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_QUEST']; ?></td>
|
95
|
</tr></table><?php
|
96
|
break;
|
97
|
// two special cases
|
98
|
case 'calc_text': // calculation as text
|
99
|
?><table class="captcha_table"><tr>
|
100
|
<td class="text_captcha"><?php include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php'); ?> = </td>
|
101
|
<td><input type="text" name="captcha" maxlength="10" style="width:20px" /></td>
|
102
|
<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_RES']; ?></td>
|
103
|
</tr></table><?php
|
104
|
break;
|
105
|
case 'calc_image': // calculation with image (old captcha)
|
106
|
case 'calc_ttf_image': // calculation with varying background and ttf-font
|
107
|
?><table class="captcha_table"><tr>
|
108
|
<td class="image_captcha"><img src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t"; ?>" alt="Captcha" /></td><td> = </td>
|
109
|
<td><input type="text" name="captcha" maxlength="10" style="width:20px" /></td>
|
110
|
<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_RES']; ?></td>
|
111
|
</tr></table><?php
|
112
|
break;
|
113
|
// normal images
|
114
|
case 'ttf_image': // captcha with varying background and ttf-font
|
115
|
case 'old_image': // old captcha
|
116
|
?><table class="captcha_table"><tr>
|
117
|
<td class="image_captcha"><img src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t"; ?>" alt="Captcha" /></td>
|
118
|
<td><input type="text" name="captcha" maxlength="10" style="width:50px" /></td>
|
119
|
<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_TEXT']; ?></td>
|
120
|
</tr></table><?php
|
121
|
break;
|
122
|
}
|
123
|
} elseif($action=='image') {
|
124
|
switch(CAPTCHA_TYPE) {
|
125
|
case 'text': // text-captcha
|
126
|
case 'calc_text': // calculation as text
|
127
|
include(WB_PATH.'/include/captcha/captchas/'.CAPTCHA_TYPE.'.php');
|
128
|
break;
|
129
|
case 'calc_image': // calculation with image (old captcha)
|
130
|
case 'calc_ttf_image': // calculation with varying background and ttf-font
|
131
|
case 'ttf_image': // captcha with varying background and ttf-font
|
132
|
case 'old_image': // old captcha
|
133
|
echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t";
|
134
|
break;
|
135
|
}
|
136
|
} elseif($action=='input') {
|
137
|
switch(CAPTCHA_TYPE) {
|
138
|
case 'text': // text-captcha
|
139
|
?><input type="text" name="captcha" maxlength="50" style="width:150px" /><?php
|
140
|
break;
|
141
|
case 'calc_text': // calculation as text
|
142
|
?><input type="text" name="captcha" maxlength="10" style="width:20px" /><?php
|
143
|
break;
|
144
|
case 'calc_image': // calculation with image (old captcha)
|
145
|
case 'calc_ttf_image': // calculation with varying background and ttf-font
|
146
|
?><input type="text" name="captcha" maxlength="10" style="width:20px" /><?php
|
147
|
break;
|
148
|
// normal images
|
149
|
case 'ttf_image': // captcha with varying background and ttf-font
|
150
|
case 'old_image': // old captcha
|
151
|
?><input type="text" name="captcha" maxlength="10" style="width:50px" /><?php
|
152
|
break;
|
153
|
}
|
154
|
} elseif($action=='text') {
|
155
|
switch(CAPTCHA_TYPE) {
|
156
|
// one special case
|
157
|
case 'text': // text-captcha
|
158
|
echo $MOD_CAPTCHA['VERIFICATION_INFO_QUEST'];
|
159
|
break;
|
160
|
// two special cases
|
161
|
case 'calc_text': // calculation as text
|
162
|
echo $MOD_CAPTCHA['VERIFICATION_INFO_RES'];
|
163
|
break;
|
164
|
case 'calc_image': // calculation with image (old captcha)
|
165
|
case 'calc_ttf_image': // calculation with varying background and ttf-font
|
166
|
echo $MOD_CAPTCHA['VERIFICATION_INFO_RES'];
|
167
|
break;
|
168
|
// normal images
|
169
|
case 'ttf_image': // captcha with varying background and ttf-font
|
170
|
case 'old_image': // old captcha
|
171
|
echo $MOD_CAPTCHA['VERIFICATION_INFO_TEXT'];
|
172
|
break;
|
173
|
}
|
174
|
}
|
175
|
}
|
176
|
}
|
177
|
?>
|