function do_get_poll() { global $vbulletin, $db, $foruminfo, $threadinfo, $postid, $vbphrase; if (empty($threadinfo['threadid'])) { json_error(ERR_INVALID_THREAD); } $threadid = $vbulletin->GPC['threadid']; $counter = 1; $pollid = $threadinfo['pollid']; if (!$pollid) { json_error(ERR_INVALID_THREAD); } $forumperms = fetch_permissions($threadinfo['forumid']); // get poll info $pollinfo = $db->query_first_slave("\n\tSELECT *\n\tFROM " . TABLE_PREFIX . "poll\n\tWHERE pollid = {$pollid}\n "); require_once DIR . '/includes/class_bbcode.php'; $bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list()); $pollinfo['question'] = prepare_utf8_string(strip_tags(remove_bbcode(unhtmlspecialchars($pollinfo['question']), true, true))); $splitoptions = explode('|||', $pollinfo['options']); $splitoptions = array_map('rtrim', $splitoptions); $splitvotes = explode('|||', $pollinfo['votes']); $showresults = 0; $uservoted = 0; if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canvote'])) { $nopermission = 1; } if (!$pollinfo['active'] or !$threadinfo['open'] or $pollinfo['dateline'] + $pollinfo['timeout'] * 86400 < TIMENOW and $pollinfo['timeout'] != 0 or $nopermission) { //thread/poll is closed, ie show results no matter what $showresults = 1; } else { //get userid, check if user already voted $voted = intval(fetch_bbarray_cookie('poll_voted', $pollid)); if ($voted) { $uservoted = 1; } } if ($pollinfo['timeout'] and !$showresults) { $pollendtime = vbdate($vbulletin->options['timeformat'], $pollinfo['dateline'] + $pollinfo['timeout'] * 86400); $pollenddate = vbdate($vbulletin->options['dateformat'], $pollinfo['dateline'] + $pollinfo['timeout'] * 86400); $show['pollenddate'] = true; } else { $show['pollenddate'] = false; } foreach ($splitvotes as $index => $value) { $pollinfo['numbervotes'] += $value; } if ($vbulletin->userinfo['userid'] > 0) { $pollvotes = $db->query_read_slave("\n\t SELECT voteoption\n\t FROM " . TABLE_PREFIX . "pollvote\n\t WHERE userid = " . $vbulletin->userinfo['userid'] . " AND pollid = {$pollid}\n\t"); if ($db->num_rows($pollvotes) > 0) { $uservoted = 1; } } if ($showresults or $uservoted) { if ($uservoted) { $uservote = array(); while ($pollvote = $db->fetch_array($pollvotes)) { $uservote["{$pollvote['voteoption']}"] = 1; } } } $options = array(); foreach ($splitvotes as $index => $value) { $arrayindex = $index + 1; if ($value <= 0) { $percent = 0; } else { $percent = vb_number_format($value < $pollinfo['numbervotes'] ? $value / $pollinfo['numbervotes'] * 100 : 100, 0); } $options[] = array('voted' => iif($uservote["{$arrayindex}"], true, false), 'percent' => $percent, 'title' => prepare_utf8_string(strip_tags(remove_bbcode(unhtmlspecialchars($splitoptions["{$index}"]), true, true)) . $titleadd), 'votes' => $value); } // Phrase parts below if ($nopermission) { $pollstatus = $vbphrase['you_may_not_vote_on_this_poll']; } else { if ($showresults) { $pollstatus = $vbphrase['this_poll_is_closed']; } else { if ($uservoted) { $pollstatus = $vbphrase['you_have_already_voted_on_this_poll']; } } } $out = array('title' => prepare_utf8_string($pollinfo['question']), 'pollstatus' => prepare_utf8_string($pollstatus), 'options' => $options, 'total' => $pollinfo['numbervotes'], 'canvote' => !$nopermission && !$uservoted); if ($pollinfo['multiple']) { $out['multiple'] = true; } return $out; }
public function actionGetProfile() { $visitor = XenForo_Visitor::getInstance(); $permissions = $visitor->getPermissions(); $session_model = $this->getModelFromCache('XenForo_Model_Session'); $userid = $this->_input->filterSingle('userid', XenForo_Input::UINT); if (!$userid) { $userid = XenForo_Visitor::getUserId(); } try { $user = $this->getHelper('UserProfile')->assertUserProfileValidAndViewable($userid, array('join' => XenForo_Model_User::FETCH_LAST_ACTIVITY)); } catch (Exception $e) { json_error($e->getControllerResponse()->errorText->render()); } $online_info = $session_model->getSessionActivityRecords(array('user_id' => $user['user_id'], 'cutOff' => array('>', $session_model->getOnlineStatusTimeout()))); $is_online = false; if (count($online_info) == 1) { $is_online = true; } $posts = $user['message_count']; $joindate = prepare_utf8_string(XenForo_Locale::date($user['register_date'], 'absolute')); $out = array('username' => prepare_utf8_string(strip_tags($user['username'])), 'posts' => $posts, 'joindate' => $joindate, 'online' => $is_online, 'avatar_upload' => $visitor->canUploadAvatar()); $maxFileSize = XenForo_Permission::hasPermission($permissions, 'avatar', 'maxFileSize'); if ($maxFileSize > 0) { $out['avatar_resize'] = true; } $avatarurl = process_avatarurl(XenForo_Template_Helper_Core::getAvatarUrl($user, 'm')); if (strpos($avatarurl, '/xenforo/avatars/avatar_') !== false) { $avatarurl = ''; } if ($avatarurl != '') { $out['avatarurl'] = $avatarurl; } if ($visitor->hasAdminPermission('ban')) { $out['ban'] = true; } // New Profile Fields $groups = array(); // About $out_group = array('name' => 'about', 'values' => array(array('name' => prepare_utf8_string(fr_get_phrase('messages')), 'value' => strval($posts)), array('name' => prepare_utf8_string(fr_get_phrase('joined')), 'value' => $joindate), array('name' => prepare_utf8_string(fr_get_phrase('likes_received')), 'value' => strval($user['like_count'])))); $groups[] = $out_group; // Additional information $out_group = array('name' => 'additional'); // Status if (!empty($user['status'])) { $out_group['values'][] = array('name' => prepare_utf8_string(fr_get_phrase('status')), 'value' => prepare_utf8_string($user['status'])); } // Location if (!empty($user['location'])) { $out_group['values'][] = array('name' => prepare_utf8_string(fr_get_phrase('location')), 'value' => prepare_utf8_string($user['location'])); } // Occupation if (!empty($user['occupation'])) { $out_group['values'][] = array('name' => prepare_utf8_string(fr_get_phrase('occupation')), 'value' => prepare_utf8_string($user['occupation'])); } // About if (!empty($user['about'])) { $out_group['values'][] = array('name' => prepare_utf8_string(fr_get_phrase('about')), 'value' => prepare_utf8_string(remove_bbcode($user['about'], true, true))); } if (count($out_group['values'])) { $groups[] = $out_group; } $out['groups'] = $groups; return $out; }
function fr_parse_conversation($message, $bbcode = false) { $message_tree = vB_Api::instance('content_privatemessage')->getMessage($message['nodeid']); $new_posts = false; $message_ids = array(); foreach ($message_tree['messages'] as $message) { if (!$message['msgread']) { $message_ids[] = $message['nodeid']; $new_posts = true; } } if ($new_posts) { vB_Api::instance('content_privatemessage')->setRead($message_ids, 0); } $message = $message_tree['message']; $out = array('conversation_id' => $message['nodeid'], 'title' => $message['title'] ? $message['title'] : remove_bbcode($message['pagetext']), 'new_posts' => $new_posts, 'total_messages' => count($message_tree['messages'])); if ($message['lastcontentid'] > 0) { $lastcontent = $message_tree['messages'][$message['lastcontentid']]; $out['userid'] = $message['lastauthorid']; $out['username'] = $message['lastauthorid'] > 0 ? $message['lastcontentauthor'] : (string) new vB_Phrase('global', 'guest'); $out['preview'] = make_preview($lastcontent['rawtext']); $out['lastmessagetime'] = fr_date($message['lastcontent']); } else { $out['userid'] = $message['userid']; $out['username'] = $message['authorname']; $out['preview'] = make_preview($message['rawtext']); $out['lastmessagetime'] = fr_date($message['publishdate']); } return $out; }
public function actionGetConversation() { $conversationid = $this->_input->filterSingle('conversationid', XenForo_Input::UINT); $signature = $this->_input->filterSingle('signature', XenForo_Input::UINT); $page = max($this->_input->filterSingle('page', XenForo_Input::UINT), 1); $perpage = $this->_input->filterSingle('perpage', XenForo_Input::UINT); if (!$perpage) { $perpage = XenForo_Application::get('options')->messagesPerPage; } $conversation_model = $this->_getConversationModel(); $session_model = $this->getModelFromCache('XenForo_Model_Session'); try { $conversation_info = $this->_getConversationOrError($conversationid); } catch (Exception $e) { json_error($e->getControllerResponse()->errorText->render()); } $gotomessageid = 0; if ($page == FR_LAST_POST) { if (!$conversation_info['last_read_date']) { $page = 1; } else { if ($conversation_info['last_read_date'] >= $conversation_info['last_message_date']) { $first_unread = false; } else { $first_unread = $conversation_model->getNextMessageInConversation($conversationid, $conversation_info['last_read_date']); } if (!$first_unread || $first_unread['message_id'] == $conversation_info['last_message_id']) { $page = floor($conversation_info['reply_count'] / $perpage) + 1; $gotomessageid = $conversation_info['last_message_id']; } else { $before = $conversation_model->countMessagesBeforeDateInConversation($conversationid, $first_unread['message_date']); $page = floor($before / $perpage) + 1; $gotomessageid = $first_unread['message_id']; } } } $recipients = $conversation_model->getConversationRecipients($conversationid); $messages = $conversation_model->getConversationMessages($conversationid, array('page' => $page, 'perPage' => $perpage)); $max = $conversation_model->getMaximumMessageDate($messages); if ($max > $conversation_info['last_read_date']) { $conversation_model->markConversationAsRead($conversationid, XenForo_Visitor::getUserId(), $max, $conversation_info['last_message_date']); } $messages = $conversation_model->prepareMessages($messages, $conversation_info); $user_model = $this->getModelFromCache('XenForo_Model_User'); foreach ($messages as &$message) { $user = $user_model->getUserById($message['user_id']); $online_info = $session_model->getSessionActivityRecords(array('user_id' => $message['user_id'], 'cutOff' => array('>', $session_model->getOnlineStatusTimeout()))); $is_online = false; if (count($online_info) == 1) { $is_online = true; } list($text, $nuked_quotes, $images) = parse_post(fr_strip_smilies($this, XenForo_Helper_String::censorString($message['message'])), true); $fr_images = array(); foreach ($images as $image) { $fr_images[] = array('img' => $image); } $avatarurl = ''; if ($user !== false) { $avatarurl = process_avatarurl(XenForo_Template_Helper_Core::getAvatarUrl($user, 'm')); if (strpos($avatarurl, '/xenforo/avatars/avatar_') !== false) { $avatarurl = ''; } } $out = array('post_id' => $message['message_id'], 'thread_id' => $message['conversation_id'], 'username' => prepare_utf8_string(strip_tags($message['username'])), 'joindate' => prepare_utf8_string(XenForo_Locale::date($message['register_date'], 'absolute')), 'usertitle' => XenForo_Template_Helper_Core::helperUserTitle($user), 'numposts' => $user ? $user['message_count'] : 0, 'userid' => $message['user_id'], 'online' => $is_online, 'post_timestamp' => prepare_utf8_string(XenForo_Locale::dateTime($message['message_date'], 'absolute')), 'fr_images' => $fr_images, 'text' => $text, 'quotable' => $nuked_quotes); if ($avatarurl != '') { $out['avatarurl'] = $avatarurl; } if ($signature) { $sig = trim(strip_tags(remove_bbcode($message['signature'], true, true), '<a>')); $sig = str_replace(array("\t", "\r"), array('', ''), $sig); $sig = str_replace("\n\n", "\n", $sig); $out['sig'] = prepare_utf8_string($sig); } $message_data[] = $out; } $out = array('posts' => $message_data, 'total_posts' => $conversation_info['reply_count'] + 1, 'page' => $page, 'canattach' => false, 'canpost' => true, 'title' => prepare_utf8_string(XenForo_Helper_String::censorString($conversation_info['title'])), 'thread_link' => process_avatarurl(XenForo_Link::buildPublicLink('conversations', $conversation_info))); if ($gotomessageid) { $out['gotopostid'] = $gotomessageid; } $r = array_values($conversation_model->getConversationRecipients($conversationid)); $recipients = ''; for ($i = 0; $i < count($r); $i++) { if ($i != 0) { $recipients .= ', '; } $recipients .= prepare_utf8_string(strip_tags($r[$i]['username'])); } $out['recipients'] = $recipients; return $out; }
function parse_post($text, $allowsmilie = false) { global $nuke_quotes, $fr_platform, $images; $images = array(); if (is_ipb()) { // Replace <br.*/> with \n $text = preg_replace('#<br.*?/>#is', "\n", $text); } $smilies = false; $v = process_input(array('smilies' => BOOLEAN)); if (isset($v['smilies'])) { $smilies = $v['smilies'] === true; } // Trim each line $lines = preg_split("/\n/", $text); for ($i = 0; $i < count($lines); $i++) { $lines[$i] = trim($lines[$i]); } $text = join("\n", $lines); $text = prepare_utf8_string($text, false); $bbcode = new StringParser_BBCode(); $bbcode->setGlobalCaseSensitive(false); // Handle default BBCode $bbcode->addCode('quote', 'callback_replace', 'handle_quotes', array(), 'inline', array('listitem', 'block', 'inline', 'link'), array('')); $bbcode->addCode('url', 'usecontent?', 'handle_url', array('usecontent_param' => 'default'), 'link', array('listitem', 'block', 'inline'), array('link')); $bbcode->addCode('source', 'usecontent?', 'handle_url', array('usecontent_param' => 'default'), 'link', array('listitem', 'block', 'inline'), array('link')); if (!is_mybb()) { // myBB wonky attachment codes are already handled $bbcode->addCode('attach', 'callback_replace', 'handle_attach', array(), 'inline', array('listitem', 'block', 'inline', 'link'), array('')); } $bbcode->addCode('attach', 'callback_replace', 'handle_attach', array(), 'inline', array('listitem', 'block', 'inline', 'link'), array('')); $bbcode->addCode('img', 'callback_replace', 'handle_image', array(), 'inline', array('listitem', 'block', 'inline', 'link'), array('')); $bbcode->addCode('imgl', 'callback_replace', 'handle_image', array(), 'inline', array('listitem', 'block', 'inline', 'link'), array('')); $bbcode->addCode('imgr', 'callback_replace', 'handle_image', array(), 'inline', array('listitem', 'block', 'inline', 'link'), array('')); //$bbcode->addCode('spoiler', 'callback_replace', 'handle_spoiler', array(), 'inline', //array('listitem', 'block', 'inline', 'link'), array('')); $bbcode->addCode('b', 'callback_replace', 'handle_bbcode_bold', array('usecontent_param' => array('default')), 'inline', array('listitem', 'block', 'inline', 'link'), array()); $bbcode->addCode('i', 'callback_replace', 'handle_bbcode_italic', array('usecontent_param' => array('default')), 'inline', array('listitem', 'block', 'inline', 'link'), array()); $bbcode->addCode('color', 'callback_replace', 'handle_bbcode_color', array('usecontent_param' => array('default')), 'inline', array('listitem', 'block', 'inline', 'link'), array()); $bbcode->setCodeFlag('color', 'closetag', BBCODE_CLOSETAG_MUSTEXIST); // Video Link BBCode $bbcode->addCode('yt', 'callback_replace', 'fr_handle_youtube', array(), 'inline', array('listitem', 'block', 'inline', 'link'), array('')); $bbcode->addCode('youtube', 'callback_replace', 'fr_handle_youtube', array(), 'inline', array('listitem', 'block', 'inline', 'link'), array('')); $bbcode->addCode('video', 'callback_replace', 'handle_video', array(), 'inline', array('listitem', 'block', 'inline', 'link'), array('')); $bbcode->addCode('ame', 'callback_replace', 'handle_video', array(), 'inline', array('listitem', 'block', 'inline', 'link'), array('')); $bbcode->addCode('media', 'callback_replace', is_xen() ? 'handle_xen_media' : 'handle_video', array(), 'inline', array('listitem', 'block', 'inline', 'link'), array('')); $bbcode->addCode('tex', 'callback_replace', 'fr_handle_tex', array(), 'inline', array('listitem', 'block', 'inline', 'link'), array('')); if (function_exists('fr_branded_bbcode_handler')) { @fr_branded_bbcode_handler($bbcode); } if (is_mybb()) { $bbcode->setMixedAttributeTypes(true); } $nuked_quotes = $text; $text = htmlspecialchars_uni($text); $nuke_quotes = true; $nuked_quotes = $bbcode->parse($nuked_quotes); if (is_ipb()) { $nuked_quotes = ipb_handle_attachments($nuked_quotes); } $nuke_quotes = false; $text = $bbcode->parse($text); if (is_ipb()) { $text = ipb_handle_attachments($text); } // Snag out images preg_match_all('#\\[IMG\\](.*?)\\[/IMG\\]#is', $text, $matches); $text = preg_replace("#\\[IMG\\](.*?)\\[/IMG\\]#is", '', $text); $nuked_quotes = preg_replace("#\\[IMG\\](.*?)\\[/IMG\\]#is", '', $nuked_quotes); if ($smilies) { if (is_vb()) { global $vbulletin; $parser = new vB_BbCodeParser($vbulletin, fetch_tag_list()); $text = $parser->parse_smilies($text, false); $text = preg_replace_callback('#img src="(.*?)"#is', parse_post_callback, $text); } } $text = preg_replace("#\n\n\n+#", "\n\n", $text); $text = preg_replace("#\n#", "<br/>", $text); $text = remove_bbcode($text); $nuked_quotes = preg_replace("#\n\n\n+#", "\n\n", $nuked_quotes); $nuked_quotes = remove_bbcode($nuked_quotes); return array($text, $nuked_quotes, $images); }
function fr_post_to_bbcode($node) { require_once DIR . '/includes/class_core.php'; require_once DIR . '/includes/class_bbcode.php'; $post = array(); $bbcode_parser = new vB_BbCodeParser(vB::get_registry(), fetch_tag_list()); $post['signature'] = ''; if (!empty($node['content']['signature']['raw'])) { $bbcode_parser->set_parse_userinfo($node['content']['userinfo']); $post['signature'] = $bbcode_parser->parse($node['content']['signature']['raw'], 'signature', true, false, '', $node['content']['signaturepic'], true); $sig = trim(remove_bbcode(strip_tags($post['signature']), true, true), '<a>'); $sig = str_replace(array("\t", "\r"), array('', ''), $sig); $sig = str_replace("\n\n", "\n", $sig); $post['signature'] = $sig; } list($text, , $images) = parse_post($node['content']['rawtext']); $post['html'] = $text; $post['images'] = $images; return $post; }
public function actionGetThread() { $threadid = $this->_input->filterSingle('threadid', XenForo_Input::UINT); $postid = $this->_input->filterSingle('postid', XenForo_Input::UINT); $signature = $this->_input->filterSingle('signature', XenForo_Input::UINT); $page = max($this->_input->filterSingle('page', XenForo_Input::UINT), 1); $perpage = $this->_input->filterSingle('perpage', XenForo_Input::UINT); if (!$perpage) { $perpage = XenForo_Application::get('options')->messagesPerPage; } $visitor = XenForo_Visitor::getInstance(); $user_model = $this->getModelFromCache('XenForo_Model_User'); $thread_model = $this->_getThreadModel(); $post_model = $this->_getPostModel(); $forum_model = $this->_getForumModel(); $session_model = $this->getModelFromCache('XenForo_Model_Session'); $helper = $this->getHelper('ForumThreadPost'); $post_helper = new ForumRunner_ControllerHelper_Post($this); try { list($thread_info, $forum_info) = $helper->assertThreadValidAndViewable($threadid, array('readUserId' => $visitor['user_id'], 'watchUserId' => $visitor['user_id']), array('readUserId' => $visitor['user_id'])); } catch (Exception $e) { json_error($e->getControllerResponse()->errorText->render()); } $gotopostid = 0; if ($page == FR_LAST_POST) { // Figure out our last post page and post id $options = $post_model->getPermissionBasedPostFetchOptions($thread_info, $forum_info); $read_date = $thread_model->getMaxThreadReadDate($thread_info, $forum_info); $first_unread = $post_model->getNextPostInThread($threadid, $read_date, $options); if (!$first_unread) { $first_unread = $post_model->getLastPostInThread($threadid, $options); } if ($first_unread) { $page = floor($first_unread['position'] / $perpage) + 1; $gotopostid = $first_unread['post_id']; } else { $page = 1; } } else { if ($postid) { try { list($tpost, $tthread, $tforum) = $helper->assertPostValidAndViewable($postid); } catch (Exception $e) { json_error($e->getControllerResponse()->errorText->render()); } $page = floor($tpost['position'] / $perpage) + 1; $gotopostid = $postid; } } if ($thread_model->isRedirect($thread_info)) { // Redirect thread! XXX RKJ } $this->canonicalizePageNumber($page, $perpage, $thread_info['reply_count'] + 1, 'threads', $thread_info); $post_options = array_merge($post_model->getPermissionBasedPostFetchOptions($thread_info, $forum_info), array('perPage' => $perpage, 'page' => $page, 'join' => XenForo_Model_Post::FETCH_USER | XenForo_Model_Post::FETCH_USER_PROFILE | XenForo_Model_Post::FETCH_FORUM, 'likeUserId' => $visitor['user_id'])); if (!empty($post_options['deleted'])) { $post_options['join'] |= XenForo_Model_Post::FETCH_DELETION_LOG; } $posts = $post_model->getPostsInThread($threadid, $post_options); $posts = $post_model->getAndMergeAttachmentsIntoPosts($posts); $mod = array(); $perms = $visitor->getNodePermissions($thread_info['node_id']); $thread_mod = $thread_model->addInlineModOptionToThread($thread_info, $forum_info, $perms); $max_post_date = $first_unread = $deleted = $moderated = 0; foreach ($posts as &$post) { $post_mod = $post_model->addInlineModOptionToPost($post, $thread_info, $forum_info, $perms); $mod = array_merge($mod, $post_mod); $post = $post_model->preparePost($post, $thread_info, $forum_info, $perms); if ($post['post_date'] > $max_post_date) { $max_post_date = $post['post_date']; } if ($post['isDeleted']) { $deleted++; } if ($post['isModerated']) { $moderated++; } if (!$first_unread && $post['isNew']) { $first_unread = $post['post_id']; } } $thread_model->markThreadRead($thread_info, $forum_info, $max_post_date, $visitor['user_id']); fr_update_subsent($thread_info['thread_id'], $max_post_date); $thread_model->logThreadView($threadid); $post_data = array(); foreach ($posts as &$post) { $user = $user_model->getUserById($post['user_id']); $online_info = $session_model->getSessionActivityRecords(array('user_id' => $post['user_id'], 'cutOff' => array('>', $session_model->getOnlineStatusTimeout()))); $is_online = false; if (count($online_info) == 1) { $is_online = true; } $fr_images = $docattach = array(); if (isset($post['attachments']) && is_array($post['attachments'])) { foreach ($post['attachments'] as $attachment) { $ext = strtolower($attachment['extension']); $link = XenForo_Link::buildPublicLink('attachments', $attachment); if ($ext == 'jpe' || $ext == 'jpeg' || $ext == 'png' || $ext == 'gif' || $ext == 'jpg') { $data = array('img' => fr_get_xenforo_bburl() . '/' . $link); if ($attachment['thumbnailUrl']) { $data['tmb'] = fr_get_xenforo_bburl() . '/' . $attachment['thumbnailUrl']; } $fr_images[] = $data; } else { if ($ext == 'pdf') { $docattach[] = fr_get_xenforo_bburl() . '/' . $link; } } } } list($text, $nuked_quotes, $images) = parse_post(fr_strip_smilies($this, XenForo_Helper_String::censorString($post['message'])), true); if (count($fr_images) > 0) { $text .= "<br/>"; foreach ($fr_images as $attachment) { $text .= "<img src=\"{$attachment['img']}\"/>"; } } foreach ($images as $image) { $fr_images[] = array('img' => $image); } $avatarurl = ''; if ($user !== false) { $avatarurl = process_avatarurl(XenForo_Template_Helper_Core::getAvatarUrl($user, 'm')); if (strpos($avatarurl, '/xenforo/avatars/avatar_') !== false) { $avatarurl = ''; } } $post_page = floor($post['position'] / XenForo_Application::get('options')->messagesPerPage) + 1; $out = array('post_id' => $post['post_id'], 'thread_id' => $post['thread_id'], 'forum_id' => $post['node_id'], 'forum_title' => prepare_utf8_string(strip_tags($post['node_title'])), 'username' => prepare_utf8_string(strip_tags($post['username'])), 'joindate' => prepare_utf8_string(XenForo_Locale::date($post['register_date'], 'absolute')), 'usertitle' => strip_tags(XenForo_Template_Helper_Core::helperUserTitle($user)), 'numposts' => $user ? $user['message_count'] : 0, 'userid' => $post['user_id'], 'canlike' => $post['canLike'] ? true : false, 'likes' => $post['like_date'] > 0 ? true : false, 'title' => prepare_utf8_string(XenForo_Helper_String::censorString($post['title'])), 'online' => $is_online, 'post_timestamp' => prepare_utf8_string(XenForo_Locale::dateTime($post['post_date'], 'absolute')), 'post_link' => fr_get_xenforo_bburl() . '/' . XenForo_Link::buildPublicLink('threads', $thread_info, array('page' => $post_page)) . '#post-' . $post['post_id'], 'fr_images' => $fr_images); if ($post['canDelete']) { $out['candelete'] = true; } if ($post['likes']) { $out['likestext'] = prepare_utf8_string($post_helper->likesHtml($post['post_id'], $post['likes'], $post['like_date'], $post['likeUsers'])); $like_users = ''; for ($i = 0; $i < count($post['likeUsers']); $i++) { if ($i != 0) { $like_users .= ', '; } $like_users .= $post['likeUsers'][$i]['username']; } $out['likesusers'] = prepare_utf8_string($like_users); } if ($avatarurl != '') { $out['avatarurl'] = $avatarurl; } if ($post['message_state'] == 'deleted') { $out += array('deleted' => true, 'del_username' => prepare_utf8_string(strip_tags($post['delete_username']))); if ($post['delete_reason']) { $out['del_reason'] = prepare_utf8_string($post['delete_reason']); } } else { if ($post['canEdit']) { $out += array('canedit' => $post['canEdit']); } $out += array('text' => $text, 'quotable' => $nuked_quotes, 'edittext' => prepare_utf8_string($post['message'])); } if (count($docattach)) { $out['docattach'] = $docattach; } if ($signature) { $sig = trim(strip_tags(remove_bbcode($post['signature'], true, true), '<a>')); $sig = str_replace(array("\t", "\r"), array('', ''), $sig); $sig = str_replace("\n\n", "\n", $sig); $out['sig'] = prepare_utf8_string($sig); } $post_data[] = $out; } $out = array('posts' => $post_data, 'total_posts' => $thread_info['reply_count'] + 1, 'page' => $page, 'canpost' => $thread_model->canReplyToThread($thread_info, $forum_info), 'canattach' => $forum_model->canUploadAndManageAttachment($forum_info), 'title' => prepare_utf8_string(XenForo_Helper_String::censorString($thread_info['title'])), 'thread_link' => process_avatarurl(XenForo_Link::buildPublicLink('threads', $thread_info, array('page' => $page))), 'subscribed' => $thread_info['thread_is_watched'] ? 1 : 0); if ($gotopostid) { $out['gotopostid'] = $gotopostid; } if ($thread_info['discussion_type'] == 'poll') { $poll_model = $this->_getPollModel(); $poll = $poll_model->getPollByContent('thread', $threadid); if ($poll) { $out['pollid'] = $poll['poll_id']; } } $modbit = 0; if (isset($mod['delete']) && $mod['delete']) { $modbit |= MOD_DELETEPOST; } if ($thread_info['sticky'] && isset($thread_mod['unstick']) && $thread_mod['unstick']) { $modbit |= MOD_UNSTICK; } if (!$thread_info['sticky'] && isset($thread_mod['stick']) && $thread_mod['stick']) { $modbit |= MOD_STICK; } if (isset($thread_mod['delete']) && $thread_mod['delete']) { $modbit |= MOD_DELETETHREAD; } XenForo_Application::setDebugMode(true); if ($thread_info['discussion_open'] && isset($thread_mod['lock']) && $thread_mod['lock']) { $modbit |= MOD_CLOSE; } if (!$thread_info['discussion_open'] && isset($thread_mod['unlock']) && $thread_mod['unlock']) { $modbit |= MOD_OPEN; } if (isset($thread_mod['move']) && $thread_mod['move']) { $modbit |= MOD_MOVETHREAD; } if (XenForo_Permission::hasPermission($visitor['permissions'], 'general', 'cleanSpam')) { $modbit |= MOD_SPAM_CONTROLS; } $out['mod'] = $modbit; return $out; }