blog->settings->addNamespace('dcReCaptcha'); $this->blog_settings =& $core->blog->settings->dcReCaptcha; $public_key = $this->blog_settings->reCaptcha_public_key; $private_key = $this->blog_settings->reCaptcha_private_key; $theme = $this->blog_settings->reCaptcha_theme; $comments_form_enable = $this->blog_settings->reCaptcha_comments_form_enable; $this->settings = array( 'public_key' => $public_key, 'private_key' => $private_key, 'theme' => $theme, 'comments_form_enable' => $comments_form_enable ); } public function setSettings($public_key,$private_key,$theme,$comments_form_enable) { $this->settings = array( 'public_key' => $public_key, 'private_key' => $private_key, 'theme' => $theme, 'comments_form_enable' => $comments_form_enable ); } public function getSettings() { return $this->settings; } public function checkAnswer() { if (!isset($_POST["recaptcha_challenge_field"]) || !isset($_POST["recaptcha_response_field"])) { return null; } else { $recaptcha_challenge_field = $_POST["recaptcha_challenge_field"]; $recaptcha_response_field = $_POST["recaptcha_response_field"]; } $resp = recaptcha_check_answer($this->settings['private_key'], http::realIP(), $recaptcha_challenge_field, $recaptcha_response_field); if(!$resp->is_valid) { return $resp->error; } else { return (boolean) true; } } public function getReCaptchaHtml() { return recaptcha_get_html($this->settings['public_key'],null); } public function getReCaptchaJs($lang='fr') { $res = ''."\n"; return $res; } public function getApiUrl() { return 'http://www.google.com/recaptcha'; } }