Hello guys,
I had been trying to ignore this problem as it happens only once in a while. I use to write a sql script to clean up the spam. But it surfaced again this time, posting some 50 spams. I thought I would do something about it, like I had told sometime back.
This is what I have done. I have done only one testing.
I have enhanced the banIP functionality to ban an IP if there has been posting from this IP in the last 10 mins. Presumption is that a normal human being will require atleast 10 mins of reading to post a sensible comment . It can be changed based on individual requirement
Please change the code in comment.class.php under comment/joscomment folder in the function
function isBlocked($ip)
function isBlocked($ip)
{
if ($this->_ban != '') {
$ipList = split(',', $this->_ban);
foreach($ipList as $item) {
if (trim($item) == $ip) return true;
}
}
//Ingu :: check if comments have been posted within the last 10 mins from the same IP
//if yes, disallow. For a human being to comment properly, he would spend more than
// 10 mins to ponder
global $database;
$database->SetQuery("SELECT * FROM jos_comment WHERE ip='$ip' and date > DATE_SUB(now(),INTERVAL '0:10' HOUR_MINUTE)");
$data = $database->loadAssocList(); // or die('Database error: getNewPost!');
if ($data) {
//if some rows are returned, mark the IP as a banned ip.
return true;
}
return false;
}
Hope this helps fellow guys.
Hey Daniel,
Maybe this feature can flow into the regular release. The number of mins can be parameterized. Check it out.
Cheers,
Ingu