Revision 640
Added by thorn almost 17 years ago
text.php | ||
---|---|---|
27 | 27 |
if(defined('WB_PATH') == false) { exit("Cannot access this file directly"); } |
28 | 28 |
|
29 | 29 |
global $admin; |
30 |
global $database; |
|
30 | 31 |
$name = 'text'; |
31 | 32 |
$file = WB_PATH."/temp/.captcha_$name.php"; |
32 | 33 |
|
... | ... | |
34 | 35 |
$_SESSION['captcha'] = rand(0,99999); |
35 | 36 |
|
36 | 37 |
// get questions and answers |
37 |
$qa = array(); |
|
38 |
@$content = file($file); |
|
39 |
if($content===FALSE) { |
|
40 |
echo '<b>Error</b>: Can not read text! Enter <b>0</b> to solve this captcha'; |
|
41 |
$_SESSION['captcha'] = '0'; |
|
42 |
return; |
|
38 |
$text_qa=''; |
|
39 |
$table = TABLE_PREFIX.'mod_captcha_control'; |
|
40 |
if($query = $database->query("SELECT ct_text FROM $table")) { |
|
41 |
$data = $query->fetchRow(); |
|
42 |
$text_qa = $admin->strip_slashes($data['ct_text']); |
|
43 | 43 |
} |
44 |
$content = explode("\n", $text_qa); |
|
45 |
|
|
44 | 46 |
reset($content); |
45 | 47 |
while($s = current($content)) { |
46 | 48 |
// get question |
... | ... | |
56 | 58 |
} else { |
57 | 59 |
$lang='XX'; |
58 | 60 |
$q=substr($s,1); |
61 |
if($q=='') { |
|
62 |
next($content); |
|
63 |
continue; |
|
64 |
} |
|
59 | 65 |
} |
60 | 66 |
// get answer |
61 | 67 |
$s=next($content); |
... | ... | |
67 | 73 |
next($content); |
68 | 74 |
} |
69 | 75 |
} |
70 |
if($qa == array()) { |
|
76 |
if(!isset($qa) || $qa == array()) {
|
|
71 | 77 |
echo '<b>Error</b>: no text defined! Enter <b>0</b> to solve this captcha'; |
72 | 78 |
$_SESSION['captcha'] = '0'; |
73 | 79 |
return; |
... | ... | |
91 | 97 |
|
92 | 98 |
echo $k; |
93 | 99 |
|
94 |
?> |
|
100 |
?> |
Also available in: Unified diff
Text-captcha: moved text-file to database.