Пример #1
0
 /**
  * Verifies the title is valid and sets up the title for saving (wordwrap, censor, etc).
  *
  * @param	string	Title text
  *
  * @param	bool	Whether the title is valid
  */
 function verify_title(&$title)
 {
     // replace html-encoded spaces with actual spaces
     $title = preg_replace('/&#(0*32|x0*20);/', ' ', $title);
     $title = trim($title);
     if ($this->registry->options['titlemaxchars'] and $title != $this->existing['title']) {
         if (!empty($this->info['show_title_error'])) {
             if (($titlelen = vbstrlen($title)) > $this->registry->options['titlemaxchars']) {
                 // title too long
                 $this->error('title_toolong', $titlelen, $this->registry->options['titlemaxchars']);
                 return false;
             }
         } else {
             if (empty($this->info['is_automated'])) {
                 // not showing the title length error, just chop it
                 $title = vbchop($title, $this->registry->options['titlemaxchars']);
             }
         }
     }
     require_once DIR . '/includes/functions_newpost.php';
     // censor, remove all caps subjects, and htmlspecialchars title
     $title = fetch_no_shouting_text(fetch_censored_text($title));
     // do word wrapping
     $title = fetch_word_wrapped_string($title);
     return true;
 }
Пример #2
0
/**
* Fetches picture info for the specified picture/album combination. That is,
* the picture must be in the specified album. Also does some preperation on
* the data for display.
*
* @param	integer	ID of picture
* @param	integer	ID of album
*
* @return	array	Array of picture information
*/
function fetch_pictureinfo($attachmentid, $albumid)
{
	global $vbulletin;

	$pictureinfo = $vbulletin->db->query_first("
		SELECT
			a.attachmentid, a.userid, a.caption, a.reportthreadid, a.state, a.dateline, a.contentid AS albumid,
			fd.filedataid, fd.filesize, fd.width, fd.height, fd.thumbnail_filesize, IF(fd.thumbnail_filesize > 0, 1, 0) AS hasthumbnail
		FROM " . TABLE_PREFIX . "attachment AS a
		INNER JOIN " . TABLE_PREFIX . "filedata AS fd ON (a.filedataid = fd.filedataid)
		INNER JOIN " . TABLE_PREFIX . "album AS album ON (a.contentid = album.albumid)
		WHERE
			a.attachmentid = " . intval($attachmentid) . "
				AND
			album.albumid = " . intval($albumid) . "
	");

	if (!$pictureinfo)
	{
		return array();
	}

	$pictureinfo['caption_html'] = nl2br(fetch_word_wrapped_string(fetch_censored_text($pictureinfo['caption'])));

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

	return $pictureinfo;
}
function fetch_event_date_time($info)
{
    global $timerange, $vbulletin, $vbphrase, $months, $days, $day, $month, $year, $holiday, $eventdate;
    global $titlecolor, $date1, $date2, $time1, $time2, $recurcriteria, $allday, $show;
    require_once DIR . '/includes/functions_misc.php';
    $daterange = '';
    $recurcriteria = '';
    $show['recuroption'] = false;
    $titlecolor = 'alt1';
    $info['title'] = htmlspecialchars_uni($info['title']);
    if ($wordwrap != 0) {
        $info['title'] = fetch_word_wrapped_string($info['title']);
    }
    $info['event'] = iif(empty($info['event']), '&nbsp', parse_calendar_bbcode($info['event'], $info['allowsmilies']));
    if (!$info['recurring'] and !$info['singleday']) {
        $daystamp = gmmktime(0, 0, 0, $month, $day, $year);
        $eventfirstday = gmmktime(0, 0, 0, gmdate('n', $info['dateline_from_user']), gmdate('j', $info['dateline_from_user']), gmdate('Y', $info['dateline_from_user']));
        $eventlastday = gmmktime(0, 0, 0, gmdate('n', $info['dateline_to_user']), gmdate('j', $info['dateline_to_user']), gmdate('Y', $info['dateline_to_user']));
        if ($info['dateline_from'] == $daystamp) {
            if ($eventfirstday == $daystamp) {
                if ($eventfirstday != $eventlastday) {
                    if (vbdate('g:ia', $info['dateline_from_user'], false, false) == '12:00am') {
                        $allday = true;
                    } else {
                        $time2 = vbgmdate($vbulletin->options['timeformat'], gmmktime(0, 0, 0, $month, $day, $year));
                    }
                }
            }
        } else {
            if ($eventlastday == $daystamp) {
                $time1 = gmdate($vbulletin->options['timeformat'], gmmktime(0, 0, 0, $month, $day, $year));
                $time1 = vbgmdate($vbulletin->options['timeformat'], gmmktime(0, 0, 0, $month, $day, $year));
            } else {
                $allday = true;
                // Used in conditional
            }
        }
    }
    if ($info['holidayid']) {
        $eventdate = vbgmdate($vbulletin->options['dateformat'], gmmktime(0, 0, 0, $month, $day, $year));
    } else {
        if ($info['singleday']) {
            $eventdate = vbgmdate($vbulletin->options['dateformat'], $info['dateline_from']);
        } else {
            $date1 = vbgmdate($vbulletin->options['dateformat'], $info['dateline_from_user']);
            $date2 = vbgmdate($vbulletin->options['dateformat'], $info['dateline_to_user']);
            $time1 = vbgmdate($vbulletin->options['timeformat'], $info['dateline_from_user']);
            $time2 = vbgmdate($vbulletin->options['timeformat'], $info['dateline_to_user']);
            if ($info['recurring']) {
                $recurcriteria = fetch_event_criteria($info);
                $show['recuroption'] = true;
            } else {
                $show['daterange'] = iif($date1 != $date2, true, false);
                $eventdate = vbgmdate($vbulletin->options['dateformat'], $info['dateline_from_user']);
            }
        }
    }
    return $info;
}
Пример #4
0
/**
* Fetches picture info for the specified picture/album combination. That is,
* the picture must be in the specified album. Also does some preperation on
* the data for display.
*
* @param	integer	ID of picture
* @param	integer	ID of album
*
* @return	array	Array of picture information
*/
function fetch_pictureinfo($attachmentid, $albumid)
{
    global $vbulletin;
    $pictureinfo = $vbulletin->db->query_first("\n\t\tSELECT\n\t\t\ta.attachmentid, a.userid, a.caption, a.reportthreadid, a.state, a.dateline, a.contentid AS albumid,\n\t\t\tfd.filedataid, fd.filesize, fd.width, fd.height, fd.thumbnail_filesize, IF(fd.thumbnail_filesize > 0, 1, 0) AS hasthumbnail\n\t\tFROM " . TABLE_PREFIX . "attachment AS a\n\t\tINNER JOIN " . TABLE_PREFIX . "filedata AS fd ON (a.filedataid = fd.filedataid)\n\t\tINNER JOIN " . TABLE_PREFIX . "album AS album ON (a.contentid = album.albumid)\n\t\tWHERE\n\t\t\ta.attachmentid = " . intval($attachmentid) . "\n\t\t\t\tAND\n\t\t\talbum.albumid = " . intval($albumid) . "\n\t");
    if (!$pictureinfo) {
        return array();
    }
    $pictureinfo['caption_html'] = nl2br(fetch_word_wrapped_string(fetch_censored_text($pictureinfo['caption'])));
    return $pictureinfo;
}
Пример #5
0
/**
* Fetches picture info for the specified picture/album combination. That is,
* the picture must be in the specified album. Also does some preperation on
* the data for display.
*
* @param	integer	ID of picture
* @param	integer	ID of album
*
* @return	array	Array of picture information
*/
function fetch_pictureinfo($pictureid, $albumid)
{
    global $vbulletin;
    $pictureinfo = $vbulletin->db->query_first("\n\t\tSELECT picture.pictureid, picture.userid, picture.caption, picture.extension, picture.filesize,\n\t\t\tpicture.width, picture.height, picture.reportthreadid, picture.state,\n\t\t\tpicture.idhash, picture.thumbnail_filesize, albumpicture.dateline, albumpicture.albumid\n\t\tFROM " . TABLE_PREFIX . "albumpicture AS albumpicture\n\t\tINNER JOIN " . TABLE_PREFIX . "picture AS picture ON (picture.pictureid = albumpicture.pictureid)\n\t\tWHERE albumpicture.albumid = " . intval($albumid) . "\n\t\t\tAND albumpicture.pictureid = " . intval($pictureid));
    if (!$pictureinfo) {
        return array();
    }
    $pictureinfo['caption_html'] = nl2br(fetch_word_wrapped_string(fetch_censored_text($pictureinfo['caption'])));
    ($hook = vBulletinHook::fetch_hook('album_fetch_pictureinfo')) ? eval($hook) : false;
    return $pictureinfo;
}
Пример #6
0
/**
* Fetches the tagbits for display in an entry
*
* @param	array	Blog info
*
* @return	string	Tag bits
*/
function fetch_entry_tagbits($bloginfo, &$userinfo)
{
	global $vbulletin, $vbphrase, $show, $template_hook;

	if ($bloginfo['taglist'])
	{
		$tag_array = explode(',', $bloginfo['taglist']);

		$tag_list = array();
		foreach ($tag_array AS $tag)
		{
			$tag = trim($tag);
			if ($tag === '')
			{
				continue;
			}
			$tag_url = urlencode(unhtmlspecialchars($tag));
			$tag = fetch_word_wrapped_string($tag);

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

			$templater = vB_Template::create('blog_tagbit');
				$templater->register('tag', $tag);
				$templater->register('tag_url', $tag_url);
				$templater->register('userinfo', $userinfo);
				$templater->register('pageinfo', array('tag' => $tag_url));
			$tag_list[] = trim($templater->render());
		}
	}
	else
	{
		$tag_list = array();
	}

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

	return implode(", ", $tag_list);
}
Пример #7
0
    if ($p == 0) {
        $p = 1;
    }
    $output .= print_archive_page_navigation($threadinfo['replycount'] + 1, $vbulletin->options['archive_postsperpage'], "t-{$threadinfo['threadid']}");
    $posts = $db->query_read_slave("\n\t\tSELECT post.postid, post.pagetext, IFNULL( user.username , post.username ) AS username, dateline\n\t\tFROM " . TABLE_PREFIX . "post AS post\n\t\tLEFT JOIN " . TABLE_PREFIX . "user AS user ON (user.userid = post.userid)\n\t\tWHERE threadid = {$threadinfo['threadid']}\n\t\t\tAND visible = 1\n\t\t\t{$globalignore}\n\t\tORDER BY dateline ASC\n\t\tLIMIT " . ($p - 1) * $vbulletin->options['archive_postsperpage'] . ',' . $vbulletin->options[archive_postsperpage]);
    if ($pda and false) {
        $output .= "<span id=\"posting\"><a href=\"?message=1\" rel=\"nofollow\">New Reply</a></span>";
    }
    $i = 0;
    while ($post = $db->fetch_array($posts)) {
        $i++;
        $post['pagetext_simp'] = strip_bbcode($post['pagetext']);
        $post['postdate'] = vbdate($vbulletin->options['dateformat'], $post['dateline']);
        $post['posttime'] = vbdate($vbulletin->options['timeformat'], $post['dateline']);
        if ($vbulletin->options['wordwrap'] != 0) {
            $post['pagetext_simp'] = fetch_word_wrapped_string($post['pagetext_simp']);
        }
        $post['pagetext_simp'] = fetch_censored_text($post['pagetext_simp']);
        ($hook = vBulletinHook::fetch_hook('archive_thread_post')) ? eval($hook) : false;
        $output .= "\n<div class=\"post\"><div class=\"posttop\"><div class=\"username\">{$post['username']}</div><div class=\"date\">{$post['postdate']}, {$post['posttime']}</div></div>";
        $output .= "<div class=\"posttext\">" . nl2br(htmlspecialchars_uni($post['pagetext_simp'])) . "</div></div><hr />\n\n";
    }
}
// ********************************************************************************************
// display login
if ($do == 'login') {
    $output .= print_archive_navigation(array());
    $output .= "<p class=\"largefont\">{$vbphrase['view_full_version']}: <a href=\"" . $vbulletin->options['bburl'] . '/' . $vbulletin->options['forumhome'] . '.php">' . $vbulletin->options['bbtitle'] . "</a></p>\n";
    if (SLASH_METHOD) {
        $loginlink = 'index.php' . (!empty($querystring) ? "/{$querystring}" : '') . '?login=1';
    } else {
Пример #8
0
	/**
	* Processes miscellaneous post items at the beginning of the construction process.
	*/
	function prep_post_start()
	{
		$this->post = array_merge($this->post, convert_bits_to_array($this->post['options'], $this->registry->bf_misc_useroptions));
		$this->post = array_merge($this->post, convert_bits_to_array($this->post['adminoptions'], $this->registry->bf_misc_adminoptions));

		// do word wrap
		if ($this->registry->options['wordwrap'])
		{
			$this->post['title'] = fetch_word_wrapped_string($this->post['title']);
		}
		$this->post['title'] = fetch_censored_text($this->post['title']);

		// init imod checkbox value
		$this->post['checkbox_value'] = 0;
	}
Пример #9
0
    if ($compare['oldver'] and $compare['newver']) {
        // make the diff
        require_once DIR . '/includes/class_diff.php';
        $textdiff_obj = new vB_Text_Diff($compare['oldver']['pagetext'], $compare['newver']['pagetext']);
        $diff = $textdiff_obj->fetch_diff();
        ($hook = vBulletinHook::fetch_hook('posthistory_compare')) ? eval($hook) : false;
        foreach ($diff as $diffrow) {
            $compare_show = array();
            if ($diffrow->old_class == 'unchanged' and $diffrow->new_class == 'unchanged') {
                // no change
                $compare_show['olddata'] = fetch_word_wrapped_string(nl2br(htmlspecialchars_uni(implode("\n", $diffrow->fetch_data_old()))));
                $compare_show['template'] = 'posthistory_content_not_changed';
            } else {
                // something has changed
                $compare_show['olddata'] = fetch_word_wrapped_string(nl2br(htmlspecialchars_uni(implode("\n", $diffrow->fetch_data_old()))));
                $compare_show['newdata'] = fetch_word_wrapped_string(nl2br(htmlspecialchars_uni(implode("\n", $diffrow->fetch_data_new()))));
                $compare_show['template'] = 'posthistory_content_changed';
            }
            ($hook = vBulletinHook::fetch_hook('posthistory_comparebit')) ? eval($hook) : false;
            eval('$comparebits .= "' . fetch_template($compare_show['template']) . '";');
        }
        $show['titlecompare'] = $compare['oldver']['title'] != $compare['newver']['title'];
        $oldtitle = $compare['oldver']['title'] !== '' ? $compare['oldver']['title'] : '&nbsp;';
        $newtitle = $compare['newver']['title'] !== '' ? $compare['newver']['title'] : '&nbsp;';
        $form_do = 'list';
        $button_text = $vbphrase['go_back'];
    }
}
// #############################################################################
// draw navbar
$navbits = array();
Пример #10
0
function process_thread_array($thread, $lastread = -1, $allowicons = -1)
{
    global $vbphrase, $stylevar, $foruminfo, $vbulletin;
    global $newthreads, $dotthreads, $perpage, $ignore, $show;
    static $pperpage;
    if ($pperpage == 0) {
        // lets calculate posts per page
        // the following code should be left just in case we plan to use this function in showthread at some point
        if (THIS_SCRIPT != 'showthread') {
            $pperpage = sanitize_maxposts();
        } else {
            $pperpage = sanitize_maxposts($perpage);
        }
    }
    // init value for the inline moderation checkbox
    $thread['checkbox_value'] = 0;
    if (can_moderate($thread['forumid'], 'caneditthreads') or $thread['open'] and $thread['postuserid'] == $vbulletin->userinfo['userid'] and $forumperms = fetch_permissions($thread['forumid']) and $forumperms & $vbulletin->bf_ugp_forumpermissions['caneditpost'] and $thread['dateline'] + $vbulletin->options['editthreadtitlelimit'] * 60 > TIMENOW) {
        $thread['title_editable'] = '<a rel="vB::AJAX"></a>';
        $show['ajax_js'] = true;
    } else {
        $thread['title_editable'] = '';
    }
    if ($thread['open'] != 10 and (can_moderate($thread['forumid'], 'canopenclose') or $thread['postuserid'] == $vbulletin->userinfo['userid'] and $forumperms = fetch_permissions($thread['forumid']) and $forumperms & $vbulletin->bf_ugp_forumpermissions['canopenclose'])) {
        $thread['openclose_editable'] = '<a rel="vB::AJAX"></a>';
        $show['ajax_js'] = true;
    } else {
        $thread['openclose_editable'] = '';
    }
    /*if ($thread['postuserid'] == $vbulletin->userinfo['userid'])
    	{
    		$forumperms = fetch_permissions($thread['forumid']);
    		if ($forumperms & $vbulletin->bf_ugp_forumpermissions['canopenclose'])
    		{
    			$thread['openclose_editable'] .= "<div><strong>Own thread</strong></div>";
    		}
    	}*/
    if ($allowicons == -1) {
        $allowicons = $vbulletin->forumcache["{$thread['forumid']}"]['options'] & $vbulletin->bf_misc_forumoptions['allowicons'];
    }
    if ($lastread == -1) {
        $lastread = $vbulletin->userinfo['lastvisit'];
    }
    $show['rexpires'] = $show['rmanage'] = $show['threadmoved'] = $show['paperclip'] = $show['unsubscribe'] = false;
    // thread forumtitle
    if (empty($thread['forumtitle'])) {
        $thread['forumtitle'] = $vbulletin->forumcache["{$thread['forumid']}"]['title'];
    }
    // word wrap title
    if ($vbulletin->options['wordwrap'] != 0) {
        $thread['threadtitle'] = fetch_word_wrapped_string($thread['threadtitle']);
    }
    $thread['threadtitle'] = fetch_censored_text($thread['threadtitle']);
    if ($thread['prefixid']) {
        $thread['prefix_plain_html'] = htmlspecialchars_uni($vbphrase["prefix_{$thread['prefixid']}_title_plain"]);
        $thread['prefix_rich'] = $vbphrase["prefix_{$thread['prefixid']}_title_rich"];
    } else {
        $thread['prefix_plain_html'] = '';
        $thread['prefix_rich'] = '';
    }
    // format thread preview if there is one
    if ($ignore["{$thread['postuserid']}"]) {
        $thread['preview'] = '';
    } else {
        if (isset($thread['preview']) and $vbulletin->options['threadpreview'] > 0) {
            $thread['preview'] = strip_quotes($thread['preview']);
            $thread['preview'] = htmlspecialchars_uni(fetch_censored_text(fetch_trimmed_title(strip_bbcode($thread['preview'], false, true), $vbulletin->options['threadpreview'])));
        }
    }
    // thread last reply date/time
    $thread['lastpostdate'] = vbdate($vbulletin->options['dateformat'], $thread['lastpost'], true);
    $thread['lastposttime'] = vbdate($vbulletin->options['timeformat'], $thread['lastpost']);
    // post reply date/time (for search results as posts mainly)
    if ($thread['postdateline']) {
        $thread['postdate'] = vbdate($vbulletin->options['dateformat'], $thread['postdateline'], true);
        $thread['posttime'] = vbdate($vbulletin->options['timeformat'], $thread['postdateline']);
    } else {
        $thread['postdate'] = '';
        $thread['posttime'] = '';
    }
    // thread not moved
    if ($thread['open'] != 10) {
        // allow ratings?
        if ($foruminfo['allowratings']) {
            // show votes?
            if ($thread['votenum'] and $thread['votenum'] >= $vbulletin->options['showvotes']) {
                $thread['voteavg'] = vb_number_format($thread['votetotal'] / $thread['votenum'], 2);
                $thread['rating'] = intval(round($thread['votetotal'] / $thread['votenum']));
            } else {
                $thread['rating'] = 0;
            }
        } else {
            $thread['rating'] = 0;
            $thread['votenum'] = 0;
        }
        // moderated thread?
        if (!$thread['visible']) {
            $thread['moderatedprefix'] = $vbphrase['moderated_thread_prefix'];
            $thread['checkbox_value'] += THREAD_FLAG_INVISIBLE;
        } else {
            $thread['moderatedprefix'] = '';
        }
        // deleted thread?
        if ($thread['visible'] == 2) {
            $thread['checkbox_value'] += THREAD_FLAG_DELETED;
            $thread['del_reason'] = fetch_censored_text($thread['del_reason']);
        }
        // sticky thread?
        if ($thread['sticky']) {
            $show['sticky'] = true;
            $thread['typeprefix'] = $vbphrase['sticky_thread_prefix'];
            $thread['checkbox_value'] += THREAD_FLAG_STICKY;
        } else {
            $show['sticky'] = false;
            $thread['typeprefix'] = '';
        }
        // thread contains poll?
        if ($thread['pollid'] != 0) {
            $thread['typeprefix'] .= $vbphrase['poll_thread_prefix'];
            $thread['checkbox_value'] += THREAD_FLAG_POLL;
        }
        // multipage nav
        $thread['totalposts'] = $thread['replycount'] + 1;
        $total =& $thread['totalposts'];
        if (($vbulletin->options['allowthreadedmode'] == 0 or $vbulletin->userinfo['threadedmode'] == 0 and empty($vbulletin->GPC[COOKIE_PREFIX . 'threadedmode']) or $vbulletin->GPC[COOKIE_PREFIX . 'threadedmode'] == 'linear') and $thread['totalposts'] > $pperpage and $vbulletin->options['linktopages']) {
            $thread['totalpages'] = ceil($thread['totalposts'] / $pperpage);
            $address = 'showthread.php?' . $vbulletin->session->vars['sessionurl'] . "t={$thread['threadid']}";
            $address2 = "{$thread['highlight']}";
            $curpage = 0;
            $thread['pagenav'] = '';
            $show['pagenavmore'] = false;
            while ($curpage++ < $thread['totalpages']) {
                if ($vbulletin->options['maxmultipage'] and $curpage > $vbulletin->options['maxmultipage']) {
                    $show['pagenavmore'] = true;
                    break;
                }
                $pagenumbers = fetch_start_end_total_array($curpage, $pperpage, $thread['totalposts']);
                eval('$thread[pagenav] .= " ' . fetch_template('threadbit_pagelink') . '";');
            }
        } else {
            $thread['pagenav'] = '';
        }
        // allow thread icons?
        if ($allowicons) {
            // get icon from icon cache
            if ($thread['threadiconid']) {
                $thread['threadiconpath'] = $vbulletin->iconcache["{$thread['threadiconid']}"]['iconpath'];
                $thread['threadicontitle'] = $vbulletin->iconcache["{$thread['threadiconid']}"]['title'];
            }
            // show poll icon
            if ($thread['pollid'] != 0) {
                $show['threadicon'] = true;
                $thread['threadiconpath'] = "{$stylevar['imgdir_misc']}/poll_posticon.gif";
                $thread['threadicontitle'] = $vbphrase['poll'];
            } else {
                if ($thread['threadiconpath']) {
                    $show['threadicon'] = true;
                } else {
                    if (!empty($vbulletin->options['showdeficon'])) {
                        $show['threadicon'] = true;
                        $thread['threadiconpath'] = $vbulletin->options['showdeficon'];
                        $thread['threadicontitle'] = '';
                    } else {
                        $show['threadicon'] = false;
                        $thread['threadiconpath'] = '';
                        $thread['threadicontitle'] = '';
                    }
                }
            }
        } else {
            $show['threadicon'] = false;
            $thread['threadiconpath'] = '';
            $thread['threadicontitle'] = '';
        }
        // thread has attachment?
        if ($thread['attach'] > 0) {
            $show['paperclip'] = true;
            $thread['checkbox_value'] += THREAD_FLAG_ATTACH;
        }
        // folder icon generation
        $thread['statusicon'] = '';
        // show dot folder?
        if ($vbulletin->userinfo['userid'] and $vbulletin->options['showdots'] and $dotthreads["{$thread['threadid']}"]) {
            $thread['statusicon'] .= '_dot';
            $thread['dot_count'] = $dotthreads["{$thread['threadid']}"]['count'];
            $thread['dot_lastpost'] = $dotthreads["{$thread['threadid']}"]['lastpost'];
        }
        // show hot folder?
        if ($vbulletin->options['usehotthreads'] and ($thread['replycount'] >= $vbulletin->options['hotnumberposts'] and $vbulletin->options['hotnumberposts'] > 0 or $thread['views'] >= $vbulletin->options['hotnumberviews'] and $vbulletin->options['hotnumberviews'] > 0)) {
            $thread['statusicon'] .= '_hot';
        }
        // show locked folder?
        if (!$thread['open']) {
            $thread['statusicon'] .= '_lock';
            $thread['checkbox_value'] += THREAD_FLAG_CLOSED;
        }
        // show new folder?
        if ($thread['lastpost'] > $lastread) {
            if ($vbulletin->options['threadmarking'] and $thread['threadread']) {
                $threadview = $thread['threadread'];
            } else {
                $threadview = intval(fetch_bbarray_cookie('thread_lastview', $thread['threadid']));
            }
            if ($thread['lastpost'] > $threadview) {
                $thread['statusicon'] .= '_new';
                $show['gotonewpost'] = true;
            } else {
                $newthreads--;
                $show['gotonewpost'] = false;
            }
        } else {
            $show['gotonewpost'] = false;
        }
        // format numbers nicely
        $thread['replycount'] = vb_number_format($thread['replycount']);
        $thread['views'] = vb_number_format($thread['views']);
        $thread['realthreadid'] = $thread['threadid'];
    } else {
        // thread has been moved, lets delete if required!
        if (can_moderate($thread['forumid'])) {
            if ($thread['expires']) {
                if ($thread['expires'] <= TIMENOW) {
                    $threadman =& datamanager_init('Thread', $vbulletin, ERRTYPE_STANDARD, 'threadpost');
                    $threadman->set_existing($thread);
                    $threadman->delete(false, true, NULL, false);
                    unset($threadman);
                }
                $show['rexpires'] = true;
                $thread['expiredate'] = vbdate($vbulletin->options['dateformat'], $thread['expires']);
                $thread['expiretime'] = vbdate($vbulletin->options['timeformat'], $thread['expires']);
            }
            $show['rmanage'] = can_moderate($thread['forumid'], 'canmanagethreads');
        }
        $thread['realthreadid'] = $thread['threadid'];
        $thread['redirectthreadid'] = $thread['threadid'];
        $thread['threadid'] = $thread['pollid'];
        $thread['replycount'] = '-';
        $thread['views'] = '-';
        $show['threadicon'] = false;
        $thread['statusicon'] = '_moved' . iif($thread['lastpost'] > $lastread, '_new');
        $thread['pagenav'] = '';
        $thread['movedprefix'] = $vbphrase['moved_thread_prefix'];
        $thread['rating'] = 0;
        $thread['votenum'] = 0;
        $thread['pagenav'] = '';
        $show['gotonewpost'] = false;
        $thread['showpagenav'] = false;
        $show['sticky'] = false;
        $show['threadmoved'] = true;
    }
    $show['subscribed'] = iif($thread['issubscribed'], true, false);
    $show['pagenav'] = iif($thread['pagenav'] != '', true, false);
    $show['guestuser'] = iif(!$thread['postuserid'], true, false);
    $show['threadrating'] = iif($thread['rating'] > 0, true, false);
    $show['threadcount'] = iif($thread['dot_count'], true, false);
    $show['taglist'] = ($vbulletin->options['threadtagging'] and !empty($thread['taglist']));
    ($hook = vBulletinHook::fetch_hook('threadbit_process')) ? eval($hook) : false;
    return $thread;
}
Пример #11
0
         $show['unapprove'] = false;
     }
 }
 // Create bit factory
 $bitfactory = new vB_Group_Bit_Factory($vbulletin, $itemtype);
 // Build message bits for all items
 $messagebits = '';
 while ($item = $collection->fetch_item()) {
     if (!$do_discussions) {
         $discussion = fetch_socialdiscussioninfo($item['discussionid']);
         $group = fetch_socialgroupinfo($discussion['groupid']);
     } else {
         $group = fetch_socialgroupinfo($item['groupid']);
     }
     // add group name to message
     $group['name'] = fetch_word_wrapped_string(fetch_censored_text($group['name']));
     // force items to be visible
     if ('new' != $type) {
         $item['state'] = 'visible';
     }
     $bit =& $bitfactory->create($item, $group);
     $messagebits .= $bit->construct();
 }
 unset($bitfactory, $bit);
 // Set counts for view
 list($first, $last, $messageshown, $messagetotal) = array_values($collection->fetch_counts());
 // Legacy for templates
 $show['havemessages'] = (bool) $messagetotal;
 // Get actual resolved page number in case input was normalised
 $pagenumber = $show['pagenumber'] = $collection->fetch_pagenumber();
 $quantity = $collection->fetch_quantity();
