/** * @see \wcf\form\IForm::validate() */ public function validate() { parent::validate(); if (!$this->accept) { throw new UserInputException('accept'); } }
/** * @see \wcf\form\IForm::validate() */ public function validate() { parent::validate(); if ($this->timeframe < 1) { throw new UserInputException('timeframe'); } }
/** * @see \wcf\form\IForm::validate() */ public function validate() { parent::validate(); // valid event ids $validEventIDs = array(); foreach ($this->events as $events) { foreach ($events as $event) { $validEventIDs[] = $event->eventID; if (!isset($this->settings[$event->eventID]['enabled'])) { $this->settings[$event->eventID]['enabled'] = 0; } } } foreach ($this->settings as $eventID => &$settings) { // validate event id if (!in_array($eventID, $validEventIDs)) { throw new UserInputException(); } // ensure 'enabled' exists if (!isset($settings['enabled'])) { $settings['enabled'] = 0; } // ensure 'mailNotificationType' exists if (!isset($settings['mailNotificationType']) || !in_array($settings['mailNotificationType'], self::$validMailNotificationTypes)) { $settings['mailNotificationType'] = 'none'; } } unset($settings); }
/** * @see \wcf\form\IForm::validate() */ public function validate() { parent::validate(); if (!I18nHandler::getInstance()->validateValue('categoryName', true)) { throw new UserInputException('categoryName', 'multilingual'); } }
/** * @see \wcf\form\IForm::validate() */ public function validate() { parent::validate(); // check if file is uploaded or linked if (!empty($this->file['tmp_name'])) { $this->backup = $this->file['tmp_name']; } else { if ($this->fileLink != '') { //check if file is external url if (FileUtil::isURL($this->fileLink)) { try { //download file $this->backup = FileUtil::downloadFileFromHttp($this->fileLink, 'cms_backup'); } catch (SystemException $e) { //download failed throw new UserInputException('fileLink', 'downloadFailed'); } } else { //file not found if (!file_exists($this->fileLink)) { throw new UserInputException('fileLink', 'notFound'); } else { $this->backup = $this->fileLink; } } } else { throw new UserInputException('file', 'empty'); } } }
/** * @see \wcf\form\IForm::validate() */ public function validate() { parent::validate(); if (WCF::getUser()->disableAvatar) { throw new PermissionDeniedException(); } if ($this->avatarType != 'custom' && $this->avatarType != 'gravatar') { $this->avatarType = 'none'; } switch ($this->avatarType) { case 'custom': if (!WCF::getUser()->avatarID) { throw new UserInputException('custom'); } break; case 'gravatar': if (!MODULE_GRAVATAR) { $this->avatarType = 'none'; break; } // test gravatar if (!Gravatar::test(WCF::getUser()->email)) { throw new UserInputException('gravatar', 'notFound'); } break; } }
/** * @see \wcf\form\IForm::validate() */ public function validate() { AbstractForm::validate(); if (empty($this->masterPassword)) { throw new UserInputException('masterPassword'); } // check password security if (mb_strlen($this->masterPassword) < 12) { throw new UserInputException('masterPassword', 'notSecure'); } // digits if (!Regex::compile('\\d')->match($this->masterPassword)) { throw new UserInputException('masterPassword', 'notSecure'); } // latin characters (lower-case) if (!Regex::compile('[a-z]')->match($this->masterPassword)) { throw new UserInputException('masterPassword', 'notSecure'); } // latin characters (upper-case) if (!Regex::compile('[A-Z]')->match($this->masterPassword)) { throw new UserInputException('masterPassword', 'notSecure'); } // password equals username if ($this->masterPassword == WCF::getUser()->username) { throw new UserInputException('masterPassword', 'notSecure'); } // confirm master password if (empty($this->confirmMasterPassword)) { throw new UserInputException('confirmMasterPassword'); } if ($this->confirmMasterPassword != $this->masterPassword) { throw new UserInputException('confirmMasterPassword', 'notEqual'); } }
/** * @see \wcf\form\IForm::validate() */ public function validate() { $this->errorType = array_merge($this->optionHandler->validate(), $this->errorType); parent::validate(); if (!empty($this->errorType)) { throw new UserInputException('options', $this->errorType); } }
/** * @see \wcf\form\IForm::validate() */ public function validate() { parent::validate(); $this->validateName(); $this->validateFolderName(); if ($this->parentTemplateGroupID && !isset($this->availableTemplateGroups[$this->parentTemplateGroupID])) { throw new UserInputException('parentTemplateGroupID', 'notValid'); } }
/** * @see \wcf\form\IForm::validate() */ public function validate() { parent::validate(); foreach ($this->points as $objectTypeID => $points) { if ($points < 0) { throw new UserInputException($objectTypeID, 'greaterThan'); } } }
/** * @see \wcf\form\IForm::validate() */ public function validate() { parent::validate(); if (empty($this->server)) { throw new UserInputException('server'); } if (!PackageUpdateServer::isValidServerURL($this->server)) { throw new UserInputException('server', 'notValid'); } }
/** * @see \wcf\form\IForm::validate() */ public function validate() { parent::validate(); // username $this->validateUsername(); // password $this->validatePassword(); // email $this->validateEmail(); }
/** * @see \wcf\form\IForm::validate() */ public function validate() { if (WCF::getUser()->disableSignature) { throw new PermissionDeniedException(); } AbstractForm::validate(); if (!empty($this->text)) { $this->validateText(); } }
/** * @see \wcf\form\IForm::validate() */ public function validate() { parent::validate(); if (empty($this->masterPassword)) { throw new UserInputException('masterPassword'); } // check password if (!PasswordUtil::secureCompare(MASTER_PASSWORD, PasswordUtil::getDoubleSaltedHash($this->masterPassword, MASTER_PASSWORD))) { throw new UserInputException('masterPassword', 'notValid'); } }
/** * @see \wcf\form\IForm::validate() */ public function validate() { parent::validate(); // validate title if (empty($this->title)) { throw new UserInputException('title'); } // validate less if (empty($_POST['less'])) { throw new UserInputException('less'); } }
/** * @see \wcf\form\IForm::validate() */ public function validate() { parent::validate(); if (empty($this->source['name'])) { throw new UserInputException('source'); } if (empty($this->source['tmp_name'])) { throw new UserInputException('source', 'uploadFailed'); } try { // check if the uploaded file is a package $archive = new PackageArchive($this->source['tmp_name']); $archive->openArchive(); // check if the package is an application if ($archive->getPackageInfo('isApplication')) { throw new SystemException("Package is application"); } // check if the package includes a style $containsStyle = false; $installInstructions = $archive->getInstallInstructions(); foreach ($installInstructions as $instruction) { if ($instruction['pip'] == 'style') { $containsStyle = true; break; } } if (!$containsStyle) { throw new SystemException("Package contains no style"); } $filename = FileUtil::getTemporaryFilename('package_', preg_replace('!^.*(?=\\.(?:tar\\.gz|tgz|tar)$)!i', '', basename($this->source['name']))); if (!@move_uploaded_file($this->source['tmp_name'], $filename)) { throw new SystemException("Cannot move uploaded file"); } WCF::getSession()->register('stylePackageImportLocation', $filename); HeaderUtil::redirect(LinkHandler::getInstance()->getLink('PackageStartInstall', array('action' => 'install'))); exit; } catch (SystemException $e) { // ignore errors } try { $this->style = StyleEditor::import($this->source['tmp_name']); } catch (\Exception $e) { @unlink($this->source['tmp_name']); throw new UserInputException('source', 'importFailed'); } }
/** * @see \wcf\form\IForm::validate() */ public function validate() { parent::validate(); // get user $this->user = new User($this->userID); if (!$this->user->userID) { throw new UserInputException('userID', 'notValid'); } if (!$this->lostPasswordKey) { throw new UserInputException('lostPasswordKey'); } if (!$this->user->lostPasswordKey) { throw new UserInputException('lostPasswordKey', 'notValid'); } if ($this->user->lostPasswordKey != $this->lostPasswordKey) { throw new UserInputException('lostPasswordKey', 'notValid'); } }
/** * @see \wcf\form\IForm::validate() */ public function validate() { parent::validate(); // check file if (!file_exists($this->filename)) { throw new UserInputException('languageFile'); } // try to import try { // open xml document $xml = new XML(); $xml->load($this->filename); // import xml document $this->language = LanguageEditor::importFromXML($xml, -1); } catch (SystemException $e) { throw new UserInputException($this->importField, $e->getMessage()); } }
/** * @see \wcf\form\IForm::validate() */ public function validate() { parent::validate(); // validate fields if (empty($this->title)) { throw new UserInputException('title'); } if (empty($this->regex)) { throw new UserInputException('regex'); } if (empty($this->html)) { throw new UserInputException('html'); } $lines = explode("\n", StringUtil::unifyNewlines($this->regex)); foreach ($lines as $line) { if (!Regex::compile($line)->isValid()) { throw new UserInputException('regex', 'notValid'); } } }
/** * @see \wcf\form\IForm::validate() */ public function validate() { parent::validate(); if ($this->enable == 1) { // add default language if (!in_array(LanguageFactory::getInstance()->getDefaultLanguageID(), $this->languageIDs)) { $this->languageIDs[] = LanguageFactory::getInstance()->getDefaultLanguageID(); } // validate language ids $contentLanguages = 0; foreach ($this->languageIDs as $languageID) { if (isset($this->languages[$languageID])) { $contentLanguages++; } } if ($contentLanguages < 2) { throw new UserInputException('languageIDs'); } } }
/** * @see wcf\form\IForm::validate() */ public function validate() { parent::validate(); if (empty($this->updates)) { throw new UserInputException('updates'); } // build update stack $this->packageUpdate = PackageUpdateDispatcher::getInstance()->prepareInstallation($this->updates, array(), isset($_POST['send'])); try { $this->packageUpdate->buildPackageInstallationStack(); $this->excludedPackages = $this->packageUpdate->getExcludedPackages(); if (!empty($this->excludedPackages)) { throw new UserInputException('excludedPackages'); } } catch (SystemException $e) { // show detailed error message throw new UserInputException('updates', $e); } }
/** * @see \wcf\form\IForm::validate() */ public function validate() { parent::validate(); // upload if ($this->optionImport && $this->optionImport['error'] != 4) { if ($this->optionImport['error'] != 0) { throw new UserInputException('optionImport', 'uploadFailed'); } try { $xml = new XML(); $xml->load($this->optionImport['tmp_name']); $xpath = $xml->xpath(); foreach ($xpath->query('/options/option') as $option) { $this->options[$xpath->query('name', $option)->item(0)->nodeValue] = $xpath->query('value', $option)->item(0)->nodeValue; } } catch (SystemException $e) { throw new UserInputException('optionImport', 'importFailed'); } } else { throw new UserInputException('optionImport'); } }
/** * @see wcf\form\IForm::validate() */ public function validate() { parent::validate(); // upload if ($this->optionImport && $this->optionImport['error'] != 4) { if ($this->optionImport['error'] != 0) { throw new UserInputException('optionImport', 'uploadFailed'); } try { $xml = new XML($this->optionImport['tmp_name']); $optionsXML = $xml->getElementTree('options'); foreach ($optionsXML['children'] as $option) { $name = $value = ''; foreach ($option['children'] as $optionData) { switch ($optionData['name']) { case 'name': $name = $optionData['cdata']; break; case 'value': $value = $optionData['cdata']; break; } } if (!empty($name)) { $this->options[$name] = $value; } } } catch (SystemException $e) { throw new UserInputException('optionImport', 'importFailed'); } } else { throw new UserInputException('optionImport'); } }
/** * @see wcf\form\IForm::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 (empty($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 \wcf\form\IForm::validate() */ public function validate() { parent::validate(); if (empty($this->title)) { throw new UserInputException('title'); } if (strlen($this->title) > 255) { throw new UserInputException('title', 'tooLong'); } if (!isset($this->userGroups[$this->groupID])) { throw new UserInputException('groupID', 'notValid'); } $hasData = false; foreach ($this->conditions as $conditions) { foreach ($conditions as $condition) { $condition->getProcessor()->validate(); if (!$hasData && $condition->getProcessor()->getData() !== null) { $hasData = true; } } } if (!$hasData) { throw new UserInputException('conditions'); } }
/** * @see wcf\form\IForm::validate() */ public function validate() { parent::validate(); // validate title if (!I18nHandler::getInstance()->validateValue('title')) { if (I18nHandler::getInstance()->isPlainValue('title')) { throw new UserInputException('title'); } else { throw new UserInputException('title', 'multilingual'); } } // validate subTitle if (!I18nHandler::getInstance()->validateValue('subTitle', false, true)) { throw new UserInputException('subTitle'); } // validate description if (!I18nHandler::getInstance()->validateValue('description', false, true)) { throw new UserInputException('description'); } // validate style id if ($this->styleID && !isset($this->availableStyles[$this->styleID])) { throw new UserInputException('styleID', 'notValid'); } }
/** * @see \wcf\form\IForm::validate() */ public function validate() { parent::validate(); // option name if (!I18nHandler::getInstance()->validateValue('optionName', true)) { throw new UserInputException('optionName', 'multilingual'); } // category name if (empty($this->categoryName)) { throw new UserInputException('categoryName'); } $sql = "SELECT\tcategoryID\n\t\t\tFROM\twcf" . WCF_N . "_user_option_category\n\t\t\tWHERE\tcategoryName = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array($this->categoryName)); if ($statement->fetchArray() === false) { throw new UserInputException('categoryName'); } // option type if (!in_array($this->optionType, self::$availableOptionTypes)) { throw new UserInputException('optionType'); } // select options if (in_array($this->optionType, self::$optionTypesUsingSelectOptions) && empty($this->selectOptions)) { throw new UserInputException('selectOptions'); } if ($this->outputClass && !class_exists($this->outputClass)) { throw new UserInputException('outputClass', 'doesNotExist'); } if ($this->editable < 1 || $this->editable > 3) { $this->editable = 3; } }
/** * @see \wcf\form\IForm::validate() */ public function validate() { parent::validate(); $this->exporter->setData($this->dbHost, $this->dbUser, $this->dbPassword, $this->dbName, $this->dbPrefix, $this->fileSystemPath, $this->additionalData); // validate database Access try { $this->exporter->validateDatabaseAccess(); } catch (DatabaseException $e) { WCF::getTPL()->assign('exception', $e); throw new UserInputException('database'); } // validate selected data if (!$this->exporter->validateSelectedData($this->selectedData)) { throw new UserInputException('selectedData'); } // validate file access if (!$this->exporter->validateFileAccess()) { throw new UserInputException('fileSystemPath'); } // validate user merge mode switch ($this->userMergeMode) { case UserImporter::MERGE_MODE_EMAIL: case UserImporter::MERGE_MODE_USERNAME_OR_EMAIL: break; default: $this->userMergeMode = UserImporter::MERGE_MODE_EMAIL; } }
/** * @see \wcf\form\IForm::validate() */ public function validate() { parent::validate(); if ($this->action == 'group' && empty($this->groupIDs)) { throw new UserInputException('groupIDs'); } if ($this->action == '' && empty($this->userIDs)) { throw new IllegalLinkException(); } 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 \wcf\form\IForm::validate() */ public function validate() { parent::validate(); // validate position if (!in_array($this->position, array('body', 'sidebar'))) { throw new UserInputException('position'); } if ($this->position == 'sidebar' && !$this->objectType->allowsidebar) { throw new UserInputException('position'); } if ($this->position == 'body' && !$this->objectType->allowcontent) { throw new UserInputException('position'); } // validate show order if ($this->showOrder == 0) { $childIDs = ContentCache::getInstance()->getChildIDs($this->parentID ?: null); if (!empty($childIDs)) { $showOrders = array(); foreach ($childIDs as $childID) { $content = ContentCache::getInstance()->getContent($childID); $showOrders[] = $content->showOrder; } array_unique($showOrders); if (isset($this->contentID)) { $content = ContentCache::getInstance()->getContent($this->contentID); if ($content->showOrder == max($showOrders) && max($showOrders) != 0) { $this->showOrder = max($showOrders); } else { $this->showOrder = intval(max($showOrders) + 1); } } else { $this->showOrder = intval(max($showOrders) + 1); } } else { $this->showOrder = 1; } } if (!I18nHandler::getInstance()->validateValue('title')) { if (I18nHandler::getInstance()->isPlainValue('title')) { throw new UserInputException('title'); } else { throw new UserInputException('title', 'multilingual'); } } $page = new Page($this->pageID); if (!$page->pageID) { throw new UserInputException('pageID', 'invalid'); } // validate object type specific parameters $this->objectType->getProcessor()->validate($this->contentData); }