コード例 #1
0
 /**
  * @see	\wcf\system\option\IOptionType::validate()
  */
 public function validate(Option $option, $newValue)
 {
     if (!$newValue) {
         return;
     }
     $selection = CaptchaHandler::getInstance()->getCaptchaSelection();
     if (!isset($selection[$newValue])) {
         throw new UserInputException($option->optionName);
     }
 }
コード例 #2
0
 /**
  * @see	\wcf\page\IPage::readData()
  */
 public function readData()
 {
     if (!WCF::getUser()->userID && $this->useCaptcha && $this->captchaObjectTypeName) {
         $this->captchaObjectType = CaptchaHandler::getInstance()->getObjectTypeByName($this->captchaObjectTypeName);
         if ($this->captchaObjectType === null) {
             throw new SystemException("Unknown captcha object type with name '" . $this->captchaObjectTypeName . "'");
         }
         if (!$this->captchaObjectType->getProcessor()->isAvailable()) {
             $this->captchaObjectType = null;
         }
     }
     parent::readData();
 }
コード例 #3
0
ファイル: RegisterForm.class.php プロジェクト: jacboy/WCF
 /**
  * @see	\wcf\page\IPage::readData()
  */
 public function readData()
 {
     if ($this->useCaptcha && $this->captchaObjectTypeName) {
         $this->captchaObjectType = CaptchaHandler::getInstance()->getObjectTypeByName($this->captchaObjectTypeName);
         if ($this->captchaObjectType === null) {
             throw new SystemException("Unknown captcha object type with id '" . $this->captchaObjectTypeName . "'");
         }
         if (!$this->captchaObjectType->getProcessor()->isAvailable()) {
             $this->captchaObjectType = null;
         }
         if (WCF::getSession()->getVar('noRegistrationCaptcha')) {
             $this->captchaObjectType = null;
         }
     }
     parent::readData();
     if (empty($_POST)) {
         $this->languageID = WCF::getLanguage()->languageID;
         if (WCF::getSession()->getVar('__username')) {
             $this->username = WCF::getSession()->getVar('__username');
             WCF::getSession()->unregister('__username');
         }
         if (WCF::getSession()->getVar('__email')) {
             $this->email = $this->confirmEmail = WCF::getSession()->getVar('__email');
             WCF::getSession()->unregister('__email');
         }
         WCF::getSession()->register('registrationStartTime', TIME_NOW);
         // generate random field names
         $this->randomFieldNames = array('username' => UserRegistrationUtil::getRandomFieldName('username'), 'email' => UserRegistrationUtil::getRandomFieldName('email'), 'confirmEmail' => UserRegistrationUtil::getRandomFieldName('confirmEmail'), 'password' => UserRegistrationUtil::getRandomFieldName('password'), 'confirmPassword' => UserRegistrationUtil::getRandomFieldName('confirmPassword'));
         WCF::getSession()->register('registrationRandomFieldNames', $this->randomFieldNames);
     }
 }
コード例 #4
0
 /**
  * Validates the captcha challenge.
  */
 protected function validateCaptcha()
 {
     if (WCF::getUser()->userID) {
         return;
     }
     if (CAPTCHA_TYPE) {
         $this->captchaObjectType = CaptchaHandler::getInstance()->getObjectTypeByName(CAPTCHA_TYPE);
         if ($this->captchaObjectType === null) {
             throw new SystemException("Unknown captcha object type with name '" . CAPTCHA_TYPE . "'");
         }
         if (!$this->captchaObjectType->getProcessor()->isAvailable()) {
             $this->captchaObjectType = null;
         }
     }
     if ($this->captchaObjectType === null) {
         return;
     }
     try {
         $this->captchaObjectType->getProcessor()->readFormParameters();
         $this->captchaObjectType->getProcessor()->validate();
     } catch (UserInputException $e) {
         $this->validationErrors = array_merge($this->validationErrors, array($e->getField() => $e->getType()));
     }
 }