Ejemplo n.º 1
0
 /**
  * 
  * Get different possible errors before registering an user
  * @return Array errors
  */
 public function get_errors()
 {
     $constraints = new \CODOF\Constraints\User();
     $constraints->username($this->username);
     $constraints->password($this->password);
     $constraints->mail($this->mail);
     $errors = $constraints->get_errors();
     if (\CODOF\Util::get_opt('captcha') == "enabled") {
         require_once ABSPATH . 'sys/Ext/recaptcha/recaptchalib.php';
         $privatekey = \CODOF\Util::get_opt("captcha_private_key");
         // your secret key
         $secret = $privatekey;
         // empty response
         $response = null;
         // check secret key
         $reCaptcha = new \ReCaptcha($secret);
         if ($_POST["g-recaptcha-response"]) {
             $response = $reCaptcha->verifyResponse($_SERVER["REMOTE_ADDR"], $_POST["g-recaptcha-response"]);
         }
         if (!($response != null && $response->success)) {
             $errors[] = _t("capcha entered was wrong");
         }
     }
     return $errors;
 }