Esempio n. 1
0
 /**
  * Checks if the captcha is solved now.
  *
  * @return boolean True if the captcha is solved, false if not.
  */
 protected function verifyCaptcha()
 {
     //check session and generate captcha if necessary
     if (parent::verifyCaptcha()) {
         return true;
     }
     //recaptcha_response_field
     //recaptcha_challenge_field
     //Services_ReCaptcha::validate() may only be called if
     // the form has been submitted. Otherwise we get nasty
     // errors.
     $isSubmitted = false;
     foreach ($this->getContainer()->getDataSources() as $ds) {
         if ($ds instanceof HTML_QuickForm2_DataSource_Submit) {
             $isSubmitted = true;
             break;
         }
     }
     if (!$isSubmitted) {
         return false;
     }
     if ($this->getReCaptcha()->validate()) {
         $this->getSession()->solved = true;
         return true;
     }
     return false;
 }
 /**
  * Checks if the captcha is solved now.
  * Uses $capSolved variable or user input, which is compared
  * with the pre-set correct answer.
  *
  * Calls generateCaptcha() if it has not been called before.
  *
  * In case user solution and answer match, a session variable
  * is set so that the captcha is seen as completed across
  * form submissions.
  *
  * @uses $capGenerated
  * @uses generateCaptcha()
  *
  * @return boolean TRUE if the captcha is solved
  */
 protected function verifyCaptcha()
 {
     // Check session and generate captcha if necessary
     if (parent::verifyCaptcha()) {
         return true;
     }
     if ($this->getSession()->answer === null) {
         //no captcha answer?
         //FIXME: regenerate question + answer
         return false;
     }
     //verify given answer with our answer
     $userSolution = $this->getValue();
     if ($userSolution === null) {
         return false;
     }
     if ($this->getSession()->answer != $userSolution) {
         return false;
     }
     $this->getSession()->solved = true;
     return true;
 }
Esempio n. 3
0
 /**
  * Checks if the captcha is solved now.
  * Uses $capSolved variable or user input, which is compared
  * with the pre-set correct answer.
  *
  * Calls generateCaptcha() if it has not been called before.
  *
  * In case user solution and answer match, a session variable
  * is set so that the captcha is seen as completed across
  * form submissions.
  *
  * @uses $capGenerated
  * @uses generateCaptcha()
  *
  * @return boolean True if the captcha is solved
  */
 protected function verifyCaptcha()
 {
     //check session and generate captcha if necessary
     if (parent::verifyCaptcha()) {
         return true;
     }
     //verify given answer with our answer
     $userSolution = $this->getValue();
     if ($this->getSession()->answer === null) {
         //no stored captcha answer?
         return false;
     } else {
         if ($userSolution === null || $this->getSession()->answer != $userSolution) {
             return false;
         } else {
             $this->getSession()->solved = true;
             return true;
         }
     }
 }