Beispiel #1
0
 /**
  * XoopsCaptcha::verify()
  *
  * Verify user submission
  *
  * @param bool $skipMember
  * @param string $name
  *
  * @return bool
  */
 public function verify($skipMember = null, $name = null)
 {
     $xoops = Xoops::getInstance();
     $sessionName = empty($name) ? $this->name : $name;
     $skipMember = $skipMember === null ? $_SESSION["{$sessionName}_skipmember"] : $skipMember;
     $maxAttempts = $_SESSION["{$sessionName}_maxattempts"];
     $attempt = $_SESSION["{$sessionName}_attempt"];
     $is_valid = false;
     // Skip CAPTCHA verification if disabled
     if (!$this->isActive()) {
         $is_valid = true;
         // Skip CAPTCHA for member if set
     } else {
         if ($xoops->isUser() && !empty($skipMember)) {
             $is_valid = true;
             // Kill too many attempts
         } else {
             if (!empty($maxAttempts) && $attempt > $maxAttempts) {
                 $this->message[] = XoopsLocale::E_TO_MANY_ATTEMPTS;
                 // Verify the code
             } else {
                 $is_valid = $this->handler->verify($sessionName);
             }
         }
     }
     if (!$is_valid) {
         // Increase the attempt records on failure
         $_SESSION["{$sessionName}_attempt"]++;
         // Log the error message
         $this->message[] = XoopsLocale::E_INVALID_CONFIRMATION_CODE;
     } else {
         // reset attempt records on success
         $_SESSION["{$sessionName}_attempt"] = null;
     }
     $this->destroyGarbage(true);
     return $is_valid;
 }