Exemplo n.º 1
0
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (strlen($this->applicationText) > self::APPLICATION_TEXT_LENGTH) {
         throw new UserInputException('applicationText', 'notValid');
     }
 }
Exemplo n.º 2
0
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if ($this->action == 'rename') {
         if (!PlanetUtil::isValid($this->newName)) {
             throw new UserInputException('newName', 'notValid');
         }
     } else {
         if ($this->action == 'delete') {
             // main planet
             if (LWCore::getPlanet()->planetID == WCF::getUser()->id_planet) {
                 throw new SystemException('tried to delete main planet');
             }
             // password
             if (!WCF::getUser()->checkPassword($this->password)) {
                 throw new UserInputException('password', 'notValid');
             }
             // check fleets (moon, if existing and planet)
             if (LWCore::getPlanet()->planetKind == 1 && LWCore::getPlanet()->getMoon() != null) {
                 if (count(Fleet::getByPlanetID(LWCore::getPlanet()->getMoon()->planetID, Fleet::OFIARA | Fleet::OWNER))) {
                     throw new UserInputException('password', 'activityMoon');
                 }
             }
             // check current
             if (count(Fleet::getByPlanetID(LWCore::getPlanet()->planetID, Fleet::OFIARA | Fleet::OWNER))) {
                 throw new UserInputException('password', 'activity');
             }
         }
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     AbstractForm::validate();
     if ($this->applicationStatus < 0 || $this->applicationStatus > 3) {
         throw new UserInputException('applicationStatus');
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (empty($this->reason)) {
         throw new UserInputException('reason');
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (strlen($this->circularText) > self::CIRCULAR_TEXT_LENGTH) {
         throw new UserInputException('answerText', 'notValid');
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (empty($this->usernames)) {
         throw new UserInputException('usernames');
     }
     // explode multiple usernames to an array
     $usernameArray = explode(',', $this->usernames);
     $error = array();
     // loop through users
     foreach ($usernameArray as $username) {
         $username = StringUtil::trim($username);
         if (empty($username)) {
             continue;
         }
         try {
             // get user
             $user = new UserEditor(null, null, $username);
             if (!$user->userID) {
                 throw new UserInputException('username', 'notFound');
             }
             // no error
             $this->users[] = $user;
         } catch (UserInputException $e) {
             $error[] = array('type' => $e->getType(), 'username' => $username);
         }
     }
     if (count($error)) {
         throw new UserInputException('usernames', $error);
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (empty($this->fromYear) || $this->fromYear > $this->toYear || $this->fromYear < ICSHE_MINYEAR || $this->toYear > ICSHE_MAXYEAR) {
         throw new UserInputException('timeFrame');
     }
     if (empty($this->country)) {
         throw new UserInputException('country');
     }
 }
Exemplo n.º 8
0
 /**
  * @see Form::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();
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     foreach ($this->activeOptions as $key => $option) {
         try {
             $this->validateOption($key, $option);
         } catch (UserInputException $e) {
             $this->errorType[$e->getField()] = $e->getType();
         }
     }
     if (count($this->errorType) > 0) {
         throw new UserInputException('options', $this->errorType);
     }
 }
Exemplo n.º 10
0
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     $this->loadPlanetData();
     foreach ($this->planetObjs as $planetObj) {
         if (isset($_POST['planet' . $planetObj->planetID])) {
             $sortID = intval($_POST['planet' . $planetObj->planetID]);
             while (isset($this->planets[$sortID])) {
                 ++$sortID;
             }
             $this->planets[$sortID] = $planetObj->planetID;
         }
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     // get user
     require_once WCF_DIR . 'lib/data/user/UserEditor.class.php';
     $this->user = new UserEditor($this->userID);
     if (!$this->user->userID) {
         throw new UserInputException('userID', 'invalid');
     }
     if (!$this->user->lostPasswordKey) {
         throw new UserInputException('lostPasswordKey');
     }
     if ($this->user->lostPasswordKey != $this->lostPasswordKey) {
         throw new UserInputException('lostPasswordKey', 'invalid');
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (empty($this->email)) {
         throw new UserInputException('email');
     }
     $sql = 'SELECT COUNT(email) AS count
     		FROM wcf' . WCF_N . '_' . $this->subscriberTable . "\n        \t\tWHERE email = '" . escapeString($this->email) . "'";
     $row = WCF::getDB()->getFirstRow($sql);
     if ($row['count']) {
         throw new UserInputException('email', 'notUnique');
     }
     if (!$this->checkbox) {
         throw new UserInputException('checkbox', 'notAgreed');
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if ($this->agreed === null) {
         throw new UserInputException('agreed', 'notValid');
     }
     if (strlen($this->answerText) > self::ANSWER_TEXT_LENGTH) {
         throw new UserInputException('answerText', 'notValid');
     }
     // check for application
     $sql = "SELECT COUNT(*)\r\n\t\t\t\t\t\tAS count\r\n\t\t\t\tFROM ugml_users\r\n\t\t\t\tWHERE ally_request = " . WCF::getUser()->ally_id . "\r\n\t\t\t\t\tAND id = " . $this->userID;
     $result = WCF::getDB()->getFirstRow($sql);
     if ($result['count'] != 1) {
         require_once WCF_DIR . 'lib/system/exception/IllegalLinkException.class.php';
         throw new IllegalLinkException();
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     // title
     if (empty($this->title)) {
         throw new UserInputException('title');
     }
     // conditions
     if (!count($this->ruleConditions)) {
         throw new UserInputException('ruleConditions');
     }
     foreach ($this->ruleConditions as $ruleCondition) {
         $type = isset($ruleCondition['type']) ? $ruleCondition['type'] : '';
         $condition = isset($ruleCondition['condition']) ? $ruleCondition['condition'] : '';
         $value = isset($ruleCondition['value']) ? $ruleCondition['value'] : '';
         // type
         if (!isset($this->availableRuleConditionTypes[$type])) {
             throw new UserInputException('ruleConditions');
         }
         // condition
         $availableConditions = $this->availableRuleConditionTypes[$type]->getAvailableConditions();
         if (count($availableConditions) > 0 && !isset($availableConditions[$condition])) {
             throw new UserInputException('ruleConditions');
         }
         // value
         $availableValues = $this->availableRuleConditionTypes[$type]->getAvailableValues();
         if ($this->availableRuleConditionTypes[$type]->getValueType() == 'text' && empty($value) || $this->availableRuleConditionTypes[$type]->getValueType() == 'options' && !isset($availableValues[$value])) {
             throw new UserInputException('ruleConditions');
         }
     }
     // operator
     if ($this->logicalOperator != 'and' && $this->logicalOperator != 'or' && $this->logicalOperator != 'nor') {
         throw new UserInputException('logicalOperator');
     }
     // action
     if (!isset($this->availableRuleActions[$this->ruleAction])) {
         throw new UserInputException('ruleAction');
     }
     // destination
     $availableDestinations = $this->availableRuleActions[$this->ruleAction]->getAvailableDestinations();
     if ($this->availableRuleActions[$this->ruleAction]->getDestinationType() == 'text' && empty($this->ruleDestination) || $this->availableRuleActions[$this->ruleAction]->getDestinationType() == 'options' && !isset($availableDestinations[$this->ruleDestination])) {
         throw new UserInputException('ruleAction');
     }
 }
Exemplo n.º 15
0
 public function validate()
 {
     $is_valid = parent::validate();
     if ($postcode = $this->getField('postcode')) {
         if ($postcode->isRequired()) {
             $country = $this->formatter->getCountry();
             if (!$country->checkZipCode($postcode->getValue())) {
                 // FIXME: the translator adapter is crap at the moment,
                 // but once it is not, the sprintf needs to go away.
                 $postcode->addError(sprintf($this->translator->trans('Invalid postcode - should look like "%1$s"', [], 'Shop.Forms.Errors'), $country->zip_code_format));
                 $is_valid = false;
             }
         }
     }
     if ($hookReturn = Hook::exec('actionValidateCustomerAddressForm', array('form' => $this)) != '') {
         $is_valid &= (bool) $hookReturn;
     }
     return $is_valid;
 }
Exemplo n.º 16
0
 public function validate()
 {
     $emailField = $this->getField('email');
     $id_customer = Customer::customerExists($emailField->getValue(), true, true);
     if ($id_customer && $id_customer != $this->getCustomer()->id) {
         $emailField->addError(sprintf($this->translator->trans('The email "%s" is already used, please choose another one or sign in', array(), 'Shop.Notifications.Error'), $emailField->getValue()));
     }
     // birthday is from input type text..., so we need to convert to a valid date
     $birthdayField = $this->getField('birthday');
     if (!empty($birthdayField)) {
         $birthdayValue = $birthdayField->getValue();
         if (!empty($birthdayValue)) {
             $dateBuilt = DateTime::createFromFormat(Context::getContext()->language->date_format_lite, $birthdayValue);
             if (!empty($dateBuilt)) {
                 $birthdayField->setValue($dateBuilt->format('Y-m-d'));
             }
         }
     }
     return parent::validate();
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     AbstractForm::validate();
     // check given user id
     $this->user = new UserEditor($this->userID);
     if (!$this->user->userID) {
         throw new UserInputException('u', 'notValid');
     }
     // user is already enabled
     if ($this->user->reactivationCode == 0) {
         throw new NamedUserException(WCF::getLanguage()->get('wcf.user.emailChange.error.emailAlreadyEnabled'));
     }
     // check whether the new email isn't unique anymore
     if (!UserUtil::isAvailableEmail($this->user->newEmail)) {
         throw new NamedUserException(WCF::getLanguage()->get('wcf.user.emailChange.error.email.notUnique'));
     }
     // check given activation code
     if ($this->user->reactivationCode != $this->activationCode) {
         throw new UserInputException('a', 'notValid');
     }
 }
Exemplo n.º 18
0
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (strlen($this->allianceName) < 3 || strlen($this->allianceName) > 35) {
         throw new UserInputException('allianceName', 'notValid');
     }
     if (strlen($this->allianceTag) < 3 || strlen($this->allianceTag) > 8) {
         throw new UserInputException('allianceTag', 'notValid');
     }
     // check for existing alliances
     $sql = "SELECT ally_name,\n\t\t\t\t\tally_tag\n\t\t\t\tFROM ugml_alliance\n\t\t\t\tWHERE ally_name = '" . escapeString($this->allianceName) . "'\n\t\t\t\t\tOR ally_tag = '" . escapeString($this->allianceTag) . "'";
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         if ($row['ally_name'] == $this->allianceName) {
             throw new UserInputException('allianceName', 'notUnique');
             break;
         }
         if ($row['ally_tag'] == $this->allianceTag) {
             throw new UserInputException('allianceTag', 'notUnique');
         }
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if ($this->avatarID) {
         if ($this->avatarID == -1) {
             if (empty($this->gravatar)) {
                 // check permission
                 WCF::getUser()->checkPermission('user.profile.avatar.canUploadAvatar');
                 // upload or download avatar
                 if ($this->avatarUpload && $this->avatarUpload['error'] != 4) {
                     if ($this->avatarUpload['error'] != 0) {
                         throw new UserInputException('avatarUpload', 'uploadFailed');
                     }
                     $this->avatarID = AvatarEditor::create($this->avatarUpload['tmp_name'], $this->avatarUpload['name'], 'avatarUpload', WCF::getUser()->userID);
                 } else {
                     if ($this->avatarURL != 'http://') {
                         if (StringUtil::indexOf($this->avatarURL, 'http://') !== 0) {
                             throw new UserInputException('avatarURL', 'downloadFailed');
                         }
                         try {
                             $tmpName = FileUtil::downloadFileFromHttp($this->avatarURL, 'avatar');
                         } catch (SystemException $e) {
                             throw new UserInputException('avatarURL', 'downloadFailed');
                         }
                         $this->avatarID = AvatarEditor::create($tmpName, $this->avatarURL, 'avatarURL', WCF::getUser()->userID);
                     } else {
                         throw new UserInputException('avatarUpload');
                     }
                 }
             } else {
                 $this->avatarID = 0;
             }
         } else {
             // check permission
             WCF::getUser()->checkPermission('user.profile.avatar.canUseDefaultAvatar');
             // use a default avatar
             $avatar = new AvatarEditor($this->avatarID);
             if (!$avatar->avatarID || $avatar->userID || $avatar->groupID && !in_array($avatar->groupID, WCF::getUser()->getGroupIDs()) || $avatar->neededPoints > WCF::getUser()->activityPoints) {
                 throw new UserInputException('availableAvatars', 'invalid');
             }
             // check category permissions
             if ($avatar->avatarCategoryID) {
                 $category = new AvatarCategory($avatar->avatarCategoryID);
                 if ($category->groupID && !in_array($category->groupID, WCF::getUser()->getGroupIDs()) || $category->neededPoints > WCF::getUser()->activityPoints) {
                     throw new UserInputException('availableAvatars', 'invalid');
                 }
             }
         }
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (empty($this->query)) {
         throw new UserInputException('query');
     }
     if (StringUtil::length($this->query) < 3 || strpos($this->query, '%') !== false || strpos($this->query, '_') !== false) {
         throw new UserInputException('query', 'invalid');
     }
     // search
     $itemNames = array();
     $sql = "SELECT\tlanguageItem\n\t\t\tFROM\twcf" . WCF_N . "_language_item\n\t\t\tWHERE\tlanguageID = " . WCF::getLanguage()->getLanguageID() . "\n\t\t\t\tAND languageCategoryID = (\n\t\t\t\t\tSELECT\tlanguageCategoryID\n\t\t\t\t\tFROM\twcf" . WCF_N . "_language_category\n\t\t\t\t\tWHERE\tlanguageCategory = 'wcf.help.item'\n\t\t\t\t)\n\t\t\t\tAND packageID IN (\n\t\t\t\t\tSELECT\tdependency\n\t\t\t\t\tFROM\twcf" . WCF_N . "_package_dependency\n\t\t\t\t\tWHERE\tpackageID = " . PACKAGE_ID . "\n\t\t\t\t)\n\t\t\t\tAND (\n\t\t\t\t\t(languageUseCustomValue = 0 AND languageItemValue LIKE '%" . escapeString($this->query) . "%')\n\t\t\t\t\tOR (languageUseCustomValue = 1 AND languageCustomItemValue LIKE '%" . escapeString($this->query) . "%')\n\t\t\t\t)";
     $result = WCF::getDB()->sendQuery($sql, 1000);
     while ($row = WCF::getDB()->fetchArray($result)) {
         // search parsed variables
         try {
             $languageItemValue = WCF::getLanguage()->getDynamicVariable($row['languageItem']);
             if (preg_match('!' . preg_quote($this->query) . '!i', $languageItemValue)) {
                 $itemNames[] = str_replace('.description', '', str_replace('wcf.help.item.', '', $row['languageItem']));
             }
         } catch (SystemException $e) {
         }
         // ignore errors
     }
     if (!count($itemNames)) {
         throw new NamedUserException(WCF::getLanguage()->get('wcf.help.search.error.noMatches', array('$query' => StringUtil::encodeHTML($this->query))));
     }
     // get help items
     $sql = "SELECT\t\thelpItem, permissions, options\n\t\t\tFROM\t\twcf" . WCF_N . "_help_item\n\t\t\tWHERE\t\thelpItem IN ('" . implode("','", $itemNames) . "')\n\t\t\t\t\tAND isDisabled = 0\n\t\t\tORDER BY\tshowOrder";
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         // check options
         if (!empty($row['options'])) {
             $hasEnabledOption = false;
             $options = explode(',', strtoupper($row['options']));
             foreach ($options as $option) {
                 if (defined($option) && constant($option)) {
                     $hasEnabledOption = true;
                     break;
                 }
             }
             if (!$hasEnabledOption) {
                 continue;
             }
         }
         // check permissions
         if (!empty($row['permissions'])) {
             $hasPermission = false;
             $permissions = explode(',', $row['permissions']);
             foreach ($permissions as $permission) {
                 if (WCF::getUser()->getPermission($permission)) {
                     $hasPermission = true;
                     break;
                 }
             }
             if (!$hasPermission) {
                 continue;
             }
         }
         $this->result[] = $row['helpItem'];
     }
     if (!count($this->result)) {
         throw new NamedUserException(WCF::getLanguage()->get('wcf.help.search.error.noMatches', array('$query' => StringUtil::encodeHTML($this->query))));
     }
 }
Exemplo n.º 21
0
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     if (WCF::getUser()->sim_uses < 500) {
         $sql = "UPDATE ugml_users\n\t\t\t\t\tSET sim_uses = sim_uses +1\n\t\t\t\t\tWHERE id = " . WCF::getUser()->userID . "";
         WCF::getDB()->sendQuery($sql);
         WCF::getUser()->sim_uses += 1;
         WCF::getSession()->resetUserData();
         parent::validate();
     } else {
         require_once WCF_DIR . 'lib/system/exception/NamedUserException.class.php';
         throw new NamedUserException("Du hast die erlaubte Simulationsanzahl �berschritten.");
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     $this->validateCaptcha();
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     AbstractForm::validate();
     // action
     if (!in_array($this->action, $this->availableActions)) {
         throw new UserInputException('action');
     }
     // assign to group
     if ($this->action == 'assignToGroup') {
         if (!count($this->assignToGroupIDArray)) {
             throw new UserInputException('assignToGroupIDArray');
         }
     }
     // send mail
     if ($this->action == 'sendMail') {
         if (empty($this->subject)) {
             throw new UserInputException('subject');
         }
         if (empty($this->text)) {
             throw new UserInputException('text');
         }
         if (empty($this->from)) {
             throw new UserInputException('from');
         }
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (empty($this->text)) {
         throw new UserInputException('text');
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     AbstractForm::validate();
     $this->validateText();
 }
 /**
  * @see Form::validate()	 
  */
 public function validate()
 {
     AbstractForm::validate();
     if (empty($this->menuItem)) {
         throw new UserInputException('menuItem');
     }
     $this->validateMenuitem();
 }
Exemplo n.º 27
0
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     AbstractForm::validate();
     // static fields
     if (isset($this->staticParameters['username'])) {
         $this->staticParameters['username'] = StringUtil::trim($this->staticParameters['username']);
     }
     if (isset($this->staticParameters['userID']) && !empty($this->staticParameters['userID'])) {
         $this->staticParameters['userID'] = intval($this->staticParameters['userID']);
     }
     if (isset($this->staticParameters['email'])) {
         $this->staticParameters['email'] = StringUtil::trim($this->staticParameters['email']);
     }
     if (isset($this->staticParameters['groupIDs'])) {
         $this->staticParameters['groupIDs'] = ArrayUtil::toIntegerArray($this->staticParameters['groupIDs']);
     }
     if (isset($this->staticParameters['languageIDs'])) {
         $this->staticParameters['languageIDs'] = ArrayUtil::toIntegerArray($this->staticParameters['languageIDs']);
     }
     // dynamic fields
     // no validation necessary
     // do search
     $this->search();
     if (count($this->matches) == 0) {
         $this->users = array();
         throw new UserInputException('search', 'noMatches');
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if ($this->warningID) {
         $warning = new Warning($this->warningID);
         if (!$warning->warningID) {
             $this->warningID = 0;
         } else {
             $this->title = $warning->title;
         }
     }
     if (!$this->warningID) {
         if (!WCF::getUser()->getPermission('admin.user.infraction.canWarnUserIndividual')) {
             throw new UserInputException('warningID');
         }
         if (empty($this->title)) {
             throw new UserInputException('title');
         }
     }
 }