XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
recaptcha.php
Go to the documentation of this file.
1 <?php
21 defined('XOOPS_ROOT_PATH') or die('Restricted access');
22 
24 {
30  function isActive()
31  {
32  return true;
33  }
34 
40  function render()
41  {
42  require_once dirname(__FILE__) . '/recaptcha/recaptchalib.php';
43  $form = "<script type=\"text/javascript\">
44  var RecaptchaOptions = {
45  theme : '" . $this->config['theme']."',
46  lang : '" . $this->config['lang']."'
47  };
48  </script>";
49  $form .= recaptcha_get_html($this->config['public_key']);
50  return $form;
51  }
52 
58  function verify($sessionName)
59  {
60  $is_valid = false;
61  require_once dirname(__FILE__) . '/recaptcha/recaptchalib.php';
62  if (!empty($_POST['recaptcha_response_field'])) {
63  $resp = recaptcha_check_answer(
64  $this->config['private_key'],
65  $_SERVER['REMOTE_ADDR'],
66  $_POST['recaptcha_challenge_field'],
67  $_POST['recaptcha_response_field']
68  );
69  if (!$resp->is_valid) {
70  $this->message[] = $resp->error;
71  } else {
72  $is_valid = true;
73  }
74  }
75  return $is_valid;
76  }
77 }
78 ?>