4 The page "BannedLinks" can hold URLs (or domain name / link patterns,
5 if put into square brackets) which will be filtered from the Wiki
6 everytime someone tries to put them on a page.
7 Filtering uses Google or a special redirection page to decrease
10 - use this plugin if you encounter consecutive spam injection; it
11 is the preferred/recommended method
12 - plugins/linking/zero_pagerank.php is however more accurate and
13 up-to-date with banned URLs, as it operates at rendering time
14 (but therefore was also slower)
17 // define("ZERO_PAGERANK", "http://www.google.com/url?sa=D&q=");
18 define("ZERO_PAGERANK", "http://erfurtwiki.sourceforge.net/fragments/zero_pagerank.php?url=");
19 define("EWIKI_PAGE_BANNED", "BannedLinks");
20 $ewiki_config["info_refs_once"] = 1; // disable {refs} info/ for old versions
23 $ewiki_plugins["edit_save"][] = "ewiki_edit_save_antispam_urldeface";
24 function ewiki_edit_save_antispam_urldeface(&$save, &$old) {
26 preg_match_all('°(http://[^\s*<>"\'\[\]\#]+)°', $old["content"], $old_urls);
27 preg_match_all('°(http://[^\s*<>"\'\[\]\#]+)°', $save["content"], $save_urls);
29 $added_urls = array_diff($save_urls[1], $old_urls[1]);
31 foreach ($added_urls as $url) {
33 #-- test against BannedLinks, then deface (filter page) URL
34 if (ewiki_banned_link($url)) {
35 $save["content"] = str_replace($url, ZERO_PAGERANK.urlencode($url), $save["content"]);
42 function ewiki_banned_link($href) {
43 global $ewiki_config, $ewiki_plugins;
45 #-- buffer list of banned urls
46 if (!isset($ewiki_config["banned"])) {
47 $data = ewiki_db::GET(EWIKI_PAGE_BANNED);
48 $ewiki_config["banned"] = trim(strtolower($data["refs"]));
52 if ($b = &$ewiki_config["banned"]) {
53 $href = strtolower(urldecode($href));
54 if (strpos($b, $href) !== false) { // quick string check
57 foreach (explode("\n", $b) as $bad) { // use as patterns
58 if (strpos($href, $bad) !== false) {
65 if ($pf_a = $ewiki_plugins["ban_lookup"]) {
66 foreach ($pf_a as $pf) {