示例#1
0
 /**
  * @see	\wcf\system\bbcode\IBBCode::getParsedTag()
  */
 public function getParsedTag(array $openingTag, $content, array $closingTag, BBCodeParser $parser)
 {
     $src = '';
     if (isset($openingTag['attributes'][0])) {
         $src = $openingTag['attributes'][0];
     }
     if ($parser->getOutputType() == 'text/html') {
         $float = '';
         if (isset($openingTag['attributes'][1])) {
             $float = $openingTag['attributes'][1];
         }
         $style = '';
         if ($float == 'left' || $float == 'right') {
             $style = 'float: ' . $float . '; margin: ' . ($float == 'left' ? '0 15px 7px 0' : '0 0 7px 15px') . ';';
         }
         $width = 0;
         if (isset($openingTag['attributes'][2])) {
             $width = $openingTag['attributes'][2];
             $style .= 'width: ' . $width . 'px;';
         }
         return '<img src="' . $src . '" class="jsResizeImage" alt=""' . ($style ? ' style="' . $style . '"' : '') . ' />';
     } else {
         if ($parser->getOutputType() == 'text/simplified-html') {
             $src = StringUtil::decodeHTML($src);
             $path = parse_url($src, PHP_URL_PATH);
             if ($path !== false) {
                 return StringUtil::encodeHTML(basename($path));
             }
             return '';
         }
     }
 }
示例#2
0
 /**
  * @see	\wcf\system\bbcode\IBBCode::getParsedTag()
  */
 public function getParsedTag(array $openingTag, $content, array $closingTag, BBCodeParser $parser)
 {
     if ($parser->getOutputType() == 'text/html') {
         $quoteLink = !empty($openingTag['attributes'][1]) ? $openingTag['attributes'][1] : '';
         $externalQuoteLink = !empty($openingTag['attributes'][1]) ? !ApplicationHandler::getInstance()->isInternalURL($openingTag['attributes'][1]) : false;
         if (!$externalQuoteLink) {
             $quoteLink = preg_replace('~^https?://~', RouteHandler::getProtocol(), $quoteLink);
         }
         $quoteAuthor = !empty($openingTag['attributes'][0]) ? $openingTag['attributes'][0] : '';
         $quoteAuthorObject = null;
         if ($quoteAuthor && !$externalQuoteLink) {
             $quoteAuthorLC = mb_strtolower(StringUtil::decodeHTML($quoteAuthor));
             foreach (MessageEmbeddedObjectManager::getInstance()->getObjects('com.woltlab.wcf.quote') as $user) {
                 if (mb_strtolower($user->username) == $quoteAuthorLC) {
                     $quoteAuthorObject = $user;
                     break;
                 }
             }
         }
         WCF::getTPL()->assign(array('content' => $content, 'quoteLink' => $quoteLink, 'quoteAuthor' => $quoteAuthor, 'quoteAuthorObject' => $quoteAuthorObject, 'isExternalQuoteLink' => $externalQuoteLink));
         return WCF::getTPL()->fetch('quoteBBCodeTag');
     } else {
         if ($parser->getOutputType() == 'text/simplified-html') {
             return WCF::getLanguage()->getDynamicVariable('wcf.bbcode.quote.text', array('content' => $content, 'cite' => !empty($openingTag['attributes'][0]) ? $openingTag['attributes'][0] : '')) . "\n";
         }
     }
 }
示例#3
0
 /**
  * @see	\wcf\system\bbcode\IBBCode::getParsedTag()
  */
 public function getParsedTag(array $openingTag, $content, array $closingTag, BBCodeParser $parser)
 {
     $email = '';
     if (isset($openingTag['attributes'][0])) {
         $email = $openingTag['attributes'][0];
     }
     $email = StringUtil::decodeHTML($email);
     return '<a href="mailto:' . StringUtil::encodeAllChars($email) . '">' . $content . '</a>';
 }