/**
 * Takes information regardign a group, and prepares the information within it
 * for display
 *
 * @param	array	Group Array
 * @param	bool	Whether to fetch group members and avatars
 *
 * @return	array	Group Array with prepared information
 *
 */
function prepare_socialgroup($group, $fetchmembers = false)
{
    global $vbulletin;
    if (!is_array($group)) {
        return array();
    }
    if ($fetchmembers) {
        $membersinfo = cache_group_members();
        $group['membersinfo'] = $membersinfo[$group['groupid']];
    }
    $group['joindate'] = !empty($group['joindate']) ? vbdate($vbulletin->options['dateformat'], $group['joindate'], true) : '';
    $group['createtime'] = !empty($group['createdate']) ? vbdate($vbulletin->options['timeformat'], $group['createdate'], true) : '';
    $group['createdate'] = !empty($group['createdate']) ? vbdate($vbulletin->options['dateformat'], $group['createdate'], true) : '';
    $group['lastupdatetime'] = !empty($group['lastupdate']) ? vbdate($vbulletin->options['timeformat'], $group['lastupdate'], true) : '';
    $group['lastupdatedate'] = !empty($group['lastupdate']) ? vbdate($vbulletin->options['dateformat'], $group['lastupdate'], true) : '';
    $group['visible'] = vb_number_format($group['visible']);
    $group['moderation'] = vb_number_format($group['moderation']);
    $group['members'] = vb_number_format($group['members']);
    $group['moderatedmembers'] = vb_number_format($group['moderatedmembers']);
    $group['categoryname'] = htmlspecialchars_uni($group['categoryname']);
    $group['discussions'] = vb_number_format($group['discussions']);
    $group['lastdiscussion'] = fetch_word_wrapped_string(fetch_censored_text($group['lastdiscussion']));
    $group['trimdiscussion'] = fetch_trimmed_title($group['lastdiscussion']);
    if (!($group['options'] & $vbulletin->bf_misc_socialgroupoptions['enable_group_albums'])) {
        // albums disabled in this group - force 0 pictures
        $group['picturecount'] = 0;
    }
    $group['rawpicturecount'] = $group['picturecount'];
    $group['picturecount'] = vb_number_format($group['picturecount']);
    $group['rawname'] = $group['name'];
    $group['rawdescription'] = $group['description'];
    $group['name'] = fetch_word_wrapped_string(fetch_censored_text($group['name']));
    if ($group['description']) {
        $group['shortdescription'] = fetch_word_wrapped_string(fetch_censored_text(fetch_trimmed_title($group['description'], 185)));
    } else {
        $group['shortdescription'] = $group['name'];
    }
    $group['mediumdescription'] = fetch_word_wrapped_string(fetch_censored_text(fetch_trimmed_title($group['description'], 1000)));
    $group['description'] = nl2br(fetch_word_wrapped_string(fetch_censored_text($group['description'])));
    $group['is_owner'] = $group['creatoruserid'] == $vbulletin->userinfo['userid'];
    $group['is_automoderated'] = ($group['options'] & $vbulletin->bf_misc_socialgroupoptions['owner_mod_queue'] and $vbulletin->options['sg_allow_owner_mod_queue'] and !$vbulletin->options['social_moderation']);
    $group['canviewcontent'] = (!($group['options'] & $vbulletin->bf_misc_socialgroupoptions['join_to_view']) or !$vbulletin->options['sg_allow_join_to_view'] or $group['membertype'] == 'member' or can_moderate(0, 'canmoderategroupmessages') or can_moderate(0, 'canremovegroupmessages') or can_moderate(0, 'candeletegroupmessages') or fetch_socialgroup_perm('canalwayspostmessage') or fetch_socialgroup_perm('canalwascreatediscussion'));
    $group['lastpostdate'] = vbdate($vbulletin->options['dateformat'], $group['lastpost'], true);
    $group['lastposttime'] = vbdate($vbulletin->options['timeformat'], $group['lastpost']);
    $group['lastposterid'] = $group['canviewcontent'] ? $group['lastposterid'] : 0;
    $group['lastposter'] = $group['canviewcontent'] ? $group['lastposter'] : '';
    // check read marking
    //remove notice and make readtime determination a bit more clear
    if (!empty($group['readtime'])) {
        $readtime = $group['readtime'];
    } else {
        $readtime = fetch_bbarray_cookie('group_marking', $group['groupid']);
        if (!$readtime) {
            $readtime = $vbulletin->userinfo['lastvisit'];
        }
    }
    // get thumb url
    $group['iconurl'] = fetch_socialgroupicon_url($group, true);
    // check if social group is moderated to join
    $group['membermoderated'] = 'moderated' == $group['type'];
    // posts older than markinglimit days won't be highlighted as new
    $oldtime = TIMENOW - $vbulletin->options['markinglimit'] * 24 * 60 * 60;
    $readtime = max((int) $readtime, $oldtime);
    $group['readtime'] = $readtime;
    $group['is_read'] = $readtime >= $group['lastpost'];
    // Legacy Hook 'group_prepareinfo' Removed //
    return $group;
}
Пример #13
0
 /**
  * Verify a clean (no markup) bit of text
  *
  * @param	string	Text
  */
 function verify_cleantext(&$clean_text)
 {
     $clean_text = trim(preg_replace('/&#(0*32|x0*20);/', ' ', $clean_text));
     // censor, remove all caps subjects
     require_once DIR . '/includes/functions_newpost.php';
     $clean_text = fetch_no_shouting_text(fetch_censored_text($clean_text));
     // do word wrapping
     if ($this->registry->options['wordwrap'] != 0) {
         $clean_text = fetch_word_wrapped_string($clean_text);
     }
     return true;
 }
