changed git call from https to git readonly
[atutor.git] / mods / wiki / plugins / spam / antibot_checkbox.php
1 <?php
2 /*
3    If you are having trouble with blog/comment spam, which originates
4    from hijacked Windows zombie computers this plugin can help. It adds
5    a simple [x] checkbox to the edit screen, which most bots cannot
6    overcome without being specifically retrained to target your Wiki.
7    This is just the simplest form of anti-bot captcha; something more
8    sophisticated is required as soon as the attackers adapt.
9 */
10
11 #-- text
12 $ewiki_t["en"]["ANTIBOT_CHECKBOX"] = "allow saving of page, I'm not a spambot";
13 $ewiki_t["en"]["ANTIBOT_FAILED"] = "Rejected. Go back and check the box below the [save] button.";
14
15 #-- show <checkbox>
16 $ewiki_plugins["edit_form_append"][] = "ewiki_aedit_antibot_checkbox";
17 function ewiki_aedit_antibot_checkbox($id, &$data, $action) {
18    if (!isset($GLOBALS["ewiki_no_bot"])) {
19       return(ewiki_t('<input type="checkbox" name="antibot_check" id="antibot_checkbox" value="1" /><label for="antibot_checkbox"> _{ANTIBOT_CHECKBOX}</label><br/>'));
20    }
21 }
22
23 #-- reject if not checked
24 $ewiki_plugins["edit_save"][] = "ewiki_edit_save_antibot_checkbox";
25 function ewiki_edit_save_antibot_checkbox(&$save, &$data) {
26    global $ewiki_errmsg;
27
28    if ((!$_REQUEST["antibot_check"]) && !isset($GLOBALS["ewiki_no_bot"])) {
29       $save = NULL;
30       $ewiki_errmsg = ewiki_t("ANTIBOT_FAILED");
31    }
32 }
33
34 ?>