示例#4
0
 /**
  * @see	\wcf\system\bbcode\IBBCode::getParsedTag()
  */
 public function getParsedTag(array $openingTag, $content, array $closingTag, BBCodeParser $parser)
 {
     $url = '';
     if (isset($openingTag['attributes'][0])) {
         $url = $openingTag['attributes'][0];
     }
     $noTitle = $content == $url;
     $url = StringUtil::decodeHTML($url);
     // add protocol if necessary
     if (!preg_match("/[a-z]:\\/\\//si", $url)) {
         $url = 'http://' . $url;
     }
     return StringUtil::getAnchorTag($url, !$noTitle ? $content : '', false);
 }
 /**
  * @see \wcf\system\bbcode\IBBCode::getParsedTag()
  */
 public function getParsedTag(array $openingTag, $content, array $closingTag, BBCodeParser $parser)
 {
     // copyright
     TeraliosBBCodesCopyright::callCopyright();
     $tag = mb_strtolower($openingTag['name']);
     // heading and subheading tag html.
     if ($parser->getOutputType() == 'text/html') {
         // map attributes
         $this->mapAttributes($openingTag);
         // assign attributes
         $anchor = $this->anchor;
         $noIndex = $this->noIndex;
         // check anchor and set automark
         if (BBCODES_HEADLINE_AUTOMARK == 1 && empty($anchor)) {
             $anchor = substr(md5($content), 0, 10);
         } else {
             if (empty($anchor)) {
                 $anchor = '';
             }
         }
         // check anchor
         if (!empty($anchor)) {
             $anchor = sprintf(static::$anchorPrefix, static::anchorExists($anchor, $anchor));
             if ($noIndex != true) {
                 $anchor = Directory::getInstance()->addEntry($anchor, StringUtil::decodeHTML($content), $tag == 'h1' ? true : false);
             } else {
                 $anchor = new Entry($anchor, StringUtil::decodeHTML($content));
             }
         }
         // assign to template
         WCF::getTPL()->assign(array('hsTag' => $tag, 'hsEntry' => $anchor, 'hsHeading' => $content, 'hsLinkTitle' => StringUtil::stripHTML($content)));
         return WCF::getTPL()->fetch('headingBBCode');
     } else {
         if ($parser->getOutputType('text/simplified-html')) {
             switch ($tag) {
                 case 'h1':
                     $return = '--- ' . $content . ' ---<br />';
                     break;
                 default:
                     $return = '-- ' . $content . ' --<br />';
                     break;
             }
             return $return;
         }
     }
 }
 /**
  * Formats a message for search result output.
  * 
  * @param	string		$text
  * @return	string
  */
 public function parse($text)
 {
     // remove nonessentials
     $text = Regex::compile('<!-- begin:parser_nonessential -->.*?<!-- end:parser_nonessential -->', Regex::DOT_ALL)->replace($text, '');
     // remove html codes
     $text = StringUtil::stripHTML($text);
     // decode html
     $text = StringUtil::decodeHTML($text);
     // get abstract
     $text = $this->getMessageAbstract($text);
     // encode html
     $text = StringUtil::encodeHTML($text);
     // do highlighting
     return KeywordHighlighter::getInstance()->doHighlight($text);
 }
示例#7
0
 /**
  * Returns a text-only version of given message.
  * 
  * @param	string		$message
  * @return	string
  */
 public function stripHTML($message)
 {
     // remove img tags (smilies)
     $message = preg_replace('~<img src="[^"]+" alt="([^"]+)" />~', '\\1', $message);
     // strip other HTML tags
     $message = StringUtil::stripHTML($message);
     // decode HTML entities
     $message = StringUtil::decodeHTML($message);
     return $message;
 }
