示例#1
0
 /**
  * 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\system\option\ISearchableUserOption::getCondition()
	 */
	public function getCondition(PreparedStatementConditionBuilder &$conditions, Option $option, $value) {
		if (!is_array($value) || empty($value)) return false;
		$value = ArrayUtil::trim($value);
		if (empty($value)) return false;
		
		$conditions->add("option_value.userOption".$option->optionID." = ?", array(implode("\n", $value)));
		return true;
	}
 /**
  * @see	\wcf\system\option\IOptionType::validate()
  */
 public function validate(Option $option, $newValue)
 {
     parent::validate($option, $newValue);
     if ($option->allowedbbcodepermission) {
         $disallowedBBCodes = BBCodeParser::getInstance()->validateBBCodes($newValue, explode(',', ArrayUtil::trim(WCF::getSession()->getPermission($option->allowedbbcodepermission))));
         if (!empty($disallowedBBCodes)) {
             WCF::getTPL()->assign('disallowedBBCodes', $disallowedBBCodes);
             throw new UserInputException($option->optionName, 'disallowedBBCodes');
         }
     }
 }
示例#4
0
 /**
  * @see	\wcf\form\IForm::readFormParameters()
  */
 public function readFormParameters()
 {
     parent::readFormParameters();
     if (isset($_POST['name'])) {
         $this->name = StringUtil::trim($_POST['name']);
     }
     if (isset($_POST['languageID'])) {
         $this->languageID = intval($_POST['languageID']);
     }
     // actually these are synonyms
     if (isset($_POST['tags']) && is_array($_POST['tags'])) {
         $this->synonyms = ArrayUtil::trim($_POST['tags']);
     }
 }
 public function getParsedTag(array $openingTag, $content, array $closingTag, BBCodeParser $parser)
 {
     // copyright
     TeraliosBBCodesCopyright::callCopyright();
     // first attribut is icon!
     $icon = isset($openingTag['attributes'][0]) ? StringUtil::trim($openingTag['attributes'][0]) : 'fa-rebel';
     // Yes, Rebel icon as default icon! ;)
     if (substr($icon, 0, 3) != 'fa-') {
         $icon = 'fa-' . $icon;
     }
     // map attributes
     $this->mapAttributes(ArrayUtil::trim($openingTag['attributes']));
     return '<span class="icon' . ($this->size > 0 ? ' icon' . $this->size : '') . ' ' . $icon . ($this->float != 'none' ? ' iconBB' . ucfirst($this->float) : '') . ' iconBBCode"></span>';
 }
 public function readFormParameters()
 {
     parent::readFormParameters();
     if (isset($_POST['tags']) && is_array($_POST['tags'])) {
         $this->tags = ArrayUtil::trim($_POST['tags']);
     }
     if (isset($_POST['time'])) {
         $this->time = $_POST['time'];
     }
     if (isset($_POST['imageID'])) {
         $this->imageID = intval($_POST['imageID']);
     }
     if (isset($_POST['teaser'])) {
         $this->teaser = StringUtil::trim($_POST['teaser']);
     }
     if (MODULE_POLL && WCF::getSession()->getPermission('user.cms.news.canStartPoll')) {
         PollManager::getInstance()->readFormParameters();
     }
 }
 /**
  * Returns a rendered message preview.
  * 
  * @return	array
  */
 public function getMessagePreview()
 {
     // get options
     $enableBBCodes = isset($this->parameters['options']['enableBBCodes']) ? 1 : 0;
     $enableHtml = isset($this->parameters['options']['enableHtml']) ? 1 : 0;
     $enableSmilies = isset($this->parameters['options']['enableSmilies']) ? 1 : 0;
     $preParse = isset($this->parameters['options']['preParse']) ? 1 : 0;
     $allowedBBCodesPermission = isset($this->parameters['allowedBBCodesPermission']) ? $this->parameters['allowedBBCodesPermission'] : 'user.message.allowedBBCodes';
     // validate permissions for options
     if ($enableBBCodes && !WCF::getSession()->getPermission('user.message.canUseBBCodes')) {
         $enableBBCodes = 0;
     }
     if ($enableHtml && !WCF::getSession()->getPermission('user.message.canUseHtml')) {
         $enableHtml = 0;
     }
     if ($enableSmilies && !WCF::getSession()->getPermission('user.message.canUseSmilies')) {
         $enableSmilies = 0;
     }
     // check if disallowed bbcode are used
     if ($enableBBCodes && $allowedBBCodesPermission) {
         $disallowedBBCodes = MessageParser::getInstance()->validateBBCodes($this->parameters['data']['message'], ArrayUtil::trim(explode(',', WCF::getSession()->getPermission($allowedBBCodesPermission))));
         if (!empty($disallowedBBCodes)) {
             throw new UserInputException('message', WCF::getLanguage()->getDynamicVariable('wcf.message.error.disallowedBBCodes', array('disallowedBBCodes' => $disallowedBBCodes)));
         }
     }
     // get message
     $message = StringUtil::trim($this->parameters['data']['message']);
     // get embedded objects
     MessageEmbeddedObjectManager::getInstance()->parseTemporaryMessage($message);
     // parse URLs
     if ($preParse && $enableBBCodes) {
         if ($allowedBBCodesPermission) {
             $message = PreParser::getInstance()->parse($message, ArrayUtil::trim(explode(',', WCF::getSession()->getPermission($allowedBBCodesPermission))));
         } else {
             $message = PreParser::getInstance()->parse($message);
         }
     }
     // parse message
     $preview = MessageParser::getInstance()->parse($message, $enableSmilies, $enableHtml, $enableBBCodes, false);
     return array('message' => $preview);
 }
    /**
     * Parses given message for specific bbcode parameters.
     * 
     * @param	string		$message
     * @param	string		$bbcode		bbcode name
     * @return	array
     */
    public static function getFirstParameters($message, $bbcode)
    {
        $pattern = '~\\[' . $bbcode . '=
				(\'(?:[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'|(?:[^,\\]]*))
				(?:,(?:\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'|[^,\\]]*))*
			\\]~ix';
        if (preg_match_all($pattern, $message, $matches)) {
            foreach ($matches[1] as &$value) {
                // remove quotes
                if (mb_substr($value, 0, 1) == "'" && mb_substr($value, -1) == "'") {
                    $value = str_replace("\\'", "'", $value);
                    $value = str_replace("\\\\", "\\", $value);
                    $value = mb_substr($value, 1, -1);
                }
            }
            $results = ArrayUtil::trim($matches[1]);
            $results = array_unique($results);
            return $results;
        }
        return array();
    }
 /**
  * @see	\wcf\action\IAction::readParameters()
  */
 public function readParameters()
 {
     AbstractSecureAction::readParameters();
     if (isset($_POST['actionName'])) {
         $this->actionName = StringUtil::trim($_POST['actionName']);
     }
     if (isset($_POST['getFullQuoteObjectIDs'])) {
         $this->_getFullQuoteObjectIDs = intval($_POST['getFullQuoteObjectIDs']);
     }
     if (isset($_POST['objectTypes']) && is_array($_POST['objectTypes'])) {
         $this->objectTypes = ArrayUtil::trim($_POST['objectTypes']);
     }
     if (isset($_POST['quoteIDs'])) {
         $this->quoteIDs = ArrayUtil::trim($_POST['quoteIDs']);
         // validate quote ids
         foreach ($this->quoteIDs as $key => $quoteID) {
             if (MessageQuoteManager::getInstance()->getQuote($quoteID) === null) {
                 unset($this->quoteIDs[$key]);
             }
         }
     }
 }
 /**
  * @see	\wcf\system\SingletonFactory::init()
  */
 protected function init()
 {
     if (isset($_GET['highlight'])) {
         $keywordString = $_GET['highlight'];
         // 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->searchQuery = $keywordString;
             }
         } else {
             $this->searchQuery = ArrayUtil::trim(explode(' ', $keywordString));
             if (empty($this->searchQuery)) {
                 $this->searchQuery = false;
             } else {
                 if (count($this->searchQuery) == 1) {
                     $this->searchQuery = reset($this->searchQuery);
                 }
             }
         }
     }
 }
 /**
  * @see	\wcf\form\IForm::readFormParameters()
  */
 public function readFormParameters()
 {
     parent::readFormParameters();
     if (isset($_POST['enableDelayedPublication'])) {
         $this->enableDelayedPublication = intval($_POST['enableDelayedPublication']);
     }
     if (isset($_POST['publicationDate'])) {
         $this->publicationDate = $_POST['publicationDate'];
     }
     if (isset($_POST['enableAutomaticArchiving'])) {
         $this->enableAutomaticArchiving = intval($_POST['enableAutomaticArchiving']);
     }
     if (isset($_POST['archivingDate'])) {
         $this->archivingDate = $_POST['archivingDate'];
     }
     if (isset($_POST['teaser'])) {
         $this->teaser = StringUtil::trim($_POST['teaser']);
     }
     if (isset($_POST['tags']) && is_array($_POST['tags'])) {
         $this->tags = ArrayUtil::trim($_POST['tags']);
     }
     if (isset($_POST['isHot'])) {
         $this->isHot = intval($_POST['isHot']);
     }
     // news picture
     if (NEWS_ENABLE_NEWSPICTURE) {
         if (isset($_POST['pictureID'])) {
             $this->pictureID = intval($_POST['pictureID']);
         }
         $this->picture = new NewsPicture($this->pictureID);
     }
     // sources
     if (NEWS_ENTRY_ENABLE_SOURCES && isset($_POST['sourceLink']) && is_array($_POST['sourceLink']) && isset($_POST['sourceText']) && is_array($_POST['sourceText'])) {
         $sourceLinks = $_POST['sourceLink'];
         $sourceTexts = $_POST['sourceText'];
         foreach ($sourceLinks as $index => $sourceLink) {
             $this->sources[$index] = array('sourceLink' => StringUtil::trim($sourceLink));
             if (isset($sourceTexts[$index])) {
                 $this->sources[$index]['sourceText'] = StringUtil::trim($sourceTexts[$index]);
                 unset($sourceTexts[$index]);
             }
         }
         foreach ($sourceTexts as $index => $sourceText) {
             $this->sources[$index] = array('sourceText' => StringUtil::trim($sourceText));
         }
     }
     // quotes
     MessageQuoteManager::getInstance()->readFormParameters();
     // polls
     if ($this->canCreatePoll()) {
         PollManager::getInstance()->readFormParameters();
     }
 }
