Check our new

Forum for users of JoomlaWatch / ExtraWatch for Joomla, Wordpress, Drupal, Magento, Prestashop

JoomlaWatch / ExtraWatch has following features: live real-time visitor statistics, location of your visitors on a map, blocking of users based on bad word list, front-end counters, click heat map, definition of goals and rules, graphs, directory size monitoring, monitoring of increase of database data in time, nightly email reports, interactive HTML5 chart of traffic flow within your website, SEO report with keyword statistics and keyword position trends

Welcome, Guest
Please Login or Register.    Lost Password?

New function for MathGuard
(1 viewing) (1) Guest
Go to bottomPage: 1
TOPIC: New function for MathGuard
New function for MathGuard 11 Years, 6 Months ago  
I created this very simple new function for MathGuard that basically creates two hidden inputs, one with the answer the user should enter, and the other with the encrypted answer.

This function is very usefull when you have the form in the same page as the one that checks the MathGuard answer, as when the form is sent, the error: "Bad answer, go back to school!" would appear, as no MathGuard code would have been sent.

In my case, I have the MathGuard question in "page 1". Which sends the user's answer to "page 2". If the answer is incorrect, it shows the message "Bad answer, go back to school!". If the message is correct, it shows the form. When the form is sent, it is posted in "page 2" that validates the inputs, and if they are right, sends the e-mail. If I didn't use this function, when I sent the form, the error "Bad answer, go back to school!" would appear, as no MathGuard code or answer would have been sent.

Here is the function to be added in ClassMathGuard.php:


/*Inserts the question and the answer as hidden, so that they can be sent to the same page again. Funtion by Thumped*/
function insertQuestionAnswer($prime = 41) { //default prime is 37, you can change it when specifying the different parameter
$a = rand() % 10; // generates the random number
$b = rand() % 10; // generates the random number
$ab = $a + $b;
$code = MathGuard :: generateCode($a, $b, $prime);
$output .= "" .
"<input type='hidden' name='mathguard_answer' value='$ab' /><input type='hidden' name='mathguard_code' value='$code' />";
echo $output;

I hope this helps someone.
user193 (Visitor)

The administrator has disabled public write access.
Re:New function for MathGuard 11 Years, 5 Months ago  
Thank you for your suggestion ,

But don't you think this would be for nothing? You will paste the security answer directly into HTML code and this can easily help the spambots.

This way they would have to read this hidden field, fill with it the answer box and submit the form.

Makes no sense for me how this could help other users. Only in case you are an author of some spambot
user194 (Visitor)

The administrator has disabled public write access.
Go to topPage: 1

This website uses cookies to ensure you get the best experience on our website. Learn More.

Got It!