Handler: Spam-Protection for comments

Compatible with: R4.2
Current version:
Credits: AhA

Concerned files:

  • /handlers/show.php
  • /handlers/addcomment.php
  • /lang/wacko.xy.php

Documentation

for users available for copy and paste

How to / Changes

Step one

Add the following changes to the file /handlers/page/show.php:


Go to the lines 225/226 and you'll find the following code:


<textarea name="body" rows="6" cols="7" style="width: 100%"></textarea><br />
<input type="submit" value="<?php echo $this->_t('AttachCommentButton'); ?>" accesskey="s" />


Add the following code between the lines 225 and 226 (sorry, it's in german):


Schutz gegen Spam: Schreibe die Zahlen von 1-5 in das Feld  
<input name="nospam" type="text" value="" />  


Instead of 2 lines, you get now the following 4 lines:


<textarea name="body" rows="6" cols="7" style="width: 100%"></textarea><br />
Schutz gegen Spam: Schreibe die Zahlen von 1-5 in das Feld  
<input name="nospam" type="text" value="" />  
<input type="submit" value="<?php echo $this->_t('AttachCommentButton'); ?>" accesskey="s" />

Step two

Add the following changes to the file /handlers/page/addcomment.php:


1. Go to the lines 16/17, where you'll find the following code:


$body = trim($_POST['body']);
echo "Comment".$num."<p>".$body."<p>".$this->tag;


Add the following code between line 16 and 17:


$nospam = trim($_POST['nospam']);


The whole thing (lines 16, 17, 18):


$body = trim($_POST['body']);
$nospam = trim($_POST['nospam']);
echo "Comment".$num."<p>".$body."<p>".$this->tag;


2. Go to the lines 20-22, where you'll find the following code:


$this->set_message($this->_t('EmptyComment'));
}
else


Add the following code after line 21:


elseif (!strchr($nospam, "12345")) {
// Antispam-number must be entered
$this->set_message($this->_t('AntiSpam')); 
}


The whole new thing (lines 20-27):


$this->set_message($this->_t('EmptyComment'));
}  
elseif (!strchr($nospam, "12345")) {
// Antispam-number must be entered
$this->set_message($this->_t('AntiSpam')); 
}
else

Step three

Add the following line to the file /lang/wacko.de.php or your preferred localization-file:


"AntiSpam"    => "Schreibe die erforderlichen Angaben in das Feld.",

Localization (optional)

put this at the end of your language file


/lang/wacko.xy.php

//hacks
"YourPhrase" => "your translation here",


pls. notice that this entry will not survive an Wacko upgrade, so you have to redo this


[xy] proposed translations
[de] ...
[fr]
[ru]

To Do


Referring pages:

Dev/PatchesHacks
Users/AhA

Personal remarks

The hack is in german and "written" by an absolute "layman" (non-professional), but it functions and it is easy to install. Download the zip-file, unzip it and just copy the 3 files in the indicated directories (don't forget to rename the originals!


Download


Good luck

Show Files (1 file)