示例#12
0
 /**
  * @see	wcf\form\IForm::readFormParameters()
  */
 public function readFormParameters()
 {
     parent::readFormParameters();
     if (isset($_POST['sum'])) {
         $this->sum = (int) $_POST['sum'];
     }
     if (isset($_POST['reason'])) {
         $this->reason = StringUtil::trim($_POST['reason']);
     }
     if (isset($_POST['username'])) {
         $this->usernames = StringUtil::trim($_POST['username']);
     }
     if (isset($_POST['isModerativ']) && $_POST['isModerativ'] == 1 && WCF::getSession()->getPermission('mod.jcoins.canModTransfer')) {
         $this->isModerativ = 1;
     }
     if (count(explode(',', $this->usernames)) > 0) {
         $users = explode(',', $this->usernames);
         $this->user = UserProfile::getUserProfilesByUsername(ArrayUtil::trim(explode(',', $this->usernames)));
     }
 }
示例#13
0
 /**
  * Validates parameters for current request.
  * 
  * @param	\wcf\system\message\IMessageQuickReplyAction	$object
  * @param	array<array>					$parameters
  * @param	string						$containerClassName
  * @param	string						$containerDecoratorClassName
  */
 public function validateParameters(IMessageQuickReplyAction $object, array &$parameters, $containerClassName, $containerDecoratorClassName = '')
 {
     if (!isset($parameters['data']['message'])) {
         throw new UserInputException('message');
     }
     $parameters['data']['message'] = StringUtil::trim(MessageUtil::stripCrap($parameters['data']['message']));
     if (empty($parameters['data']['message'])) {
         throw new UserInputException('message', WCF::getLanguage()->get('wcf.global.form.error.empty'));
     }
     $parameters['lastPostTime'] = isset($parameters['lastPostTime']) ? intval($parameters['lastPostTime']) : 0;
     if (!$parameters['lastPostTime']) {
         throw new UserInputException('lastPostTime');
     }
     $parameters['pageNo'] = isset($parameters['pageNo']) ? intval($parameters['pageNo']) : 0;
     if (!$parameters['pageNo']) {
         throw new UserInputException('pageNo');
     }
     $parameters['objectID'] = isset($parameters['objectID']) ? intval($parameters['objectID']) : 0;
     if (!$parameters['objectID']) {
         throw new UserInputException('objectID');
     }
     $this->container = new $containerClassName($parameters['objectID']);
     if (!empty($containerDecoratorClassName)) {
         if (!ClassUtil::isInstanceOf($containerDecoratorClassName, 'wcf\\data\\DatabaseObjectDecorator')) {
             throw new SystemException("'" . $containerDecoratorClassName . "' does not extend 'wcf\\data\\DatabaseObjectDecorator'");
         }
         $this->container = new $containerDecoratorClassName($this->container);
     }
     $object->validateContainer($this->container);
     // validate message
     $object->validateMessage($this->container, $parameters['data']['message']);
     // check for message quote ids
     $parameters['removeQuoteIDs'] = isset($parameters['removeQuoteIDs']) && is_array($parameters['removeQuoteIDs']) ? ArrayUtil::trim($parameters['removeQuoteIDs']) : array();
     // check for tmp hash (attachments)
     $parameters['tmpHash'] = '';
     if (isset($parameters['data']['tmpHash'])) {
         $parameters['tmpHash'] = StringUtil::trim($parameters['data']['tmpHash']);
         unset($parameters['data']['tmpHash']);
     }
     // message settings
     $parameters['data'] = array_merge($parameters['data'], MessageFormSettingsHandler::getSettings($parameters));
     $parameters['data']['enableHtml'] = 0;
     $parameters['data']['showSignature'] = WCF::getUser()->userID ? WCF::getUser()->showSignature : 0;
     EventHandler::getInstance()->fireAction($this, 'validateParameters', $parameters);
 }
