/**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     // validate class path
     if (empty($this->classPath)) {
         throw new UserInputException('classPath');
     }
     try {
         $package = new Package($this->packageID);
         if (!@file_exists(FileUtil::getRealPath(WCF_DIR . $package->getDir() . $this->classPath))) {
             throw new UserInputException('classPath', 'doesNotExist');
         }
     } catch (SystemException $e) {
         throw new UserInputException('classPath', 'doesNotExist');
     }
     try {
         CronjobEditor::validate($this->startMinute, $this->startHour, $this->startDom, $this->startMonth, $this->startDow);
     } catch (SystemException $e) {
         // extract field name
         $fieldName = '';
         if (preg_match("/cronjob attribute '(.*)'/", $e->getMessage(), $match)) {
             $fieldName = $match[1];
         }
         throw new UserInputException($fieldName, 'notValid');
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (count($this->templatePacks) > 0) {
         if (!$this->templatePackID) {
             throw new UserInputException('templatePackID');
         }
         // template pack
         if ($this->templatePackID) {
             $templatePack = new TemplatePackEditor($this->templatePackID);
             if (!$templatePack->templatePackID) {
                 throw new UserInputException('templatePackID');
             }
         }
     } else {
         if (empty($this->templatePackName)) {
             throw new UserInputException('templatePackName');
         }
         if (empty($this->templatePackFolderName)) {
             throw new UserInputException('templatePackFolderName');
         }
         // create template pack
         $this->templatePackID = TemplatePackEditor::create($this->templatePackName, FileUtil::addTrailingSlash($this->templatePackFolderName));
         // get available template packs
         $this->templatePacks = TemplatePackEditor::getTemplatePacks();
         // reset values
         $this->templatePackName = $this->templatePackFolderName = '';
     }
     // template name
     $this->validateTemplateName();
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (empty($this->userIDs)) {
         throw new IllegalLinkException();
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     // query
     if (empty($this->query)) {
         throw new UserInputException('query');
     }
     // test regex
     if ($this->useRegex) {
         try {
             preg_match('/' . $this->query . '/', '');
         } catch (SystemException $e) {
             throw new UserInputException('query', 'invalidRegex');
         }
     }
     if ($this->searchVariableName) {
         $this->replace = 0;
     }
     // get results
     $results = LanguageEditor::search($this->query, $this->replace ? $this->replaceBy : null, $this->languageID ? $this->languageID : null, $this->useRegex, $this->caseSensitive, $this->searchVariableName);
     if (count($results)) {
         $languageItems = array();
         foreach ($results as $result) {
             if (!isset($languageItems[$result['languageID']])) {
                 $languageItems[$result['languageID']] = array();
             }
             $languageItems[$result['languageID']][] = $result;
         }
         WCF::getTPL()->assign(array('languageItems' => $languageItems, 'languages' => WCF::getCache()->get('languages', 'languages')));
         WCF::getTPL()->display('languageSearchResult');
         exit;
     } else {
         WCF::getTPL()->assign('noMatches', true);
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (empty($this->categoryName)) {
         throw new UserInputException('categoryName');
     }
 }
 /**
  * @see Form::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 Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (!$this->sourceLanguageID) {
         throw new UserInputException('sourceLanguageID');
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (empty($this->title)) {
         throw new UserInputException('title');
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     //  validate topic
     $this->validateTopic();
     // validate text
     $this->validateText();
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (empty($this->server)) {
         throw new UserInputException('server');
     }
     if (!UpdateServer::isValidServerURL($this->server)) {
         throw new UserInputException('server', 'notValid');
     }
 }
 public function validate()
 {
     parent::validate();
     if (empty($this->serverName)) {
         throw new UserInputException('serverName');
     }
     if (empty($this->serverPort)) {
         throw new UserInputException('serverPort');
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     //  validate name
     $this->validateName();
     // validate link
     $this->validateLink();
     // validate icon
     $this->validateIcon();
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (empty($this->masterPassword)) {
         throw new UserInputException('masterPassword');
     }
     // check password
     if (StringUtil::getSaltedHash($this->masterPassword, MASTER_PASSWORD_SALT) != MASTER_PASSWORD) {
         throw new UserInputException('masterPassword', 'invalid');
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     // counter
     if (!isset($this->counters[$this->counter])) {
         throw new UserInputException('counter');
     }
     // limit
     if ($this->limit < 1) {
         throw new UserInputException('limit');
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (!empty($this->uploadPackage['name'])) {
         $this->validateUploadPackage();
     } else {
         if (!empty($this->downloadPackage)) {
             $this->validateDownloadPackage();
         } else {
             throw new UserInputException('uploadPackage');
         }
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     // validate title
     if (empty($this->title)) {
         throw new UserInputException('title');
     }
     // validate group id
     $group = new Group($this->groupID);
     if (!$group->groupID) {
         throw new UserInputException('groupID');
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (empty($this->username)) {
         throw new UserInputException('username');
     }
     $sql = 'SELECT userID, COUNT(userID) AS count
     		FROM wcf' . WCF_N . "_user\n        \t\tWHERE username = '******'\n        \t\tGROUP BY userID";
     $row = WCF::getDB()->getFirstRow($sql);
     if (!$row['count']) {
         throw new UserInputException('username', 'notValid');
     }
     $this->user = new User($row['userID']);
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (!empty($this->filename)) {
         // import style
         $this->style = StyleEditor::import($this->filename, PACKAGE_ID, $this->destinationStyle !== null && $this->destinationStyle->styleID ? $this->destinationStyle : null);
     } else {
         // import destination
         if ($this->destinationStyle !== null && !$this->destinationStyle->styleID) {
             throw new UserInputException('destinationStyleID');
         }
         // upload style
         if ($this->styleUpload && $this->styleUpload['error'] != 4) {
             if ($this->styleUpload['error'] != 0) {
                 throw new UserInputException('styleUpload', 'uploadFailed');
             }
             $this->newFilename = $this->styleUpload['tmp_name'];
             try {
                 $this->styleData = StyleEditor::getStyleData($this->styleUpload['tmp_name']);
             } catch (SystemException $e) {
                 throw new UserInputException('styleUpload', 'invalid');
             }
             // copy file
             $newFilename = FileUtil::getTemporaryFilename('style_');
             if (@move_uploaded_file($this->styleUpload['tmp_name'], $newFilename)) {
                 $this->newFilename = $newFilename;
             }
         } else {
             if ($this->styleURL != 'http://') {
                 if (StringUtil::indexOf($this->styleURL, 'http://') !== 0) {
                     throw new UserInputException('styleURL', 'downloadFailed');
                 }
                 try {
                     $this->newFilename = FileUtil::downloadFileFromHttp($this->styleURL, 'style');
                 } catch (SystemException $e) {
                     throw new UserInputException('styleURL', 'downloadFailed');
                 }
                 try {
                     $this->styleData = StyleEditor::getStyleData($this->newFilename);
                 } catch (SystemException $e) {
                     throw new UserInputException('styleURL', 'invalid');
                 }
             } else {
                 throw new UserInputException('styleUpload');
             }
         }
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     // validate group id
     $group = new Group($this->groupID);
     if (!$group->groupID) {
         throw new UserInputException('groupID');
     }
     // category
     if ($this->avatarCategoryID != 0) {
         $avatarCategory = new AvatarCategory($this->avatarCategoryID);
         if (!$avatarCategory->avatarCategoryID) {
             throw new UserInputException('avatarCategoryID');
         }
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (empty($this->kind)) {
         throw new UserInputException('kind');
     }
     if (empty($this->rulesetTable)) {
         throw new UserInputException('rulesetTable');
     }
     if (empty($this->rulesetColumn)) {
         throw new UserInputException('rulesetColumn');
     }
     if (empty($this->rulesetColumnTime)) {
         throw new UserInputException('rulesetColumnTime');
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     // action
     if (!in_array($this->action, self::$availableActions)) {
         throw new UserInputException('action');
     }
     // tables
     foreach ($this->tablenameArray as $key => $tablename) {
         if (!isset($this->loggedTables[$tablename])) {
             unset($this->tablenameArray[$key]);
         }
     }
     if (!count($this->tablenameArray)) {
         throw new UserInputException('tablenameArray');
     }
 }
 /**
  * @see	Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (!count($this->updates)) {
         throw new UserInputException('updates');
     }
     // build update stack
     $this->packageUpdate = new PackageUpdate($this->updates, array(), isset($_POST['send']));
     try {
         $this->packageUpdate->buildPackageInstallationStack();
         $this->excludedPackages = $this->packageUpdate->getExcludedPackages();
         if (count($this->excludedPackages)) {
             throw new UserInputException('excludedPackages');
         }
     } catch (SystemException $e) {
         // show detailed error message
         throw new UserInputException('updates', $e);
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     ACPForm::validate();
     if (empty($this->masterPassword)) {
         throw new UserInputException('masterPassword');
     }
     // check password security
     if (StringUtil::length($this->masterPassword) < 8) {
         throw new UserInputException('masterPassword', 'notSecure');
     }
     // digits
     if (!preg_match('![0-9]+!', $this->masterPassword)) {
         throw new UserInputException('masterPassword', 'notSecure');
     }
     // latin characters (lower-case)
     if (!preg_match('![a-z]+!', $this->masterPassword)) {
         throw new UserInputException('masterPassword', 'notSecure');
     }
     // latin characters (upper-case)
     if (!preg_match('![A-Z]+!', $this->masterPassword)) {
         throw new UserInputException('masterPassword', 'notSecure');
     }
     // special characters
     if (!preg_match('![^A-Za-z0-9]+!', $this->masterPassword)) {
         throw new UserInputException('masterPassword', 'notSecure');
     }
     // search for identical admin passwords
     $sql = "SELECT\tpassword, salt\n\t\t\tFROM\twcf" . WCF_N . "_user\n\t\t\tWHERE\tuserID IN (\n\t\t\t\t\tSELECT\tuserID\n\t\t\t\t\tFROM\twcf" . WCF_N . "_user_to_groups\n\t\t\t\t\tWHERE\tgroupID = 4\n\t\t\t\t)";
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         if (StringUtil::getDoubleSaltedHash($this->masterPassword, $row['salt']) == $row['password']) {
             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 Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if ($this->action == 'group') {
         if (!count($this->groupIDs)) {
             throw new UserInputException('groupIDs');
         }
     }
     if ($this->action == '') {
         if (empty($this->userIDs)) {
             throw new IllegalLinkException();
         }
     }
     if (empty($this->subject)) {
         throw new UserInputException('subject');
     }
     if (empty($this->text)) {
         throw new UserInputException('text');
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if ($this->enable == 1) {
         // add default language
         if (!in_array(Language::getDefaultLanguageID(), $this->languageIDs)) {
             $this->languageIDs[] = Language::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 Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (empty($this->userIDs)) {
         throw new IllegalLinkException();
     }
     // groups
     /*if (!count($this->groupIDs)) {
     			throw new UserInputException('groupIDs');
     		}*/
     foreach ($this->groupIDs as $groupID) {
         $group = new Group($groupID);
         if (!$group->groupID) {
             throw new UserInputException('groupIDs');
         }
         if (!$group->isAccessible()) {
             throw new PermissionDeniedException();
         }
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if ($this->action == 'modify') {
         if (empty($_POST['menuItem'])) {
             throw new UserInputException('menuItem', 'empty');
         } else {
             if (empty($_POST['menuItemLink'])) {
                 throw new UserInputException('menuItemLink', 'empty');
             } else {
                 if (!empty($_POST['showOrder']) && !preg_match('/^\\d+$/', $_POST['showOrder'])) {
                     throw new UserInputException('showOrder', 'empty');
                 } else {
                     if (!AdminTools::validateLinkExists($this->menuItemID, $this->linkCur['menuItem'])) {
                         throw new UserInputException('menuItem', 'exists');
                     }
                 }
             }
         }
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     // title
     if (empty($this->title)) {
         throw new UserInputException('title');
     }
     // validate group id
     $group = new Group($this->groupID);
     if (!$group->groupID) {
         throw new UserInputException('groupID');
     }
     // gender
     if ($this->gender < 0 || $this->gender > 2) {
         throw new UserInputException('gender');
     }
     // repeat
     if (!empty($this->image) && $this->repeatImage < 1) {
         throw new UserInputException('repeatImage');
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     // export is only from active WCF databse possible
     $this->dbName = WCF::getDB()->getDatabaseName();
     // build filename and path
     $path = WCF_DIR . 'acp/backup/';
     $iilegalPath = false;
     // no user input
     if (empty($this->backupFileName)) {
         $this->backupFileName = $this->dbName . '_' . date('Y_m_d_H_i') . '.sql';
     } else {
         if (dirname($this->backupFileName) != '.') {
             // check if user try to save file outside of backup directory
             $userPath = explode("/", dirname($this->backupFileName));
             $depth = 0;
             foreach ($userPath as $dir) {
                 if (empty($dir)) {
                 } elseif ($dir == '..') {
                     $depth--;
                 } else {
                     $depth++;
                 }
             }
             if ($depth < 0) {
                 throw new UserInputException('backupFileName');
             }
             if (!file_exists(FileUtil::getRealPath($path . $this->backupFileName))) {
                 throw new UserInputException('backupFileName');
             }
         }
     }
     if ($this->isGzip) {
         $this->backupFileName .= '.gz';
     }
     // tables
     if (!$this->exportAll && !count($this->exportTables)) {
         throw new UserInputException('exportTables');
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     // language category
     $categoryName = '';
     if (empty($this->newLanguageCategory)) {
         if (!isset($this->languageCategories[$this->languageCategoryID])) {
             throw new UserInputException('languageCategoryID');
         }
         $categoryName = $this->languageCategories[$this->languageCategoryID];
     } else {
         // language category syntax
         if (!preg_match('/[a-z0-9_]+(?:\\.[a-z0-9_]+)+/i', $this->newLanguageCategory)) {
             throw new UserInputException('newLanguageCategory', 'invalid');
         }
         $sql = "SELECT\tCOUNT(*) AS count\n\t\t\t\tFROM\twcf" . WCF_N . "_language_category\n\t\t\t\tWHERE\tlanguageCategory = '" . escapeString($this->newLanguageCategory) . "'";
         $row = WCF::getDB()->getFirstRow($sql);
         if ($row['count']) {
             throw new UserInputException('newLanguageCategory', 'notUnique');
         }
         $categoryName = $this->newLanguageCategory;
     }
     if (StringUtil::indexOfIgnoreCase($this->languageItemName, $categoryName) === false) {
         $this->languageItemName = $categoryName . ($this->languageItemName ? '.' . $this->languageItemName : '');
     }
     // language item
     if (empty($this->languageItemName)) {
         throw new UserInputException('languageItemName');
     }
     // language item syntax
     if (!preg_match('/[a-z0-9_]+(?:\\.[a-z0-9_]+){2,}/i', $this->languageItemName)) {
         throw new UserInputException('languageItemName', 'invalid');
     }
     $sql = "SELECT\tCOUNT(*) AS count\n\t\t\tFROM\twcf" . WCF_N . "_language_item\n\t\t\tWHERE\tlanguageItem = '" . escapeString($this->languageItemName) . "'\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)";
     $row = WCF::getDB()->getFirstRow($sql);
     if ($row['count']) {
         throw new UserInputException('languageItemName', 'notUnique');
     }
 }