/** * @see wcf\form\IForm::readFormParameters() */ public function readFormParameters() { parent::readFormParameters(); if (isset($_POST['serverURL'])) $this->serverURL = StringUtil::trim($_POST['serverURL']); if (isset($_POST['loginUsername'])) $this->loginUsername = $_POST['loginUsername']; if (isset($_POST['loginPassword'])) $this->loginPassword = $_POST['loginPassword']; }
/** * @see \wcf\form\IForm::readFormParameters() */ public function readFormParameters() { parent::readFormParameters(); if (isset($_POST['server'])) { $this->server = StringUtil::trim($_POST['server']); } }
/** * Validates the access-token and performs the login. */ protected function checkAccessToken() { if (isset($_REQUEST['at'])) { list($userID, $token) = explode('-', StringUtil::trim($_REQUEST['at'])); if (WCF::getUser()->userID) { if ($userID == WCF::getUser()->userID && PasswordUtil::secureCompare(WCF::getUser()->accessToken, $token)) { // everything is fine, but we are already logged in return; } else { // token is invalid throw new IllegalLinkException(); } } else { $user = new User($userID); if (PasswordUtil::secureCompare($user->accessToken, $token)) { // token is valid -> change user SessionHandler::getInstance()->changeUser($user, true); } else { // token is invalid throw new IllegalLinkException(); } } } }
/** * @see \wcf\page\IPage::readParameters() */ public function readParameters() { parent::readParameters(); if (isset($_REQUEST['search'])) { $this->search = StringUtil::trim($_REQUEST['search']); } }
/** * Parses search keywords. * * @param string $keywordString */ protected function parseKeywords($keywordString) { // convert encoding if necessary if (!StringUtil::isUTF8($keywordString)) { $keywordString = StringUtil::convertEncoding('ISO-8859-1', 'UTF-8', $keywordString); } // remove bad wildcards $keywordString = preg_replace('/(?<!\\w)\\*/', '', $keywordString); // remove search operators $keywordString = preg_replace('/[\\+\\-><()~]+/', '', $keywordString); if (mb_substr($keywordString, 0, 1) == '"' && mb_substr($keywordString, -1) == '"') { // phrases search $keywordString = StringUtil::trim(mb_substr($keywordString, 1, -1)); if (!empty($keywordString)) { $this->keywords = array_merge($this->keywords, array(StringUtil::encodeHTML($keywordString))); } } else { // replace word delimiters by space $keywordString = str_replace(array('.', ','), ' ', $keywordString); $keywords = ArrayUtil::encodeHTML(ArrayUtil::trim(explode(' ', $keywordString))); if (!empty($keywords)) { $this->keywords = array_merge($this->keywords, $keywords); } } }
/** * @see wcf\form\IForm::readFormParameters() */ public function readFormParameters() { parent::readFormParameters(); if (isset($_POST['className'])) { $this->className = StringUtil::trim($_POST['className']); } if (isset($_POST['description'])) { $this->description = StringUtil::trim($_POST['description']); } if (isset($_POST['startMinute'])) { $this->startMinute = StringUtil::replace(' ', '', $_POST['startMinute']); } if (isset($_POST['startHour'])) { $this->startHour = StringUtil::replace(' ', '', $_POST['startHour']); } if (isset($_POST['startDom'])) { $this->startDom = StringUtil::replace(' ', '', $_POST['startDom']); } if (isset($_POST['startMonth'])) { $this->startMonth = StringUtil::replace(' ', '', $_POST['startMonth']); } if (isset($_POST['startDow'])) { $this->startDow = StringUtil::replace(' ', '', $_POST['startDow']); } }
/** * @see wcf\system\option\ISearchableUserOption::getCondition() */ public function getCondition(PreparedStatementConditionBuilder &$conditions, Option $option, $value) { $value = StringUtil::trim($value); if (!$value) return false; $conditions->add("option_value.userOption".$option->optionID." = ?", array($value)); return true; }
/** * Sets element value. * * @param string $value */ public function setValue($value) { if (!is_string($value)) { die(print_r($value, true)); } $this->value = StringUtil::trim($value); }
/** * @see \wcf\form\IForm::readFormParameters() */ public function readFormParameters() { parent::readFormParameters(); if (isset($_POST['title'])) { $this->title = StringUtil::trim($_POST['title']); } }
/** * @see wcf\system\option\ISearchableUserOption::getCondition() */ public function getCondition(PreparedStatementConditionBuilder &$conditions, Option $option, $value) { $value = StringUtil::trim($value); if (empty($value)) return false; $conditions->add("option_value.userOption".$option->optionID." LIKE ?", array('%'.addcslashes($value, '_%').'%')); return true; }
/** * @see \wcf\action\IAction::readParameters() */ public function readParameters() { if (!MODULE_POLL) { throw new IllegalLinkException(); } AbstractSecureAction::readParameters(); if (isset($_POST['actionName'])) { $this->actionName = StringUtil::trim($_POST['actionName']); } if (isset($_POST['pollID'])) { $this->pollID = intval($_POST['pollID']); } $polls = PollManager::getInstance()->getPolls(array($this->pollID)); if (!isset($polls[$this->pollID])) { throw new UserInputException('pollID'); } $this->poll = $polls[$this->pollID]; // load related object $this->relatedObject = PollManager::getInstance()->getRelatedObject($this->poll); if ($this->relatedObject === null) { if ($this->poll->objectID) { throw new SystemException("Missing related object for poll id '" . $this->poll->pollID . "'"); } } else { $this->poll->setRelatedObject($this->relatedObject); } // validate action switch ($this->actionName) { case 'getResult': if (!$this->poll->canSeeResult()) { throw new PermissionDeniedException(); } break; case 'getVote': case 'vote': if (!$this->poll->canVote()) { throw new PermissionDeniedException(); } break; default: throw new SystemException("Unknown action '" . $this->actionName . "'"); break; } if (isset($_POST['optionIDs']) && is_array($_POST['optionIDs'])) { $this->optionIDs = ArrayUtil::toIntegerArray($_POST['optionIDs']); if (count($this->optionIDs) > $this->poll->maxVotes) { throw new PermissionDeniedException(); } $optionIDs = array(); foreach ($this->poll->getOptions() as $option) { $optionIDs[] = $option->optionID; } foreach ($this->optionIDs as $optionID) { if (!in_array($optionID, $optionIDs)) { throw new PermissionDeniedException(); } } } }
/** * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::prepareImport() */ protected function prepareImport(array $data) { $data = array('bbcodeTag' => mb_strtolower(StringUtil::trim($data['attributes']['name'])), 'htmlOpen' => !empty($data['elements']['htmlopen']) ? $data['elements']['htmlopen'] : '', 'htmlClose' => !empty($data['elements']['htmlclose']) ? $data['elements']['htmlclose'] : '', 'allowedChildren' => !empty($data['elements']['allowedchildren']) ? $data['elements']['allowedchildren'] : 'all', 'wysiwygIcon' => !empty($data['elements']['wysiwygicon']) ? $data['elements']['wysiwygicon'] : '', 'attributes' => isset($data['elements']['attributes']) ? $data['elements']['attributes'] : array(), 'className' => !empty($data['elements']['classname']) ? $data['elements']['classname'] : '', 'isSourceCode' => !empty($data['elements']['sourcecode']) ? 1 : 0, 'buttonLabel' => isset($data['elements']['buttonlabel']) ? $data['elements']['buttonlabel'] : '', 'originIsSystem' => 1); if ($data['wysiwygIcon'] && $data['buttonLabel']) { $data['showButton'] = 1; } return $data; }
/** * @see \wcf\form\IForm::readFormParameters() */ public function readFormParameters() { // call readFormParameters event EventHandler::getInstance()->fireAction($this, 'readFormParameters'); if (isset($_POST['activeTabMenuItem'])) { $this->activeTabMenuItem = StringUtil::trim($_POST['activeTabMenuItem']); } }
/** * @see wcf\action\Action::readParameters() */ public function readParameters() { AbstractSecureAction::readParameters(); if (isset($_POST['action'])) $this->action = StringUtil::trim($_POST['action']); if (isset($_POST['containerData']) && is_array($_POST['containerData'])) $this->containerData = $_POST['containerData']; if (isset($_POST['objectIDs']) && is_array($_POST['objectIDs'])) $this->objectIDs = ArrayUtil::toIntegerArray($_POST['objectIDs']); if (isset($_POST['pageClassName'])) $this->pageClassName = StringUtil::trim($_POST['pageClassName']); if (isset($_POST['type'])) $this->type = StringUtil::trim($_POST['type']); }
/** * Creates a new instance of memcached. */ public function __construct() { if (!class_exists('Memcached')) { throw new SystemException('memcached support is not enabled.'); } // init memcached $this->memcached = new \Memcached(); // add servers $tmp = explode("\n", StringUtil::unifyNewlines(CACHE_SOURCE_MEMCACHED_HOST)); $servers = array(); $defaultWeight = floor(100 / count($tmp)); $regex = new Regex('^\[([a-z0-9\:\.]+)\](?::([0-9]{1,5}))?(?::([0-9]{1,3}))?$', Regex::CASE_INSENSITIVE); foreach ($tmp as $server) { $server = StringUtil::trim($server); if (!empty($server)) { $host = $server; $port = 11211; // default memcached port $weight = $defaultWeight; // check for IPv6 if ($regex->match($host)) { $matches = $regex->getMatches(); $host = $matches[1]; if (isset($matches[2])) { $port = $matches[2]; } if (isset($matches[3])) { $weight = $matches[3]; } } else { // IPv4, try to get port and weight if (strpos($host, ':')) { $parsedHost = explode(':', $host); $host = $parsedHost[0]; $port = $parsedHost[1]; if (isset($parsedHost[2])) { $weight = $parsedHost[2]; } } } $servers[] = array($host, $port, $weight); } } $this->memcached->addServers($servers); // test connection $this->memcached->get('testing'); // set variable prefix to prevent collision $this->prefix = substr(sha1(WCF_DIR), 0, 8) . '_'; }
/** * @see \wcf\system\bbcode\IBBCode::getParsedTag() */ public function getParsedTag(array $openingTag, $content, array $closingTag, BBCodeParser $parser) { if (mb_strpos($content, '[*]') !== false) { // get list elements $listElements = preg_split('/\\[\\*\\]/', StringUtil::trim($content), -1, PREG_SPLIT_NO_EMPTY); // remove empty elements foreach ($listElements as $key => $val) { $listElements[$key] = StringUtil::trim($val); if (empty($listElements[$key]) || $listElements[$key] == '<br />') { unset($listElements[$key]); } } if (!empty($listElements)) { // get list style type $listType = 'disc'; if (isset($openingTag['attributes'][0])) { $listType = $openingTag['attributes'][0]; } $listType = strtolower($listType); // replace old types if ($listType == '1') { $listType = 'decimal'; } if ($listType == 'a') { $listType = 'lower-latin'; } if ($parser->getOutputType() == 'text/html') { // build list html $listHTML = 'ol'; if ($listType == 'none' || $listType == 'circle' || $listType == 'square' || $listType == 'disc') { $listHTML = 'ul'; } return '<' . $listHTML . ' style="list-style-type: ' . $listType . '" class="nativeList"><li>' . implode('</li><li>', $listElements) . '</li></' . $listHTML . '>'; } else { if ($parser->getOutputType() == 'text/simplified-html') { $result = ''; $i = 1; foreach ($listElements as $listElement) { switch ($listType) { case 'decimal': $result .= $i . '. '; break; default: $result .= '- '; } $result .= $listElement . "\n"; $i++; } return $result; } } } } // no valid list // return bbcode as text return $openingTag['source'] . $content . $closingTag['source']; }
/** * @see wcf\action\IAction::readParameters() */ public function readParameters() { parent::readParameters(); if (isset($_POST['actionName'])) $this->actionName = StringUtil::trim($_POST['actionName']); if (isset($_POST['className'])) $this->className = StringUtil::trim($_POST['className']); if (empty($this->className) || !class_exists($this->className)) { throw new UserInputException('className'); } }
/** * @see \wcf\system\captcha\ICaptchaHandler::readFormParameters() */ public function readFormParameters() { if (isset($_POST['captchaQuestion'])) { $this->captchaQuestion = StringUtil::trim($_POST['captchaQuestion']); } if (isset($_POST['captchaAnswer'])) { $this->captchaAnswer = StringUtil::trim($_POST['captchaAnswer']); } }
/** * @see \wcf\system\bbcode\IBBCode::getParsedTag() */ public function getParsedTag(array $openingTag, $content, array $closingTag, BBCodeParser $parser) { // copyright TeraliosBBCodesCopyright::callCopyright(); $content = StringUtil::trim($content); if (!empty($content) || mb_strpos($content, '[.]') !== false && mb_strpos($content, '[:]') !== false) { $content = str_replace('[.]', '[*]', $content); // build main list elements $listElements = preg_split('#\\[\\*\\]#', $content, -1, PREG_SPLIT_NO_EMPTY); foreach ($listElements as $key => $val) { $val = StringUtil::trim($val); if (empty($val) || $val == '<br />') { unset($listElements[$key]); } else { $listElements[$key] = $val; } } // build list if (!empty($listElements)) { $listContent = ''; foreach ($listElements as $point) { if (mb_substr_count($point, '[:]') == 1) { // reset key and value. $key = $value = ''; // split list element on [:] in key and definition of key. list($key, $value) = preg_split('#\\[:\\]#', $point, -1); $key = StringUtil::trim($key); $value = StringUtil::trim($value); if (empty($value)) { $value = WCF::getLanguage()->get('wcf.bbcode.dlist.noDefinition'); } // key is not empty. if (!empty($key)) { if ($parser->getOutputType() == 'text/html') { $listContent .= '<dt>' . $key . '</dt><dd>' . $value . '</dd>'; } else { if ($parser->getOutputType() == 'text/simplified-html') { $listContent .= '*' . $key . ': ' . $value . "\n"; } } } } } if (!empty($listContent)) { if ($parser->getOutputType() == 'text/html') { return '<dl class="dlistBBCode">' . $listContent . '</dl><span></span>'; } else { if ($parser->getOutputType() == 'text/simplified-html') { return $listContent; } } } } } return '[dlist]' . $content . '[/dlist]'; }
/** * @see \wcf\form\IForm::readFormParameters() */ public function readFormParameters() { parent::readFormParameters(); if (isset($_FILES['file'])) { $this->file = $_FILES['file']; } if (isset($_POST['fileLink'])) { $this->fileLink = StringUtil::trim($_POST['fileLink']); } }
/** * @see \wcf\system\option\user\IUserOptionOutput::getOutput() */ public function getOutput(User $user, UserOption $option, $value) { $value = StringUtil::trim($value); if (empty($value)) { return ''; } MessageParser::getInstance()->setOutputType('text/html'); WCF::getTPL()->assign(array('option' => $option, 'value' => MessageParser::getInstance()->parse($value))); return WCF::getTPL()->fetch('messageUserOptionOutput'); }
/** * @see \wcf\page\IPage::readParameters() */ public function readParameters() { parent::readParameters(); if (isset($_REQUEST['exceptionID'])) { $this->exceptionID = StringUtil::trim($_REQUEST['exceptionID']); } if (isset($_REQUEST['logFile'])) { $this->logFile = StringUtil::trim($_REQUEST['logFile']); } }
/** * @see \wcf\form\IForm::readFormParameters() */ public function readFormParameters() { parent::readFormParameters(); if (isset($_POST['username'])) { $this->username = StringUtil::trim($_POST['username']); } if (isset($_POST['email'])) { $this->email = StringUtil::trim($_POST['email']); } }
/** * @see wcf\form\IForm::readFormParameters() */ public function readFormParameters() { parent::readFormParameters(); if (isset($_POST['username'])) { $this->username = StringUtil::trim($_POST['username']); } if (isset($_POST['password'])) { $this->password = $_POST['password']; } }
/** * @see wcf\action\IAction::readParameters() */ public function readParameters() { parent::readParameters(); if (isset($_POST['parameters']) && is_array($_POST['parameters'])) { $this->parameters = $_POST['parameters']; } if (isset($_POST['typeName'])) { $this->typeName = StringUtil::trim($_POST['typeName']); } }
/** * @see \wcf\form\IForm::readFormParameters() */ public function readFormParameters() { parent::readFormParameters(); if (isset($_POST['username'])) { $this->username = StringUtil::trim($_POST['username']); $this->user = User::getUserByUsername($this->username); } if (isset($_POST['activationCode'])) { $this->activationCode = intval($_POST['activationCode']); } }
/** * Handles a POST or GET request. * * @param PackageInstallationQueue $queue */ public static function handleRequest(PackageInstallationQueue $queue) { $formName = (isset($_REQUEST['formName'])) ? StringUtil::trim($_REQUEST['formName']) : ''; // ignore request if (empty($formName) || !self::findForm($queue, $formName)) return; // get document $document = self::getForm($queue, $formName); $document->handleRequest(); self::updateForm($queue, $document); }
/** * @see \wcf\form\IForm::readFormParameters() */ public function readFormParameters() { parent::readFormParameters(); if (!$this->stylePackageImportLocation) { if (isset($_POST['downloadPackage'])) { $this->downloadPackage = StringUtil::trim($_POST['downloadPackage']); } if (isset($_FILES['uploadPackage'])) { $this->uploadPackage = $_FILES['uploadPackage']; } } }
/** * @see wcf\page\IPage::readParameters() */ public function readParameters() { if (isset($_REQUEST['id'])) $this->categoryID = intval($_REQUEST['id']); $this->category = new OptionCategory($this->categoryID); if (!isset($this->category->categoryID)) { throw new IllegalLinkException(); } $this->categoryName = $this->category->categoryName; if (isset($_GET['optionName'])) $this->optionName = StringUtil::trim($_GET['optionName']); parent::readParameters(); }
/** * @see \wcf\action\IAction::readParameters() */ public function readParameters() { parent::readParameters(); if (isset($_POST['interfaceName'])) { $this->interfaceName = StringUtil::trim($_POST['interfaceName']); } if (isset($_POST['objectIDs']) && is_array($_POST['objectIDs'])) { $this->objectIDs = ArrayUtil::toIntegerArray($_POST['objectIDs']); } if (isset($_POST['parameters']) && is_array($_POST['parameters'])) { $this->parameters = $_POST['parameters']; } }