PluginProbe
Watu Quiz / 3.4.4
Watu Quiz v3.4.4
3.4.8 trunk 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.5.3 3.4.6 3.4.7
watu / lib / text-captcha.php

text-captcha.php in Watu Quiz 3.4.4, at lib/text-captcha.php

38 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 class WatuTextCaptcha {
3 // verify the captcha
4 static function verify($question, $answer) {
5 $answer = stripslashes($answer);
6
7 $captcha_questions = get_option('watu_text_captcha');
8 $captcha_questions = explode("\n", $captcha_questions);
9
10 $question = base64_decode($question);
11
12 foreach($captcha_questions as $captcha_question) {
13 list($q, $a) = explode("=", $captcha_question);
14 $q = trim($q);
15 $q = stripslashes($q);
16 $a = stripslashes($a);
17
18 if(strcmp($q, $question) == 0 and strcasecmp(trim($a), trim($answer)) == 0) return true;
19 }
20
21 // in any other case return false
22 return false;
23 }
24
25 // generate the captcha
26 static function generate() {
27 $captcha_questions = get_option('watu_text_captcha');
28 $captcha_questions = explode("\n", $captcha_questions);
29
30 // just get random
31 shuffle($captcha_questions);
32 $question = $captcha_questions[0];
33 list($q, $a) = explode("=", $question);
34 $q = stripslashes($q);
35
36 return trim($q)." <input type='text' name='watu_text_captcha_answer'>\n<input type='hidden' name='watu_text_captcha_question' value=\"".base64_encode(trim($q))."\">";
37 }
38 }