Пример #14
0
 /**
  * Sets the values for user[usertitle] and user[customtitle]
  *
  * @param	string	Custom user title text
  * @param	boolean	Whether or not to reset a custom title to the default user title
  * @param	array	Array containing all information for the user's primary usergroup
  * @param	boolean	Whether or not a user can use custom user titles ($permissions['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canusecustomtitle'])
  * @param	boolean	Whether or not the user is an administrator ($permissions['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel'])
  */
 function set_usertitle($customtext, $reset, $usergroup, $canusecustomtitle, $isadmin)
 {
     $customtitle = $this->existing['customtitle'];
     $usertitle = $this->existing['usertitle'];
     if ($canusecustomtitle) {
         // user is allowed to set a custom title
         if ($reset or $customtitle == 0 and $customtext === '') {
             // reset custom title or we don't have one but are allowed to
             if (empty($usergroup['usertitle'])) {
                 $gettitle = $this->dbobject->query_first("\n\t\t\t\t\t\tSELECT title\n\t\t\t\t\t\tFROM " . TABLE_PREFIX . "usertitle\n\t\t\t\t\t\tWHERE minposts <= " . intval($this->existing['posts']) . "\n\t\t\t\t\t\tORDER BY minposts DESC\n\t\t\t\t\t\tLIMIT 1\n\t\t\t\t\t");
                 $usertitle = $gettitle['title'];
             } else {
                 $usertitle = $usergroup['usertitle'];
             }
             $customtitle = 0;
         } else {
             if ($customtext) {
                 // set custom text
                 $usertitle = fetch_censored_text($customtext);
                 if (!can_moderate() or can_moderate() and !$this->registry->options['ctCensorMod']) {
                     $usertitle = $this->censor_custom_title($usertitle);
                 }
                 $customtitle = $isadmin ? 1 : 2;
                 // regular user - run htmlspecialchars
                 if ($customtitle == 2) {
                     $usertitle = fetch_word_wrapped_string($usertitle, 25);
                 }
             }
         }
     } else {
         if ($customtitle != 1) {
             if (empty($usergroup['usertitle'])) {
                 $gettitle = $this->dbobject->query_first("\n\t\t\t\t\tSELECT title\n\t\t\t\t\tFROM " . TABLE_PREFIX . "usertitle\n\t\t\t\t\tWHERE minposts <= " . intval($this->existing['posts']) . "\n\t\t\t\t\tORDER BY minposts DESC\n\t\t\t\t\tLIMIT 1\n\t\t\t\t");
                 $usertitle = $gettitle['title'];
             } else {
                 $usertitle = $usergroup['usertitle'];
             }
             $customtitle = 0;
         }
     }
     $this->set('usertitle', $usertitle);
     $this->set('customtitle', $customtitle);
 }
Пример #15
0
	else if ($ignore["$post[userid]"])
	{
		$show['adminignore'] = false;
		$bit_template = 'printthreadbit_ignore';
	}
	else
	{
		$bit_template = 'printthreadbit';
	}

	$post['postdate'] = vbdate($vbulletin->options['dateformat'], $post['dateline']);
	$post['posttime'] = vbdate($vbulletin->options['timeformat'], $post['dateline']);

	if ($vbulletin->options['wordwrap'])
	{
		$post['title'] = fetch_word_wrapped_string($post['title']);
	}

	if (!$post['userid'])
	{
		$post['username'] = $post['postusername'];
	}

	$post['message'] = $bbcode_parser->parse($post['pagetext'], 'nonforum', false);

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

	$templater = vB_Template::create($bit_template);
	$templater->register('post', $post);
	$templater->register('xhtml_id', ++$xhtml);
	$postbits .= $templater->render();
