changed git call from https to git readonly
[atutor.git] / mods / wiki / plugins / linking / zero_pagerank.php
1 <?php
2
3 /*
4    enabling this will filter all BannedLinks through a page rank
5    killer (google.com itself or "fragments/zero_pagerank.php")
6    - you could use "plugins/edit/spam_deface" alternatively
7    - the advantage of _this_ plugin however is, that it always can
8      filter banned urls, while the plugins/edit/ version only works
9      at edit time (and if the URL was already listed on BannedLinks)
10 */
11
12 // define("ZERO_PAGERANK", "http://erfurtwiki.sourceforge.net/fragments/zero_pagerank.php?url=");
13 define("ZERO_PAGERANK", "http://www.google.com/url?sa=D&q=");
14 define("EWIKI_PAGE_BANNED", "BannedLinks");
15 $ewiki_config["info_refs_once"] = 1;
16
17
18 $ewiki_plugins["link_url"][] = "ewiki_link_url_zero_pagerank";
19 function ewiki_link_url_zero_pagerank(&$href, &$title) {
20    if (ewiki_banned_link($href)) {
21       $href = ZERO_PAGERANK . urlencode($href);
22    }
23 }
24
25
26 function ewiki_banned_link($href) {
27    global $ewiki_config;
28    
29    #-- buffer list of banned urls
30    if (!isset($ewiki_config["banned"])) {
31       $data = ewiki_db::GET(EWIKI_PAGE_BANNED);
32       $ewiki_config["banned"] = trim(strtolower($data["refs"]));
33    }
34
35    #-- check for entry
36    if ($b = &$ewiki_config["banned"]) {
37       $href = strtolower(urldecode($href));
38       if (strpos($b, $href) !== false) {
39          return(true);
40       }
41       foreach (explode("\n", $b) as $bad) {
42          if (strpos($href, $bad) !== false) {
43             return(true);
44          }
45       }
46    }
47
48    #-- advanced
49    if ($pf_a = $ewiki_plugins["ban_lookup"]) {
50       foreach ($pf_a as $pf) {
51          if ($pf($href)) {
52             return(true);
53          }
54       }
55    }
56
57    return(false);
58 }
59
60
61 ?>