changed git call from https to git readonly
[atutor.git] / mods / wiki / plugins / spam / cookieusers.php
1 <?php
2 /*
3    AntiSpam-plugins can safely be disabled for real users, which we can
4    easily sort out, because of cookies which bots and zombie machines
5    won't usually gain (ProtectedEmail and other Captcha-pass cookies).
6    This is another anti-trigger plugin.
7 */
8
9 define("EWIKI_UP_NOBOTCHK", "disable_bot_checks");
10
11 #-- detect already set cookies
12 $ewiki_plugins["init"][] = "ewiki_anti_trigger_bots_dont_use_cookies";
13 function ewiki_anti_trigger_bots_dont_use_cookies() {
14    global $ewiki_no_bot, $ewiki_config;
15    if (defined("EWIKI_UP_NOSPAMBOT") && isset($_COOKIES[EWIKI_UP_NOSPAMBOT])
16    or defined("EWIKI_UP_NOBOTCHK") && isset($_COOKIES[EWIKI_UP_NOBOTCHK])) {
17       $ewiki_no_bot = 1;
18    }
19    else {
20       $ewiki_config["bot_disable"] = 1;   // send a cookie later...
21    }
22 }
23
24 #-- set cookie for real users - after any captcha was solved e.g.
25 $ewiki_plugins["page_final"][] = "ewiki_page_final_cookieusers_set";
26 function ewiki_page_final_cookieusers_set() {
27    global $ewiki_no_bot, $ewiki_config;
28    if ($ewiki_no_bot && $ewiki_config["bot_disable"]) {
29       setcookie(EWIKI_UP_NOBOTCHK, "1", time()+21*24*3600, "/");
30    }
31 }
32
33 ?>