XOOPS  2.6.0
recaptcha.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
27 {
33  public function isActive()
34  {
35  return true;
36  }
37 
43  public function render()
44  {
45  include_once __DIR__ . '/recaptcha/recaptchalib.php';
46  $form = "<script type=\"text/javascript\">
47  var RecaptchaOptions = {
48  theme : '" . (empty($this->config['theme']) ? '' : $this->config['theme']) . "',
49  lang : '" . (empty($this->config['lang']) ? '' : $this->config['lang']) . "'
50  };
51  </script>";
52  $public_key = empty($this->config['public_key']) ? '' : $this->config['public_key'];
53  $form .= recaptcha_get_html($public_key);
54  return $form;
55  }
56 
63  public function verify($sessionName = null)
64  {
65  $is_valid = false;
66  include_once __DIR__ . '/recaptcha/recaptchalib.php';
67  if (!empty($_POST['recaptcha_response_field'])) {
68  $resp = recaptcha_check_answer($this->config['private_key'], $_SERVER['REMOTE_ADDR'],
69  $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']);
70  if (!$resp->is_valid) {
71  $this->handler->message[] = $resp->error;
72  } else {
73  $is_valid = true;
74  }
75  }
76  return $is_valid;
77  }
78 }
$_SERVER['REQUEST_URI']
$form
Definition: xoops_code.php:21
verify($sessionName=null)
Definition: recaptcha.php:63
recaptcha_get_html($pubkey, $error=null, $use_ssl=false)
recaptcha_check_answer($privkey, $remoteip, $challenge, $response, $extra_params=array())