=====SpamBlacklist Plugin===== This is a spam blacklisting plugin, I've written. The blacklist is stored on a wiki page. You may optionally enable a log file to log successfully blocked spam. The plugin is using [[http://en.wikipedia.org/wiki/teergrubing teergrubing]] to keep the connection of the spammer open for at least 20 seconds! At first, place the following code as a new file, with the filename **spamblacklist.php**, under **3rdparty/plugins**, into your wikka installation: %%(php;1) config["sbl_page"]) die("SpamBlacklist: Please configure the plugin first!"); $body = sb_unhtmlentities(trim($body)); $sb_blacklist = $wikkaref->LoadPage($wikkaref->config["sbl_page"]); if ((!$wikkaref->GetUser() || !$wikkaref->config["sbl_only_anon"]) && $wikkaref->tag != $wikkaref->config["sbl_page"]) { if ($sb_blacklist && isset($sb_blacklist["body"])) { $sb_blacklist = $sb_blacklist["body"]; $sb_blacklist = explode("\n", $sb_blacklist); foreach ($sb_blacklist as $sb_expression) { if (preg_match('/(^\s*$|^\s*#)/', $sb_expression)) continue; if (preg_match($sb_expression, $body)) { if ($wikkaref->config["sbl_logfile"]) { $sb_fp = fopen($wikkaref->config["sbl_logfile"], "a"); if ($sb_fp && flock($sb_fp, LOCK_EX)) { $sb_logline = date("M d Y H:i:s") . "\t"; $sb_logline .= $sb_expression . "\t"; $sb_logline .= $wikkaref->GetUserName() . "\n"; fwrite($sb_fp, $sb_logline); fclose($sb_fp); } } sb_do_output_magic($wikkaref); exit(); } } } } } // Function for decoding all html entities // http://www.php.net/manual/en/function.html-entity-decode.php function sb_unhtmlentities($string) { $string = html_entity_decode($string); $string = preg_replace('~([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string); $string = preg_replace('~([0-9]+);~e', 'chr("\\1")', $string); return $string; } // Function for doing the output magic // Will send the user a message first // Then a short definition of "spam" is sent *really* slow, to slow down // the spammer (teergrubing). The whole process takes about 20 seconds. // This should be within the "max_execution_time" of most providers. function sb_do_output_magic($wikkaref) { $slow_message = array("Spamming", "is", "the", "abuse", "of", "electronic", "messaging", "systems", "to", "send", "unsolicited", "bulk", "messages,", "which", "are", "almost", "universally", "undesired."); while(@ob_end_clean()); $headercode = file_get_contents("actions/header.php"); $headercode = str_replace('$this->', '$wikkaref->', $headercode); eval("?>" . $headercode); print("