Revision 624
Added by thorn almost 17 years ago
trunk/CHANGELOG | ||
---|---|---|
10 | 10 |
# = Bugfix |
11 | 11 |
! = Update/Change |
12 | 12 |
|
13 |
------------------------------------- 2.7.0 ------------------------------------- |
|
13 |
------------------------------------- 2.7.0 ------------------------------------- |
|
14 |
28-Jan-2008 Thomas Hornik |
|
15 |
+ Added Text-CAPTCHA on request. The captcha-text will be stored in temp/.captcha_text.txt |
|
14 | 16 |
27-Jan-2008 Christian Sommer |
15 | 17 |
! fixed CSS background color of the installer CSS |
16 | 18 |
! replaced static text with variable text from language file |
trunk/wb/include/captcha/captchas/text.php | ||
---|---|---|
1 |
<?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') == false) { exit("Cannot access this file directly"); } |
|
28 |
|
|
29 |
$name = 'text'; |
|
30 |
$file = WB_PATH."/temp/.captcha_$name.txt"; |
|
31 |
|
|
32 |
srand((double)microtime()*100000); |
|
33 |
$_SESSION['captcha'] = rand(0,99999); |
|
34 |
|
|
35 |
// get questions and answers |
|
36 |
$qa = array(); |
|
37 |
@$content = file($file); |
|
38 |
if($content===FALSE) { |
|
39 |
echo '<b>Error</b>: Can not read text! Enter <b>0</b> to solve this captcha'; |
|
40 |
$_SESSION['captcha'] = '0'; |
|
41 |
exit; |
|
42 |
} |
|
43 |
reset($content); |
|
44 |
while($s = current($content)) { |
|
45 |
// get question |
|
46 |
$s=trim(rtrim(rtrim($s,"\n"),"\r")); // remove newline |
|
47 |
if($s=='' OR $s{0}!='?') { |
|
48 |
next($content); |
|
49 |
continue; |
|
50 |
} |
|
51 |
if(isset($s{3}) && $s{3}==':') { |
|
52 |
$lang=substr($s,1,2); |
|
53 |
$q=substr($s,4); |
|
54 |
} else { |
|
55 |
$lang='XX'; |
|
56 |
$q=substr($s,1); |
|
57 |
} |
|
58 |
// get answer |
|
59 |
$s=next($content); |
|
60 |
$s=trim(rtrim(rtrim($s,"\n"),"\r")); // remove newline |
|
61 |
if($s{0}!='!') continue; |
|
62 |
$a=substr($s,1); |
|
63 |
$qa[$lang][$q]=$a; |
|
64 |
next($content); |
|
65 |
} |
|
66 |
if($qa == array()) { |
|
67 |
echo '<b>Error</b>: no text defined! Enter <b>0</b> to solve this captcha'; |
|
68 |
$_SESSION['captcha'] = '0'; |
|
69 |
exit; |
|
70 |
} |
|
71 |
|
|
72 |
// choose language to use |
|
73 |
if(defined('LANGUAGE') && isset($qa[LANGUAGE])) |
|
74 |
$lang = LANGUAGE; |
|
75 |
else |
|
76 |
$lang = 'XX'; |
|
77 |
if(!isset($qa[$lang])) { |
|
78 |
echo '<b>Error</b>: no text defined! Enter <b>0</b> to solve this captcha'; |
|
79 |
$_SESSION['captcha'] = '0'; |
|
80 |
exit; |
|
81 |
} |
|
82 |
|
|
83 |
// choose random question |
|
84 |
$k = array_rand($qa[$lang]); |
|
85 |
|
|
86 |
$_SESSION['captcha'] = $qa[$lang][$k]; |
|
87 |
|
|
88 |
echo $k; |
|
89 |
|
|
90 |
?> |
|
0 | 91 |
trunk/wb/include/captcha/captcha.php | ||
---|---|---|
61 | 61 |
'calc_image'=>$MOD_CAPTCHA_CONTROL['CALC_IMAGE'], |
62 | 62 |
'calc_ttf_image'=>$MOD_CAPTCHA_CONTROL['CALC_TTF_IMAGE'], |
63 | 63 |
'ttf_image'=>$MOD_CAPTCHA_CONTROL['TTF_IMAGE'], |
64 |
'old_image'=>$MOD_CAPTCHA_CONTROL['OLD_IMAGE'] |
|
64 |
'old_image'=>$MOD_CAPTCHA_CONTROL['OLD_IMAGE'], |
|
65 |
'text'=>$MOD_CAPTCHA_CONTROL['TEXT'] |
|
65 | 66 |
); |
66 | 67 |
} elseif(extension_loaded('gd') && function_exists('imagepng')) { |
67 | 68 |
$useable_captchas = array( |
68 | 69 |
'calc_text'=>$MOD_CAPTCHA_CONTROL['CALC_TEXT'], |
69 | 70 |
'calc_image'=>$MOD_CAPTCHA_CONTROL['CALC_IMAGE'], |
70 |
'old_image'=>$MOD_CAPTCHA_CONTROL['OLD_IMAGE'] |
|
71 |
'old_image'=>$MOD_CAPTCHA_CONTROL['OLD_IMAGE'], |
|
72 |
'text'=>$MOD_CAPTCHA_CONTROL['TEXT'] |
|
71 | 73 |
); |
72 | 74 |
} else { |
73 | 75 |
$useable_captchas = array( |
74 |
'calc_text'=>$MOD_CAPTCHA_CONTROL['CALC_TEXT'] |
|
76 |
'calc_text'=>$MOD_CAPTCHA_CONTROL['CALC_TEXT'], |
|
77 |
'text'=>$MOD_CAPTCHA_CONTROL['TEXT'] |
|
75 | 78 |
); |
76 | 79 |
} |
77 | 80 |
|
... | ... | |
82 | 85 |
$_SESSION['captcha_time'] = $t; |
83 | 86 |
|
84 | 87 |
switch(CAPTCHA_TYPE) { |
88 |
// 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 |
<td><input type="text" name="captcha" maxlength="10" style="width:70px" /></td> |
|
93 |
<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_QUEST']; ?></td> |
|
94 |
</tr></table><?php |
|
95 |
break; |
|
85 | 96 |
// two special cases |
86 | 97 |
case 'calc_text': // calculation as text |
87 | 98 |
?><table class="captcha_table"><tr> |
88 |
<td><?php include(WB_PATH.'/include/captcha/captchas/calc_text.php'); ?> = </td> |
|
99 |
<td class="text_captcha"><?php include(WB_PATH.'/include/captcha/captchas/calc_text.php'); ?> = </td>
|
|
89 | 100 |
<td><input type="text" name="captcha" maxlength="5" style="width:20px" /></td> |
90 | 101 |
<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_RES']; ?></td> |
91 | 102 |
</tr></table><?php |
92 | 103 |
break; |
93 | 104 |
case 'calc_image': // calculation with image (old captcha) |
94 | 105 |
?><table class="captcha_table"><tr> |
95 |
<td><img src="<?php echo WB_URL."/include/captcha/captchas/calc_image.php?t=$t"; ?>" alt="Captcha" /></td><td> = </td> |
|
106 |
<td class="image_captcha"><img src="<?php echo WB_URL."/include/captcha/captchas/calc_image.php?t=$t"; ?>" alt="Captcha" /></td><td> = </td>
|
|
96 | 107 |
<td><input type="text" name="captcha" maxlength="5" style="width:20px" /></td> |
97 | 108 |
<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_RES']; ?></td> |
98 | 109 |
</tr></table><?php |
... | ... | |
102 | 113 |
case 'calc_ttf_image': // calculation with varying background and ttf-font |
103 | 114 |
case 'old_image': // old captcha |
104 | 115 |
?><table class="captcha_table"><tr> |
105 |
<td><img src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t"; ?>" alt="Captcha" /></td> |
|
116 |
<td class="image_captcha"><img src="<?php echo WB_URL.'/include/captcha/captchas/'.CAPTCHA_TYPE.".php?t=$t"; ?>" alt="Captcha" /></td>
|
|
106 | 117 |
<td><input type="text" name="captcha" maxlength="5" style="width:50px" /></td> |
107 | 118 |
<td class="captcha_expl"><?php echo $MOD_CAPTCHA['VERIFICATION_INFO_TEXT']; ?></td> |
108 | 119 |
</tr></table><?php |
trunk/wb/modules/captcha_control/tool.php | ||
---|---|---|
51 | 51 |
captcha_type = '$captcha_type' |
52 | 52 |
"); |
53 | 53 |
|
54 |
// save text-captchas |
|
55 |
if($_POST['captcha_type'] == 'text') { |
|
56 |
$text_qa=$admin->add_slashes($_POST['text_qa']); |
|
57 |
if($fh = fopen(WB_PATH.'/temp/.captcha_text.txt', 'wb')) { |
|
58 |
fwrite($fh, $text_qa); |
|
59 |
fclose($fh); |
|
60 |
} |
|
61 |
} |
|
62 |
|
|
54 | 63 |
// check if there is a database error, otherwise say successful |
55 | 64 |
if($database->is_error()) { |
56 | 65 |
$admin->print_error($database->get_error(), $js_back); |
... | ... | |
63 | 72 |
// include captcha-file |
64 | 73 |
require_once(WB_PATH .'/include/captcha/captcha.php'); |
65 | 74 |
|
75 |
// load text-captchas |
|
76 |
$text_qa=''; |
|
77 |
if(file_exists(WB_PATH.'/include/captcha/captchas/text.php')) { |
|
78 |
if(file_exists(WB_PATH.'/temp/.captcha_text.txt')) { |
|
79 |
@$content = file(WB_PATH.'/temp/.captcha_text.txt'); |
|
80 |
if($content!==FALSE) { |
|
81 |
$text_qa = $admin->strip_slashes(implode('', $content)); |
|
82 |
} |
|
83 |
} |
|
84 |
} |
|
85 |
|
|
66 | 86 |
// script to load image |
67 | 87 |
?> |
68 | 88 |
<script type="text/javascript"> |
... | ... | |
83 | 103 |
pics["calc_text"] = new Image(); |
84 | 104 |
pics["calc_text"].src = "<?php echo WB_URL.'/include/captcha/captchas/calc_text.png'?>"; |
85 | 105 |
|
106 |
pics["text"] = new Image(); |
|
107 |
pics["text"].src = "<?php echo WB_URL.'/include/captcha/captchas/text.png'?>"; |
|
108 |
|
|
86 | 109 |
function load_captcha_image() { |
87 | 110 |
document.captcha_example.src = pics[document.store_settings.captcha_type.value].src; |
111 |
toggle_text_qa(); |
|
88 | 112 |
} |
113 |
|
|
114 |
function toggle_text_qa() { |
|
115 |
if(document.store_settings.captcha_type.value == 'text' ) { |
|
116 |
document.getElementById('text_qa').style.display = ''; |
|
117 |
} else { |
|
118 |
document.getElementById('text_qa').style.display = 'none'; |
|
119 |
} |
|
120 |
} |
|
121 |
|
|
89 | 122 |
</script> |
90 | 123 |
<?php |
91 | 124 |
|
... | ... | |
126 | 159 |
</select> |
127 | 160 |
</td> |
128 | 161 |
</tr> |
162 |
<tr id="text_qa" style="display:<?php if($captcha_type=='text') echo ''; else echo 'none'; ;?>;"> |
|
163 |
<td class="setting_name"><?php echo $MOD_CAPTCHA_CONTROL['CAPTCHA_ENTER_TEXT'];?>:</td> |
|
164 |
<td class="setting_value" colspan="2"> |
|
165 |
<textarea name="text_qa" wrap="off" cols="50" rows="10"><?php echo $text_qa; ?></textarea> |
|
166 |
</td> |
|
167 |
</tr> |
|
129 | 168 |
<tr> |
130 | 169 |
<td><?php echo $MOD_CAPTCHA_CONTROL['USE_SIGNUP_CAPTCHA'];?>:</td> |
131 | 170 |
<td> |
trunk/wb/modules/captcha_control/languages/EN.php | ||
---|---|---|
39 | 39 |
$MOD_CAPTCHA_CONTROL['DISABLED'] = 'Disabled'; |
40 | 40 |
$MOD_CAPTCHA_CONTROL['ASP_CONF'] = 'Advanced Spam Protection Configuration'; |
41 | 41 |
$MOD_CAPTCHA_CONTROL['ASP_TEXT'] = 'Activate ASP (if available)'; |
42 |
$MOD_CAPTCHA_CONTROL['ASP_EXP'] = 'ASP tries to determine if a form-inputs was originated from a human or a spam-bot.'; |
|
43 |
$MOD_CAPTCHA_CONTROL['CALC_TEXT'] = "Calculation as text"; |
|
44 |
$MOD_CAPTCHA_CONTROL['CALC_IMAGE'] = "Calculation as image"; |
|
45 |
$MOD_CAPTCHA_CONTROL['CALC_TTF_IMAGE'] = "Calculation as image with varying fonts and backgrounds"; |
|
46 |
$MOD_CAPTCHA_CONTROL['TTF_IMAGE'] = "Image with varying fonts and backgrounds"; |
|
47 |
$MOD_CAPTCHA_CONTROL['OLD_IMAGE'] = "Old style (not recommended)"; |
|
42 |
$MOD_CAPTCHA_CONTROL['ASP_EXP'] = 'ASP tries to determine if a form-input was originated from a human or a spam-bot.'; |
|
43 |
$MOD_CAPTCHA_CONTROL['CALC_TEXT'] = 'Calculation as text'; |
|
44 |
$MOD_CAPTCHA_CONTROL['CALC_IMAGE'] = 'Calculation as image'; |
|
45 |
$MOD_CAPTCHA_CONTROL['CALC_TTF_IMAGE'] = 'Calculation as image with varying fonts and backgrounds'; |
|
46 |
$MOD_CAPTCHA_CONTROL['TTF_IMAGE'] = 'Image with varying fonts and backgrounds'; |
|
47 |
$MOD_CAPTCHA_CONTROL['OLD_IMAGE'] = 'Old style (not recommended)'; |
|
48 |
$MOD_CAPTCHA_CONTROL['TEXT'] = 'Text-CAPTCHA'; |
|
49 |
$MOD_CAPTCHA_CONTROL['CAPTCHA_ENTER_TEXT']= 'Questions and Answers'; |
|
48 | 50 |
|
49 | 51 |
$MOD_CAPTCHA['VERIFICATION'] = 'Verification'; |
50 | 52 |
$MOD_CAPTCHA['ADDITION'] = 'add'; |
... | ... | |
52 | 54 |
$MOD_CAPTCHA['MULTIPLIKATION'] = 'multiply'; |
53 | 55 |
$MOD_CAPTCHA['VERIFICATION_INFO_RES'] = 'Fill in the result'; |
54 | 56 |
$MOD_CAPTCHA['VERIFICATION_INFO_TEXT'] = 'Fill in the text'; |
57 |
$MOD_CAPTCHA['VERIFICATION_INFO_QUEST'] = 'Answer the question'; |
|
55 | 58 |
$MOD_CAPTCHA['INCORRECT_VERIFICATION'] = 'Verification failed'; |
56 | 59 |
|
57 | 60 |
?> |
trunk/wb/modules/captcha_control/languages/DE.php | ||
---|---|---|
43 | 43 |
$MOD_CAPTCHA_CONTROL['ASP_CONF'] = 'Erweiterter-Spam-Schutz (ASP) Einstellungen'; |
44 | 44 |
$MOD_CAPTCHA_CONTROL['ASP_TEXT'] = 'ASP benutzen (wenn im Modul vorhanden)'; |
45 | 45 |
$MOD_CAPTCHA_CONTROL['ASP_EXP'] = 'ASP versucht anhand der verschiedenen Verhaltensweisen zu erkennen, ob eine Formular-Eingabe von einem Menschen oder einem Spam-Bot kommt.'; |
46 |
$MOD_CAPTCHA_CONTROL['CALC_TEXT'] = "Rechnung als Text"; |
|
47 |
$MOD_CAPTCHA_CONTROL['CALC_IMAGE'] = "Rechnung als Bild"; |
|
48 |
$MOD_CAPTCHA_CONTROL['CALC_TTF_IMAGE'] = "Rechnung als Bild mit wechselnden Schriften und Hintergründen"; |
|
49 |
$MOD_CAPTCHA_CONTROL['TTF_IMAGE'] = "Bild mit wechselnden Schriften und Hintergründen"; |
|
50 |
$MOD_CAPTCHA_CONTROL['OLD_IMAGE'] = "Alter Stil (nicht empfohlen)"; |
|
46 |
$MOD_CAPTCHA_CONTROL['CALC_TEXT'] = 'Rechnung als Text'; |
|
47 |
$MOD_CAPTCHA_CONTROL['CALC_IMAGE'] = 'Rechnung als Bild'; |
|
48 |
$MOD_CAPTCHA_CONTROL['CALC_TTF_IMAGE'] = 'Rechnung als Bild mit wechselnden Schriften und Hintergründen'; |
|
49 |
$MOD_CAPTCHA_CONTROL['TTF_IMAGE'] = 'Bild mit wechselnden Schriften und Hintergründen'; |
|
50 |
$MOD_CAPTCHA_CONTROL['OLD_IMAGE'] = 'Alter Stil (nicht empfohlen)'; |
|
51 |
$MOD_CAPTCHA_CONTROL['TEXT'] = 'Text-CAPTCHA'; |
|
52 |
$MOD_CAPTCHA_CONTROL['CAPTCHA_ENTER_TEXT']= 'Fragen und Antworten'; |
|
51 | 53 |
|
52 | 54 |
$MOD_CAPTCHA['VERIFICATION'] = 'Prüfziffer'; |
53 | 55 |
$MOD_CAPTCHA['ADDITION'] = 'plus'; |
... | ... | |
55 | 57 |
$MOD_CAPTCHA['MULTIPLIKATION'] = 'mal'; |
56 | 58 |
$MOD_CAPTCHA['VERIFICATION_INFO_RES'] = 'Bitte Ergebnis eintragen'; |
57 | 59 |
$MOD_CAPTCHA['VERIFICATION_INFO_TEXT'] = 'Bitte Text eintragen'; |
60 |
$MOD_CAPTCHA['VERIFICATION_INFO_QUEST'] = 'Bitte Frage beantworten'; |
|
58 | 61 |
$MOD_CAPTCHA['INCORRECT_VERIFICATION'] = 'Ergebnis ist falsch. Bitte neu eintragen'; |
59 | 62 |
|
60 | 63 |
?> |
Also available in: Unified diff
Added Text-CAPTCHA on request. The captcha-text will be stored in temp/.captcha_text.txt