示例#8
0
 public function readData()
 {
     parent::readData();
     VisitCountHandler::getInstance()->count();
     WCF::getBreadcrumbs()->add(new Breadcrumb(WCF::getLanguage()->get('cms.page.news'), LinkHandler::getInstance()->getLink('NewsCategoryList', array('application' => 'cms'))));
     $this->commentObjectTypeID = CommentHandler::getInstance()->getObjectTypeID('de.codequake.cms.news.comment');
     $this->commentManager = CommentHandler::getInstance()->getObjectType($this->commentObjectTypeID)->getProcessor();
     $this->commentList = CommentHandler::getInstance()->getCommentList($this->commentManager, $this->commentObjectTypeID, $this->newsID);
     $newsEditor = new NewsEditor($this->news->getDecoratedObject());
     $newsEditor->update(array('clicks' => $this->news->clicks + 1));
     // get Tags
     if (MODULE_TAGGING) {
         $this->tags = $this->news->getTags();
     }
     if ($this->news->teaser != '') {
         MetaTagHandler::getInstance()->addTag('description', 'description', $this->news->teaser);
     } else {
         MetaTagHandler::getInstance()->addTag('description', 'description', StringUtil::decodeHTML(StringUtil::stripHTML($this->news->getExcerpt())));
     }
     if (!empty($this->tags)) {
         MetaTagHandler::getInstance()->addTag('keywords', 'keywords', implode(',', $this->tags));
     }
     MetaTagHandler::getInstance()->addTag('og:title', 'og:title', $this->news->subject . ' - ' . WCF::getLanguage()->get(PAGE_TITLE), true);
     MetaTagHandler::getInstance()->addTag('og:url', 'og:url', LinkHandler::getInstance()->getLink('News', array('application' => 'cms', 'object' => $this->news->getDecoratedObject())), true);
     MetaTagHandler::getInstance()->addTag('og:type', 'og:type', 'article', true);
     if ($this->news->getImage() != null) {
         MetaTagHandler::getInstance()->addTag('og:image', 'og:image', $this->news->getImage()->getLink(), true);
     }
     if ($this->news->getUserProfile()->facebook != '') {
         MetaTagHandler::getInstance()->addTag('article:author', 'article:author', 'https://facebook.com/' . $this->news->getUserProfile()->facebook, true);
     }
     if (FACEBOOK_PUBLIC_KEY != '') {
         MetaTagHandler::getInstance()->addTag('fb:app_id', 'fb:app_id', FACEBOOK_PUBLIC_KEY, true);
     }
     MetaTagHandler::getInstance()->addTag('og:description', 'og:description', StringUtil::decodeHTML(StringUtil::stripHTML($this->news->getExcerpt())), true);
     if ($this->news->isNew()) {
         $newsAction = new NewsAction(array($this->news->getDecoratedObject()), 'markAsRead', array('viewableNews' => $this->news));
         $newsAction->executeAction();
     }
     // fetch likes
     if (MODULE_LIKE) {
         $objectType = LikeHandler::getInstance()->getObjectType('de.codequake.cms.likeableNews');
         LikeHandler::getInstance()->loadLikeObjects($objectType, array($this->newsID));
         $this->likeData = LikeHandler::getInstance()->getLikeObjects($objectType);
     }
 }
 private static function fixStatusUpdate($string)
 {
     // <br /> to newline
     $string = str_ireplace('<br />', "\n", $string);
     $string = str_ireplace('<br>', "\n", $string);
     // decode html entities
     $string = StringUtil::decodeHTML($string);
     // replace single quote entity
     $string = str_replace('&#39;', "'", $string);
     return $string;
 }
 /**
  * Exports users.
  */
 public function exportUsers($offset, $limit)
 {
     // prepare password update
     $sql = "UPDATE\twcf" . WCF_N . "_user\n\t\t\tSET\tpassword = ?\n\t\t\tWHERE\tuserID = ?";
     $passwordUpdateStatement = WCF::getDB()->prepareStatement($sql);
     $userIDs = $this->database->zrange('users:joindate', $offset, $offset + $limit);
     if (!$userIDs) {
         throw new SystemException('Could not fetch userIDs');
     }
     foreach ($userIDs as $userID) {
         $row = $this->database->hgetall('user:'******'Invalid user');
         }
         $data = array('username' => $row['username'], 'password' => '', 'email' => $row['email'], 'registrationDate' => intval($row['joindate'] / 1000), 'banned' => $row['banned'] ? 1 : 0, 'banReason' => '', 'lastActivityTime' => intval($row['lastonline'] / 1000), 'signature' => self::convertMarkdown($row['signature']));
         static $gravatarRegex = null;
         if ($gravatarRegex === null) {
             $gravatarRegex = new Regex('https://(?:secure\\.)?gravatar\\.com/avatar/([a-f0-9]{32})');
         }
         if ($gravatarRegex->match($row['picture'])) {
             $matches = $gravatarRegex->getMatches();
             if ($matches[1] === md5($row['email'])) {
                 $data['enableGravatar'] = 1;
             }
         }
         $birthday = \DateTime::createFromFormat('m/d/Y', StringUtil::decodeHTML($row['birthday']));
         // get user options
         $options = array('birthday' => $birthday ? $birthday->format('Y-m-d') : '', 'homepage' => StringUtil::decodeHTML($row['website']), 'location' => StringUtil::decodeHTML($row['location']));
         $additionalData = array('options' => $options);
         $newUserID = ImportHandler::getInstance()->getImporter('com.woltlab.wcf.user')->import($row['uid'], $data, $additionalData);
         // update password hash
         if ($newUserID) {
             $password = PasswordUtil::getSaltedHash($row['password'], $row['password']);
             $passwordUpdateStatement->execute(array($password, $newUserID));
         }
     }
 }
