Handler: Spam-Protection for comments
| Compatible with: R4.2 Current version: Credits: AhA[link1] |
1. Concerned files:
- /handlers/show.php
- /handlers/addcomment.php
- /lang/wacko.xy.php
2. Documentation
for users available for copy and paste3. How to / Changes
3.1. 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" /> 3.2. 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 3.3. 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.", 3.4. Localization (optional)
put this at the end of your language filelang/custom.<lang>.php
//hacks 'YourPhrase' => 'your translation here',
[xy] proposed translations
[de] ...
[fr]
[ru]
4. To Do
Referring pages:
- Dev/PatchesHacks[link2]
- Users/AhA[link3]
5. 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[link4]
Good luck
- [link1] https://wackowiki.org/doc/Users?profile=AhA
- [link2] https://wackowiki.org/doc/Dev/PatchesHacks#a-249
- [link3] https://wackowiki.org/doc/Users/AhA#a-249
- [link4] http://www.osrm.ch/~AHeutsch/wackowikisfc.zip