/**
  * Формирует(но не сохраняет) тело сообщения
  *
  * @param array $post
  * @global vB_Registry $vbulletin
  * @return string
  */
 protected function _make_message_body($post)
 {
     global $vbulletin, $foruminfo, $threadinfo;
     $message = '';
     if (!intval($this->_post_id)) {
         return $message;
     }
     if (empty($post['pagetext'])) {
         $post['pagetext'] = $post['message'];
     }
     $post['allowsmilie'] = $post['enablesmilies'];
     // get attachments
     require_once DIR . '/packages/vbattach/attach.php';
     $attach = new vB_Attach_Display_Content($vbulletin, 'vBForum_Post');
     $postattach = $attach->fetch_postattach(0, $this->_post_id);
     $post['attachments'] = $postattach;
     $userinfo = fetch_userinfo($post['userid']);
     require_once DIR . '/includes/class_postbit.php';
     $postbit_factory = new vB_Postbit_Factory();
     $postbit_factory->registry =& $vbulletin;
     $postbit_factory->forum =& $foruminfo;
     $postbit_factory->thread =& $threadinfo;
     $postbit_factory->cache = array();
     $postbit_factory->bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list());
     $postbit_factory->bbcode_parser->set_parse_userinfo($userinfo);
     $postbit_obj =& $postbit_factory->fetch_postbit('post_nntp');
     $this->_body = $postbit_obj->construct_postbit($post);
     return $this->_body;
 }
Example #2
0
 $postarray = array();
 while ($post = $db->fetch_array($cacheposts)) {
     $postarray["{$post['postid']}"] = $post;
 }
 if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canseethumbnails'])) {
     $vbulletin->options['attachthumbs'] = 0;
 }
 if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['cangetattachment'])) {
     $vbulletin->options['viewattachedimages'] = ($vbulletin->options['viewattachedimages'] and $vbulletin->options['attachthumbs']) ? 1 : 0;
 }
 // init
 $postcount = 0;
 $postbits = '';
 $saveparsed = '';
 $jspostbits = '';
 $postbit_factory = new vB_Postbit_Factory();
 $postbit_factory->registry =& $vbulletin;
 $postbit_factory->forum =& $foruminfo;
 $postbit_factory->thread =& $thread;
 $postbit_factory->cache = array();
 $postbit_factory->bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list());
 foreach (explode(',', $cache_postids) as $id) {
     // get the post from the post array
     if (!isset($postarray["{$id}"])) {
         continue;
     }
     $post = $postarray["{$id}"];
     if ($tachyuser = in_coventry($post['userid']) and !can_moderate($thread['forumid'])) {
         continue;
     }
     if ($post['visible'] == 2) {
Example #3
0
    require_once DIR . '/includes/functions_bigthree.php';
    $vbulletin->input->clean_gpc('r', array('pmid' => TYPE_UINT));
    require_once DIR . '/includes/class_xml.php';
    $xml = new vB_AJAX_XML_Builder($vbulletin, 'text/xml');
    $xml->add_group('response');
    if ($vbulletin->userinfo['userid'] and $vbulletin->GPC['pmid']) {
        $pm = $db->query_first_slave("\n\t\t\tSELECT pm.parentpmid, pmtext.dateline\n\t\t\tFROM " . TABLE_PREFIX . "pm AS pm\n\t\t\tINNER JOIN " . TABLE_PREFIX . "pmtext AS pmtext ON(pmtext.pmtextid = pm.pmtextid)\n\t\t\tWHERE pm.userid=" . $vbulletin->userinfo['userid'] . " AND pm.pmid=" . $vbulletin->GPC['pmid'] . "\n\t\t");
    }
    if (empty($pm)) {
        $xml->add_tag('error', 1);
    } else {
        $threadresult = $vbulletin->db->query_read_slave("\n\t\t\tSELECT pm.*, pmtext.*\n\t\t\tFROM " . TABLE_PREFIX . "pm AS pm\n\t\t\tINNER JOIN " . TABLE_PREFIX . "pmtext AS pmtext ON(pmtext.pmtextid = pm.pmtextid)\n\t\t\tWHERE (pm.parentpmid=" . $pm['parentpmid'] . "\n\t\t\t\t\tOR pm.pmid = " . $pm['parentpmid'] . ")\n\t\t\tAND pm.pmid != " . $vbulletin->GPC['pmid'] . "\n\t\t\tAND pm.userid=" . $vbulletin->userinfo['userid'] . "\n\t\t\tAND pmtext.dateline < " . intval($pm['dateline']) . "\n\t\t\tORDER BY pmtext.dateline DESC\n\t\t");
        if ($vbulletin->db->num_rows($threadresult)) {
            $threadpms = '';
            while ($threadpm = $vbulletin->db->fetch_array($threadresult)) {
                $postbit_factory = new vB_Postbit_Factory();
                $postbit_factory->registry =& $vbulletin;
                $postbit_factory->cache = array();
                $postbit_factory->bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list());
                $postbit_obj =& $postbit_factory->fetch_postbit('pm');
                $threadpms .= $postbit_obj->construct_postbit($threadpm);
            }
        } else {
            $threadpms = vB_Template::create('pm_nomessagehistory')->render();
        }
        $xml->add_tag('html', process_replacement_vars($threadpms));
    }
    $xml->close_group();
    $xml->print_xml(true);
}
// ############################### start pm folder view ###############################
Example #4
0
	}
	else
	{
		$show['viewall'] = false;
	}

	require_once(DIR . '/includes/class_postbit.php');

	$show['announcement'] = true;

	$counter = 0;
	$anncids = array();
	$announcebits = '';
	$announceread = array();

	$postbit_factory = new vB_Postbit_Factory();
	$postbit_factory->registry =& $vbulletin;
	$postbit_factory->forum =& $foruminfo;
	$postbit_factory->cache = array();
	$postbit_factory->bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list());

	while ($post = $db->fetch_array($announcements))
	{
		$postbit_obj =& $postbit_factory->fetch_postbit('announcement');

		$post['counter'] = ++$counter;

		$announcebits .= $postbit_obj->construct_postbit($post);
		$anncids[] = $post['announcementid'];
		$announceread[] = "($post[announcementid], " . $vbulletin->userinfo['userid'] . ")";
	}
