====== Blacklisting ======
The internet isn't the place it used to be anymore. Everything good gets corrupted and so it is with Wikis. [[meatball>WikiSpam]] is -- like Spam in blogs and email -- on the rise. If you use [[DokuWiki]] in your Intranet this is no problem for you. But if you intend to use it on the open Internet you may want to blacklist some known Spam words.
For using a blacklist in DokuWiki enable the ''usewordblock'' option in ''conf/dokuwiki.php'' and edit the ''conf/wordblock.conf''. The file contains [[wp>Regular Expressions]] (Perl compatible) if any of these match saving is disallowed.
By default the list contains the expressions maintained by the folks at [[http://chongqed.org/|chongqed.org]]. To update your blacklist run the following command (adding it as a daily cronjob could be a good idea):
$> wget http://blacklist.chongqed.org/ -O conf/wordblock.conf
When your Wiki is spammed despite a current blacklist, please take the time to [[http://chongqed.org/submit.html|submit spammers]] to chongqed.org. You can also report spam on their [[http://wiki.chongqed.org//SpamReport|wiki]] if that is more convenient.
If you want to do IP based blocking you should use Apache's [[http://httpd.apache.org/docs/mod/mod_access.html#deny|deny from]] directives.
\\
===== Logging of blocked Attacks =====
This small change makes it possible to log blocked attacks in \DATA\meta\wordblock.log and can also be used for block lists debugging.\\
But need a modification of a original Dokuwiki file.
**File:**
\inc\common.php
**Search Line:**
if(preg_match('#('.join('|',$re).')#si',$text, $match=array())) {
return true;
}
**Change:**
if(preg_match('#('.join('|',$re).')#si',$text, $match=array())) {
preg_match('#('.join('|',$re).')#si',$text, $match);
io_saveFile($conf['metadir'].'/wordblock.log', date($conf['dformat'])."\t".$match[0]."\t".$ID.$_SERVER['REMOTE_USER']."\t".$_SERVER['REMOTE_ADDR'].":".$_SERVER['SERVER_PORT']."\t".gethostbyaddr($_SERVER['REMOTE_ADDR'])."\t".$_SERVER['HTTP_USER_AGENT']."\n",true);
return true;
}