示例#14
0
	/**
	 * Creates a generic index name.
	 * 
	 * @param	string		$tableName
	 * @param	string		$columns
	 * @param	string		$suffix
	 * @return	string		index name
	 */
	protected static function getGenericIndexName($tableName, $columns, $suffix = '') {
		// get first column
		$columns = ArrayUtil::trim(explode(',', $columns));
		
		return md5($tableName . '_' . reset($columns)) . ($suffix ? '_' . $suffix : '');
	}
	/**
	 * @see	wcf\system\database\editor\DatabaseEditor::addIndex()
	 */
	public function addIndex($tableName, $indexName, $indexData) {
		$columns = ArrayUtil::trim(explode(',', $indexData['columns']));
		if (empty($indexName)) {
			// create index name
			$indexName = $tableName.'_'.(!empty($columns[0]) ? $columns[0] : 'generic').'_key';
			
			// solve naming conflicts
			$indices = $this->getIndices($tableName);
			$i = 2;
			while (in_array($indexName, $indices)) {
				$indexName = $tableName.'_'.(!empty($columns[0]) ? $columns[0] : 'generic').'_'.$i.'_key';
				$i++;
			}
		}
		else if ($indexData['type'] != 'FULLTEXT') {
			$indexName = $tableName.'_'.$indexName.'_key';
		}
		
		if ($indexData['type'] == 'FULLTEXT') {
			// add new column for fulltext index
			$sql = "ALTER TABLE ".$tableName." ADD COLUMN ".$indexName." tsvector";
			$statement = $this->dbObj->prepareStatement($sql);
			$statement->execute();
			
			// add gin index
			$sql = "CREATE INDEX ".$tableName."_".$indexName."_fulltext_key ON ".$tableName." USING gin(".$indexName.")";
			$statement = $this->dbObj->prepareStatement($sql);
			$statement->execute();
			
			// update fulltext index
			$sql = "UPDATE	".$tableName."
				SET	".$indexName." = to_tsvector('english', \"".implode('" || \' \' || "', $columns)."\")";
			$statement = $this->dbObj->prepareStatement($sql);
			$statement->execute();
			
			// add trigger
			$sql = "CREATE TRIGGER		".$tableName."_".$indexName."_trigger
				BEFORE INSERT OR UPDATE
				ON			".$tableName."
				FOR EACH ROW EXECUTE PROCEDURE
				tsvector_update_trigger(".$indexName.", 'pg_catalog.english', ".implode(', ', $columns).");";
			$statement = $this->dbObj->prepareStatement($sql);
			$statement->execute();
		}
		else {
			$sql = "CREATE ".($indexData['type'] == 'UNIQUE' ? "UNIQUE " : "")."INDEX ".$indexName." ON ".$tableName." (".$indexData['columns'].")";
			$statement = $this->dbObj->prepareStatement($sql);
			$statement->execute();
		}
	}
示例#16
0
 /**
  * @see	\wcf\form\IForm::readFormParameters()
  */
 public function readFormParameters()
 {
     parent::readFormParameters();
     if (isset($_POST['selectedData']) && is_array($_POST['selectedData'])) {
         $this->selectedData = $_POST['selectedData'];
     }
     if (isset($_POST['dbHost'])) {
         $this->dbHost = StringUtil::trim($_POST['dbHost']);
     }
     if (isset($_POST['dbUser'])) {
         $this->dbUser = StringUtil::trim($_POST['dbUser']);
     }
     if (isset($_POST['dbPassword'])) {
         $this->dbPassword = $_POST['dbPassword'];
     }
     if (isset($_POST['dbName'])) {
         $this->dbName = StringUtil::trim($_POST['dbName']);
     }
     if (isset($_POST['dbPrefix'])) {
         $this->dbPrefix = StringUtil::trim($_POST['dbPrefix']);
     }
     if (isset($_POST['fileSystemPath'])) {
         $this->fileSystemPath = StringUtil::trim($_POST['fileSystemPath']);
     }
     if (isset($_POST['userMergeMode'])) {
         $this->userMergeMode = intval($_POST['userMergeMode']);
     }
     if (isset($_POST['additionalData'])) {
         $this->additionalData = ArrayUtil::trim($_POST['additionalData']);
     }
 }
 /**
  * Reads a list of quote ids to remove.
  */
 public function readFormParameters()
 {
     if (isset($_REQUEST['__removeQuoteIDs']) && is_array($_REQUEST['__removeQuoteIDs'])) {
         $quoteIDs = ArrayUtil::trim($_REQUEST['__removeQuoteIDs']);
         foreach ($quoteIDs as $index => $quoteID) {
             if (!isset($this->quoteData[$quoteID])) {
                 unset($quoteIDs[$index]);
             }
         }
         if (!empty($quoteIDs)) {
             $this->removeQuoteIDs = array_merge($this->removeQuoteIDs, $quoteIDs);
         }
     }
 }
示例#18
0
 /**
  * modify forum post
  *
  * @param $oMbqEtForumPost
  */
 public function mdfMbqEtForumPost($oMbqEtForumPost, $mbqOpt)
 {
     $oBoard = $oMbqEtForumPost->oMbqEtForumTopic->oMbqEtForum->mbqBind['oDetailedBoardNode']->getBoard();
     $oThread = $oMbqEtForumPost->oMbqEtForumTopic->mbqBind['oViewableThread']->getDecoratedObject();
     $oPost = $oMbqEtForumPost->mbqBind['oViewablePost']->getDecoratedObject();
     //ref wbb\form\PostEditForm,wcf\form\MessageForm,wbb\form\ThreadAddForm
     $oMbqEtForumPost->postTitle->setOriValue(StringUtil::trim($oMbqEtForumPost->postTitle->oriValue));
     $oMbqEtForumPost->postContent->setOriValue(MessageUtil::stripCrap(StringUtil::trim($oMbqEtForumPost->postContent->oriValue)));
     $editReason = '';
     $attachmentObjectType = 'com.woltlab.wbb.post';
     $attachmentObjectID = $oMbqEtForumPost->postId->oriValue;
     if ($oThread->firstPostID == $oMbqEtForumPost->postId->oriValue) {
         $enableMultilingualism = true;
         $isFirstPost = true;
     }
     $tmpHash = StringUtil::getRandomID();
     $attachmentParentObjectID = $oBoard->boardID;
     //$attachmentParentObjectID = 0;
     //settings
     $preParse = $enableSmilies = $enableBBCodes = $showSignature = $subscribeThread = $enableHtml = 0;
     $preParse = 1;
     if (WCF::getSession()->getPermission('user.message.canUseSmilies')) {
         $enableSmilies = 1;
     }
     //if (WCF::getSession()->getPermission('user.message.canUseHtml')) $enableHtml = 1;
     if (WCF::getSession()->getPermission('user.message.canUseBBCodes')) {
         $enableBBCodes = 1;
     }
     $showSignature = 1;
     $subscribeThread = 1;
     $type = Thread::TYPE_DEFAULT;
     if ($oThread->isSticky) {
         $type = Thread::TYPE_STICKY;
     } elseif ($oThread->isAnnouncement) {
         MbqError::alert('', __METHOD__ . ',line:' . __LINE__ . '.' . 'Sorry,do not support announcement type.');
     }
     if ($oBoard->getPermission('canHideEditNote')) {
         $hideEditNote = true;
     } else {
         $hideEditNote = false;
     }
     // get max text length
     $maxTextLength = WCF::getSession()->getPermission('user.board.maxPostLength');
     $minCharLength = WBB_POST_MIN_CHAR_LENGTH;
     $minWordCount = WBB_POST_MIN_WORD_COUNT;
     //begin validate
     $allowedBBCodesPermission = 'user.message.allowedBBCodes';
     //validateSubject
     if (StringUtil::length($oMbqEtForumPost->postTitle->oriValue) > 255) {
         MbqError::alert('', "Post title is too long.", '', MBQ_ERR_APP);
     }
     // search for censored words
     if (ENABLE_CENSORSHIP) {
         $result = Censorship::getInstance()->test($oMbqEtForumPost->postTitle->oriValue);
         if ($result) {
             MbqError::alert('', "Found censored words in post title.", '', MBQ_ERR_APP);
         }
     }
     //validateText
     if (empty($oMbqEtForumPost->postContent->oriValue)) {
         MbqError::alert('', "Need post content.", '', MBQ_ERR_APP);
     }
     // check text length
     if ($maxTextLength != 0 && StringUtil::length($oMbqEtForumPost->postContent->oriValue) > $maxTextLength) {
         MbqError::alert('', "Post content is too long.", '', MBQ_ERR_APP);
     }
     if ($enableBBCodes && $allowedBBCodesPermission) {
         $disallowedBBCodes = BBCodeParser::getInstance()->validateBBCodes($oMbqEtForumPost->postContent->oriValue, ArrayUtil::trim(explode(',', WCF::getSession()->getPermission($allowedBBCodesPermission))));
         if (!empty($disallowedBBCodes)) {
             MbqError::alert('', "Post content included disallowed bbcodes.", '', MBQ_ERR_APP);
         }
     }
     // search for censored words
     if (ENABLE_CENSORSHIP) {
         $result = Censorship::getInstance()->test($oMbqEtForumPost->postContent->oriValue);
         if ($result) {
             MbqError::alert('', "Found censored words in post content.", '', MBQ_ERR_APP);
         }
     }
     if ($minCharLength && StringUtil::length($oMbqEtForumPost->postContent->oriValue) < $minCharLength) {
         MbqError::alert('', "Post content is too short.", '', MBQ_ERR_APP);
     }
     if ($minWordCount && count(explode(' ', $oMbqEtForumPost->postContent->oriValue)) < $minWordCount) {
         MbqError::alert('', "Need more words in Post content", '', MBQ_ERR_APP);
     }
     //attachment
     if (MODULE_ATTACHMENT && $attachmentObjectType) {
         $attachmentHandler = new AttachmentHandler($attachmentObjectType, $attachmentObjectID, $tmpHash, $attachmentParentObjectID);
     }
     //save
     if ($preParse) {
         // BBCodes are enabled
         if ($enableBBCodes) {
             if ($allowedBBCodesPermission) {
                 $oMbqEtForumPost->postContent->setOriValue(PreParser::getInstance()->parse($oMbqEtForumPost->postContent->oriValue, ArrayUtil::trim(explode(',', WCF::getSession()->getPermission($allowedBBCodesPermission)))));
             } else {
                 $oMbqEtForumPost->postContent->setOriValue(PreParser::getInstance()->parse($oMbqEtForumPost->postContent->oriValue));
             }
         } else {
             $oMbqEtForumPost->postContent->setOriValue(PreParser::getInstance()->parse($oMbqEtForumPost->postContent->oriValue, array()));
         }
     }
     // save post
     $data = array('subject' => $oMbqEtForumPost->postTitle->oriValue, 'message' => $oMbqEtForumPost->postContent->oriValue, 'enableBBCodes' => $enableBBCodes, 'enableHtml' => $enableHtml, 'enableSmilies' => $enableSmilies, 'showSignature' => $showSignature);
     if (!$hideEditNote && (WCF::getUser()->userID != $oPost->userID || $oPost->time <= TIME_NOW - WBB_POST_EDIT_HIDE_EDIT_NOTE_PERIOD * 60)) {
         $data['editCount'] = $oPost->editCount + 1;
         $data['editReason'] = $editReason;
         $data['editor'] = WCF::getUser()->username;
         $data['editorID'] = WCF::getUser()->userID;
         $data['lastEditTime'] = TIME_NOW;
     }
     $oPostAction = new PostAction(array($oPost), 'update', array('attachmentHandler' => $attachmentHandler, 'data' => $data, 'isEdit' => true));
     $oPostAction->executeAction();
     $threadData = array();
     if (isset($isFirstPost) && $isFirstPost) {
         // update title
         if ($oMbqEtForumPost->postTitle->oriValue != $oMbqEtForumPost->oMbqEtForumTopic->topicTitle->oriValue) {
             $threadData['topic'] = $oMbqEtForumPost->postTitle->oriValue;
         }
         // handle thread type
         switch ($type) {
             case Thread::TYPE_DEFAULT:
                 $threadData['isSticky'] = 0;
                 $threadData['isAnnouncement'] = 0;
                 break;
             case Thread::TYPE_STICKY:
                 $threadData['isSticky'] = 1;
                 $threadData['isAnnouncement'] = 0;
                 break;
             case Thread::TYPE_ANNOUNCEMENT:
                 $threadData['isSticky'] = 0;
                 $threadData['isAnnouncement'] = 1;
                 break;
         }
     }
     if (isset($isFirstPost) && $isFirstPost || !empty($threadData)) {
         $threadData = array('data' => $threadData);
         if ($isFirstPost) {
             $threadData['announcementBoardIDs'] = array();
         }
         //!!!
         $threadAction = new ThreadAction(array($oThread), 'update', $threadData);
         $threadAction->executeAction();
     }
     // save subscription
     if (WCF::getUser()->userID) {
         if ($subscribeThread && !$oThread->isSubscribed()) {
             $action = new UserObjectWatchAction(array(), 'subscribe', array('data' => array('objectID' => $oPost->threadID, 'objectType' => 'com.woltlab.wbb.thread'), 'enableNotification' => UserNotificationHandler::getInstance()->getEventSetting('com.woltlab.wbb.post', 'post') !== false ? 1 : 0));
             $action->executeAction();
         } else {
             if (!$subscribeThread && $oThread->isSubscribed()) {
                 $action = new UserObjectWatchAction(array(), 'unsubscribe', array('data' => array('objectID' => $oPost->threadID, 'objectType' => 'com.woltlab.wbb.thread')));
                 $action->executeAction();
             }
         }
     }
     return $oMbqEtForumPost;
 }
 /**
  * Map attributes.
  * @param	array	$attributes
  */
 protected function mapAttributes($openingTag)
 {
     // reset attributes
     $this->anchor = '';
     $this->noIndex = false;
     if (isset($openingTag['attributes'])) {
         $attributes = ArrayUtil::trim($openingTag['attributes']);
         // first is no index
         if (isset($attributes[0]) && is_numeric($attributes[0])) {
             $this->noIndex = $attributes[0];
             if (isset($attributes[1]) && preg_match('#^[a-zA-Z0-9_]$#', $attributes[1])) {
                 $this->anchor = $attributes[1];
             }
         } else {
             if (isset($attributes[0]) && preg_match('#^[a-zA-Z0-9_]$#', $attributes[0])) {
                 $this->anchor = $attributes[0];
                 if (isset($attributes[1]) && is_numeric($attributes[1])) {
                     $this->noIndex = $attributes[1];
                 }
             }
         }
         $this->noIndex = $this->noIndex == 1 ? true : false;
     }
 }
示例#20
0
 /**
  * add private conversation
  *
  * @param  Object  $oMbqEtPc
  */
 public function addMbqEtPc($oMbqEtPc)
 {
     //ref wcf\form\MessageForm,wcf\form\ConversationAddForm
     $oMbqEtPc->convTitle->setOriValue(StringUtil::trim($oMbqEtPc->convTitle->oriValue));
     $oMbqEtPc->convContent->setOriValue(MessageUtil::stripCrap(StringUtil::trim($oMbqEtPc->convContent->oriValue)));
     $attachmentObjectType = 'com.woltlab.wcf.conversation.message';
     $attachmentObjectID = 0;
     $tmpHash = StringUtil::getRandomID();
     $attachmentParentObjectID = 0;
     // check max pc permission
     if (ConversationHandler::getInstance()->getConversationCount() >= WCF::getSession()->getPermission('user.conversation.maxConversations')) {
         MbqError::alert('', 'Sorry.You can not create more conversations.', '', MBQ_ERR_APP);
     }
     //settings
     $preParse = $enableSmilies = $enableBBCodes = $showSignature = $enableHtml = 0;
     $preParse = 1;
     if (WCF::getSession()->getPermission('user.message.canUseSmilies')) {
         $enableSmilies = 1;
     }
     //if (WCF::getSession()->getPermission('user.message.canUseHtml')) $enableHtml = 1;
     if (WCF::getSession()->getPermission('user.message.canUseBBCodes')) {
         $enableBBCodes = 1;
     }
     $showSignature = 1;
     // get max text length
     $maxTextLength = WCF::getSession()->getPermission('user.conversation.maxLength');
     //begin validate
     try {
         $participantIDs = Conversation::validateParticipants(implode(",", $oMbqEtPc->userNames->oriValue));
     } catch (UserInputException $e) {
         MbqError::alert('', $e->getMessage(), '', MBQ_ERR_APP);
     } catch (Exception $e) {
         MbqError::alert('', $e->getMessage(), '', MBQ_ERR_APP);
     }
     if (empty($participantIDs)) {
         MbqError::alert('', 'Need valid participant user ids.', '', MBQ_ERR_APP);
     }
     // check number of participants
     if (count($participantIDs) > WCF::getSession()->getPermission('user.conversation.maxParticipants')) {
         MbqError::alert('', 'Too many participants.', '', MBQ_ERR_APP);
     }
     $allowedBBCodesPermission = 'user.message.allowedBBCodes';
     //validateSubject
     if (empty($oMbqEtPc->convTitle->oriValue)) {
         MbqError::alert('', "Need conversation title.", '', MBQ_ERR_APP);
     }
     if (StringUtil::length($oMbqEtPc->convTitle->oriValue) > 255) {
         MbqError::alert('', "Conversation title is too long.", '', MBQ_ERR_APP);
     }
     // search for censored words
     if (ENABLE_CENSORSHIP) {
         $result = Censorship::getInstance()->test($oMbqEtPc->convTitle->oriValue);
         if ($result) {
             MbqError::alert('', "Found censored words in conversation title.", '', MBQ_ERR_APP);
         }
     }
     //validateText
     if (empty($oMbqEtPc->convContent->oriValue)) {
         MbqError::alert('', "Need conversation content.", '', MBQ_ERR_APP);
     }
     // check text length
     if ($maxTextLength != 0 && StringUtil::length($oMbqEtPc->convContent->oriValue) > $maxTextLength) {
         MbqError::alert('', "Conversation content is too long.", '', MBQ_ERR_APP);
     }
     if ($enableBBCodes && $allowedBBCodesPermission) {
         $disallowedBBCodes = BBCodeParser::getInstance()->validateBBCodes($oMbqEtPc->convContent->oriValue, ArrayUtil::trim(explode(',', WCF::getSession()->getPermission($allowedBBCodesPermission))));
         if (!empty($disallowedBBCodes)) {
             MbqError::alert('', "Conversation content included disallowed bbcodes.", '', MBQ_ERR_APP);
         }
     }
     // search for censored words
     if (ENABLE_CENSORSHIP) {
         $result = Censorship::getInstance()->test($oMbqEtPc->convContent->oriValue);
         if ($result) {
             MbqError::alert('', "Found censored words in conversation content.", '', MBQ_ERR_APP);
         }
     }
     //language
     $languageID = NULL;
     //attachment
     if (MODULE_ATTACHMENT && $attachmentObjectType) {
         $attachmentHandler = new AttachmentHandler($attachmentObjectType, $attachmentObjectID, $tmpHash, $attachmentParentObjectID);
     }
     //save
     if ($preParse) {
         // BBCodes are enabled
         if ($enableBBCodes) {
             if ($allowedBBCodesPermission) {
                 $oMbqEtPc->convContent->setOriValue(PreParser::getInstance()->parse($oMbqEtPc->convContent->oriValue, ArrayUtil::trim(explode(',', WCF::getSession()->getPermission($allowedBBCodesPermission)))));
             } else {
                 $oMbqEtPc->convContent->setOriValue(PreParser::getInstance()->parse($oMbqEtPc->convContent->oriValue));
             }
         } else {
             $oMbqEtPc->convContent->setOriValue(PreParser::getInstance()->parse($oMbqEtPc->convContent->oriValue, array()));
         }
     }
     // save conversation
     $data = array('subject' => $oMbqEtPc->convTitle->oriValue, 'time' => TIME_NOW, 'userID' => WCF::getUser()->userID, 'username' => WCF::getUser()->username, 'isDraft' => 0, 'participantCanInvite' => 0);
     $conversationData = array('data' => $data, 'attachmentHandler' => $attachmentHandler, 'messageData' => array('message' => $oMbqEtPc->convContent->oriValue, 'enableBBCodes' => $enableBBCodes, 'enableHtml' => $enableHtml, 'enableSmilies' => $enableSmilies, 'showSignature' => $showSignature));
     $conversationData['participants'] = $participantIDs;
     $conversationData['invisibleParticipants'] = array();
     $objectAction = new ConversationAction(array(), 'create', $conversationData);
     $resultValues = $objectAction->executeAction();
     if ($resultValues['returnValues']->conversationID) {
         $convId = $resultValues['returnValues']->conversationID;
         $messageId = $resultValues['returnValues']->messageID;
         $oMbqRdEtPc = MbqMain::$oClk->newObj('MbqRdEtPc');
         $oMbqEtPc = $oMbqRdEtPc->initOMbqEtPc($convId, array('case' => 'byConvId'));
     } else {
         MbqError::alert('', "Can not create topic.", '', MBQ_ERR_APP);
     }
     return $oMbqEtPc;
 }
 /**
  * @see	\wcf\form\IForm::readFormParameters()
  */
 public function readFormParameters()
 {
     parent::readFormParameters();
     if (isset($_POST['fileSubject'])) {
         $this->fileSubject = StringUtil::trim($_POST['fileSubject']);
     }
     if (isset($_POST['tags']) && is_array($_POST['tags'])) {
         $this->tags = ArrayUtil::trim($_POST['tags']);
     }
     if (isset($_POST['teaser'])) {
         $this->teaser = StringUtil::trim($_POST['teaser']);
     }
     if (!empty($_POST['uploadID'])) {
         $this->uploadID = intval($_POST['uploadID']);
         $this->fileUpload = new FileUpload($this->uploadID);
     }
     if (isset($_POST['website'])) {
         $this->website = StringUtil::trim($_POST['website']);
     }
 }
示例#22
0
 /**
  * Takes a string of comma separated tags and splits it into an array.
  * 
  * @param	string		$tags
  * @param	string		$separators
  * @return	array<string>
  */
 public static function splitString($tags, $separators = ',;')
 {
     return array_unique(ArrayUtil::trim(preg_split('/[' . preg_quote($separators) . ']/', $tags)));
 }
 /**
  * Check pages and set parse status.
  */
 public static function parseFootnotes()
 {
     $request = RequestHandler::getInstance()->getActiveRequest();
     $pageName = StringUtil::toLowerCase($request->getPageName());
     $allowedPages = ArrayUtil::trim(explode("\n", StringUtil::toLowerCase(BBCODES_FOOTNOTE_PARSE_PAGE)));
     if (in_array($pageName, $allowedPages)) {
         static::$parse = true;
     } else {
         static::$parse = false;
     }
 }
 /**
  * Exports threads.
  */
 public function exportThreads($offset, $limit)
 {
     $sql = "SELECT\t\tthread.*,\n\t\t\t\t\t(\n\t\t\t\t\t\tSELECT\tMAX(dateline)\n\t\t\t\t\t\tFROM\t" . $this->databasePrefix . "moderatorlog moderatorlog\n\t\t\t\t\t\tWHERE\t\tthread.threadid = moderatorlog.threadid\n\t\t\t\t\t\t\tAND\ttype = ?\n\t\t\t\t\t) AS deleteTime\n\t\t\tFROM\t\t" . $this->databasePrefix . "thread thread\n\t\t\tWHERE\t\tthread.threadid BETWEEN ? AND ?\n\t\t\tORDER BY\tthread.threadid";
     $statement = $this->database->prepareStatement($sql);
     $statement->execute(array(14, $offset + 1, $offset + $limit));
     // 14 = soft delete
     while ($row = $statement->fetchArray()) {
         $data = array('boardID' => $row['forumid'], 'topic' => StringUtil::decodeHTML($row['title']), 'time' => $row['dateline'], 'userID' => $row['postuserid'], 'username' => $row['postusername'], 'views' => $row['views'], 'isAnnouncement' => 0, 'isSticky' => $row['sticky'], 'isDisabled' => $row['visible'] == 1 ? 0 : 1, 'isClosed' => $row['open'] == 1 ? 0 : 1, 'isDeleted' => $row['visible'] == 2 ? 1 : 0, 'movedThreadID' => $row['open'] == 10 && $row['pollid'] ? $row['pollid'] : null, 'movedTime' => 0, 'isDone' => 0, 'deleteTime' => $row['deleteTime'] ?: 0, 'lastPostTime' => $row['lastpost']);
         $additionalData = array();
         if ($row['prefixid']) {
             $additionalData['labels'] = array($row['prefixid']);
         }
         if ($row['taglist'] !== null) {
             $tags = ArrayUtil::trim(explode(',', $row['taglist']));
             $additionalData['tags'] = $tags;
         }
         ImportHandler::getInstance()->getImporter('com.woltlab.wbb.thread')->import($row['threadid'], $data, $additionalData);
     }
 }
 /**
  * @see	\wcf\system\attachment\IAttachmentObjectType::getAllowedExtensions()
  */
 public function getAllowedExtensions()
 {
     return ArrayUtil::trim(explode("\n", WCF::getSession()->getPermission('user.conversation.allowedAttachmentExtensions')));
 }
 /**
  * Maps bbcode attributes to html/template attributes.
  * 
  * @param	array	$openingTag
  */
 protected function mapAttributes($openingTag)
 {
     // reset attributes
     $this->title = '';
     $this->position = 'none';
     if (isset($openingTag['attributes'])) {
         $attributes = ArrayUtil::trim($openingTag['attributes']);
         if (isset($attributes[0])) {
             if (preg_match('#^(left|right)$#i', $attributes[0])) {
                 $this->position = mb_strtolower($attributes[0]);
                 if (isset($attributes[1])) {
                     $this->title = $attributes[1];
                 }
             } else {
                 $this->title = $attributes[0];
                 if (isset($attributes[1]) && preg_match('#^(left|right)$#i', $attributes[0])) {
                     $this->position = mb_strtolower($attributes[1]);
                 }
             }
         }
     }
     // map attributes
     if (empty($this->title)) {
         $this->title = WCF::getLanguage()->get('wcf.bbcode.proContra');
     }
 }
示例#27
0
 /**
  * add private conversation message
  *
  * @param  Object  $oMbqEtPcMsg
  * @param  Object  $oMbqEtPc
  */
 public function addMbqEtPcMsg($oMbqEtPcMsg, $oMbqEtPc)
 {
     $oConversation = $oMbqEtPc->mbqBind['oViewableConversation']->getDecoratedObject();
     //ref wcf\form\MessageForm,wcf\form\ConversationMessageAddForm
     $oMbqEtPcMsg->msgContent->setOriValue(MessageUtil::stripCrap(StringUtil::trim($oMbqEtPcMsg->msgContent->oriValue)));
     $attachmentObjectType = 'com.woltlab.wcf.conversation.message';
     $attachmentObjectID = 0;
     $tmpHash = StringUtil::getRandomID();
     $attachmentParentObjectID = 0;
     //settings
     $preParse = $enableSmilies = $enableBBCodes = $showSignature = $enableHtml = 0;
     $preParse = 1;
     if (WCF::getSession()->getPermission('user.message.canUseSmilies')) {
         $enableSmilies = 1;
     }
     //if (WCF::getSession()->getPermission('user.message.canUseHtml')) $enableHtml = 1;
     if (WCF::getSession()->getPermission('user.message.canUseBBCodes')) {
         $enableBBCodes = 1;
     }
     $showSignature = 1;
     // get max text length
     $maxTextLength = WCF::getSession()->getPermission('user.conversation.maxLength');
     //!!! use this,is better than 0
     //begin validate
     $allowedBBCodesPermission = 'user.message.allowedBBCodes';
     //validateText
     if (empty($oMbqEtPcMsg->msgContent->oriValue)) {
         MbqError::alert('', "Need message content.", '', MBQ_ERR_APP);
     }
     // check text length
     if ($maxTextLength != 0 && StringUtil::length($oMbqEtPcMsg->msgContent->oriValue) > $maxTextLength) {
         MbqError::alert('', "Message content is too long.", '', MBQ_ERR_APP);
     }
     if ($enableBBCodes && $allowedBBCodesPermission) {
         $disallowedBBCodes = BBCodeParser::getInstance()->validateBBCodes($oMbqEtPcMsg->msgContent->oriValue, ArrayUtil::trim(explode(',', WCF::getSession()->getPermission($allowedBBCodesPermission))));
         if (!empty($disallowedBBCodes)) {
             MbqError::alert('', "Message content included disallowed bbcodes.", '', MBQ_ERR_APP);
         }
     }
     // search for censored words
     if (ENABLE_CENSORSHIP) {
         $result = Censorship::getInstance()->test($oMbqEtPcMsg->msgContent->oriValue);
         if ($result) {
             MbqError::alert('', "Found censored words in message content.", '', MBQ_ERR_APP);
         }
     }
     //language
     $languageID = NULL;
     //attachment
     if (MODULE_ATTACHMENT && $attachmentObjectType) {
         $attachmentHandler = new AttachmentHandler($attachmentObjectType, $attachmentObjectID, $tmpHash, $attachmentParentObjectID);
     }
     //save
     if ($preParse) {
         // BBCodes are enabled
         if ($enableBBCodes) {
             if ($allowedBBCodesPermission) {
                 $oMbqEtPcMsg->msgContent->setOriValue(PreParser::getInstance()->parse($oMbqEtPcMsg->msgContent->oriValue, ArrayUtil::trim(explode(',', WCF::getSession()->getPermission($allowedBBCodesPermission)))));
             } else {
                 $oMbqEtPcMsg->msgContent->setOriValue(PreParser::getInstance()->parse($oMbqEtPcMsg->msgContent->oriValue));
             }
         } else {
             $oMbqEtPcMsg->msgContent->setOriValue(PreParser::getInstance()->parse($oMbqEtPcMsg->msgContent->oriValue, array()));
         }
     }
     // save message
     $data = array('conversationID' => $oConversation->conversationID, 'message' => $oMbqEtPcMsg->msgContent->oriValue, 'time' => TIME_NOW, 'userID' => WCF::getUser()->userID, 'username' => WCF::getUser()->username, 'enableBBCodes' => $enableBBCodes, 'enableHtml' => $enableHtml, 'enableSmilies' => $enableSmilies, 'showSignature' => $showSignature);
     $messageData = array('data' => $data, 'attachmentHandler' => $attachmentHandler);
     $objectAction = new ConversationMessageAction(array(), 'create', $messageData);
     $resultValues = $objectAction->executeAction();
     if ($resultValues['returnValues']->messageID) {
         $oMbqEtPcMsg->msgId->setOriValue($resultValues['returnValues']->messageID);
     } else {
         MbqError::alert('', "Can not create topic.", '', MBQ_ERR_APP);
     }
     return $oMbqEtPcMsg;
 }
 /**
  * add forum topic
  *
  * @param  $oMbqEtForumTopic
  */
 public function addMbqEtForumTopic($oMbqEtForumTopic)
 {
     $oMbqRdEtForum = MbqMain::$oClk->newObj('MbqRdEtForum');
     $objsMbqEtForum = $oMbqRdEtForum->getObjsMbqEtForum(array($oMbqEtForumTopic->forumId->oriValue), array('case' => 'byForumIds'));
     if ($oMbqEtForum = $objsMbqEtForum[0]) {
         $oBoard = $oMbqEtForum->mbqBind['oDetailedBoardNode']->getBoard();
     } else {
         MbqError::alert('', "Need valid forum.", '', MBQ_ERR_APP);
     }
     //ref wcf\form\MessageForm,wbb\form\ThreadAddForm
     $oMbqEtForumTopic->topicTitle->setOriValue(StringUtil::trim($oMbqEtForumTopic->topicTitle->oriValue));
     $oMbqEtForumTopic->topicContent->setOriValue(MessageUtil::stripCrap(StringUtil::trim($oMbqEtForumTopic->topicContent->oriValue)));
     $attachmentObjectType = 'com.woltlab.wbb.post';
     $attachmentObjectID = 0;
     $tmpHash = $oMbqEtForumTopic->groupId->oriValue ? $oMbqEtForumTopic->groupId->oriValue : StringUtil::getRandomID();
     $attachmentParentObjectID = $oBoard->boardID;
     //settings
     $preParse = $enableSmilies = $enableBBCodes = $showSignature = $subscribeThread = $enableHtml = 0;
     $preParse = 1;
     if (WCF::getSession()->getPermission('user.message.canUseSmilies')) {
         $enableSmilies = 1;
     }
     //if (WCF::getSession()->getPermission('user.message.canUseHtml')) $enableHtml = 1;
     if (WCF::getSession()->getPermission('user.message.canUseBBCodes')) {
         $enableBBCodes = 1;
     }
     $showSignature = 1;
     $subscribeThread = 1;
     $type = Thread::TYPE_DEFAULT;
     // get max text length
     $maxTextLength = WCF::getSession()->getPermission('user.board.maxPostLength');
     $minCharLength = WBB_THREAD_MIN_CHAR_LENGTH;
     $minWordCount = WBB_THREAD_MIN_WORD_COUNT;
     //begin validate
     $allowedBBCodesPermission = 'user.message.allowedBBCodes';
     //validateSubject
     if (empty($oMbqEtForumTopic->topicTitle->oriValue)) {
         MbqError::alert('', "Need topic title.", '', MBQ_ERR_APP);
     }
     if (StringUtil::length($oMbqEtForumTopic->topicTitle->oriValue) > 255) {
         MbqError::alert('', "Topic title is too long.", '', MBQ_ERR_APP);
     }
     // search for censored words
     if (ENABLE_CENSORSHIP) {
         $result = Censorship::getInstance()->test($oMbqEtForumTopic->topicTitle->oriValue);
         if ($result) {
             MbqError::alert('', "Found censored words in topic title.", '', MBQ_ERR_APP);
         }
     }
     //validateText
     if (empty($oMbqEtForumTopic->topicContent->oriValue)) {
         MbqError::alert('', "Need topic content.", '', MBQ_ERR_APP);
     }
     // check text length
     if ($maxTextLength != 0 && StringUtil::length($oMbqEtForumTopic->topicContent->oriValue) > $maxTextLength) {
         MbqError::alert('', "Topic content is too long.", '', MBQ_ERR_APP);
     }
     if ($enableBBCodes && $allowedBBCodesPermission) {
         $disallowedBBCodes = BBCodeParser::getInstance()->validateBBCodes($oMbqEtForumTopic->topicContent->oriValue, ArrayUtil::trim(explode(',', WCF::getSession()->getPermission($allowedBBCodesPermission))));
         if (!empty($disallowedBBCodes)) {
             MbqError::alert('', "Topic content included disallowed bbcodes.", '', MBQ_ERR_APP);
         }
     }
     // search for censored words
     if (ENABLE_CENSORSHIP) {
         $result = Censorship::getInstance()->test($oMbqEtForumTopic->topicContent->oriValue);
         if ($result) {
             MbqError::alert('', "Found censored words in topic content.", '', MBQ_ERR_APP);
         }
     }
     if ($minCharLength && StringUtil::length($oMbqEtForumTopic->topicContent->oriValue) < $minCharLength) {
         MbqError::alert('', "Topic content is too short.", '', MBQ_ERR_APP);
     }
     if ($minWordCount && count(explode(' ', $oMbqEtForumTopic->topicContent->oriValue)) < $minWordCount) {
         MbqError::alert('', "Need more words in topic content", '', MBQ_ERR_APP);
     }
     //language
     //$languageID = LanguageFactory::getInstance()->getUserLanguage()->languageID;
     $languageID = NULL;
     //attachment
     if (MODULE_ATTACHMENT && $attachmentObjectType) {
         $attachmentHandler = new AttachmentHandler($attachmentObjectType, $attachmentObjectID, $tmpHash, $attachmentParentObjectID);
     }
     //save
     if ($preParse) {
         // BBCodes are enabled
         if ($enableBBCodes) {
             if ($allowedBBCodesPermission) {
                 $oMbqEtForumTopic->topicContent->setOriValue(PreParser::getInstance()->parse($oMbqEtForumTopic->topicContent->oriValue, ArrayUtil::trim(explode(',', WCF::getSession()->getPermission($allowedBBCodesPermission)))));
             } else {
                 $oMbqEtForumTopic->topicContent->setOriValue(PreParser::getInstance()->parse($oMbqEtForumTopic->topicContent->oriValue));
             }
         } else {
             $oMbqEtForumTopic->topicContent->setOriValue(PreParser::getInstance()->parse($oMbqEtForumTopic->topicContent->oriValue, array()));
         }
     }
     // save thread
     $data = array('boardID' => $oMbqEtForumTopic->forumId->oriValue, 'languageID' => $languageID, 'topic' => $oMbqEtForumTopic->topicTitle->oriValue, 'time' => TIME_NOW, 'userID' => MbqMain::$oCurMbqEtUser->userId->oriValue, 'username' => MbqMain::$oCurMbqEtUser->loginName->oriValue, 'hasLabels' => 0);
     $data['isClosed'] = 0;
     if (!$oBoard->getPermission('canStartThreadWithoutModeration')) {
         $data['isDisabled'] = 1;
     }
     $threadData = array('data' => $data, 'board' => $oBoard, 'attachmentHandler' => $attachmentHandler, 'postData' => array('message' => $oMbqEtForumTopic->topicContent->oriValue, 'enableBBCodes' => $enableBBCodes, 'enableHtml' => $enableHtml, 'enableSmilies' => $enableSmilies, 'showSignature' => $showSignature), 'tags' => array(), 'subscribeThread' => $subscribeThread);
     $oThreadAction = new ThreadAction(array(), 'create', $threadData);
     $resultValues = $oThreadAction->executeAction();
     if ($resultValues['returnValues']->threadID) {
         $oMbqEtForumTopic->topicId->setOriValue($resultValues['returnValues']->threadID);
         $oMbqRdEtForumTopic = MbqMain::$oClk->newObj('MbqRdEtForumTopic');
         $oMbqEtForumTopic = $oMbqRdEtForumTopic->initOMbqEtForumTopic($oMbqEtForumTopic->topicId->oriValue, array('case' => 'byTopicId'));
         //for get state
         /* mark forum topic read */
         $this->markForumTopicRead($oMbqEtForumTopic);
     } else {
         MbqError::alert('', "Can not create topic.", '', MBQ_ERR_APP);
     }
 }
 /**
  * Maps bbcode attributes to html/template attributes.
  * 
  * @param	array	$openingTag
  */
 protected function mapAttributes($openingTag)
 {
     // reset attributes
     $this->title = $this->position = '';
     $this->size = 0;
     if (isset($openingTag['attributes'])) {
         $attributes = ArrayUtil::trim($openingTag['attributes']);
         // first ist position
         if (preg_match('#^(left|right)$#i', $attributes[0])) {
             $this->position = $attributes[0];
             // Attribute 2 and 3
             if (isset($attributes[1])) {
                 // attribute is size
                 if (preg_match('#^(1|2|3|4)$#', $attributes[1])) {
                     $this->size = $attributes[1];
                     // third is title.
                     if (isset($attributes[2])) {
                         $this->title = $attributes[2];
                     }
                 } else {
                     $this->title = $attributes[1];
                     // attribute 3 must be size.
                     if (isset($attributes[2]) && preg_match('#^(1|2|3|4)$#', $attributes[2])) {
                         $this->size = $attributes[2];
                     }
                 }
             }
         } else {
             if (preg_match('#^(1|2|3|4)$#', $attributes[0])) {
                 $this->size = $attributes[0];
                 // Attribute 2 and 3
                 if (isset($attributes[1])) {
                     // attribute is position
                     if (preg_match('#^(left|right)$#si', $attributes[1])) {
                         $this->position = $attributes[1];
                         // third is title.
                         if (isset($attributes[2])) {
                             $this->title = $attributes[2];
                         }
                     } else {
                         // second is title
                         $this->title = $attributes[1];
                         // third must be size.
                         if (isset($attributes[2]) && preg_match('#^(left|right)$#i', $attributes[2])) {
                             $this->position = $attributes[2];
                         }
                     }
                 }
             } else {
                 $this->title = $attributes[0];
                 // Attribute 2 and 3
                 if (isset($attributes[1])) {
                     // second is position
                     if (preg_match('#^(left|right)$#si', $attributes[1])) {
                         $this->position = $attributes[1];
                         // third must be size.
                         if (isset($attributes[2]) && preg_match('#^(1|2|3|4)$#', $attributes[2])) {
                             $this->size = $attributes[2];
                         }
                     } else {
                         if (preg_match('#^(1|2|3|4)$#', $attributes[1])) {
                             $this->size = $attributes[1];
                             // third must be position
                             if (isset($attributes[2]) && preg_match('#^(left|right)$#i', $attributes[2])) {
                                 $this->position = $attributes[2];
                             }
                         }
                     }
                 }
             }
         }
     }
     // position check
     if (!empty($this->position)) {
         $this->position = mb_strtolower($this->position);
     }
 }
 /**
  * @see	\wcf\system\option\ISearchableConditionUserOption::addCondition()
  */
 public function addCondition(UserList $userList, Option $option, $value)
 {
     if (!is_array($value) || empty($value)) {
         return false;
     }
     $value = ArrayUtil::trim($value);
     $userList->getConditionBuilder()->add("user_option_value.userOption" . $option->optionID . " REGEXP '" . '(^|\\n)' . implode('\\n([^\\n]*\\n)*', array_map('escapeString', $value)) . '($|\\n)' . "'");
 }