Example #5
0
function do_get_post()
{
    global $vbulletin, $db, $foruminfo, $threadinfo, $postid, $postinfo;
    $vbulletin->input->clean_array_gpc('r', array('type' => TYPE_STR));
    $type = 'html';
    if ($vbulletin->GPC['type']) {
        $type = $vbulletin->GPC['type'];
    }
    if (!$postinfo['postid']) {
        standard_error(fetch_error('invalidid', $vbphrase['post'], $vbulletin->options['contactuslink']));
    }
    if ((!$postinfo['visible'] or $postinfo['isdeleted']) and !can_moderate($threadinfo['forumid'])) {
        standard_error(fetch_error('invalidid', $vbphrase['post'], $vbulletin->options['contactuslink']));
    }
    if ((!$threadinfo['visible'] or $threadinfo['isdeleted']) and !can_moderate($threadinfo['forumid'])) {
        standard_error(fetch_error('invalidid', $vbphrase['thread'], $vbulletin->options['contactuslink']));
    }
    $forumperms = fetch_permissions($threadinfo['forumid']);
    if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) or !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads'])) {
        json_error(ERR_NO_PERMISSION);
    }
    if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers']) and ($threadinfo['postuserid'] != $vbulletin->userinfo['userid'] or $vbulletin->userinfo['userid'] == 0)) {
        json_error(ERR_NO_PERMISSION);
    }
    // check if there is a forum password and if so, ensure the user has it set
    verify_forum_password($foruminfo['forumid'], $foruminfo['password']);
    $postbit_factory = new vB_Postbit_Factory();
    $postbit_factory->registry =& $vbulletin;
    $postbit_factory->forum =& $foruminfo;
    $postbit_factory->cache = array();
    $postbit_factory->bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list());
    $post = $db->query_first_slave("\n\tSELECT\n\tpost.*, post.username AS postusername, post.ipaddress AS ip, IF(post.visible = 2, 1, 0) AS isdeleted,\n\t    user.*, userfield.*, usertextfield.*,\n\t    " . iif($foruminfo['allowicons'], 'icon.title as icontitle, icon.iconpath,') . "\n\t    IF(user.displaygroupid=0, user.usergroupid, user.displaygroupid) AS displaygroupid, infractiongroupid,\n\t\t" . iif($vbulletin->options['avatarenabled'], 'avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight,') . "\n\t\t" . ((can_moderate($threadinfo['forumid'], 'canmoderateposts') or can_moderate($threadinfo['forumid'], 'candeleteposts')) ? 'spamlog.postid AS spamlog_postid,' : '') . "\n\t\teditlog.userid AS edit_userid, editlog.username AS edit_username, editlog.dateline AS edit_dateline, editlog.reason AS edit_reason, editlog.hashistory,\n\t\tpostparsed.pagetext_html, postparsed.hasimages,\n\t\tsigparsed.signatureparsed, sigparsed.hasimages AS sighasimages,\n\t\tsigpic.userid AS sigpic, sigpic.dateline AS sigpicdateline, sigpic.width AS sigpicwidth, sigpic.height AS sigpicheight\n\t\t" . iif(!($permissions['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canseehiddencustomfields']), $vbulletin->profilefield['hidden']) . "\n\t\t{$hook_query_fields}\n\t\tFROM " . TABLE_PREFIX . "post AS post\n\t\tLEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = post.userid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "userfield AS userfield ON(userfield.userid = user.userid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON(usertextfield.userid = user.userid)\n\t\t" . iif($foruminfo['allowicons'], "LEFT JOIN " . TABLE_PREFIX . "icon AS icon ON(icon.iconid = post.iconid)") . "\n\t\t" . iif($vbulletin->options['avatarenabled'], "LEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON(avatar.avatarid = user.avatarid) LEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON(customavatar.userid = user.userid)") . "\n\t\t" . ((can_moderate($threadinfo['forumid'], 'canmoderateposts') or can_moderate($threadinfo['forumid'], 'candeleteposts')) ? "LEFT JOIN " . TABLE_PREFIX . "spamlog AS spamlog ON(spamlog.postid = post.postid)" : '') . "\n\t\tLEFT JOIN " . TABLE_PREFIX . "editlog AS editlog ON(editlog.postid = post.postid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "postparsed AS postparsed ON(postparsed.postid = post.postid AND postparsed.styleid = " . intval(STYLEID) . " AND postparsed.languageid = " . intval(LANGUAGEID) . ")\n\t\tLEFT JOIN " . TABLE_PREFIX . "sigparsed AS sigparsed ON(sigparsed.userid = user.userid AND sigparsed.styleid = " . intval(STYLEID) . " AND sigparsed.languageid = " . intval(LANGUAGEID) . ")\n\t\tLEFT JOIN " . TABLE_PREFIX . "sigpic AS sigpic ON(sigpic.userid = post.userid)\n\t\t{$hook_query_joins}\n\t\tWHERE post.postid = {$postid}\n    ");
    $types = vB_Types::instance();
    $contenttypeid = $types->getContentTypeID('vBForum_Post');
    $attachments = $db->query_read_slave("\n\t\tSELECT\n\t\t\tfd.thumbnail_dateline, fd.filesize, IF(fd.thumbnail_filesize > 0, 1, 0) AS hasthumbnail, fd.thumbnail_filesize,\n\t\t\ta.dateline, a.state, a.attachmentid, a.counter, a.contentid AS postid, a.filename,\n\t\t\ttype.contenttypes\n\t\tFROM " . TABLE_PREFIX . "attachment AS a\n\t\tINNER JOIN " . TABLE_PREFIX . "filedata AS fd ON (a.filedataid = fd.filedataid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "attachmenttype AS type ON (fd.extension = type.extension)\n\t\tWHERE\n\t\t\ta.contentid = {$postid}\n\t\t\t\tAND\n\t\t\ta.contenttypeid = {$contenttypeid}\n\t\tORDER BY a.attachmentid\n\t");
    $fr_images = array();
    while ($attachment = $db->fetch_array($attachments)) {
        $lfilename = strtolower($attachment['filename']);
        if (strpos($lfilename, '.jpe') !== false || strpos($lfilename, '.png') !== false || strpos($lfilename, '.gif') !== false || strpos($lfilename, '.jpg') !== false || strpos($lfilename, '.jpeg') !== false) {
            $tmp = array('img' => $vbulletin->options['bburl'] . '/attachment.php?attachmentid=' . $attachment['attachmentid']);
            if ($vbulletin->options['attachthumbs']) {
                $tmp['tmb'] = $vbulletin->options['bburl'] . '/attachment.php?attachmentid=' . $attachment['attachmentid'] . '&stc=1&thumb=1';
            }
            $fr_images[] = $tmp;
        }
    }
    $postbits = '';
    $postbit_obj =& $postbit_factory->fetch_postbit('post');
    $postbit_obj->cachable = $post_cachable;
    $postbits .= $postbit_obj->construct_postbit($post);
    if ($type == 'html') {
        $bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list());
        $vbulletin->templatecache['bbcode_quote'] = '
<div style=\\"margin:0px; margin-top:0px;\\">
	<table cellpadding=\\"$stylevar[cellpadding]\\" cellspacing=\\"0\\" border=\\"0\\" width=\\"100%\\">
	<tr>
		<td class=\\"alt2\\" style=\\"border:1px solid #777777;\\">
			".(($show[\'username\']) ? ("
				<div>
					" . construct_phrase("$vbphrase[originally_posted_by_x]", "$username") . "
				</div>
				<div style=\\"font-style:italic\\">$message</div>
			") : ("
				$message
			"))."
		</td>
	</tr>
	</table>
</div>
	';
        $css = <<<EOF
<style type="text/css">
body {
  margin: 0;
  padding: 3;
  font: 13px Arial, Helvetica, sans-serif;
}
.alt2 {
  background-color: #e6edf5;
  font: 13px Arial, Helvetica, sans-serif;
}
html {
    -webkit-text-size-adjust: none;
}
</style>
EOF;
        $html = $css . $bbcode_parser->parse($post['pagetext']);
        $image = '';
    } else {
        if ($type == 'facebook') {
            $html = fetch_censored_text(strip_bbcode(strip_quotes($post['pagetext']), false, true));
            if (count($fr_images)) {
                $image = $fr_images[0]['img'];
            }
        }
    }
    // Figure out if we can post
    $canpost = true;
    if ($threadinfo['isdeleted'] or !$threadinfo['visible'] and !can_moderate($threadinfo['forumid'], 'canmoderateposts')) {
        $canpost = false;
    }
    if (!$foruminfo['allowposting'] or $foruminfo['link'] or !$foruminfo['cancontainthreads']) {
        $canpost = false;
    }
    if (!$threadinfo['open']) {
        if (!can_moderate($threadinfo['forumid'], 'canopenclose')) {
            $canpost = false;
        }
    }
    if (($vbulletin->userinfo['userid'] != $threadinfo['postuserid'] or !$vbulletin->userinfo['userid']) and (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers']) or !($forumperms & $vbulletin->bf_ugp_forumpermissions['canreplyothers']))) {
        $canpost = false;
    }
    if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) or !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads']) or !($forumperms & $vbulletin->bf_ugp_forumpermissions['canreplyown']) and $vbulletin->userinfo['userid'] == $threadinfo['postuserid']) {
        $canpost = false;
    }
    // Avatar work
    $avatarurl = '';
    if ($post['avatarurl']) {
        $avatarurl = process_avatarurl($post['avatarurl']);
    }
    // Get post date/time
    $postdate = vbdate($vbulletin->options['dateformat'], $post['dateline'], 1);
    $posttime = vbdate($vbulletin->options['timeformat'], $post['dateline']);
    // Parse the post for quotes and inline images
    list($text, $nuked_quotes, $images) = parse_post($post['pagetext'], $post['allowsmilie'] && $usesmilies);
    $out = array('html' => prepare_utf8_string($html), 'post_id' => $post['postid'], 'thread_id' => $post['threadid'], 'forum_id' => $foruminfo['forumid'], 'forum_title' => prepare_utf8_string($foruminfo['title_clean']), 'username' => prepare_utf8_string(strip_tags($post['username'])), 'joindate' => prepare_utf8_string($post['joindate']), 'usertitle' => prepare_utf8_string(strip_tags($post['usertitle'])), 'numposts' => $post['posts'] ? (string) $post['posts'] : '0', 'userid' => $post['userid'], 'title' => prepare_utf8_string($post['title']), 'post_timestamp' => prepare_utf8_string(date_trunc($postdate) . ' ' . $posttime), 'canpost' => $canpost, 'quotable' => $nuked_quotes, 'canattach' => $forumperms & $vbulletin->bf_ugp_forumpermissions['canpostattachment'] and $vbulletin->userinfo['userid'], 'edittext' => prepare_utf8_string($post['pagetext']));
    if ($avatarurl != '') {
        $out['avatarurl'] = $avatarurl;
    }
    if ($post['editlink']) {
        $out['canedit'] = true;
    }
    if ($image != '') {
        $out['image'] = $image;
    }
    return $out;
}
Example #6
0
 $limitupper = $vbulletin->GPC['pagenumber'] * $vbulletin->GPC['perpage'];
 if ($limitupper > $totalnotes) {
     $limitupper = $totalnotes;
     if ($limitlower > $totalnotes) {
         $limitlower = $totalnotes - $vbulletin->GPC['perpage'];
     }
 }
 if ($limitlower <= 0) {
     $limitlower = 1;
 }
 $counter = 0;
 $postcount = ($vbulletin->GPC['pagenumber'] - 1) * $vbulletin->GPC['perpage'];
 $hook_query_fields = $hook_query_joins = '';
 ($hook = vBulletinHook::fetch_hook('usernote_viewuser_query')) ? eval($hook) : false;
 $notes = $db->query_read_slave("\r\n\t\tSELECT usernote.*, usernote.username as postusername, user.*, userfield.*,\r\n\t\tIF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid, infractiongroupid,\r\n\t\tIF(posterid=0, 0, user.userid) AS userid\r\n\t\t" . iif($vbulletin->options['avatarenabled'], ",avatar.avatarpath,NOT ISNULL(customavatar.userid) AS hascustomavatar,customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight") . "\r\n\t\t{$hook_query_fields}\r\n\t\tFROM " . TABLE_PREFIX . "usernote AS usernote\r\n\t\tLEFT JOIN " . TABLE_PREFIX . "user AS user ON(usernote.posterid=user.userid)\r\n\t\tLEFT JOIN " . TABLE_PREFIX . "userfield AS userfield ON(userfield.userid=user.userid)\r\n\t\tLEFT JOIN " . TABLE_PREFIX . "usergroup AS usergroup ON(user.usergroupid=usergroup.usergroupid)\r\n\t\t" . iif($vbulletin->options['avatarenabled'], "LEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON(avatar.avatarid=user.avatarid) LEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON(customavatar.userid=user.userid)") . "\r\n\t\t{$hook_query_joins}\r\n\t\tWHERE usernote.userid = {$userinfo['userid']}\r\n\t\tORDER BY usernote.dateline LIMIT " . ($limitlower - 1) . ", " . $vbulletin->GPC['perpage'] . "\r\n\t");
 $postbit_factory = new vB_Postbit_Factory();
 $postbit_factory->registry =& $vbulletin;
 $postbit_factory->cache = array();
 $postbit_factory->bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list());
 while ($post = $db->fetch_array($notes)) {
     $postbit_obj =& $postbit_factory->fetch_postbit('usernote');
     $post['postcount'] = ++$postcount;
     $post['postid'] = $post['usernoteid'];
     $post['viewself'] = $viewself;
     $notebits .= $postbit_obj->construct_postbit($post);
 }
 $show['notes'] = $notebits != '';
 $db->free_result($notes);
 unset($note);
 $pagenav = construct_page_nav($vbulletin->GPC['pagenumber'], $vbulletin->GPC['perpage'], $totalnotes, 'usernote.php?' . $vbulletin->session->vars['sessionurl'] . "u={$userinfo['userid']}&amp;pp=" . $vbulletin->GPC['perpage']);
 // generate navbar
