ae2c91d68f905e523ddbb7c6f4911dedf2689bcc
[atutor.git] / mods / wiki / plugins / lib / spamblock_whois.php
1 <?php
2 /*
3    Initiates a whois query on the domain names of newly added URLs,
4    compares gathered informations against "BannedLinks" data (names
5    or email / addresses) and blocks any suspect 'contributions'. Works
6    only in conjunction with "plugins/edit/spam_deface".
7    
8    @feature: spammer-lookup-whois
9    @depends: spam-link-deface
10    @title: spammer whois lookup
11    @desc: scans newly submitted links against whois databases
12 */
13
14
15 $ewiki_plugins["ban_loopup"][] = "ewiki_spam_ban_whois_lookup";
16
17 function ewiki_spam_ban_whois_lookup($href) {
18    global $ewiki_config;
19    $b = &$ewiki_config["banned"];   // is already filled at this point
20    
21    $p1 = strpos($href, "//") + 2;
22    $domain = substr($href, $p1);
23    $domain = substr($href, 0, strpos($domain, "/"));
24
25    $whoistxt = `whois -H -T dn,ro,pn $domain`;
26    if ($whoistxt = strtolower($whoistxt)) {
27       foreach (explode("\n", $b) as $pat) {
28          if (strpos($whoistxt, $pat)) {
29             return(true);
30          }
31       }
32    }
33 }
34
35 ?>