Пример #16
0
 /**
  * Prepare any data needed for the output
  *
  * @param	string	The id of the block
  * @param	array	Options specific to the block
  */
 function prepare_output($id = '', $options = array())
 {
     global $show, $vbphrase;
     $this->block_data = array();
     $membergroups = fetch_membergroupids_array($this->profile->userinfo);
     $this->block_data['membergroupcount'] = 0;
     $membergroupbits = '';
     foreach ($membergroups as $usergroupid) {
         $usergroup = $this->registry->usergroupcache["{$usergroupid}"];
         if ($usergroup['ispublicgroup']) {
             $templater = vB_Template::create('memberinfo_publicgroupbit');
             $templater->register('usergroup', $usergroup);
             $membergroupbits .= $templater->render();
             $this->block_data['membergroupcount']++;
         }
     }
     $this->block_data['membergroupbits'] = $membergroupbits;
     if ($this->registry->options['socnet'] & $this->registry->bf_misc_socnet['enable_groups']) {
         $socialgroups = $this->registry->db->query_read_slave("\n\t\t\t\tSELECT socialgroup.groupid, socialgroup.name, socialgroup.description, socialgroup.dateline, sgicon.dateline AS icondateline,\n\t\t\t\t\tsgicon.thumbnail_width AS iconthumb_width, sgicon.thumbnail_height AS iconthumb_height\n\t\t\t\tFROM " . TABLE_PREFIX . "socialgroupmember AS socialgroupmember\n\t\t\t\tINNER JOIN " . TABLE_PREFIX . "socialgroup AS socialgroup ON\n\t\t\t\t\t(socialgroup.groupid = socialgroupmember.groupid)\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "socialgroupicon AS sgicon ON sgicon.groupid = socialgroup.groupid\n\t\t\t\tWHERE\n\t\t\t\t\tsocialgroupmember.userid = " . $this->profile->userinfo['userid'] . "\n\t\t\t\t\tAND socialgroupmember.type = 'member'\n\t\t\t\tORDER BY socialgroup.name\n\t\t\t");
         $showgrouplink = $this->registry->userinfo['permissions']['socialgrouppermissions'] & $this->registry->bf_ugp_socialgrouppermissions['canviewgroups'] ? true : false;
         require_once DIR . '/includes/functions_socialgroup.php';
         $socialgroupbits = '';
         $useicons = $this->registry->db->num_rows($socialgroups) <= 12;
         while ($socialgroup = $this->registry->db->fetch_array($socialgroups)) {
             $socialgroup = prepare_socialgroup($socialgroup);
             if (!$useicons) {
                 $socialgroup['name_html'] = fetch_word_wrapped_string(fetch_censored_text($socialgroup['name']));
             }
             if ($useicons) {
                 $templater = vB_Template::create('memberinfo_socialgroupbit');
             } else {
                 $templater = vB_Template::create('memberinfo_socialgroupbit_text');
             }
             $templater->register('showgrouplink', $showgrouplink);
             $templater->register('socialgroup', $socialgroup);
             $socialgroupbits .= $templater->render();
         }
         $this->block_data['socialgroupbits'] = $socialgroupbits;
         $this->block_data['socialgroupcount'] = $this->registry->db->num_rows($socialgroups);
     } else {
         $this->block_data['socialgroupbits'] = '';
         $this->block_data['socialgroupcount'] = 0;
     }
     $this->block_data['show_join_link'] = ((!empty($this->block_data['socialgroupbits']) or $this->profile->prepared['myprofile']) and $this->registry->userinfo['permissions']['socialgrouppermissions'] & $this->registry->bf_ugp_socialgrouppermissions['canjoingroups'] and $this->registry->options['socnet'] & $this->registry->bf_misc_socnet['enable_groups']);
 }
Пример #17
0
	/**
	* Verifies the description is valid and sets up the title for saving (wordwrap, censor, etc).
	*
	* @param	string	Title text
	*
	* @param	bool	Whether the title is valid
	*/
	function verify_description(&$desc)
	{
		// replace html-encoded spaces with actual spaces
		$desc = preg_replace('/&#(0*32|x0*20);/', ' ', $desc);

		require_once(DIR . '/includes/functions_newpost.php');
		// censor, remove all caps subjects, and htmlspecialchars post title
		$desc = htmlspecialchars_uni(fetch_no_shouting_text(fetch_censored_text(trim($desc))));

		// do word wrapping
		$desc = fetch_word_wrapped_string($desc, $this->registry->options['blog_wordwrap']);

		return true;
	}
Пример #18
0
/**
 * Takes information regardign a group, and prepares the information within it
 * for display
 *
 * @param	array	Group Array
 *
 * @return	array	Group Array with prepared information
 *
 */
function prepare_socialgroup($group)
{
    global $vbulletin;
    if (!is_array($group)) {
        return array();
    }
    $group['joindate'] = $group['joindate'] ? vbdate($vbulletin->options['dateformat'], $group['joindate'], true) : '';
    $group['createdate'] = $group['createdate'] ? vbdate($vbulletin->options['dateformat'], $group['createdate'], true) : '';
    $group['members'] = vb_number_format($group['members']);
    $group['moderatedmembers'] = vb_number_format($group['moderatedmembers']);
    if (!($group['options'] & $vbulletin->bf_misc_socialgroupoptions['enable_group_albums'])) {
        // albums disabled in this group - force 0 pictures
        $group['picturecount'] = 0;
    }
    $group['rawpicturecount'] = $group['picturecount'];
    $group['picturecount'] = vb_number_format($group['picturecount']);
    $group['rawname'] = $group['name'];
    $group['rawdescription'] = $group['description'];
    $group['name'] = fetch_word_wrapped_string(fetch_censored_text($group['name']));
    $group['shortdescription'] = fetch_word_wrapped_string(fetch_censored_text(fetch_trimmed_title($group['description'], 200)));
    $group['description'] = nl2br(fetch_word_wrapped_string(fetch_censored_text($group['description'])));
    $group['is_owner'] = $group['creatoruserid'] == $vbulletin->userinfo['userid'];
    $group['is_automoderated'] = ($group['options'] & $vbulletin->bf_misc_socialgroupoptions['owner_mod_queue'] and $vbulletin->options['sg_allow_owner_mod_queue'] and !$vbulletin->options['social_moderation']);
    $group['canviewcontent'] = (!($group['options'] & $vbulletin->bf_misc_socialgroupoptions['join_to_view']) or !$vbulletin->options['sg_allow_join_to_view'] or $group['membertype'] == 'member' or can_moderate(0, 'canmoderategroupmessages') or can_moderate(0, 'canremovegroupmessages') or can_moderate(0, 'candeletegroupmessages') or can_moderate(0, 'candeletegroupmessages'));
    $group['lastpostdate'] = vbdate($vbulletin->options['dateformat'], $group['lastpost'], true);
    $group['lastposttime'] = vbdate($vbulletin->options['timeformat'], $group['lastpost']);
    $group['lastposterid'] = $group['canviewcontent'] ? $group['lastposterid'] : 0;
    $group['lastposter'] = $group['canviewcontent'] ? $group['lastposter'] : '';
    ($hook = vBulletinHook::fetch_hook('group_prepareinfo')) ? eval($hook) : false;
    return $group;
}
Пример #19
0
        $vbulletin->url = fetch_seo_url('entry', $bloginfo);
        eval(print_standard_redirect('redirect_blog_sentemail'));
    } else {
        $_REQUEST['do'] = 'sendtofriend';
        $show['errors'] = true;
        foreach ($errors as $errormessage) {
            $templater = vB_Template::create('newpost_errormessage');
            $templater->register('errormessage', $errormessage);
            $errormessages .= $templater->render();
        }
    }
}
// ############################### start send to friend ###############################
if ($_REQUEST['do'] == 'sendtofriend') {
    ($hook = vBulletinHook::fetch_hook('blog_sendtofriend_start')) ? eval($hook) : false;
    $bloginfo['title'] = fetch_word_wrapped_string($bloginfo['title'], $vbulletin->options['blog_wordwrap']);
    if ($show['errors']) {
        $stf = array('name' => htmlspecialchars_uni($vbulletin->GPC['sendtoname']), 'email' => htmlspecialchars_uni($vbulletin->GPC['sendtoemail']), 'title' => htmlspecialchars_uni($vbulletin->GPC['emailsubject']), 'message' => htmlspecialchars_uni($vbulletin->GPC['emailmessage']));
    } else {
        $stf = array('name' => '', 'email' => '', 'title' => $bloginfo['title'], 'message' => construct_phrase($vbphrase['blog_thought_might_be_interested'], $vbulletin->options['bburl'], $bloginfo['blogid'], $vbulletin->userinfo['userid'], $vbulletin->userinfo['username']));
    }
    $usernamecode = vB_Template::create('newpost_usernamecode')->render();
    // image verification
    $human_verify = '';
    if (fetch_require_hvcheck('contactus')) {
        require_once DIR . '/includes/class_humanverify.php';
        $verification =& vB_HumanVerify::fetch_library($vbulletin);
        $human_verify = $verification->output_token();
    }
    $sidebar =& build_user_sidebar($bloginfo);
    $navbits[fetch_seo_url('blog', $bloginfo, null, 'userid', 'blog_title')] = $bloginfo['blog_title'];
Пример #20
0
        }
        $pendingfriendrequests = vb_number_format($pendingfriendrequests);
    }
}
// ############################### start visitor messages ###############################
$show['newvisitormessages'] = false;
if ($vbulletin->userinfo['vm_enable'] and $vbulletin->options['socnet'] & $vbulletin->bf_misc_socnet['enable_visitor_messaging'] and $vbulletin->userinfo['permissions']['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canviewmembers']) {
    list($newvisitormessages) = $vbulletin->db->query_first("\n\t\tSELECT COUNT(*)\n\t\tFROM " . TABLE_PREFIX . "visitormessage\n\t\t\tWHERE userid = " . $vbulletin->userinfo['userid'] . "\n\t\t\tAND state = 'visible'\n\t\t\tAND postuserid <>  " . $vbulletin->userinfo['userid'] . "\n\t\t\tAND messageread = 0\n\t\tGROUP BY userid\n\t", DBARRAY_NUM);
    $show['newvisitormessages'] = $newvisitormessages ? true : false;
    if ($show['newvisitormessages']) {
        $visitormessages = $db->query_read("\n\t\t\tSELECT user.username, user.userid, visitormessage.vmid, visitormessage.dateline, visitormessage.pagetext\n\t\t\tFROM " . TABLE_PREFIX . "user AS user\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "visitormessage AS visitormessage ON (user.userid = visitormessage.postuserid)\n\t\t\tWHERE visitormessage.userid = " . $vbulletin->userinfo['userid'] . "\n\t\t\t\tAND visitormessage.state = 'visible'\n\t\t\t\tAND visitormessage.messageread = 0\n\t\t\tORDER BY visitormessage.dateline DESC\n\t\t\tLIMIT " . min($newvisitormessages, 5));
        $newvisitormessagebits = '';
        while ($visitormessage = $db->fetch_array($visitormessages)) {
            $visitormessage['formatteddate'] = vbdate($vbulletin->options['dateformat'], $visitormessage['dateline'], true);
            $visitormessage['formattedtime'] = vbdate($vbulletin->options['timeformat'], $visitormessage['dateline'], true);
            $visitormessage['summary'] = fetch_word_wrapped_string(fetch_censored_text(fetch_trimmed_title(strip_bbcode($visitormessage['pagetext'], true, true), 50)));
            $username = $visitormessage["username"];
            $userid = $visitormessage["userid"];
            eval('$userbit = "' . fetch_template('pm_messagelistbit_user') . '";');
            eval('$newvisitormessagebits .= "' . fetch_template('usercp_newvisitormessagebit') . '";');
        }
        $newpublicmessages = vb_number_format($newpublicmessages);
    }
}
// ############################### start social groups ###############################
$show['groupattention'] = false;
if ($vbulletin->options['socnet'] & $vbulletin->bf_misc_socnet['enable_groups']) {
    list($groupsneedattention) = $vbulletin->db->query_first("\n\t\tSELECT COUNT(*)\n\t\tFROM " . TABLE_PREFIX . "socialgroup\n\t\tWHERE creatoruserid = " . $vbulletin->userinfo['userid'] . "\n\t\t\tAND moderatedmembers > 0\n\t", DBARRAY_NUM);
    $show['groupattention'] = $groupsneedattention ? true : false;
    if ($show['groupattention']) {
        $groups = $db->query_read("\n\t\t\tSELECT *\n\t\t\tFROM " . TABLE_PREFIX . "socialgroup\n\t\t\tWHERE creatoruserid = " . $vbulletin->userinfo['userid'] . "\n\t\t\t\tAND moderatedmembers > 0\n\t\t\tORDER by dateline ASC\n\t\t");
Пример #21
0
 $perpage = $vbulletin->options['albums_perpage'];
 $total_pages = max(ceil($albumcount['total'] / $perpage), 1);
 // handle the case of 0 albums
 $pagenumber = $vbulletin->GPC['pagenumber'] > $total_pages ? $total_pages : $vbulletin->GPC['pagenumber'];
 $start = ($pagenumber - 1) * $perpage;
 $hook_query_fields = $hook_query_joins = $hook_query_where = '';
 ($hook = vBulletinHook::fetch_hook('album_user_query')) ? eval($hook) : false;
 // fetch data and prepare data
 $albums = $db->query_read("\n\t\tSELECT album.*,\n\t\t\tpicture.pictureid, picture.extension, picture.idhash,\n\t\t\tpicture.thumbnail_dateline, picture.thumbnail_width, picture.thumbnail_height\n\t\t\t{$hook_query_fields}\n\t\tFROM " . TABLE_PREFIX . "album AS album\n\t\tLEFT JOIN " . TABLE_PREFIX . "picture AS picture ON (album.coverpictureid = picture.pictureid AND picture.thumbnail_filesize > 0)\n\t\t{$hook_query_joins}\n\t\tWHERE album.userid = {$userinfo['userid']}\n\t\t\tAND album.state IN ('" . implode("', '", $state) . "')\n\t\t\t{$hook_query_where}\n\t\tORDER BY album.lastpicturedate DESC\n\t\tLIMIT {$start}, {$perpage}\n\t");
 $albumbits = '';
 while ($album = $db->fetch_array($albums)) {
     $album['picturecount'] = vb_number_format($album['visible']);
     $album['picturedate'] = vbdate($vbulletin->options['dateformat'], $album['lastpicturedate'], true);
     $album['picturetime'] = vbdate($vbulletin->options['timeformat'], $album['lastpicturedate']);
     $album['description_html'] = nl2br(fetch_word_wrapped_string(fetch_censored_text($album['description'])));
     $album['title_html'] = fetch_word_wrapped_string(fetch_censored_text($album['title']));
     $album['coverthumburl'] = $album['pictureid'] ? fetch_picture_url($album, $album, true) : '';
     $album['coverdimensions'] = $album['thumbnail_width'] ? "width=\"{$album['thumbnail_width']}\" height=\"{$album['thumbnail_height']}\"" : '';
     if ($album['state'] == 'private') {
         $show['personalalbum'] = true;
         $albumtype = $vbphrase['private_album_paren'];
     } else {
         if ($album['state'] == 'profile') {
             $show['personalalbum'] = true;
             $albumtype = $vbphrase['profile_album_paren'];
         } else {
             $show['personalalbum'] = false;
         }
     }
     if ($album['moderation'] and (can_moderate(0, 'canmoderatepictures') or $vbulletin->userinfo['userid'] == $album['userid'])) {
         $show['moderated'] = true;
Пример #22
0
     if (!$pagenumber) {
         $pagenumber = 1;
     }
     $start = ($pagenumber - 1) * $perpage;
     $picturebits = '';
     $pictures = $vbulletin->db->query_read("\n\t\t\tSELECT SQL_CALC_FOUND_ROWS\n\t\t\t\tuser.*, albumpicture.dateline, albumpicture.albumid, album.title AS albumtitle\n\t\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\t,picture.pictureid, picture.extension, picture.filesize, picture.idhash, picture.caption,\n\t\t\t\tpicture.thumbnail_filesize, picture.thumbnail_dateline, picture.thumbnail_width, picture.thumbnail_height\n\t\t\t\t{$hook_query_fields}\n\t\t\tFROM " . TABLE_PREFIX . "picture AS picture\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "user AS user ON (picture.userid = user.userid)\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "albumpicture AS albumpicture ON (albumpicture.pictureid = picture.pictureid)\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "album AS album ON (album.albumid = albumpicture.albumid)\n\t\t\t" . ($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\t{$hook_query_joins}\n\t\t\tWHERE picture.state = 'moderation'\n\t\t\t\t{$datecut}\n\t\t\t\t{$hook_query_where}\n\t\t\tORDER BY {$sqlsortfield} {$sqlsortorder}\n\t\t\tLIMIT {$start}, {$perpage}\n\t\t");
     list($picturetotal) = $vbulletin->db->query_first("SELECT FOUND_ROWS()", DBARRAY_NUM);
     if ($start >= $picturetotal) {
         $pagenumber = ceil($picturetotal / $perpage);
     }
 } while ($start >= $picturetotal and $picturetotal);
 require_once DIR . '/includes/functions_album.php';
 $show['picture'] = true;
 while ($picture = $db->fetch_array($pictures)) {
     fetch_musername($picture);
     $picture['albumtitle'] = fetch_word_wrapped_string(fetch_censored_text($picture['albumtitle']));
     // $picture contains comment, picture, and album info
     $pictureinfo = prepare_pictureinfo_thumb($picture, $picture);
     eval('$picturebits .= "' . fetch_template('moderation_picturebit') . '";');
 }
 $pagenavbits = array("do=viewpics");
 if ($perpage != $vbulletin->options['vm_perpage']) {
     $pagenavbits[] = "pp={$perpage}";
 }
 if ($daysprune != ($vbulletin->userinfo['daysprune'] ? $vbulletin->userinfo['daysprune'] : 30)) {
     $pagenavbits[] = "daysprune={$daysprune}";
 }
 if ($sortfield != 'dateline') {
     $pagenavbits[] = "sortfield={$sortfield}";
 }
 if ($vbulletin->GPC['sortorder'] == 'asc') {
Пример #23
0
 /**
  * Word wraps the text if enabled.
  *
  * @param	string	Text to wrap
  *
  * @return	string	Wrapped text
  */
 function do_word_wrap($text)
 {
     if ($this->registry->options['wordwrap'] != 0) {
         $text = fetch_word_wrapped_string($text, false, '  ');
     }
     return $text;
 }
Пример #24
0
/**
* Fetches the tagbits for display in a thread.
*
* @param	array	Tags
*
* @return	string	Tag bits, including a none word and progress image
*/
function fetch_tagbits($tags)
{
	global $vbulletin, $vbphrase, $show, $template_hook;


	if ($tags)
	{
		$tag_array = explode(',', $tags);

		$tag_list = '';
		foreach ($tag_array AS $tag)
		{
			$tag = trim($tag);
			if ($tag === '')
			{
				continue;
			}
			$tag_url = urlencode(unhtmlspecialchars($tag));
			$tag = fetch_word_wrapped_string($tag);

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

//			$tag_list .= ($tag_list != '' ? ', ' : '');
			$templater = vB_Template::create('tagbit');
				$templater->register('tag', $tag);
				$templater->register('tag_url', $tag_url);
			$tag_list .= trim($templater->render());
		}
	}
	else
	{
		$tag_list = '';
	}

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

	$templater = vB_Template::create('tagbit_wrapper');
		$templater->register('tag_list', $tag_list);
	$wrapped = $templater->render();
	return $wrapped;
}
Пример #25
0
     print_no_permission();
 }
 if ($group['membertype'] != 'member' and !can_moderate(0, 'caneditalbumpicture')) {
     if ($vbulletin->userinfo['permissions']['socialgrouppermissions'] & $vbulletin->bf_ugp_socialgrouppermissions['canjoingroups'] and can_join_group($group)) {
         standard_error(fetch_error('must_be_group_member_view_add_pictures_join_x', 'group.php?' . $vbulletin->session->vars['sessionurl'] . 'do=join&amp;groupid=' . $group['groupid']));
     } else {
         standard_error(fetch_error('must_be_group_member_view_add_pictures'));
     }
 }
 $pictureinfo = fetch_socialgroup_picture($vbulletin->GPC['pictureid'], $group['groupid']);
 if (!$pictureinfo) {
     standard_error(fetch_error('invalidid', $vbphrase['picture'], $vbulletin->options['contactuslink']));
 }
 $pictureinfo['adddate'] = vbdate($vbulletin->options['dateformat'], $pictureinfo['dateline'], true);
 $pictureinfo['addtime'] = vbdate($vbulletin->options['timeformat'], $pictureinfo['dateline']);
 $pictureinfo['caption_html'] = nl2br(fetch_word_wrapped_string(fetch_censored_text($pictureinfo['caption'])));
 $navpictures_sql = $db->query_read_slave("\n\t\tSELECT socialgrouppicture.pictureid\n\t\tFROM " . TABLE_PREFIX . "socialgrouppicture AS socialgrouppicture\n\t\tINNER JOIN " . TABLE_PREFIX . "picture AS picture ON (socialgrouppicture.pictureid = picture.pictureid)\n\t\tINNER JOIN " . TABLE_PREFIX . "socialgroupmember AS socialgroupmember ON\n\t\t\t(socialgroupmember.userid = picture.userid AND socialgroupmember.groupid = {$group['groupid']} AND socialgroupmember.type = 'member')\n\t\tWHERE socialgrouppicture.groupid = {$group['groupid']}\n\t\tORDER BY socialgrouppicture.dateline DESC\n\t");
 $pic_location = fetch_picture_location_info($navpictures_sql, $pictureinfo['pictureid']);
 ($hook = vBulletinHook::fetch_hook('group_picture')) ? eval($hook) : false;
 $show['edit_picture_option'] = ($pictureinfo['userid'] == $vbulletin->userinfo['userid'] or can_moderate(0, 'caneditalbumpicture'));
 $show['remove_picture_option'] = ($pictureinfo['userid'] == $vbulletin->userinfo['userid'] or fetch_socialgroup_modperm('canremovepicture', $group));
 if ($show['edit_picture_option']) {
     // we need an album this picture is in to edit it
     $album = $db->query_first_slave("\n\t\t\tSELECT albumid\n\t\t\tFROM " . TABLE_PREFIX . "albumpicture\n\t\t\tWHERE pictureid = {$pictureinfo['pictureid']}\n\t\t\tLIMIT 1\n\t\t");
 }
 $show['reportlink'] = ($vbulletin->userinfo['userid'] and ($vbulletin->options['rpforumid'] or $vbulletin->options['enableemail'] and $vbulletin->options['rpemail']));
 if ($vbulletin->options['pc_enabled']) {
     require_once DIR . '/includes/functions_picturecomment.php';
     $pagenumber = $vbulletin->GPC['pagenumber'];
     $perpage = $vbulletin->GPC['perpage'];
     $picturecommentbits = fetch_picturecommentbits($pictureinfo, $messagestats, $pagenumber, $perpage, $vbulletin->GPC['commentid'], $vbulletin->GPC['showignored']);
Пример #26
0
 /**
  * Verifies that the title is valid
  *
  * @param	String	Title
  *
  * @return 	boolean	Returns true if title is valid
  */
 function verify_title(&$title)
 {
     // replace html-encoded spaces with actual spaces
     $title = preg_replace('/&#(0*32|x0*20);/', ' ', $title);
     // do word wrapping
     if ($this->registry->options['wordwrap'] != 0) {
         $title = fetch_word_wrapped_string($title);
     }
     require_once DIR . '/includes/functions_newpost.php';
     // censor, remove all caps subjects, and htmlspecialchars post title
     $title = htmlspecialchars_uni(fetch_no_shouting_text(fetch_censored_text($title)));
     $title = trim($title);
     if (empty($title)) {
         $this->error('invalid_title_specified');
         return false;
     }
     return true;
 }
Пример #27
0
$threadinfo =& $thread;
($hook = vBulletinHook::fetch_hook('showthread_getinfo')) ? eval($hook) : false;
// *********************************************************************************
// check for visible / deleted thread
if (!$thread['visible'] and !can_moderate($thread['forumid'], 'canmoderateposts') or $thread['isdeleted'] and !can_moderate($thread['forumid'])) {
    eval(standard_error(fetch_error('invalidid', $vbphrase['thread'], $vbulletin->options['contactuslink'])));
}
// *********************************************************************************
// Tachy goes to coventry
if (in_coventry($thread['postuserid']) and !can_moderate($thread['forumid'])) {
    eval(standard_error(fetch_error('invalidid', $vbphrase['thread'], $vbulletin->options['contactuslink'])));
}
// *********************************************************************************
// do word wrapping for the thread title
if ($vbulletin->options['wordwrap'] != 0) {
    $thread['title'] = fetch_word_wrapped_string($thread['title']);
}
$thread['title'] = fetch_censored_text($thread['title']);
$thread['meta_description'] = strip_bbcode(strip_quotes($thread['description']), false, true);
$thread['meta_description'] = htmlspecialchars_uni(fetch_censored_text(fetch_trimmed_title($thread['meta_description'], 500, false)));
// *********************************************************************************
// words to highlight from the search engine
if (!empty($vbulletin->GPC['highlight'])) {
    $highlight = preg_replace('#\\*+#s', '*', $vbulletin->GPC['highlight']);
    if ($highlight != '*') {
        $regexfind = array('\\*', '\\<', '\\>');
        $regexreplace = array('[\\w.:@*/?=]*?', '<', '>');
        $highlight = preg_quote(strtolower($highlight), '#');
        $highlight = explode(' ', $highlight);
        $highlight = str_replace($regexfind, $regexreplace, $highlight);
        foreach ($highlight as $val) {
Пример #28
0
function do_get_thread()
{
    global $vbulletin, $db, $foruminfo, $threadinfo, $postid, $vault, $vbphrase;
    $vbulletin->input->clean_array_gpc('r', array('pagenumber' => TYPE_UINT, 'perpage' => TYPE_UINT, 'password' => TYPE_STR, 'signature' => TYPE_BOOL));
    if (empty($threadinfo['threadid'])) {
        json_error(ERR_INVALID_THREAD);
    }
    $threadedmode = 0;
    $threadid = $vbulletin->GPC['threadid'];
    // Goto first unread post?
    if ($vbulletin->GPC['pagenumber'] == FR_LAST_POST) {
        $threadinfo = verify_id('thread', $threadid, 1, 1);
        if ($vbulletin->options['threadmarking'] and $vbulletin->userinfo['userid']) {
            $vbulletin->userinfo['lastvisit'] = max($threadinfo['threadread'], $threadinfo['forumread'], TIMENOW - $vbulletin->options['markinglimit'] * 86400);
        } else {
            if (($tview = intval(fetch_bbarray_cookie('thread_lastview', $threadid))) > $vbulletin->userinfo['lastvisit']) {
                $vbulletin->userinfo['lastvisit'] = $tview;
            }
        }
        $coventry = fetch_coventry('string');
        $posts = $db->query_first("\n\t    SELECT MIN(postid) AS postid\n\t    FROM " . TABLE_PREFIX . "post\n\t    WHERE threadid = {$threadinfo['threadid']}\n\t    AND visible = 1\n\t    AND dateline > " . intval($vbulletin->userinfo['lastvisit']) . "\n\t    " . ($coventry ? "AND userid NOT IN ({$coventry})" : "") . "\n\t    LIMIT 1\n\t");
        if ($posts['postid']) {
            $postid = $posts['postid'];
        } else {
            $postid = $threadinfo['lastpostid'];
        }
    }
    // *********************************************************************************
    // workaround for header redirect issue from forms with enctype in IE
    // (use a scrollIntoView javascript call in the <body> onload event)
    $onload = '';
    // *********************************************************************************
    // set $perpage
    $perpage = max(FR_MIN_PERPAGE, min($vbulletin->GPC['perpage'], FR_MAX_PERPAGE));
    // FRNR
    //$perpage = sanitize_maxposts($vbulletin->GPC['perpage']);
    // *********************************************************************************
    // set post order
    if ($vbulletin->userinfo['postorder'] == 0) {
        $postorder = '';
    } else {
        $postorder = 'DESC';
    }
    // *********************************************************************************
    // get thread info
    $thread = verify_id('thread', $threadid, 1, 1);
    $threadinfo =& $thread;
    ($hook = vBulletinHook::fetch_hook('showthread_getinfo')) ? eval($hook) : false;
    // *********************************************************************************
    // check for visible / deleted thread
    if (!$thread['visible'] and !can_moderate($thread['forumid'], 'canmoderateposts') or $thread['isdeleted'] and !can_moderate($thread['forumid'])) {
        json_error(ERR_INVALID_THREAD);
    }
    // *********************************************************************************
    // Tachy goes to coventry
    if (in_coventry($thread['postuserid']) and !can_moderate($thread['forumid'])) {
        json_error(ERR_INVALID_THREAD);
    }
    // FRNR Start
    // Check the forum password (set necessary cookies)
    if ($vbulletin->GPC['password'] && $foruminfo['password'] == $vbulletin->GPC['password']) {
        // set a temp cookie for guests
        if (!$vbulletin->userinfo['userid']) {
            set_bbarray_cookie('forumpwd', $foruminfo['forumid'], md5($vbulletin->userinfo['userid'] . $vbulletin->GPC['password']));
        } else {
            set_bbarray_cookie('forumpwd', $foruminfo['forumid'], md5($vbulletin->userinfo['userid'] . $vbulletin->GPC['password']), 1);
        }
    }
    // FRNR End
    // *********************************************************************************
    // do word wrapping for the thread title
    if ($vbulletin->options['wordwrap'] != 0) {
        $thread['title'] = fetch_word_wrapped_string($thread['title']);
    }
    $thread['title'] = fetch_censored_text($thread['title']);
    $thread['meta_description'] = strip_bbcode(strip_quotes($thread['description']), false, true);
    $thread['meta_description'] = htmlspecialchars_uni(fetch_censored_text(fetch_trimmed_title($thread['meta_description'], 500, false)));
    // *********************************************************************************
    // words to highlight from the search engine
    if (!empty($vbulletin->GPC['highlight'])) {
        $highlight = preg_replace('#\\*+#s', '*', $vbulletin->GPC['highlight']);
        if ($highlight != '*') {
            $regexfind = array('\\*', '\\<', '\\>');
            $regexreplace = array('[\\w.:@*/?=]*?', '<', '>');
            $highlight = preg_quote(strtolower($highlight), '#');
            $highlight = explode(' ', $highlight);
            $highlight = str_replace($regexfind, $regexreplace, $highlight);
            foreach ($highlight as $val) {
                if ($val = trim($val)) {
                    $replacewords[] = htmlspecialchars_uni($val);
                }
            }
        }
    }
    // *********************************************************************************
    // make the forum jump in order to fill the forum caches
    $navpopup = array('id' => 'showthread_navpopup', 'title' => $foruminfo['title_clean'], 'link' => fetch_seo_url('thread', $threadinfo));
    construct_quick_nav($navpopup);
    // *********************************************************************************
    // get forum info
    $forum = fetch_foruminfo($thread['forumid']);
    $foruminfo =& $forum;
    // *********************************************************************************
    // check forum permissions
    $forumperms = fetch_permissions($thread['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 ($thread['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
    if (!verify_forum_password($foruminfo['forumid'], $foruminfo['password'])) {
        // FRNR
        json_error(ERR_NEED_PASSWORD, RV_NEED_FORUM_PASSWORD);
    }
    // verify that we are at the canonical SEO url
    // and redirect to this if not
    //verify_seo_url('thread|js', $threadinfo, array('pagenumber' => $_REQUEST['pagenumber']));
    // *********************************************************************************
    // jump page if thread is actually a redirect
    if ($thread['open'] == 10) {
        $destthreadinfo = fetch_threadinfo($threadinfo['pollid']);
        exec_header_redirect(fetch_seo_url('thread|js', $destthreadinfo, $pageinfo));
    }
    // *********************************************************************************
    // get ignored users
    $ignore = array();
    if (trim($vbulletin->userinfo['ignorelist'])) {
        $ignorelist = preg_split('/( )+/', trim($vbulletin->userinfo['ignorelist']), -1, PREG_SPLIT_NO_EMPTY);
        foreach ($ignorelist as $ignoreuserid) {
            $ignore["{$ignoreuserid}"] = 1;
        }
    }
    DEVDEBUG('ignored users: ' . implode(', ', array_keys($ignore)));
    // *********************************************************************************
    // filter out deletion notices if can't be seen
    if ($forumperms & $vbulletin->bf_ugp_forumpermissions['canseedelnotice'] or can_moderate($threadinfo['forumid'])) {
        $deljoin = "LEFT JOIN " . TABLE_PREFIX . "deletionlog AS deletionlog ON(post.postid = deletionlog.primaryid AND deletionlog.type = 'post')";
    } else {
        $deljoin = '';
    }
    $show['viewpost'] = can_moderate($threadinfo['forumid']) ? true : false;
    $show['managepost'] = iif(can_moderate($threadinfo['forumid'], 'candeleteposts') or can_moderate($threadinfo['forumid'], 'canremoveposts'), true, false);
    $show['approvepost'] = can_moderate($threadinfo['forumid'], 'canmoderateposts') ? true : false;
    $show['managethread'] = can_moderate($threadinfo['forumid'], 'canmanagethreads') ? true : false;
    $show['approveattachment'] = can_moderate($threadinfo['forumid'], 'canmoderateattachments') ? true : false;
    $show['inlinemod'] = (!$show['threadedmode'] and ($show['managethread'] or $show['managepost'] or $show['approvepost'])) ? true : false;
    $show['spamctrls'] = ($show['inlinemod'] and $show['managepost']);
    $url = $show['inlinemod'] ? SCRIPTPATH : '';
    // build inline moderation popup
    if ($show['popups'] and $show['inlinemod']) {
        $threadadmin_imod_menu_post = vB_Template::create('threadadmin_imod_menu_post')->render();
    } else {
        $threadadmin_imod_menu_post = '';
    }
    // *********************************************************************************
    // find the page that we should be on to display this post
    if (!empty($postid) and $threadedmode == 0) {
        $postinfo = verify_id('post', $postid, 1, 1);
        $threadid = $postinfo['threadid'];
        $getpagenum = $db->query_first("\n    \t\tSELECT COUNT(*) AS posts\n    \t\tFROM " . TABLE_PREFIX . "post AS post\n    \t\tWHERE threadid = {$threadid} AND visible = 1\n    \t\tAND dateline " . iif(!$postorder, '<=', '>=') . " {$postinfo['dateline']}\n    \t");
        $vbulletin->GPC['pagenumber'] = ceil($getpagenum['posts'] / $perpage);
    }
    // *********************************************************************************
    // update views counter
    if ($vbulletin->options['threadviewslive']) {
        // doing it as they happen; for optimization purposes, this cannot use a DM!
        $db->shutdown_query("\n    \t\tUPDATE " . TABLE_PREFIX . "thread\n    \t\tSET views = views + 1\n    \t\tWHERE threadid = " . intval($threadinfo['threadid']));
    } else {
        // or doing it once an hour
        $db->shutdown_query("\n    \t\tINSERT INTO " . TABLE_PREFIX . "threadviews (threadid)\n    \t\tVALUES (" . intval($threadinfo['threadid']) . ')');
    }
    // *********************************************************************************
    // display ratings if enabled
    $show['rating'] = false;
    if ($forum['allowratings'] == 1) {
        if ($thread['votenum'] > 0) {
            $thread['voteavg'] = vb_number_format($thread['votetotal'] / $thread['votenum'], 2);
            $thread['rating'] = intval(round($thread['votetotal'] / $thread['votenum']));
            if ($thread['votenum'] >= $vbulletin->options['showvotes']) {
                $show['rating'] = true;
            }
        }
        devdebug("threadinfo[vote] = {$threadinfo['vote']}");
        if ($threadinfo['vote']) {
            $voteselected["{$threadinfo['vote']}"] = 'selected="selected"';
            $votechecked["{$threadinfo['vote']}"] = 'checked="checked"';
        } else {
            $voteselected[0] = 'selected="selected"';
            $votechecked[0] = 'checked="checked"';
        }
    }
    // *********************************************************************************
    // set page number
    if ($vbulletin->GPC['pagenumber'] < 1) {
        $vbulletin->GPC['pagenumber'] = 1;
    } else {
        if ($vbulletin->GPC['pagenumber'] > ceil(($thread['replycount'] + 1) / $perpage)) {
            $vbulletin->GPC['pagenumber'] = ceil(($thread['replycount'] + 1) / $perpage);
        }
    }
    // *********************************************************************************
    // initialise some stuff...
    $limitlower = ($vbulletin->GPC['pagenumber'] - 1) * $perpage;
    $limitupper = $vbulletin->GPC['pagenumber'] * $perpage;
    $counter = 0;
    if ($vbulletin->options['threadmarking'] and $vbulletin->userinfo['userid']) {
        $threadview = max($threadinfo['threadread'], $threadinfo['forumread'], TIMENOW - $vbulletin->options['markinglimit'] * 86400);
    } else {
        $threadview = intval(fetch_bbarray_cookie('thread_lastview', $thread['threadid']));
        if (!$threadview) {
            $threadview = $vbulletin->userinfo['lastvisit'];
        }
    }
    $threadinfo['threadview'] = intval($threadview);
    $displayed_dateline = 0;
    ################################################################################
    ############################### SHOW POLL ######################################
    ################################################################################
    $poll = '';
    if ($thread['pollid']) {
        $pollbits = '';
        $counter = 1;
        $pollid = $thread['pollid'];
        $show['editpoll'] = iif(can_moderate($threadinfo['forumid'], 'caneditpoll'), true, false);
        // get poll info
        $pollinfo = $db->query_first_slave("\n    \t\tSELECT *\n    \t\tFROM " . TABLE_PREFIX . "poll\n    \t\tWHERE pollid = {$pollid}\n    \t");
        require_once DIR . '/includes/class_bbcode.php';
        $bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list());
        $pollinfo['question'] = $bbcode_parser->parse(unhtmlspecialchars($pollinfo['question']), $forum['forumid'], 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 !$thread['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;
            }
        }
        ($hook = vBulletinHook::fetch_hook('showthread_poll_start')) ? eval($hook) : false;
        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\t\tSELECT voteoption\n    \t\t\tFROM " . TABLE_PREFIX . "pollvote\n    \t\t\tWHERE userid = " . $vbulletin->userinfo['userid'] . " AND pollid = {$pollid}\n    \t\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;
                }
            }
        }
        $left = vB_Template_Runtime::fetchStyleVar('left');
        $right = vB_Template_Runtime::fetchStyleVar('right');
        $option['open'] = $left[0];
        $option['close'] = $right[0];
        foreach ($splitvotes as $index => $value) {
            $arrayindex = $index + 1;
            $option['uservote'] = iif($uservote["{$arrayindex}"], true, false);
            $option['question'] = $bbcode_parser->parse($splitoptions["{$index}"], $forum['forumid'], true);
            // public link
            if ($pollinfo['public'] and $value) {
                $option['votes'] = '<a href="poll.php?' . $vbulletin->session->vars['sessionurl'] . 'do=showresults&amp;pollid=' . $pollinfo['pollid'] . '">' . vb_number_format($value) . '</a>';
            } else {
                $option['votes'] = vb_number_format($value);
                //get the vote count for the option
            }
            $option['number'] = $counter;
            //number of the option
            //Now we check if the user has voted or not
            if ($showresults or $uservoted) {
                // user did vote or poll is closed
                if ($value <= 0) {
                    $option['percentraw'] = 0;
                } else {
                    if ($pollinfo['multiple']) {
                        $option['percentraw'] = $value < $pollinfo['voters'] ? $value / $pollinfo['voters'] * 100 : 100;
                    } else {
                        $option['percentraw'] = $value < $pollinfo['numbervotes'] ? $value / $pollinfo['numbervotes'] * 100 : 100;
                    }
                }
                $option['percent'] = vb_number_format($option['percentraw'], 2);
                $option['graphicnumber'] = $option['number'] % 6 + 1;
                $option['barnumber'] = round($option['percent']) * 2;
                $option['remainder'] = 201 - $option['barnumber'];
                // 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'];
                        }
                    }
                }
                ($hook = vBulletinHook::fetch_hook('showthread_polloption')) ? eval($hook) : false;
                $templater = vB_Template::create('pollresult');
                $templater->register('names', $names);
                $templater->register('option', $option);
                $pollbits .= $templater->render();
            } else {
                ($hook = vBulletinHook::fetch_hook('showthread_polloption')) ? eval($hook) : false;
                if ($pollinfo['multiple']) {
                    $templater = vB_Template::create('polloption_multiple');
                    $templater->register('option', $option);
                    $pollbits .= $templater->render();
                } else {
                    $templater = vB_Template::create('polloption');
                    $templater->register('option', $option);
                    $pollbits .= $templater->render();
                }
            }
            $counter++;
        }
        if ($pollinfo['multiple']) {
            $pollinfo['numbervotes'] = $pollinfo['voters'];
            $show['multiple'] = true;
        }
        if ($pollinfo['public']) {
            $show['publicwarning'] = true;
        } else {
            $show['publicwarning'] = false;
        }
        $displayed_dateline = $threadinfo['lastpost'];
        ($hook = vBulletinHook::fetch_hook('showthread_poll_complete')) ? eval($hook) : false;
        if ($showresults or $uservoted) {
            $templater = vB_Template::create('pollresults_table');
            $templater->register('pollbits', $pollbits);
            $templater->register('pollenddate', $pollenddate);
            $templater->register('pollendtime', $pollendtime);
            $templater->register('pollinfo', $pollinfo);
            $templater->register('pollstatus', $pollstatus);
            $poll = $templater->render();
        } else {
            $templater = vB_Template::create('polloptions_table');
            $templater->register('pollbits', $pollbits);
            $templater->register('pollenddate', $pollenddate);
            $templater->register('pollendtime', $pollendtime);
            $templater->register('pollinfo', $pollinfo);
            $poll = $templater->render();
        }
    }
    // work out if quickreply should be shown or not
    if ($vbulletin->options['quickreply'] and !$thread['isdeleted'] and !is_browser('netscape') and $vbulletin->userinfo['userid'] and ($vbulletin->userinfo['userid'] == $threadinfo['postuserid'] and $forumperms & $vbulletin->bf_ugp_forumpermissions['canreplyown'] or $vbulletin->userinfo['userid'] != $threadinfo['postuserid'] and $forumperms & $vbulletin->bf_ugp_forumpermissions['canreplyothers']) and ($thread['open'] or can_moderate($threadinfo['forumid'], 'canopenclose')) and !fetch_require_hvcheck('post')) {
        $show['quickreply'] = true;
    } else {
        $show['quickreply'] = false;
        $show['wysiwyg'] = 0;
        $quickreply = '';
    }
    $show['largereplybutton'] = (!$thread['isdeleted'] and !$show['threadedmode'] and $forum['allowposting'] and !$show['search_engine']);
    if (!$forum['allowposting']) {
        $show['quickreply'] = false;
    }
    $show['multiquote_global'] = ($vbulletin->options['multiquote'] and $vbulletin->userinfo['userid']);
    if ($show['multiquote_global']) {
        $vbulletin->input->clean_array_gpc('c', array('vbulletin_multiquote' => TYPE_STR));
        $vbulletin->GPC['vbulletin_multiquote'] = explode(',', $vbulletin->GPC['vbulletin_multiquote']);
    }
    // post is cachable if option is enabled, last post is newer than max age, and this user
    // isn't showing a sessionhash
    $post_cachable = ($vbulletin->options['cachemaxage'] > 0 and TIMENOW - $vbulletin->options['cachemaxage'] * 60 * 60 * 24 <= $thread['lastpost'] and $vbulletin->session->vars['sessionurl'] == '');
    $saveparsed = '';
    $save_parsed_sigs = '';
    ($hook = vBulletinHook::fetch_hook('showthread_post_start')) ? eval($hook) : false;
    ################################################################################
    ####################### SHOW THREAD IN LINEAR MODE #############################
    ################################################################################
    if ($threadedmode == 0) {
        // allow deleted posts to not be counted in number of posts displayed on the page;
        // prevents issue with page count on forum display being incorrect
        $ids = array();
        $lastpostid = 0;
        $hook_query_joins = $hook_query_where = '';
        ($hook = vBulletinHook::fetch_hook('showthread_query_postids')) ? eval($hook) : false;
        if (empty($deljoin) and !$show['approvepost']) {
            $totalposts = $threadinfo['replycount'] + 1;
            if (can_moderate($thread['forumid'])) {
                $coventry = '';
            } else {
                $coventry = fetch_coventry('string');
            }
            $getpostids = $db->query_read("\n    \t\t\tSELECT post.postid\n    \t\t\tFROM " . TABLE_PREFIX . "post AS post\n    \t\t\t{$hook_query_joins}\n    \t\t\tWHERE post.threadid = {$threadid}\n    \t\t\t\tAND post.visible = 1\n    \t\t\t\t" . ($coventry ? "AND post.userid NOT IN ({$coventry})" : '') . "\n    \t\t\t\t{$hook_query_where}\n    \t\t\tORDER BY post.dateline {$postorder}\n    \t\t\tLIMIT {$limitlower}, {$perpage}\n    \t\t");
            while ($post = $db->fetch_array($getpostids)) {
                if (!isset($qrfirstpostid)) {
                    $qrfirstpostid = $post['postid'];
                }
                $qrlastpostid = $post['postid'];
                $ids[] = $post['postid'];
            }
            $db->free_result($getpostids);
            $lastpostid = $qrlastpostid;
        } else {
            $getpostids = $db->query_read("\n    \t\t\tSELECT post.postid, post.visible, post.userid\n    \t\t\tFROM " . TABLE_PREFIX . "post AS post\n    \t\t\t{$hook_query_joins}\n    \t\t\tWHERE post.threadid = {$threadid}\n    \t\t\t\tAND post.visible IN (1\n    \t\t\t\t" . (!empty($deljoin) ? ",2" : "") . "\n    \t\t\t\t" . ($show['approvepost'] ? ",0" : "") . "\n    \t\t\t\t)\n    \t\t\t\t{$hook_query_where}\n    \t\t\tORDER BY post.dateline {$postorder}\n    \t\t");
            $totalposts = 0;
            if ($limitlower != 0) {
                $limitlower++;
            }
            while ($post = $db->fetch_array($getpostids)) {
                if (!isset($qrfirstpostid)) {
                    $qrfirstpostid = $post['postid'];
                }
                $qrlastpostid = $post['postid'];
                if ($post['visible'] == 1 and !in_coventry($post['userid']) and !$ignore[$post['userid']]) {
                    $totalposts++;
                }
                if ($totalposts < $limitlower or $totalposts > $limitupper) {
                    continue;
                }
                // remember, these are only added if they're going to be displayed
                $ids[] = $post['postid'];
                $lastpostid = $post['postid'];
            }
            $db->free_result($getpostids);
        }
        // '0' inside parenthesis in unlikely case we have no ids for this page
        // (this could happen if the replycount is wrong in the db)
        $postids = "post.postid IN (0" . implode(',', $ids) . ")";
        // load attachments
        if ($thread['attach']) {
            require_once DIR . '/packages/vbattach/attach.php';
            $attach = new vB_Attach_Display_Content($vbulletin, 'vBForum_Post');
            $postattach = $attach->fetch_postattach(0, $ids);
        }
        $hook_query_fields = $hook_query_joins = '';
        ($hook = vBulletinHook::fetch_hook('showthread_query')) ? eval($hook) : false;
        $posts = $db->query_read("\n    \t\tSELECT\n    \t\t\tpost.*, post.username AS postusername, post.ipaddress AS ip, IF(post.visible = 2, 1, 0) AS isdeleted,\n    \t\t\tuser.*, userfield.*, usertextfield.*,\n    \t\t\t" . iif($forum['allowicons'], 'icon.title as icontitle, icon.iconpath,') . "\n    \t\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\t" . ((can_moderate($thread['forumid'], 'canmoderateposts') or can_moderate($thread['forumid'], 'candeleteposts')) ? 'spamlog.postid AS spamlog_postid,' : '') . "\n    \t\t\t" . iif($deljoin, 'deletionlog.userid AS del_userid, deletionlog.username AS del_username, deletionlog.reason AS del_reason,') . "\n    \t\t\teditlog.userid AS edit_userid, editlog.username AS edit_username, editlog.dateline AS edit_dateline,\n    \t\t\teditlog.reason AS edit_reason, editlog.hashistory,\n    \t\t\tpostparsed.pagetext_html, postparsed.hasimages,\n    \t\t\tsigparsed.signatureparsed, sigparsed.hasimages AS sighasimages,\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" . iif(!($permissions['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canseehiddencustomfields']), $vbulletin->profilefield['hidden']) . "\n    \t\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($forum['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($thread['forumid'], 'canmoderateposts') or can_moderate($thread['forumid'], 'candeleteposts')) ? "LEFT JOIN " . TABLE_PREFIX . "spamlog AS spamlog ON(spamlog.postid = post.postid)" : '') . "\n    \t\t\t{$deljoin}\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\t{$hook_query_joins}\n    \t\tWHERE {$postids}\n    \t\tORDER BY post.dateline {$postorder}\n    \t");
        if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canseethumbnails']) and !($forumperms & $vbulletin->bf_ugp_forumpermissions['cangetattachment'])) {
            $vbulletin->options['attachthumbs'] = 0;
        }
        if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['cangetattachment'])) {
            $vbulletin->options['viewattachedimages'] = 0;
        }
        $postcount = ($vbulletin->GPC['pagenumber'] - 1) * $perpage;
        if ($postorder) {
            // Newest first
            $postcount = $totalposts - $postcount + 1;
        }
        $counter = 0;
        $postbits = '';
        $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());
        while ($post = $db->fetch_array($posts)) {
            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 ($vbulletin->GPC['viewfull'] and $post['postid'] == $postinfo['postid'] and $fetchtype != 'post' and (can_moderate($threadinfo['forumid']) or !$post['isdeleted'])) {
                $fetchtype = 'post';
            }
            if ($fetchtype != 'post' && $fetchtype != 'post_deleted') {
                continue;
            }
            ($hook = vBulletinHook::fetch_hook('showthread_postbit_create')) ? eval($hook) : false;
            $postbit_obj =& $postbit_factory->fetch_postbit($fetchtype);
            if ($fetchtype == 'post') {
                $postbit_obj->highlight =& $replacewords;
            }
            $postbit_obj->cachable = $post_cachable;
            $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);
            $postbits .= $postbit_obj->construct_postbit($post);
            // Only show after the first post, counter isn't incremented for deleted/moderated posts
            if ($post['isfirstshown']) {
                $postbits .= vB_Template::create('ad_showthread_firstpost')->render();
            }
            if ($post_cachable and $post['pagetext_html'] == '') {
                if (!empty($saveparsed)) {
                    $saveparsed .= ',';
                }
                $saveparsed .= "({$post['postid']}, " . intval($thread['lastpost']) . ', ' . intval($postbit_obj->post_cache['has_images']) . ", '" . $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) . ", '" . $db->escape_string($postbit_obj->sig_cache['text']) . "', " . intval($postbit_obj->sig_cache['has_images']) . ")";
            }
            // get first and last post ids for this page (for big reply buttons)
            if (!isset($FIRSTPOSTID)) {
                $FIRSTPOSTID = $post['postid'];
            }
            $LASTPOSTID = $post['postid'];
            if ($post['dateline'] > $displayed_dateline) {
                $displayed_dateline = $post['dateline'];
                if ($displayed_dateline <= $threadview) {
                    $updatethreadcookie = true;
                }
            }
            // FRNR Start
            // find out if first post
            $getpost = $db->query_first("\n                    SELECT firstpostid\n                    FROM " . TABLE_PREFIX . "thread\n                    WHERE threadid = {$threadinfo['threadid']}\n                ");
            $isfirstpost = $getpost['firstpostid'] == $post['postid'];
            $candelete = false;
            if ($isfirstpost and can_moderate($threadinfo['forumid'], 'canmanagethreads')) {
                $candelete = true;
            } else {
                if (!$isfirstpost and can_moderate($threadinfo['forumid'], 'candeleteposts')) {
                    $candelete = true;
                } else {
                    if (($forumperms & $vbulletin->bf_ugp_forumpermissions['candeletepost'] and !$isfirstpost or $forumperms & $vbulletin->bf_ugp_forumpermissions['candeletethread'] and $isfirstpost) and $vbulletin->userinfo['userid'] == $post['userid']) {
                        $candelete = true;
                    }
                }
            }
            // Get post date/time
            $postdate = vbdate($vbulletin->options['dateformat'], $post['dateline'], 1);
            $posttime = vbdate($vbulletin->options['timeformat'], $post['dateline']);
            $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'], $post['allowsmilie'] && $usesmilies);
            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 = '';
            // Avatar work
            if ($post['avatarurl']) {
                $avatarurl = process_avatarurl($post['avatarurl']);
            }
            $tmp = array('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']), 'online' => fetch_online_status(fetch_userinfo($post['userid']), false), 'post_timestamp' => prepare_utf8_string(date_trunc($postdate) . ' ' . $posttime), 'fr_images' => $fr_images);
            if ($candelete) {
                $tmp['candelete'] = true;
            }
            // Soft Deleted
            if ($post['visible'] == 2) {
                $tmp['deleted'] = true;
                $tmp['del_username'] = prepare_utf8_string($post['del_username']);
                if ($post['del_reason']) {
                    $tmp['del_reason'] = prepare_utf8_string($post['del_reason']);
                }
            } else {
                $tmp['text'] = $text;
                $tmp['quotable'] = $nuked_quotes;
                if ($post['editlink']) {
                    $tmp['canedit'] = true;
                    $tmp['edittext'] = prepare_utf8_string($post['pagetext']);
                }
            }
            if ($avatarurl != '') {
                $tmp['avatarurl'] = $avatarurl;
            }
            if (count($docattach) > 0) {
                $tmp['docattach'] = $docattach;
            }
            if ($vbulletin->GPC['signature']) {
                $sig = trim(remove_bbcode(strip_tags($post['signatureparsed']), true, true), '<a>');
                $sig = str_replace(array("\t", "\r"), array('', ''), $sig);
                $sig = str_replace("\n\n", "\n", $sig);
                $tmp['sig'] = prepare_utf8_string($sig);
            }
            // Begin Support for Post Thanks Hack - http://www.vbulletin.org/forum/showthread.php?t=122944
            if ($vbulletin->userinfo['userid'] && function_exists('post_thanks_off') && function_exists('can_thank_this_post') && function_exists('thanked_already') && function_exists('fetch_thanks')) {
                if (!post_thanks_off($thread['forumid'], $post, $thread['firstpostid'], THIS_SCRIPT)) {
                    global $ids;
                    if (can_thank_this_post($post, $thread['isdeleted'])) {
                        $tmp['canlike'] = true;
                    }
                    if (thanked_already($post, 0, true)) {
                        $tmp['likes'] = true;
                        if (!$vbulletin->options['post_thanks_delete_own']) {
                            $tmp['canlike'] = $tmp['likes'] = false;
                        }
                    }
                    $thanks = fetch_thanks($post['postid']);
                    $thank_users = array();
                    if (is_array($thanks)) {
                        foreach ($thanks as $thank) {
                            $thank_users[] = $thank['username'];
                        }
                    }
                    if (count($thank_users)) {
                        $tmp['likestext'] = prepare_utf8_string($vbphrase['fr_thanked_by'] . ': ' . join(', ', $thank_users));
                        $tmp['likesusers'] = join(', ', $thank_users);
                    }
                }
            }
            // End Support for Post Thanks Hack
            $posts_out[] = $tmp;
            // FRNR End
        }
        $db->free_result($posts);
        unset($post);
        if ($postbits == '' and $vbulletin->GPC['pagenumber'] > 1) {
            $pageinfo = array('page' => $vbulletin->GPC['pagenumber'] - 1);
            if (!empty($vbulletin->GPC['perpage'])) {
                $pageinfo['pp'] = $perpage;
            }
            if (!empty($vbulletin->GPC['highlight'])) {
                $pageinfo['highlight'] = urlencode($vbulletin->GPC['highlight']);
            }
            exec_header_redirect(fetch_seo_url('thread|js', $threadinfo, $pageinfo));
        }
        DEVDEBUG("First Post: {$FIRSTPOSTID}; Last Post: {$LASTPOSTID}");
        $pageinfo = array();
        if ($vbulletin->GPC['highlight']) {
            $pageinfo['highlight'] = urlencode($vbulletin->GPC['highlight']);
        }
        if (!empty($vbulletin->GPC['perpage'])) {
            $pageinfo['pp'] = $perpage;
        }
        $pagenav = construct_page_nav($vbulletin->GPC['pagenumber'], $perpage, $totalposts, 'showthread.php?' . $vbulletin->session->vars['sessionurl'] . "t={$threadinfo['threadid']}", '', '', 'thread', $threadinfo, $pageinfo);
        if ($thread['lastpost'] > $threadview) {
            if ($firstnew) {
                $firstunread = fetch_seo_url('thread', $threadinfo, array('page' => $vbulletin->GPC['pagenumber'])) . '#post' . $firstnew;
                $show['firstunreadlink'] = true;
            } else {
                $firstunread = fetch_seo_url('thread', $threadinfo, array('goto' => 'newpost'));
                $show['firstunreadlink'] = true;
            }
        } else {
            $firstunread = '';
            $show['firstunreadlink'] = false;
        }
        if ($vbulletin->userinfo['postorder']) {
            // disable ajax qr when displaying linear newest first
            $show['allow_ajax_qr'] = 0;
        } else {
            // only allow ajax on the last page of a thread when viewing oldest first
            $show['allow_ajax_qr'] = $vbulletin->GPC['pagenumber'] == ceil($totalposts / $perpage) ? 1 : 0;
        }
        ################################################################################
        ################ SHOW THREAD IN THREADED OR HYBRID MODE ########################
        ################################################################################
    } else {
        // ajax qr doesn't work with threaded controls
        $show['allow_ajax_qr'] = 0;
        require_once DIR . '/includes/functions_threadedmode.php';
        // save data
        $ipostarray = array();
        $postarray = array();
        $userarray = array();
        $postparent = array();
        $postorder = array();
        $hybridposts = array();
        $deletedparents = array();
        $totalposts = 0;
        $links = '';
        $cache_postids = '';
        $hook_query_fields = $hook_query_joins = $hook_query_where = '';
        ($hook = vBulletinHook::fetch_hook('showthread_query_postids_threaded')) ? eval($hook) : false;
        // get all posts
        $listposts = $db->query_read("\n    \t\tSELECT\n    \t\t\tpost.*, post.username AS postusername, post.ipaddress AS ip, IF(post.visible = 2, 1, 0) AS isdeleted,\n    \t\t\tuser.*, userfield.*\n    \t\t\t" . iif(!($permissions['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canseehiddencustomfields']), $vbulletin->profilefield['hidden']) . "\n    \t\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\t{$hook_query_joins}\n    \t\tWHERE threadid = {$threadid}\n    \t\t\t{$hook_query_where}\n    \t\tORDER BY postid\n    \t");
        // $toppostid is the first post in the thread
        // $curpostid is the postid passed from the URL, or if not specified, the first post in the thread
        $ids = array();
        while ($post = $db->fetch_array($listposts)) {
            if ($post['visible'] == 2 and !$deljoin or $post['visible'] == 0 and !$show['approvepost'] or in_coventry($post['userid']) and !can_moderate($thread['forumid'])) {
                $deletedparents["{$post['postid']}"] = iif(isset($deletedparents["{$post['parentid']}"]), $deletedparents["{$post['parentid']}"], $post['parentid']);
                continue;
            }
            if (empty($toppostid)) {
                $toppostid = $post['postid'];
            }
            if (empty($postid)) {
                if (empty($curpostid)) {
                    $curpostid = $post['postid'];
                    if ($threadedmode == 2 and empty($vbulletin->GPC['postid'])) {
                        $vbulletin->GPC['postid'] = $curpostid;
                    }
                    $curpostparent = $post['parentid'];
                }
            } else {
                if ($post['postid'] == $postid) {
                    $curpostid = $post['postid'];
                    $curpostparent = $post['parentid'];
                }
            }
            $postparent["{$post['postid']}"] = $post['parentid'];
            $ipostarray["{$post['parentid']}"][] = $post['postid'];
            $postarray["{$post['postid']}"] = $post;
            $userarray["{$post['userid']}"] = $db->escape_string($post['username']);
            $totalposts++;
            $ids[] = $post['postid'];
        }
        $db->free_result($listposts);
        // hooks child posts up to new parent if actual parent has been deleted or hidden
        if (count($deletedparents) > 0) {
            foreach ($deletedparents as $dpostid => $dparentid) {
                if (is_array($ipostarray[$dpostid])) {
                    foreach ($ipostarray[$dpostid] as $temppostid) {
                        $postparent[$temppostid] = $dparentid;
                        $ipostarray[$dparentid][] = $temppostid;
                        $postarray[$temppostid]['parentid'] = $dparentid;
                    }
                    unset($ipostarray[$dpostid]);
                }
                if ($curpostparent == $dpostid) {
                    $curpostparent = $dparentid;
                }
            }
        }
        unset($post, $listposts, $deletedparents);
        if ($thread['attach']) {
            require_once DIR . '/packages/vbattach/attach.php';
            $attach = new vB_Attach_Display_Content($vbulletin, 'vBForum_Post');
            $postattach = $attach->fetch_postattach(0, $ids);
        }
        // get list of usernames from post list
        $userjs = '';
        foreach ($userarray as $userid => $username) {
            if ($userid) {
                $userjs .= "pu[{$userid}] = \"" . addslashes_js($username) . "\";\n";
            }
        }
        unset($userarray, $userid, $username);
        $parent_postids = fetch_post_parentlist($curpostid);
        if (!$parent_postids) {
            $currentdepth = 0;
        } else {
            $currentdepth = sizeof(explode(',', $parent_postids));
        }
        sort_threaded_posts();
        if (empty($curpostid)) {
            eval(standard_error(fetch_error('invalidid', $vbphrase['post'], $vbulletin->options['contactuslink'])));
        }
        if ($threadedmode == 2) {
            $numhybrids = sizeof($hybridposts);
            if ($vbulletin->GPC['pagenumber'] < 1) {
                $vbulletin->GPC['pagenumber'] = 1;
            }
            $startat = ($vbulletin->GPC['pagenumber'] - 1) * $perpage;
            if ($startat > $numhybrids) {
                $vbulletin->GPC['pagenumber'] = 1;
                $startat = 0;
            }
            $endat = $startat + $perpage;
            for ($i = $startat; $i < $endat; $i++) {
                if (isset($hybridposts["{$i}"])) {
                    if (!isset($FIRSTPOSTID)) {
                        $FIRSTPOSTID = $hybridposts["{$i}"];
                    }
                    $cache_postids .= ",{$hybridposts[$i]}";
                    $LASTPOSTID = $hybridposts["{$i}"];
                }
            }
            $pageinfo = array('p' => $vbulletin->GPC['postid']);
            if ($vbulletin->GPC['highlight']) {
                $pageinfo['highlight'] = urlencode($vbulletin->GPC['highlight']);
            }
            if (!empty($vbulletin->GPC['perpage'])) {
                $pageinfo['pp'] = $perpage;
            }
            $pagenav = construct_page_nav($vbulletin->GPC['pagenumber'], $perpage, $numhybrids, 'showthread.php?' . $vbulletin->session->vars['sessionurl'] . "t={$threadinfo['threadid']}", '', '', 'thread', $threadinfo, $pageinfo);
        } else {
            $FIRSTPOSTID = $curpostid;
            $LASTPOSTID = $curpostid;
            // sort out which posts to cache:
            if (!$vbulletin->options['threaded_maxcache']) {
                $vbulletin->options['threaded_maxcache'] = 999999;
            }
            // cache $vbulletin->options['threaded_maxcache'] posts
            // take 0.25 from above $curpostid
            // and take 0.75 below
            if (sizeof($postorder) <= $vbulletin->options['threaded_maxcache']) {
                $startat = 0;
            } else {
                if ($curpostidkey + $vbulletin->options['threaded_maxcache'] * 0.75 > sizeof($postorder)) {
                    $startat = sizeof($postorder) - $vbulletin->options['threaded_maxcache'];
                } else {
                    if ($curpostidkey - $vbulletin->options['threaded_maxcache'] * 0.25 < 0) {
                        $startat = 0;
                    } else {
                        $startat = intval($curpostidkey - $vbulletin->options['threaded_maxcache'] * 0.25);
                    }
                }
            }
            unset($curpostidkey);
            foreach ($postorder as $postkey => $pid) {
                if ($postkey > $startat + $vbulletin->options['threaded_maxcache']) {
                    break;
                }
                if ($postkey >= $startat and empty($morereplies["{$pid}"])) {
                    $cache_postids .= ',' . $pid;
                }
            }
            // get next/previous posts for each post in the list
            // key: NAVJS[postid][0] = prev post, [1] = next post
            $NAVJS = array();
            $prevpostid = 0;
            foreach ($postorder as $pid) {
                $NAVJS["{$pid}"][0] = $prevpostid;
                $NAVJS["{$prevpostid}"][1] = $pid;
                $prevpostid = $pid;
            }
            $NAVJS["{$toppostid}"][0] = $pid;
            //prev button for first post
            $NAVJS["{$pid}"][1] = $toppostid;
            //next button for last post
            $navjs = '';
            foreach ($NAVJS as $pid => $info) {
                $navjs .= "pn[{$pid}] = \"{$info['0']},{$info['1']}\";\n";
            }
        }
        unset($ipostarray, $postparent, $postorder, $NAVJS, $postid, $info, $prevpostid, $postkey);
        $cache_postids = substr($cache_postids, 1);
        if (empty($cache_postids)) {
            // umm... something weird happened. Just prevent an error.
            eval(standard_error(fetch_error('invalidid', $vbphrase['post'], $vbulletin->options['contactuslink'])));
        }
        $hook_query_fields = $hook_query_joins = $hook_query_where = '';
        ($hook = vBulletinHook::fetch_hook('showthread_query')) ? eval($hook) : false;
        $cacheposts = $db->query_read("\n    \t\tSELECT\n    \t\t\tpost.*, post.username AS postusername, post.ipaddress AS ip, IF(post.visible = 2, 1, 0) AS isdeleted,\n    \t\t\tuser.*, userfield.*, usertextfield.*,\n    \t\t\t" . iif($forum['allowicons'], 'icon.title as icontitle, icon.iconpath,') . "\n    \t\t\t" . iif($vbulletin->options['avatarenabled'], 'avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,') . "\n    \t\t\t" . ((can_moderate($thread['forumid'], 'canmoderateposts') or can_moderate($thread['forumid'], 'candeleteposts')) ? 'spamlog.postid AS spamlog_postid,' : '') . "\n    \t\t\t" . iif($deljoin, "deletionlog.userid AS del_userid, deletionlog.username AS del_username, deletionlog.reason AS del_reason,") . "\n    \t\t\teditlog.userid AS edit_userid, editlog.username AS edit_username, editlog.dateline AS edit_dateline,\n    \t\t\teditlog.reason AS edit_reason, editlog.hashistory,\n    \t\t\tpostparsed.pagetext_html, postparsed.hasimages,\n    \t\t\tsigparsed.signatureparsed, sigparsed.hasimages AS sighasimages,\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" . iif(!($permissions['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canseehiddencustomfields']), $vbulletin->profilefield['hidden']) . "\n    \t\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($forum['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($thread['forumid'], 'canmoderateposts') or can_moderate($thread['forumid'], 'candeleteposts')) ? "LEFT JOIN " . TABLE_PREFIX . "spamlog AS spamlog ON(spamlog.postid = post.postid)" : '') . "\n    \t\t\t{$deljoin}\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\t{$hook_query_joins}\n    \t\tWHERE post.postid IN (" . $cache_postids . ") {$hook_query_where}\n    \t");
        // re-initialise the $postarray variable
        $postarray = array();
        while ($post = $db->fetch_array($cacheposts)) {
            $postarray["{$post['postid']}"] = $post;
        }
        if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['cangetattachment'])) {
            $vbulletin->options['viewattachedimages'] = 0;
            $vbulletin->options['attachthumbs'] = 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 ($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 ($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);
            if ($fetchtype == 'post') {
                $postbit_obj->highlight =& $replacewords;
            }
            $postbit_obj->cachable = $post_cachable;
            $post['postcount'] = ++$postcount;
            $post['attachments'] =& $postattach["{$post['postid']}"];
            $parsed_postcache = array('text' => '', 'images' => 1);
            $bgclass = 'alt2';
            if ($threadedmode == 2) {
                $postbits .= $postbit_obj->construct_postbit($post);
            } else {
                $postbit = $postbit_obj->construct_postbit($post);
                if ($curpostid == $post['postid']) {
                    $curpostdateline = $post['dateline'];
                    $curpostbit = $postbit;
                }
                $postbit = preg_replace('#</script>#i', "<\\/scr' + 'ipt>", addslashes_js($postbit));
                $jspostbits .= "pd[{$post['postid']}] = '{$postbit}';\n";
            }
            // end threaded mode
            if ($post_cachable and $post['pagetext_html'] == '') {
                if (!empty($saveparsed)) {
                    $saveparsed .= ',';
                }
                $saveparsed .= "({$post['postid']}, " . intval($thread['lastpost']) . ', ' . intval($postbit_obj->post_cache['has_images']) . ", '" . $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) . ", '" . $db->escape_string($postbit_obj->sig_cache['text']) . "', " . intval($postbit_obj->sig_cache['has_images']) . ")";
            }
            if ($post['dateline'] > $displayed_dateline) {
                $displayed_dateline = $post['dateline'];
                if ($displayed_dateline <= $threadview) {
                    $updatethreadcookie = true;
                }
            }
        }
        // end while ($post)
        $db->free_result($cacheposts);
        if ($threadedmode == 1) {
            $postbits = $curpostbit;
        }
        $templater = vB_Template::create('showthread_list');
        $templater->register('curpostid', $curpostid);
        $templater->register('highlightwords', $highlightwords);
        $templater->register('jspostbits', $jspostbits);
        $templater->register('links', $links);
        $templater->register('navjs', $navjs);
        $templater->register('threadedmode', $threadedmode);
        $templater->register('userjs', $userjs);
        $threadlist = $templater->render();
        unset($curpostbit, $post, $cacheposts, $parsed_postcache, $postbit);
    }
    ################################################################################
    ########################## END LINEAR / THREADED ###############################
    ################################################################################
    $effective_lastpost = max($displayed_dateline, $thread['lastpost']);
    // *********************************************************************************
    //set thread last view
    if ($thread['pollid'] and $vbulletin->options['updatelastpost'] and ($displayed_dateline == $thread['lastpost'] or $threadview == $thread['lastpost']) and $pollinfo['lastvote'] > $thread['lastpost']) {
        $displayed_dateline = $pollinfo['lastvote'];
    }
    if ((!$vbulletin->GPC['posted'] or $updatethreadcookie) and $displayed_dateline and $displayed_dateline > $threadview) {
        mark_thread_read($threadinfo, $foruminfo, $vbulletin->userinfo['userid'], $displayed_dateline);
    }
    // FRNR Below
    fr_update_subsent($threadinfo['threadid'], $displayed_dateline);
    if (!is_array($posts_out)) {
        $posts_out = array();
    }
    // 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;
    }
    $mod = 0;
    if (can_moderate($threadinfo['forumid'], 'candeleteposts') or can_moderate($threadinfo['forumid'], 'canremoveposts')) {
        $mod |= MOD_DELETEPOST;
    }
    if (can_moderate($threadinfo['forumid'], 'canmanagethreads')) {
        if ($threadinfo['sticky']) {
            $mod |= MOD_UNSTICK;
        } else {
            $mod |= MOD_STICK;
        }
    }
    if ($threadinfo['visible'] != 2 and can_moderate($threadinfo['forumid'], 'candeleteposts') or can_moderate($threadinfo['forumid'], 'canremoveposts') or $forumperms & $vbulletin->bf_ugp_forumpermissions['candeletepost'] and $forumperms & $vbulletin->bf_ugp_forumpermissions['candeletethread'] and $vbulletin->userinfo['userid'] == $threadinfo['postuserid'] and ($vbulletin->options['edittimelimit'] == 0 or $threadinfo['dateline'] > TIMENOW - $vbulletin->options['edittimelimit'] * 60)) {
        $mod |= MOD_DELETETHREAD;
    }
    if (can_moderate($threadinfo['forumid'], 'canopenclose') or $forumperms & $vbulletin->bf_ugp_forumpermissions['canopenclose'] and $threadinfo['postuserid'] == $vbulletin->userinfo['userid']) {
        if ($threadinfo['open']) {
            $mod |= MOD_CLOSE;
        } else {
            $mod |= MOD_OPEN;
        }
    }
    if (can_moderate($threadinfo['forumid'], 'canmanagethreads') or $forumperms & $vbulletin->bf_ugp_forumpermissions['canmove'] and $threadinfo['postuserid'] == $vbulletin->userinfo['userid']) {
        $mod |= MOD_MOVETHREAD;
    }
    if ($show['spamctrls']) {
        $mod |= MOD_SPAM_CONTROLS;
    }
    $out = array('posts' => $posts_out, 'total_posts' => $totalposts, 'page' => $vbulletin->GPC['pagenumber'], 'canpost' => $canpost ? 1 : 0, 'mod' => $mod, 'pollid' => $thread['pollid'], 'subscribed' => $threadinfo['issubscribed'] ? 1 : 0, 'title' => prepare_utf8_string($thread['title']), 'canattach' => $forumperms & $vbulletin->bf_ugp_forumpermissions['canpostattachment'] and $vbulletin->userinfo['userid']);
    if ($postid) {
        $out['gotopostid'] = $postid;
    }
    return $out;
}
Пример #29
0
 }
 $allowsmilies = iif($vbulletin->GPC['disablesmilies'], 0, 1);
 $preview = iif($vbulletin->GPC['preview'] != '', 1, 0);
 // include useful functions
 require_once DIR . '/includes/functions_newpost.php';
 // unwysiwygify the incoming data
 if ($vbulletin->GPC['wysiwyg']) {
     require_once DIR . '/includes/functions_wysiwyg.php';
     $vbulletin->GPC['message'] = convert_wysiwyg_html_to_bbcode($vbulletin->GPC['message'], $vbulletin->options['unallowhtml']);
 }
 if (empty($vbulletin->GPC['message'])) {
     eval(standard_error(fetch_error('nosubject')));
 }
 $vbulletin->GPC['title'] = fetch_censored_text($vbulletin->GPC['title']);
 if ($vbulletin->options['wordwrap'] != 0) {
     $vbulletin->GPC['title'] = fetch_word_wrapped_string($vbulletin->GPC['title']);
 }
 // remove all caps subjects
 $vbulletin->GPC['title'] = fetch_no_shouting_text($vbulletin->GPC['title']);
 $vbulletin->GPC['message'] = fetch_censored_text($vbulletin->GPC['message']);
 if ($vbulletin->GPC['parseurl'] and $vbulletin->options['unallowvbcode']) {
     $vbulletin->GPC['message'] = convert_url_to_bbcode($vbulletin->GPC['message']);
 }
 // remove sessionhash from urls:
 $vbulletin->GPC['message'] = preg_replace('/(s|sessionhash)=[a-z0-9]{32}&{0,1}/', '', $vbulletin->GPC['message']);
 $vbulletin->GPC['message'] = fetch_no_shouting_text($vbulletin->GPC['message']);
 if (vbstrlen($vbulletin->GPC['message']) > $vbulletin->options['postmaxchars'] and $vbulletin->options['postmaxchars'] != 0) {
     eval(standard_error(fetch_error('toolong', $postlength, $vbulletin->options['postmaxchars'])));
 }
 if (vbstrlen($vbulletin->GPC['message']) < $vbulletin->options['postminchars'] or $vbulletin->GPC['message'] == '') {
     eval(standard_error(fetch_error('tooshort', $vbulletin->options['postminchars'])));
Пример #30
0
/**
* Prepares issue data for display.
*
* @param	array	Issue data without any processing
*
* @return	array	Processed issue data
*/
function prepare_issue($issue)
{
    global $vbulletin, $vbphrase, $stylevar;
    if ($vbulletin->options['wordwrap'] != 0) {
        $issue['title'] = fetch_word_wrapped_string($issue['title']);
        $issue['summary'] = fetch_word_wrapped_string($issue['summary']);
    }
    $issue['title'] = fetch_censored_text($issue['title']);
    $issue['summary'] = fetch_censored_text($issue['summary']);
    $issue['lastposttime'] = vbdate($vbulletin->options['timeformat'], $issue['lastpost']);
    $issue['lastpostdate'] = vbdate($vbulletin->options['dateformat'], $issue['lastpost'], true);
    // post reply date/time (for search results as posts mainly)
    if ($issue['submitdate']) {
        $issue['submittime'] = vbdate($vbulletin->options['timeformat'], $issue['submitdate']);
        $issue['submitdate'] = vbdate($vbulletin->options['dateformat'], $issue['submitdate'], true);
    } else {
        $issue['submitdate'] = '';
        $issue['submittime'] = '';
    }
    $issue['replycount'] = vb_number_format($issue['replycount']);
    $issue['attachcount'] = vb_number_format($issue['attachcount']);
    if ($typeicon = $vbulletin->pt_issuetype["{$issue['issuetypeid']}"]['iconfile']) {
        $issue['typeicon'] = $typeicon;
    }
    $issue['issuetype'] = $vbphrase["issuetype_{$issue['issuetypeid']}_singular"];
    $issue['status'] = $vbphrase["issuestatus{$issue['issuestatusid']}"];
    $issue = fetch_issue_version_text($issue);
    if (!$issue['projectcategoryid']) {
        $issue['categorytitle'] = $vbphrase['unknown'];
    }
    $issue['priority_text'] = $vbphrase["priority_{$issue['priority']}"];
    if (!$issue['milestoneid']) {
        $issue['milestonetitle'] = $vbphrase['none_meta'];
    }
    $issue['lastread'] = issue_lastview($issue);
    $issue['newflag'] = $issue['lastpost'] > $issue['lastread'];
    ($hook = vBulletinHook::fetch_hook('project_issue_prepare')) ? eval($hook) : false;
    return $issue;
}