示例#11
0
 /**
  * Set base link.
  *
  * @param	string	$shareLink
  */
 public function setShareLink($shareLink, $isHTMLEncoded = false)
 {
     $this->shareLink = StringUtil::trim($shareLink);
     if ($isHTMLEncoded == true) {
         $this->shareLink = StringUtil::decodeHTML($this->shareLink);
     }
 }
 private static function fixMessage($string)
 {
     // align
     $string = preg_replace('~<p style="text-align:(left|center|right);">(.*?)</p>~is', "[align=\\1]\\2[/align]\n\n", $string);
     // <p> to newline
     $string = str_ireplace('<p>', "", $string);
     $string = str_ireplace('</p>', "\n\n", $string);
     $string = str_ireplace('<br>', "\n", $string);
     // strike
     $string = str_ireplace('<s>', '[s]', $string);
     $string = str_ireplace('</s>', '[/s]', $string);
     // super
     $string = str_ireplace('<sup>', '[sup]', $string);
     $string = str_ireplace('</sup>', '[/sup]', $string);
     // subscript
     $string = str_ireplace('<sub>', '[sub]', $string);
     $string = str_ireplace('</sub>', '[/sub]', $string);
     // bold
     $string = str_ireplace('<strong>', '[b]', $string);
     $string = str_ireplace('</strong>', '[/b]', $string);
     $string = str_ireplace('<b>', '[b]', $string);
     $string = str_ireplace('</b>', '[/b]', $string);
     // italic
     $string = str_ireplace('<em>', '[i]', $string);
     $string = str_ireplace('</em>', '[/i]', $string);
     $string = str_ireplace('<i>', '[i]', $string);
     $string = str_ireplace('</i>', '[/i]', $string);
     // underline
     $string = str_ireplace('<u>', '[u]', $string);
     $string = str_ireplace('</u>', '[/u]', $string);
     // font color
     $string = preg_replace('~<span style="color:(.*?);?">(.*?)</span>~is', '[color=\\1]\\2[/color]', $string);
     // font size
     $string = preg_replace('~<span style="font-size:(\\d+)px;">(.*?)</span>~is', '[size=\\1]\\2[/size]', $string);
     // font face
     $string = preg_replace_callback('~<span style="font-family:(.*?)">(.*?)</span>~is', function ($matches) {
         return "[font='" . str_replace(";", '', str_replace("'", '', $matches[1])) . "']" . $matches[2] . "[/font]";
     }, $string);
     // embedded attachments
     $string = preg_replace('~<a class="ipsAttachLink" (?:rel="[^"]*" )?href="[^"]*id=(\\d+)[^"]*".*?</a>~i', '[attach]\\1[/attach]', $string);
     $string = preg_replace('~<a.*?><img data-fileid="(\\d+)".*?</a>~i', '[attach]\\1[/attach]', $string);
     // urls
     $string = preg_replace('~<a.*?href=(?:"|\')mailto:([^"]*)(?:"|\')>(.*?)</a>~is', '[email=\'\\1\']\\2[/email]', $string);
     $string = preg_replace('~<a.*?href=(?:"|\')([^"]*)(?:"|\')>(.*?)</a>~is', '[url=\'\\1\']\\2[/url]', $string);
     // quotes
     $string = preg_replace('~<blockquote[^>]*>(.*?)</blockquote>~is', '[quote]\\1[/quote]', $string);
     // code
     $string = preg_replace('~<pre[^>]*>(.*?)</pre>~is', '[code]\\1[/code]', $string);
     // smileys
     $string = preg_replace('~<img title="([^"]*)" alt="[^"]*" src="<fileStore.core_Emoticons>[^"]*">~is', '\\1', $string);
     $string = preg_replace('~<img src="<fileStore.core_Emoticons>[^"]*" alt="[^"]*" title="([^"]*)">~is', '\\1', $string);
     // list
     $string = str_ireplace('</ol>', '[/list]', $string);
     $string = str_ireplace('</ul>', '[/list]', $string);
     $string = str_ireplace('<ul>', '[list]', $string);
     $string = str_ireplace("<ol type='1'>", '[list=1]', $string);
     $string = str_ireplace("<ol>", '[list=1]', $string);
     $string = str_ireplace('<li>', '[*]', $string);
     $string = str_ireplace('</li>', '', $string);
     // images
     $string = preg_replace('~<img[^>]+src=["\']([^"\']+)["\'][^>]*/?>~is', '[img]\\1[/img]', $string);
     // strip tags
     $string = StringUtil::stripHTML($string);
     // decode html entities
     $string = StringUtil::decodeHTML($string);
     return StringUtil::trim($string);
 }
 /**
  * Exports blog comments.
  */
 public function exportBlogComments($offset, $limit)
 {
     $sql = "SELECT\tcomment_ID, comment_parent\n\t\t\tFROM\t" . $this->databasePrefix . "comments\n\t\t\tWHERE\tcomment_ID = ?";
     $parentCommentStatement = $this->database->prepareStatement($sql, $limit, $offset);
     $sql = "SELECT\t\t*\n\t\t\tFROM\t\t" . $this->databasePrefix . "comments\n\t\t\tWHERE\tcomment_approved = ?\n\t\t\tORDER BY\tcomment_parent, comment_ID";
     $statement = $this->database->prepareStatement($sql, $limit, $offset);
     $statement->execute(array(1));
     while ($row = $statement->fetchArray()) {
         if (!$row['comment_parent']) {
             ImportHandler::getInstance()->getImporter('com.woltlab.blog.entry.comment')->import($row['comment_ID'], array('objectID' => $row['comment_post_ID'], 'userID' => $row['user_id'] ?: null, 'username' => $row['comment_author'], 'message' => StringUtil::decodeHTML($row['comment_content']), 'time' => @strtotime($row['comment_date_gmt'])));
         } else {
             $parentID = $row['comment_parent'];
             do {
                 $parentCommentStatement->execute(array($parentID));
                 $row2 = $parentCommentStatement->fetchArray();
                 if (!$row2['comment_parent']) {
                     ImportHandler::getInstance()->getImporter('com.woltlab.blog.entry.comment.response')->import($row['comment_ID'], array('commentID' => $row2['comment_ID'], 'userID' => $row['user_id'] ?: null, 'username' => $row['comment_author'], 'message' => StringUtil::decodeHTML($row['comment_content']), 'time' => @strtotime($row['comment_date_gmt'])));
                     break;
                 }
                 $parentID = $row2['comment_parent'];
             } while (true);
         }
     }
 }
 /**
  * Exports posts.
  */
 public function exportPosts($offset, $limit)
 {
     $sql = "SELECT\t\tchild.*, IF(parent.contenttypeid = child.contenttypeid, 0, 1) AS isFirstPost, text.*\n\t\t\tFROM\t\t" . $this->databasePrefix . "node child\n\t\t\tINNER JOIN\t" . $this->databasePrefix . "text text\n\t\t\tON\t\tchild.nodeid = text.nodeid\n\t\t\tINNER JOIN\t" . $this->databasePrefix . "node parent\n\t\t\tON\t\tchild.parentid = parent.nodeid\n\t\t\t\n\t\t\tINNER JOIN\t(SELECT contenttypeid FROM " . $this->databasePrefix . "contenttype WHERE class IN(?, ?)) x\n\t\t\tON\t\tx.contenttypeid = child.contenttypeid\n\t\t\t\n\t\t\tWHERE\t\tchild.nodeid BETWEEN ? AND ?\n\t\t\tORDER BY\tchild.nodeid ASC";
     $statement = $this->database->prepareStatement($sql);
     $statement->execute(array('Text', 'Poll', $offset + 1, $offset + $limit));
     while ($row = $statement->fetchArray()) {
         ImportHandler::getInstance()->getImporter('com.woltlab.wbb.post')->import($row['nodeid'], array('threadID' => $row['isFirstPost'] ? $row['nodeid'] : $row['parentid'], 'userID' => $row['userid'], 'username' => $row['authorname'], 'subject' => StringUtil::decodeHTML($row['title']), 'message' => self::fixBBCodes($row['rawtext']), 'time' => $row['created'], 'isDeleted' => $row['deleteuserid'] !== null ? 1 : 0, 'deleteTime' => $row['deleteuserid'] !== null ? TIME_NOW : 0, 'isDisabled' => $row['approved'] ? 0 : 1, 'isClosed' => 0, 'editorID' => null, 'editor' => '', 'lastEditTime' => 0, 'editCount' => 0, 'editReason' => '', 'enableSmilies' => $row['allowsmilie'], 'enableHtml' => isset($row['htmlState']) && $row['htmlState'] != 'off' ? 1 : 0, 'enableBBCodes' => 1, 'showSignature' => $row['showsignature'], 'ipAddress' => UserUtil::convertIPv4To6($row['ipaddress'])));
     }
 }
 /**
  * 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);
     }
 }
 /**
  * Exports posts.
  */
 public function exportPosts($offset, $limit)
 {
     $sql = "SELECT\t\tpost_table.*, user_table.username, editor.username AS editorName,\n\t\t\t\t\t(SELECT COUNT(*) FROM " . $this->databasePrefix . "attachments attachment_table WHERE attachment_table.post_msg_id = post_table.post_id AND in_message = ?) AS attachments\n\t\t\tFROM\t\t" . $this->databasePrefix . "posts post_table\n\t\t\tLEFT JOIN\t" . $this->databasePrefix . "users user_table\n\t\t\tON\t\tpost_table.poster_id = user_table.user_id\n\t\t\tLEFT JOIN\t" . $this->databasePrefix . "users editor\n\t\t\tON\t\tpost_table.post_edit_user = editor.user_id\n\t\t\tWHERE\t\tpost_id BETWEEN ? AND ?\n\t\t\tORDER BY\tpost_id";
     $statement = $this->database->prepareStatement($sql);
     $statement->execute(array(0, $offset + 1, $offset + $limit));
     while ($row = $statement->fetchArray()) {
         ImportHandler::getInstance()->getImporter('com.woltlab.wbb.post')->import($row['post_id'], array('threadID' => $row['topic_id'], 'userID' => $row['poster_id'], 'username' => $row['post_username'] ?: (StringUtil::decodeHTML($row['username']) ?: ''), 'subject' => StringUtil::decodeHTML($row['post_subject']), 'message' => self::fixBBCodes(StringUtil::decodeHTML($row['post_text']), $row['bbcode_uid']), 'time' => $row['post_time'], 'isDisabled' => $row['post_approved'] ? 0 : 1, 'isClosed' => $row['post_edit_locked'] ? 1 : 0, 'editorID' => $row['post_edit_user'] ?: null, 'editor' => $row['editorName'] ?: '', 'lastEditTime' => $row['post_edit_time'], 'editCount' => $row['post_edit_count'], 'editReason' => !empty($row['post_edit_reason']) ? $row['post_edit_reason'] : '', 'attachments' => $row['attachments'], 'enableSmilies' => $row['enable_smilies'], 'enableHtml' => 0, 'enableBBCodes' => $row['enable_bbcode'], 'showSignature' => $row['enable_sig'], 'ipAddress' => UserUtil::convertIPv4To6($row['poster_ip'])));
     }
 }
 /**
  * @see	\wcf\page\IPage::readData()
  */
 public function readData()
 {
     parent::readData();
     // add breadcrumbs
     WCF::getBreadcrumbs()->add(new Breadcrumb(WCF::getLanguage()->get('cms.header.menu.news'), LinkHandler::getInstance()->getLink('NewsOverview', array('application' => 'cms'))));
     if ($this->entry->isArchived) {
         WCF::getBreadcrumbs()->add(new Breadcrumb(WCF::getLanguage()->get('cms.header.menu.news.archive'), LinkHandler::getInstance()->getLink('NewsArchive', array('application' => 'cms'))));
     }
     $categories = array();
     $leafCategories = $this->entry->getLeafCategories();
     $category = reset($leafCategories);
     while ($category !== null) {
         $categories[] = $category;
         $category = $category->getParentCategory();
     }
     foreach (array_reverse($categories) as $parentCategory) {
         WCF::getBreadcrumbs()->add($parentCategory->getBreadcrumb());
     }
     // update news view count
     $this->entry->updateVisits();
     // update news visit
     if ($this->entry->isNew()) {
         $entryAction = new EntryAction(array($this->entry->getDecoratedObject()), 'markAsRead', array('viewableEntry' => $this->entry));
         $entryAction->executeAction();
     }
     // fetch news likes
     if (MODULE_LIKE) {
         $objectType = LikeHandler::getInstance()->getObjectType('de.incendium.cms.like.likeableNews');
         LikeHandler::getInstance()->loadLikeObjects($objectType, array($this->entryID));
         $this->entryLikeData = LikeHandler::getInstance()->getLikeObjects($objectType);
     }
     // get news tags
     if (MODULE_TAGGING) {
         $this->tags = TagEngine::getInstance()->getObjectTags('de.incendium.cms.news.entry', $this->entry->entryID, array($this->entry->languageID === null ? LanguageFactory::getInstance()->getDefaultLanguageID() : ""));
     }
     // get news comments
     if ($this->commentManager === null) {
         $this->objectTypeID = CommentHandler::getInstance()->getObjectTypeID('de.incendium.cms.news.comment');
         $objectType = CommentHandler::getInstance()->getObjectType($this->objectTypeID);
         $this->commentManager = $objectType->getProcessor();
     }
     $this->commentList = CommentHandler::getInstance()->getCommentList($this->commentManager, $this->objectTypeID, $this->entryID);
     // more news from this category
     $this->moreEntryList = new AccessibleEntryList();
     $this->moreEntryList->getConditionBuilder()->add("news_entry.entryID IN (SELECT entryID FROM cms" . WCF_N . "_news_entry_to_category WHERE entryID != ? AND categoryID IN (?))", array($this->entryID, $this->entry->getCategoryIDs()));
     $this->moreEntryList->sqlLimit = CMS_DASHBOARD_SIDEBAR_NEWSENTRIES;
     $this->moreEntryList->readObjects();
     // meta tags
     MetaTagHandler::getInstance()->addTag('og:title', 'og:title', $this->entry->subject . ' - ' . WCF::getLanguage()->get(PAGE_TITLE), true);
     MetaTagHandler::getInstance()->addTag('og:url', 'og:url', LinkHandler::getInstance()->getLink('NewsEntry', array('application' => 'cms', 'object' => $this->entry)), true);
     MetaTagHandler::getInstance()->addTag('og:type', 'og:type', 'article', true);
     MetaTagHandler::getInstance()->addTag('og:description', 'og:description', StringUtil::decodeHTML(StringUtil::stripHTML($this->entry->getExcerpt())), true);
     // add tags as keywords
     if (!empty($this->tags)) {
         $keywords = '';
         foreach ($this->tags as $tag) {
             if (!empty($keywords)) {
                 $keywords .= ', ';
             }
             $keywords .= $tag->name;
         }
         MetaTagHandler::getInstance()->addTag('keywords', 'keywords', $keywords);
     }
     // quotes
     MessageQuoteManager::getInstance()->initObjects('de.incendium.cms.news.entry', array($this->entry->entryID));
 }
 private static function fixBBCodes($message)
 {
     static $sizeRegex = null;
     static $quoteRegex = null;
     static $quoteCallback = null;
     if ($sizeRegex === null) {
         $quoteRegex = new Regex('\\[quote author=(.*?) link=topic=\\d+\\.msg(\\d+)#msg\\2 date=\\d+\\]');
         $quoteCallback = new Callback(function ($matches) {
             $username = str_replace(array("\\", "'"), array("\\\\", "\\'"), $matches[1]);
             $postID = $matches[2];
             $postLink = LinkHandler::getInstance()->getLink('Thread', array('application' => 'wbb', 'postID' => $postID, 'forceFrontend' => true)) . '#post' . $postID;
             $postLink = str_replace(array("\\", "'"), array("\\\\", "\\'"), $postLink);
             return "[quote='" . $username . "','" . $postLink . "']";
         });
         $sizeRegex = new Regex('\\[size=(8|10|12|14|18|24|34)pt\\]');
     }
     // use proper WCF 2 bbcode
     $message = strtr($message, array('<br />' => "\n", '[iurl]' => '[url]', '[/iurl]' => '[/url]', '[left]' => '[align=left]', '[/left]' => '[/align]', '[right]' => '[align=right]', '[/right]' => '[/align]', '[center]' => '[align=center]', '[/center]' => '[/align]', '[ftp]' => '[url]', '[/ftp]' => '[/url]', '[php]' => '[code=php]', '[/php]' => '[/code]'));
     // fix size bbcode
     $message = $sizeRegex->replace($message, '[size=\\1]');
     // convert html entities in text
     $message = StringUtil::decodeHTML($message);
     // quotes
     $message = $quoteRegex->replace($message, $quoteCallback);
     // remove crap
     $message = MessageUtil::stripCrap($message);
     return $message;
 }