Example #7
0
/**
 * Generates a Preview of a post
 *
 * @param	array	Information regarding the new post
 * @param	integer	The User ID posting
 * @param	array	Information regarding attachments
 *
 * @return	string	The Generated Preview
 *
 */
function process_post_preview(&$newpost, $postuserid = 0, $attachment_bycontent = NULL, $attachment_byattachment = NULL)
{
    global $vbphrase, $checked, $rate, $previewpost, $foruminfo, $threadinfo, $vbulletin, $show;
    require_once DIR . '/includes/class_bbcode.php';
    $bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list());
    if ($attachment_byattachment) {
        $bbcode_parser->attachments =& $attachment_byattachment;
        $bbcode_parser->containerid = $newpost['postid'] ? $newpost['postid'] : 0;
    }
    $previewpost = 1;
    $bbcode_parser->unsetattach = true;
    $previewmessage = $bbcode_parser->parse($newpost['message'], $foruminfo['forumid'], $newpost['disablesmilies'] ? 0 : 1, false, '', 3, false, $newpost['htmlstate']);
    $post = array('userid' => $postuserid ? $postuserid : $vbulletin->userinfo['userid']);
    if (!empty($attachment_byattachment)) {
        require_once DIR . '/includes/class_postbit.php';
        $post['attachments'] = $attachment_byattachment;
        $post['allattachments'] = $attachment_bycontent;
        $postbit_factory = new vB_Postbit_Factory();
        $postbit_factory->registry =& $vbulletin;
        $postbit_factory->thread =& $threadinfo;
        $postbit_factory->forum =& $foruminfo;
        $postbit_obj =& $postbit_factory->fetch_postbit('post');
        $postbit_obj->post =& $post;
        $postbit_obj->process_attachments();
    }
    if ($post['userid'] != $vbulletin->userinfo['userid']) {
        $fetchsignature = $vbulletin->db->query_first("\n\t\t\tSELECT signature\n\t\t\tFROM " . TABLE_PREFIX . "usertextfield\n\t\t\tWHERE userid = {$postuserid}\n\t\t");
        $signature =& $fetchsignature['signature'];
    } else {
        $signature = $vbulletin->userinfo['signature'];
    }
    $show['signature'] = false;
    if ($newpost['signature'] and trim($signature)) {
        $userinfo = fetch_userinfo($post['userid'], FETCH_USERINFO_SIGPIC);
        if ($post['userid'] != $vbulletin->userinfo['userid']) {
            cache_permissions($userinfo, false);
        } else {
            $userinfo['permissions'] =& $vbulletin->userinfo['permissions'];
        }
        if ($userinfo['permissions']['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canusesignature']) {
            $bbcode_parser->set_parse_userinfo($userinfo);
            $post['signature'] = $bbcode_parser->parse($signature, 'signature');
            $bbcode_parser->set_parse_userinfo(array());
            $show['signature'] = true;
        }
    }
    if ($foruminfo['allowicons'] and $newpost['iconid']) {
        if ($icon = $vbulletin->db->query_first_slave("\n\t\t\tSELECT title as title, iconpath\n\t\t\tFROM " . TABLE_PREFIX . "icon\n\t\t\tWHERE iconid = " . intval($newpost['iconid']) . "\n\t\t")) {
            $newpost['iconpath'] = $icon['iconpath'];
            $newpost['icontitle'] = $icon['title'];
        }
    } else {
        if ($vbulletin->options['showdeficon'] != '') {
            $newpost['iconpath'] = $vbulletin->options['showdeficon'];
            $newpost['icontitle'] = $vbphrase['default'];
        }
    }
    $show['messageicon'] = iif($newpost['iconpath'], true, false);
    $show['errors'] = false;
    ($hook = vBulletinHook::fetch_hook('newpost_preview')) ? eval($hook) : false;
    if ($previewmessage != '') {
        $templater = vB_Template::create('newpost_preview');
        $templater->register('errorlist', $errorlist);
        $templater->register('newpost', $newpost);
        $templater->register('post', $post);
        $templater->register('previewmessage', $previewmessage);
        $templater->register('content_type', 'forumcontent');
        $postpreview = $templater->render();
    } else {
        $postpreview = '';
    }
    construct_checkboxes($newpost);
    if ($newpost['rating']) {
        $rate["{$newpost['rating']}"] = ' selected="selected"';
    }
    return $postpreview;
}
Example #8
0
								{
									$xml->add_tag('itunes:category', '', array('text' => $cat));
								}
								$xml->close_group('itunes:category');
							}
						}
					}
					if ($podcastinfo)
					{
						$xml->add_tag('itunes:explicit', $podcastinfo['explicit'] == 1 ? 'yes' : 'no');
					}

			if (!$vbulletin->GPC['nohtml'])
			{
				require_once(DIR . '/includes/class_postbit.php');
				$postbit_factory = new vB_Postbit_Factory();
				$postbit_factory->registry =& $vbulletin;
				$postbit_factory->bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list($vbulletin->options['bburl'] . '/'));
				$postbit_factory->bbcode_parser->printable = true;
			}
			require_once(DIR . '/includes/class_bbcode_alt.php');
		break;
	}

	$i = 0;
	$viewattachedimages = $vbulletin->options['viewattachedimages'];
	$attachthumbs = $vbulletin->options['attachthumbs'];

	// list returned threads
	if (!empty($threadcache))
	{
Example #9
0
	private static function renderResult($userinfo, $post_array, $permissions,
		$forumperms, $target_url, $nodeid)
	{

		if (!count($post_array))
		{
			return '';
		}
		require_once DIR . '/includes/functions_bigthree.php' ;
		require_once DIR . '/includes/class_postbit.php' ;

		fetch_phrase_group('showthread');
		fetch_phrase_group('postbit');

		global $vbphrase;
		global $template_hook;
		global $show;
		global $thread;
		$thread = $thread->get_record();
		$threadinfo = verify_id('thread', $thread['threadid'], 1, 1);
		$foruminfo = verify_id('forum', $threadinfo['forumid'], 1, 1);
		$firstpostid = false;

		$displayed_dateline = 0;
		if (vB::$vbulletin->options['threadmarking'] AND vB::$vbulletin->userinfo['userid'])
		{
			$threadview = max($threadinfo['threadread'], $threadinfo['forumread'], TIMENOW - (vB::$vbulletin->options['markinglimit'] * 86400));
		}
		else
		{
			$threadview = intval(fetch_bbarray_cookie('thread_lastview', $thread['threadid']));
			if (!$threadview)
			{
				$threadview = vB::$vbulletin->userinfo['lastvisit'];
			}
		}
		require_once DIR . '/includes/functions_user.php';
		$show['inlinemod'] = false;
		$postids = array();

		if (! isset(vB::$vbulletin->userinfo['permissions']['cms']))
		{
			vBCMS_Permissions::getUserPerms();
		}



		$postids = ' post.postid in ('
 			. implode(', ', $post_array) .')';


		$posts =  vB::$vbulletin->db->query_read($sql = "
			SELECT
			post.*, post.username AS postusername, post.ipaddress AS ip, IF(post.visible = 2, 1, 0) AS isdeleted,
			user.*, userfield.*, usertextfield.*,
			" . iif($forum['allowicons'], 'icon.title as icontitle, icon.iconpath,') . "
			" . iif( vB::$vbulletin->options['avatarenabled'], 'avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight,') . "
			" . ((can_moderate($thread['forumid'], 'canmoderateposts') OR can_moderate($thread['forumid'], 'candeleteposts')) ? 'spamlog.postid AS spamlog_postid,' : '') . "
				" . iif($deljoin, 'deletionlog.userid AS del_userid, deletionlog.username AS del_username, deletionlog.reason AS del_reason,') . "
				editlog.userid AS edit_userid, editlog.username AS edit_username, editlog.dateline AS edit_dateline,
				editlog.reason AS edit_reason, editlog.hashistory,
				postparsed.pagetext_html, postparsed.hasimages,
				sigparsed.signatureparsed, sigparsed.hasimages AS sighasimages,
				sigpic.userid AS sigpic, sigpic.dateline AS sigpicdateline, sigpic.width AS sigpicwidth, sigpic.height AS sigpicheight,
				IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid, infractiongroupid,
			 	customprofilepic.userid AS profilepic, customprofilepic.dateline AS profilepicdateline, customprofilepic.width AS ppwidth, customprofilepic.height AS ppheight
				" . iif(!($permissions['genericpermissions'] &  vB::$vbulletin->bf_ugp_genericpermissions['canseehiddencustomfields']),  vB::$vbulletin->profilefield['hidden']) . "
				$hook_query_fields
			FROM " . TABLE_PREFIX . "post AS post
			LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = post.userid)
			LEFT JOIN " . TABLE_PREFIX . "userfield AS userfield ON(userfield.userid = user.userid)
			LEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON(usertextfield.userid = user.userid)
			" . iif($forum['allowicons'], "LEFT JOIN " . TABLE_PREFIX . "icon AS icon ON(icon.iconid = post.iconid)") . "
			" . iif( vB::$vbulletin->options['avatarenabled'], "LEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON(avatar.avatarid = user.avatarid) LEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON(customavatar.userid = user.userid)") . "
			" . ((can_moderate($thread['forumid'], 'canmoderateposts') OR can_moderate($thread['forumid'], 'candeleteposts')) ? "LEFT JOIN " . TABLE_PREFIX . "spamlog AS spamlog ON(spamlog.postid = post.postid)" : '') . "
				$deljoin
			LEFT JOIN " . TABLE_PREFIX . "editlog AS editlog ON(editlog.postid = post.postid)
			LEFT JOIN " . TABLE_PREFIX . "postparsed AS postparsed ON(postparsed.postid = post.postid AND postparsed.styleid = " . intval(STYLEID) . " AND postparsed.languageid = " . intval(LANGUAGEID) . ")
			LEFT JOIN " . TABLE_PREFIX . "sigparsed AS sigparsed ON(sigparsed.userid = user.userid AND sigparsed.styleid = " . intval(STYLEID) . " AND sigparsed.languageid = " . intval(LANGUAGEID) . ")
			LEFT JOIN " . TABLE_PREFIX . "sigpic AS sigpic ON(sigpic.userid = post.userid)
			LEFT JOIN " . TABLE_PREFIX . "customprofilepic AS customprofilepic ON (user.userid = customprofilepic.userid)
				$hook_query_joins
			WHERE $postids
			ORDER BY post.dateline
		");

		if (!($forumperms &  vB::$vbulletin->bf_ugp_forumpermissions['canseethumbnails']) AND !($forumperms &  vB::$vbulletin->bf_ugp_forumpermissions['cangetattachment']))
		{
			 vB::$vbulletin->options['attachthumbs'] = 0;
		}

		if (!($forumperms &  vB::$vbulletin->bf_ugp_forumpermissions['cangetattachment']))
		{
			 vB::$vbulletin->options['viewattachedimages'] = 0;
		}

		$postcount = count($postid_array);

		$counter = 0;
		$postbits = '';
		 vB::$vbulletin->noheader = true;
		$postbit_factory = new vB_Postbit_Factory();
		$postbit_factory->registry =  vB::$vbulletin;
		$postbit_factory->forum = $foruminfo;
		$postbit_factory->thread = $thread;
		$postbit_factory->cache = array();
		$postbit_factory->bbcode_parser = new vB_BbCodeParser( vB::$vbulletin, fetch_tag_list());
		//We need to tell the parser to handle quotes differently.
		$postbit_factory->bbcode_parser->set_quote_template('vbcms_bbcode_quote');
		$postbit_factory->bbcode_parser->set_quote_vars(array('page_url' => $target_url .
			(strpos($target_url, '?') == false ? '?' : '&')));
		$show['return_node'] = $nodeid;
		$show['avatar'] = 1;

		while ($post =  vB::$vbulletin->db->fetch_array($posts))
		{
			if (! self::canViewPost($post, $permissions) )
			{
				continue;
			}

			if (! intval($post['userid']))
			{
				$post['avatarid'] = false;
			}
			else if (!$post['hascustomavatar'])
			{
				if ($post['profilepic'])
				{
					$post['hascustomavatar'] = 1;
					$post['avatarid'] = true;
					$post['avatarpath'] = "./image.php?u=" . $post['userid']  . "&amp;dateline=" . $post['profilepicdateline'] . "&amp;type=profile";
					$post['avwidth'] = $post['ppwidth'];
					$post['avheight'] = $post['ppheight'];
				}
				else
				{
					$post['hascustomavatar'] = 1;
					$post['avatarid'] = true;
					// explicity setting avatarurl to allow guests comments to show unknown avatar
					$post['avatarurl'] = $post['avatarpath'] = vB_Template_Runtime::fetchStyleVar('imgdir_misc') . '/unknown.gif';
					$post['avwidth'] = 60;
					$post['avheight'] = 60;
				}
			}

			if ($tachyuser = in_coventry($post['userid']) AND !can_moderate($thread['forumid']))
			{
				continue;
			}

			if ($post['visible'] == 1 AND !$tachyuser)
			{
				++$counter;
				if ($postorder)
				{
					$post['postcount'] = --$postcount;
				}
				else
				{
					$post['postcount'] = ++$postcount;
				}
			}

			if ($tachyuser)
			{
				$fetchtype = 'post_global_ignore';
			}
			else if ($ignore["$post[userid]"])
			{
				$fetchtype = 'post_ignore';
			}
			else if ($post['visible'] == 2)
			{
				$fetchtype = 'post_deleted';
			}
			else
			{
				$fetchtype = 'post';
			}

			if (
				( vB::$vbulletin->GPC['viewfull'] AND $post['postid'] == $postinfo['postid'] AND $fetchtype != 'post')
				AND
				(can_moderate($threadinfo['forumid']) OR !$post['isdeleted'])
				)
			{
				$fetchtype = 'post';
			}

			($hook = vBulletinHook::fetch_hook('showthread_postbit_create')) ? eval($hook) : false;

			$postbit_obj = $postbit_factory->fetch_postbit($fetchtype);
			$postbit_obj->set_template_prefix('vbcms_');

			if ($fetchtype == 'post')
			{
				$postbit_obj->highlight = $replacewords;
			}

			if (!$firstpostid)
			{
				$firstpostid = $post['postid'];
			}

			$post['islastshown'] = ($post['postid'] == $lastpostid);
			$post['isfirstshown'] = ($counter == 1 AND $fetchtype == 'post' AND $post['visible'] == 1);
			$post['islastshown'] = ($post['postid'] == $lastpostid);
			$post['attachments'] = $postattach["$post[postid]"];

			$parsed_postcache = array('text' => '', 'images' => 1, 'skip' => false);


			$this_postbit = $postbit_obj->construct_postbit($post);

			$this_template = vB_Template::create('vbcms_comments_detail');
			$this_template->register('postid', $post['postid'] );
			$this_template->register('postbit', $this_postbit);
			$this_template->register('indent', $post_array[$this_key]['level'] * $pixel_indent);

			$postbits .= $this_template->render();
			$LASTPOST = $post;

			// Only show after the first post, counter isn't incremented for deleted/moderated posts

			if ($post_cachable AND $post['pagetext_html'] == '')
			{
				if (!empty($saveparsed))
				{
					$saveparsed .= ',';
				}
				$saveparsed .= "($post[postid], " . intval($thread['lastpost']) . ', ' . intval($postbit_obj->post_cache['has_images']) . ", '" . vB::$vbulletin->db->escape_string($postbit_obj->post_cache['text']) . "', " . intval(STYLEID) . ", " . intval(LANGUAGEID) . ")";
			}

			if (!empty($postbit_obj->sig_cache) AND $post['userid'])
			{
				if (!empty($save_parsed_sigs))
				{
					$save_parsed_sigs .= ',';
				}
				$save_parsed_sigs .= "($post[userid], " . intval(STYLEID) . ", " . intval(LANGUAGEID) . ", '" . vB::$vbulletin->db->escape_string($postbit_obj->sig_cache['text']) . "', " . intval($postbit_obj->sig_cache['has_images']) . ")";
			}
		}


		if ($LASTPOST['dateline'] > $displayed_dateline)
		{
			$displayed_dateline = $LASTPOST['dateline'];
			if ($displayed_dateline <= $threadview)
			{
				$updatethreadcookie = true;
			}
		}

		if ($firstpostid)
		{
			$this_template->register('FIRSTPOSTID', $firstpostid );
		}

		if ($lastpostid)
		{
			$this_template->register('LASTPOSTID', $lastpostid);
		}
		// Set thread last view
		if ($displayed_dateline AND $displayed_dateline > $threadview)
		{
			mark_thread_read($threadinfo, $foruminfo, vB::$vbulletin->userinfo['userid'], $displayed_dateline);
		}

		vB::$vbulletin->db->free_result($posts);
		unset($post);
		return $postbits;
	}
Example #10
0
function do_get_announcement()
{
    global $vbulletin, $db, $foruminfo;
    if (empty($foruminfo['forumid'])) {
        json_error(ERR_INVALID_FORUM);
    }
    $usesmilies = false;
    // begin vbulletin
    $forumlist = '';
    if ($announcementinfo['forumid'] > -1 or $vbulletin->GPC['forumid']) {
        $foruminfo = verify_id('forum', $vbulletin->GPC['forumid'], 1, 1);
        $curforumid = $foruminfo['forumid'];
        $forumperms = fetch_permissions($foruminfo['forumid']);
        if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) or !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads'])) {
            json_error(ERR_NO_PERMISSION);
        }
        // check if there is a forum password and if so, ensure the user has it set
        verify_forum_password($foruminfo['forumid'], $foruminfo['password']);
        $forumlist = fetch_forum_clause_sql($foruminfo['forumid'], 'announcement.forumid');
    } else {
        if (!$announcementinfo['announcementid']) {
            json_error(ERR_INVALID_ANNOUNCEMENT);
        }
    }
    $hook_query_fields = $hook_query_joins = $hook_query_where = '';
    $announcements = $db->query_read_slave("\n\t\tSELECT announcement.announcementid, announcement.announcementid AS postid, startdate, enddate, announcement.title, pagetext, announcementoptions, views, announcement.pagetext,\n\t\t\tuser.*, userfield.*, usertextfield.*,\n\t\t\tsigpic.userid AS sigpic, sigpic.dateline AS sigpicdateline, sigpic.width AS sigpicwidth, sigpic.height AS sigpicheight,\n\t\t\tIF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid, infractiongroupid\n\t\t\t" . ($vbulletin->options['avatarenabled'] ? ",avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight" : "") . "\n\t\t\t" . ($vbulletin->userinfo['userid'] ? ", NOT ISNULL(announcementread.announcementid) AS readannouncement" : "") . "\n\t\t\t{$hook_query_fields}\n\t\tFROM  " . TABLE_PREFIX . "announcement AS announcement\n\t\t" . ($vbulletin->userinfo['userid'] ? "LEFT JOIN " . TABLE_PREFIX . "announcementread AS announcementread ON(announcementread.announcementid = announcement.announcementid AND announcementread.userid = " . $vbulletin->userinfo['userid'] . ")" : "") . "\n\t\tLEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid=announcement.userid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "userfield AS userfield ON(userfield.userid=announcement.userid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON(usertextfield.userid=announcement.userid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "sigpic AS sigpic ON(sigpic.userid = announcement.userid)\n\t\t" . ($vbulletin->options['avatarenabled'] ? "LEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON(avatar.avatarid=user.avatarid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON(customavatar.userid=announcement.userid)" : "") . "\n\t\t{$hook_query_joins}\n\t\tWHERE\n\t\t\t" . ($vbulletin->GPC['announcementid'] ? "announcement.announcementid = " . $vbulletin->GPC['announcementid'] : "startdate <= " . TIMENOW . " AND enddate >= " . TIMENOW . " " . (!empty($forumlist) ? "AND {$forumlist}" : "")) . "\n\t\t\t{$hook_query_where}\n\t\tORDER BY startdate DESC, announcementid DESC\n\t");
    if ($db->num_rows($announcements) == 0) {
        // no announcements
        json_error(ERR_INVALID_ANNOUNCEMENT);
    }
    if (!$vbulletin->options['oneannounce'] and $vbulletin->GPC['announcementid'] and !empty($forumlist)) {
        $anncount = $db->query_first_slave("\n\t\t\tSELECT COUNT(*) AS total\n\t\t\tFROM " . TABLE_PREFIX . "announcement AS announcement\n\t\t\tWHERE startdate <= " . TIMENOW . "\n\t\t\t\tAND enddate >= " . TIMENOW . "\n\t\t\t\tAND {$forumlist}\n\t\t");
        $anncount['total'] = intval($anncount['total']);
        $show['viewall'] = $anncount['total'] > 1 ? true : false;
    } else {
        $show['viewall'] = false;
    }
    require_once DIR . '/includes/class_postbit.php';
    $show['announcement'] = true;
    $counter = 0;
    $anncids = array();
    $announcebits = '';
    $announceread = array();
    $postbit_factory = new vB_Postbit_Factory();
    $postbit_factory->registry =& $vbulletin;
    $postbit_factory->forum =& $foruminfo;
    $postbit_factory->cache = array();
    $postbit_factory->bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list());
    while ($post = $db->fetch_array($announcements)) {
        $postbit_obj =& $postbit_factory->fetch_postbit('announcement');
        $post['counter'] = ++$counter;
        $postbit_obj->construct_postbit($post);
        $anncids[] = $post['announcementid'];
        $announceread[] = "({$post['announcementid']}, " . $vbulletin->userinfo['userid'] . ")";
        // FRNR start
        $fr_images = array();
        $docattach = array();
        // Attachments (images).
        if (is_array($post['attachments']) && count($post['attachments']) > 0) {
            foreach ($post['attachments'] as $attachment) {
                $lfilename = strtolower($attachment['filename']);
                if (strpos($lfilename, '.jpe') !== false || strpos($lfilename, '.png') !== false || strpos($lfilename, '.gif') !== false || strpos($lfilename, '.jpg') !== false || strpos($lfilename, '.jpeg') !== false) {
                    $tmp = array('img' => $vbulletin->options['bburl'] . '/attachment.php?attachmentid=' . $attachment['attachmentid']);
                    if ($vbulletin->options['attachthumbs']) {
                        $tmp['tmb'] = $vbulletin->options['bburl'] . '/attachment.php?attachmentid=' . $attachment['attachmentid'] . '&stc=1&thumb=1';
                    }
                    $fr_images[] = $tmp;
                }
                if (strpos($lfilename, '.pdf') !== false) {
                    $docattach[] = $vbulletin->options['bburl'] . '/attachment.php?attachmentid=' . $attachment['attachmentid'];
                }
            }
        }
        // Parse the post for quotes and inline images
        list($text, $nuked_quotes, $images) = parse_post($post['pagetext'], $usesmilies, $attachments);
        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);
        }
        // Avatar work
        $avatarurl = '';
        if ($post['avatarurl']) {
            $avatarurl = process_avatarurl($post['avatarurl']);
        }
        $tmp = array('username' => prepare_utf8_string(strip_tags($post['username'])), 'userid' => $post['userid'], 'title' => prepare_utf8_string($post['title']), 'text' => $text, 'post_timestamp' => prepare_utf8_string(date_trunc($post['startdate'])), 'fr_images' => $fr_images);
        if ($avatarurl != '') {
            $tmp['avatarurl'] = $avatarurl;
        }
        $posts_out[] = $tmp;
    }
    if (!empty($anncids)) {
        $db->shutdown_query("\n\t\t\tUPDATE " . TABLE_PREFIX . "announcement\n\t\t\tSET views = views + 1\n\t\t\tWHERE announcementid IN (" . implode(', ', $anncids) . ")\n\t\t");
        if ($vbulletin->userinfo['userid']) {
            $db->shutdown_query("\n\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "announcementread\n\t\t\t\t\t(announcementid, userid)\n\t\t\t\tVALUES\n\t\t\t\t\t" . implode(', ', $announceread) . "\n\t\t\t");
        }
    }
    if (!is_array($posts_out)) {
        $posts_out = array();
    }
    return array('posts' => $posts_out, 'total_posts' => count($posts_out));
}
Example #11
0
function do_get_pm()
{
    global $vbulletin, $db;
    require_once DIR . '/includes/class_postbit.php';
    require_once DIR . '/includes/functions_bigthree.php';
    $vbulletin->input->clean_array_gpc('r', array('pmid' => TYPE_UINT, 'showhistory' => TYPE_BOOL));
    ($hook = vBulletinHook::fetch_hook('private_showpm_start')) ? eval($hook) : false;
    $pm = $db->query_first_slave("\n\t\tSELECT\n\t\t\tpm.*, pmtext.*,\n\t\t\t" . iif($vbulletin->options['privallowicons'], "icon.title AS icontitle, icon.iconpath,") . "\n\t\t\tIF(ISNULL(pmreceipt.pmid), 0, 1) AS receipt, pmreceipt.readtime, pmreceipt.denied,\n\t\t\tsigpic.userid AS sigpic, sigpic.dateline AS sigpicdateline, sigpic.width AS sigpicwidth, sigpic.height AS sigpicheight\n\t\tFROM " . TABLE_PREFIX . "pm AS pm\n\t\tLEFT JOIN " . TABLE_PREFIX . "pmtext AS pmtext ON(pmtext.pmtextid = pm.pmtextid)\n\t\t" . iif($vbulletin->options['privallowicons'], "LEFT JOIN " . TABLE_PREFIX . "icon AS icon ON(icon.iconid = pmtext.iconid)") . "\n\t\tLEFT JOIN " . TABLE_PREFIX . "pmreceipt AS pmreceipt ON(pmreceipt.pmid = pm.pmid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "sigpic AS sigpic ON(sigpic.userid = pmtext.fromuserid)\n\t\tWHERE pm.userid=" . $vbulletin->userinfo['userid'] . " AND pm.pmid=" . $vbulletin->GPC['pmid'] . "\n\t");
    if (!$pm) {
        json_error(strip_tags(fetch_error('invalidid', $vbphrase['private_message'], $vbulletin->options['contactuslink'])));
    }
    $folderjump = construct_folder_jump(0, $pm['folderid']);
    // do read receipt
    $show['receiptprompt'] = $show['receiptpopup'] = false;
    if ($pm['receipt'] == 1 and $pm['readtime'] == 0 and $pm['denied'] == 0) {
        if ($permissions['pmpermissions'] & $vbulletin->bf_ugp_pmpermissions['candenypmreceipts']) {
            // set it to denied just now as some people might have ad blocking that stops the popup appearing
            $show['receiptprompt'] = $show['receiptpopup'] = true;
            $receipt_question_js = addslashes_js(construct_phrase($vbphrase['x_has_requested_a_read_receipt'], unhtmlspecialchars($pm['fromusername'])), '"');
            $db->shutdown_query("UPDATE " . TABLE_PREFIX . "pmreceipt SET denied = 1 WHERE pmid = {$pm['pmid']}");
        } else {
            // they can't deny pm receipts so do not show a popup or prompt
            $db->shutdown_query("UPDATE " . TABLE_PREFIX . "pmreceipt SET readtime = " . TIMENOW . " WHERE pmid = {$pm['pmid']}");
        }
    } else {
        if ($pm['receipt'] == 1 and $pm['denied'] == 1) {
            $show['receiptprompt'] = true;
        }
    }
    $postbit_factory = new vB_Postbit_Factory();
    $postbit_factory->registry =& $vbulletin;
    $postbit_factory->cache = array();
    $postbit_factory->bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list());
    $postbit_obj =& $postbit_factory->fetch_postbit('pm');
    $pm_postbit = $pm;
    $postbit = $postbit_obj->construct_postbit($pm_postbit);
    // update message to show read
    if ($pm['messageread'] == 0) {
        $db->shutdown_query("UPDATE " . TABLE_PREFIX . "pm SET messageread=1 WHERE userid=" . $vbulletin->userinfo['userid'] . " AND pmid={$pm['pmid']}");
        if ($pm['folderid'] >= 0) {
            $userdm =& datamanager_init('User', $vbulletin, ERRTYPE_SILENT);
            $userdm->set_existing($vbulletin->userinfo);
            $userdm->set('pmunread', 'IF(pmunread >= 1, pmunread - 1, 0)', false);
            $userdm->save(true, true);
            unset($userdm);
        }
    }
    $cclist = array();
    $bcclist = array();
    $ccrecipients = '';
    $bccrecipients = '';
    $touser = unserialize($pm['touserarray']);
    if (!is_array($touser)) {
        $touser = array();
    }
    foreach ($touser as $key => $item) {
        if (is_array($item)) {
            foreach ($item as $subkey => $subitem) {
                $userinfo = array('userid' => $subkey, 'username' => $subitem);
                $templater = vB_Template::create('pm_messagelistbit_user');
                $templater->register('userinfo', $userinfo);
                ${$key . 'list'}[] = $templater->render();
            }
        } else {
            $userinfo = array('username' => $item, 'userid' => $key);
            $templater = vB_Template::create('pm_messagelistbit_user');
            $templater->register('userinfo', $userinfo);
            $bcclist[] = $templater->render();
        }
    }
    if (count($cclist) > 1 or is_array($touser['cc']) and !in_array($vbulletin->userinfo['username'], $touser['cc']) or $vbulletin->userinfo['userid'] == $pm['fromuserid'] and $pm['folderid'] == -1) {
        if (!empty($cclist)) {
            $ccrecipients = implode("\r\n", $cclist);
        }
        if (!empty($bcclist) and $vbulletin->userinfo['userid'] == $pm['fromuserid'] and $pm['folderid'] == -1) {
            if (empty($cclist) and count($bcclist == 1)) {
                $ccrecipients = implode("\r\n", $bcclist);
            } else {
                $bccrecipients = implode("\r\n", $bcclist);
            }
        }
        $show['recipients'] = true;
    }
    $pm['senddate'] = vbdate($vbulletin->options['dateformat'], $pm['dateline']);
    $pm['sendtime'] = vbdate($vbulletin->options['timeformat'], $pm['dateline']);
    list($text, $nuked_quotes, $images) = parse_post($pm['message'], $vbulletin->options['privallowsmilies'] && $usesmiles);
    $fr_images = array();
    foreach ($images as $image) {
        $fr_images[] = array('img' => $image);
    }
    // Avatar work
    $avatarurl = '';
    if ($pm_postbit['avatarurl']) {
        $avatarurl = process_avatarurl($pm_postbit['avatarurl']);
    }
    $to_users = unserialize($pm['touserarray']);
    $users = array();
    if ($to_users !== false) {
        if ($to_users['cc']) {
            $users = $to_users['cc'];
        } else {
            $users = $to_users;
        }
    }
    $out = array('id' => $pm['pmid'], 'pm_unread' => $pm['messageread'] == 0, 'username' => prepare_utf8_string(strip_tags($pm['fromusername'])), 'to_usernames' => prepare_utf8_string(implode('; ', $users)), 'userid' => $pm['fromuserid'], 'title' => prepare_utf8_string($pm['title']), 'online' => fetch_online_status(fetch_userinfo($pm['fromuserid']), false), 'message' => $text, 'quotable' => $nuked_quotes, 'fr_images' => $fr_images, 'pm_timestamp' => prepare_utf8_string(date_trunc($pm['senddate'] . ' ' . $pm['sendtime'])));
    if ($avatarurl != '') {
        $out['avatarurl'] = $avatarurl;
    }
    return $out;
}