PluginProbe
Watu Quiz / 3.4.6
Watu Quiz v3.4.6
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.6, at lib/text-captcha.php

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