Commit 8b9ae69b authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Allow spam score threshold to be passed for each form rather than defined on the page


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent e75240bf
......@@ -34,7 +34,6 @@ require('init.php');
require_once('pieforms/pieform.php');
require_once('lib/antispam.php');
define('TITLE', get_string('contactus'));
define('SPAM_SCORE', 3);
if ($USER->is_logged_in()) {
$userid = $USER->get('id');
......
......@@ -37,9 +37,9 @@ class NoneSpamTrap {
$this->fields = $fields;
}
public function is_spam() {
public function is_spam($threshold=3) {
// if no spam score threshold is defined, never call something spam
if (!defined('SPAM_SCORE')) {
if (empty($threshold)) {
return false;
}
$score = 0;
......@@ -49,7 +49,7 @@ class NoneSpamTrap {
$score += $this->$method($field['value']);
}
}
if ($score > SPAM_SCORE) {
if ($score > $threshold) {
return true;
}
return false;
......
......@@ -34,7 +34,6 @@ require('init.php');
require_once('pieforms/pieform.php');
require_once('lib/antispam.php');
define('TITLE', get_string('register'));
define('SPAM_SCORE', 3);
$key = param_alphanum('key', null);
/*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment