diff options
-rw-r--r-- | modules/recaptcha/controllers/admin_recaptcha.php | 14 | ||||
-rw-r--r-- | modules/recaptcha/helpers/recaptcha.php | 34 |
2 files changed, 6 insertions, 42 deletions
diff --git a/modules/recaptcha/controllers/admin_recaptcha.php b/modules/recaptcha/controllers/admin_recaptcha.php index 5fad6155..10938187 100644 --- a/modules/recaptcha/controllers/admin_recaptcha.php +++ b/modules/recaptcha/controllers/admin_recaptcha.php @@ -37,17 +37,12 @@ class Admin_Recaptcha_Controller extends Admin_Controller { $new_public_key = $form->configure_recaptcha->public_key->value; $new_private_key = $form->configure_recaptcha->private_key->value; - $this->_update_key("public_key", $old_public_key, $new_public_key); - $this->_update_key("private_key", $old_private_key, $new_private_key); + $update = $this->_update_key("public_key", $old_public_key, $new_public_key); + $update |= $this->_update_key("private_key", $old_private_key, $new_private_key); - $add_recaptcha_to = array(); - foreach ($form->configure_recaptcha->activated_forms->value as $name) { - $add_recaptcha_to[$name] = 1; + if ($update) { + message::success(t("Recaptcha Configured")); } - module::set_var("recaptcha", "form_list", serialize($add_recaptcha_to)); - log::success(t("Recaptcha active forms have changed.")); - - message::success(t("Recaptcha Configured")); recaptcha::check_config(); } } else { @@ -76,6 +71,7 @@ class Admin_Recaptcha_Controller extends Admin_Controller { if ($changed) { module::set_var("recaptcha", $type, $new_key); } + return $changed; } public function gethtml($public_key, $error=null) { diff --git a/modules/recaptcha/helpers/recaptcha.php b/modules/recaptcha/helpers/recaptcha.php index 371b4746..1d40eb09 100644 --- a/modules/recaptcha/helpers/recaptcha.php +++ b/modules/recaptcha/helpers/recaptcha.php @@ -47,10 +47,6 @@ class recaptcha_Core { ->rules("required|length[40]"); $group->private_key->error_messages("invalid", t("The private key you provided is invalid.")); - $forms_list = self::_get_form_list(); - $group->checklist("activated_forms") - ->label(t("Recaptcha Activated on:")) - ->options($forms_list); $group->submit("")->value(t("Save")); $site_domain = urlencode(stripslashes($_SERVER["HTTP_HOST"])); $form->recaptcha_site = self::API_SERVER; @@ -97,7 +93,7 @@ class recaptcha_Core { return (count(self::$options) > 0 ? "<script type=\"text/javascript\">" . "var RecaptchaOptions = {lang:'$lang'};</script>" : "") . "<script type=\"text/javascript\" src=\"$server/challenge?k=" . - "{$pubkey}$errorpart \"></script>" . $noscript; + "{$pubkey}$errorpart \"></script>"; } /** @@ -178,32 +174,4 @@ class recaptcha_Core { $response = explode("\r\n\r\n", $response, 2); return $response; } - - function _get_form_list() { - $forms = unserialize(module::get_var("recaptcha", "form_list", "a:0:{}")); - Kohana::log("debug", print_r($forms, 1)); - $form_list = array(); - - // @todo Ignore administrative forms - foreach (array_merge(glob(APPPATH . "helpers/*"), glob(MODPATH . "*/helpers/*")) as $path) { - if (preg_match("#.*/(.*)/helpers/(.*).*\.php$#", $path, $matches)) { - Kohana::log("debug", "$path => $matches[1]"); - if ("recaptcha" == $matches[1]) { - continue; - } - $content = file_get_contents($path); - - $preg_match_all = preg_match_all("#.*\"(g([A-Za-z]*)Form)\"#m", - $content, $matches, PREG_SET_ORDER); - if ($preg_match_all !== false) { - foreach ($matches as $match) { - $label = trim(preg_replace("/([A-Z])/", " $1", $match[2])); - $form_id = $match[1]; - $form_list[$form_id] = array($label, !empty($forms[$form_id])); - } - } - } - } - return $form_list; - } } |