diff --git a/code/sitefeatures/MathSpamProtection.php b/code/sitefeatures/MathSpamProtection.php
index 841894b9..091fd321 100644
--- a/code/sitefeatures/MathSpamProtection.php
+++ b/code/sitefeatures/MathSpamProtection.php
@@ -38,7 +38,15 @@ class MathSpamProtection {
static function correctAnswer($answer){
$v1 = Session::get("mathQuestionV1");
$v2 = Session::get("mathQuestionV2");
- return (MathSpamProtection::digitToWord($v1 + $v2) == $answer || ($v1 + $v2) == $answer) ? true : false;
+
+ Session::clear('mathQuestionV1');
+ Session::clear('mathQuestionV2');
+
+ if(MathSpamProtection::digitToWord($v1 + $v2) == $answer || ($v1 + $v2) == $answer){
+ return true;
+ }
+ return false;
+
}
/**
diff --git a/code/sitefeatures/PageCommentInterface.php b/code/sitefeatures/PageCommentInterface.php
index 71bad90e..83070a9b 100755
--- a/code/sitefeatures/PageCommentInterface.php
+++ b/code/sitefeatures/PageCommentInterface.php
@@ -35,15 +35,11 @@ class PageCommentInterface extends ViewableData {
new HiddenField("ParentID", "ParentID", $this->page->ID),
new TextField("Name", "Your name")
);
+
if(MathSpamProtection::isEnabled()){
$fields->push(new TextField("Math","Spam protection question: ".MathSpamProtection::getMathQuestion()));
}
- /*//TODO
- if(CaptchaSpamProtection::isEnabled()){
- $fields->push(new TextField("Captcha",CaptchaSpamProtection::getImage()."
Please copy down the text from the image above"));
- } */
-
$fields->push(new TextareaField("Comment", "Comments"));
$form = new PageCommentInterface_Form($this->controller, $this->methodName . ".PostCommentForm",$fields, new FieldSet(
@@ -116,25 +112,15 @@ class PageCommentInterface_Form extends Form {
}
//check if spam question was right.
- if(MathSpamProtection::isEnabled()){
+ if(MathSpamProtection::isEnabled()){
if(!MathSpamProtection::correctAnswer($data['Math'])){
- if(Director::is_ajax()) {
- echo "
You got the spam protection question wrong.
You got the captcha protection question wrong.