Ejemplo n.º 1
0
 /**
  * @see	\wcf\form\IForm::validate()
  */
 public function validate()
 {
     parent::validate();
     if (empty($this->username) && empty($this->email)) {
         throw new UserInputException('username');
     }
     if (!empty($this->username)) {
         $this->user = User::getUserByUsername($this->username);
         if (!$this->user->userID) {
             throw new UserInputException('username', 'notFound');
         }
     } else {
         $this->user = User::getUserByEmail($this->email);
         if (!$this->user->userID) {
             throw new UserInputException('email', 'notFound');
         }
     }
     // check if using 3rd party @author dtdesign
     if ($this->user->authData) {
         throw new UserInputException('username', '3rdParty');
     }
     // check whether a lost password request was sent in the last 24 hours
     if ($this->user->lastLostPasswordRequestTime && TIME_NOW - 86400 < $this->user->lastLostPasswordRequestTime) {
         throw new NamedUserException(WCF::getLanguage()->getDynamicVariable('wcf.user.lostPassword.error.tooManyRequests', array('hours' => ceil(($this->user->lastLostPasswordRequestTime - (TIME_NOW - 86400)) / 3600))));
     }
 }
Ejemplo n.º 2
0
 /**
  * @see	\wcf\form\IForm::validate()
  */
 public function validate()
 {
     parent::validate();
     // get search conditions
     $this->getConditions();
     // check query and author
     if (empty($this->query) && empty($this->username) && !$this->userID) {
         throw new UserInputException('q');
     }
     // build search hash
     $this->searchHash = StringUtil::getHash(serialize(array($this->query, $this->selectedObjectTypes, !$this->subjectOnly, $this->searchIndexCondition, $this->additionalConditions, $this->sortField . ' ' . $this->sortOrder, PACKAGE_ID)));
     // check search hash
     if (!empty($this->query)) {
         $parameters = array($this->searchHash, 'messages', TIME_NOW - 1800);
         if (WCF::getUser()->userID) {
             $parameters[] = WCF::getUser()->userID;
         }
         $sql = "SELECT\tsearchID\n\t\t\t\tFROM\twcf" . WCF_N . "_search\n\t\t\t\tWHERE\tsearchHash = ?\n\t\t\t\t\tAND searchType = ?\n\t\t\t\t\tAND searchTime > ?\n\t\t\t\t\t" . (WCF::getUser()->userID ? 'AND userID = ?' : 'AND userID IS NULL');
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute($parameters);
         $row = $statement->fetchArray();
         if ($row !== false) {
             HeaderUtil::redirect(LinkHandler::getInstance()->getLink('SearchResult', array('id' => $row['searchID']), 'highlight=' . urlencode($this->query)));
             exit;
         }
     }
     // do search
     $this->results = SearchEngine::getInstance()->search($this->query, $this->selectedObjectTypes, $this->subjectOnly, $this->searchIndexCondition, $this->additionalConditions, $this->sortField . ' ' . $this->sortOrder);
     // result is empty
     if (empty($this->results)) {
         $this->throwNoMatchesException();
     }
 }
Ejemplo n.º 3
0
 /**
  * @see	\wcf\form\IForm::validate()
  */
 public function validate()
 {
     parent::validate();
     // error handling
     if (empty($this->username)) {
         throw new UserInputException('username');
     }
     if (empty($this->password)) {
         throw new UserInputException('password');
     }
     $this->validateUser();
 }
Ejemplo n.º 4
0
 /**
  * @see	\wcf\form\IForm::validate()
  */
 public function validate()
 {
     if (!WCF::getUser()->userID) {
         if (empty($this->email)) {
             throw new UserInputException('email');
         }
         if (!UserUtil::isValidEmail($this->email)) {
             throw new UserInputException('email', 'notValid');
         }
     }
     if (empty($this->subject)) {
         throw new UserInputException('subject');
     }
     if (empty($this->message)) {
         throw new UserInputException('message');
     }
     parent::validate();
 }
Ejemplo n.º 5
0
 /**
  * @see	\wcf\form\IForm::validate()
  */
 public function validate()
 {
     // subject
     $this->validateSubject();
     // text
     $this->validateText();
     // multilingualism
     $this->validateContentLanguage();
     parent::validate();
 }