static function install()
 {
     $version = module::get_version("recaptcha");
     if ($version == 0) {
         module::set_version("recaptcha", 1);
     }
     recaptcha::check_config();
 }
Beispiel #2
0
 public function index()
 {
     $form = recaptcha::get_configure_form();
     if (request::method() == "post") {
         // @todo move the "save" part of this into a separate controller function
         access::verify_csrf();
         $old_public_key = module::get_var("recaptcha", "public_key");
         $old_private_key = module::get_var("recaptcha", "private_key");
         if ($form->validate()) {
             $public_key = $form->configure_recaptcha->public_key->value;
             $private_key = $form->configure_recaptcha->private_key->value;
             if ($public_key && $private_key) {
                 module::set_var("recaptcha", "public_key", $public_key);
                 module::set_var("recaptcha", "private_key", $private_key);
                 message::success(t("reCAPTCHA configured!"));
                 log::success("recaptcha", t("reCAPTCHA public and private keys set"));
                 url::redirect("admin/recaptcha");
             } else {
                 if ($public_key && !$private_key) {
                     $form->configure_recaptcha->private_key->add_error("invalid");
                 } else {
                     if ($private_key && !$public_key) {
                         $form->configure_recaptcha->public_key->add_error("invalid");
                     } else {
                         module::set_var("recaptcha", "public_key", "");
                         module::set_var("recaptcha", "private_key", "");
                         message::success(t("No keys provided.  reCAPTCHA is disabled!"));
                         log::success("recaptcha", t("reCAPTCHA public and private keys cleared"));
                         url::redirect("admin/recaptcha");
                     }
                 }
             }
         }
     }
     recaptcha::check_config();
     $view = new Admin_View("admin.html");
     $view->page_title = t("reCAPTCHA");
     $view->content = new View("admin_recaptcha.html");
     $view->content->public_key = module::get_var("recaptcha", "public_key");
     $view->content->private_key = module::get_var("recaptcha", "private_key");
     $view->content->form = $form;
     print $view;
 }
Beispiel #3
0
 public function index()
 {
     $form = recaptcha::get_configure_form();
     if (request::method() == "post") {
         $old_public_key = module::get_var("recaptcha", "public_key");
         $old_private_key = module::get_var("recaptcha", "private_key");
         if ($form->validate()) {
             $public_key = $form->configure_recaptcha->public_key->value;
             $private_key = $form->configure_recaptcha->private_key->value;
             if ($public_key && $private_key) {
                 module::set_var("recaptcha", "public_key", $public_key);
                 module::set_var("recaptcha", "private_key", $private_key);
                 message::success(t("Recaptcha configured!"));
                 log::success("recaptcha", t("Recaptcha public and private keys set"));
                 url::redirect("admin/recaptcha");
             } else {
                 if ($public_key && !$private_key) {
                     $form->configure_recaptcha->private_key->add_error("invalid");
                 } else {
                     if ($private_key && !$public_key) {
                         $form->configure_recaptcha->public_key->add_error("invalid");
                     } else {
                         module::set_var("recaptcha", "public_key", "");
                         module::set_var("recaptcha", "private_key", "");
                         message::success(t("Recaptcha disabled!"));
                         log::success("recaptcha", t("Recaptcha public and private keys cleared"));
                         url::redirect("admin/recaptcha");
                     }
                 }
             }
         }
     }
     recaptcha::check_config();
     $view = new Admin_View("admin.html");
     $view->content = new View("admin_recaptcha.html");
     $view->content->public_key = module::get_var("recaptcha", "public_key");
     $view->content->private_key = module::get_var("recaptcha", "private_key");
     $view->content->form = $form;
     print $view;
 }
 static function activate()
 {
     recaptcha::check_config();
 }