Exemplo n.º 1
0
/**
* Shows the new subscribed PT issues in the user CP
*
* @return	string	Printable issue bits
*/
function process_new_subscribed_issues()
{
    global $vbulletin, $show, $stylevar, $vbphrase, $template_hook, $vbcollapse;
    if (!($vbulletin->userinfo['permissions']['ptpermissions'] & $vbulletin->bf_ugp_ptpermissions['canviewprojecttools'])) {
        return '';
    }
    $perms_query = build_issue_permissions_query($vbulletin->userinfo);
    if (!$perms_query) {
        return '';
    }
    $marking = ($vbulletin->options['threadmarking'] and $vbulletin->userinfo['userid']);
    if ($marking) {
        $issueview_sql = "IF(issueread IS NOT NULL, issueread, " . intval(TIMENOW - $vbulletin->options['markinglimit'] * 86400) . ")";
        $issueview_sql2 = "IF(projectread IS NOT NULL, projectread, " . intval(TIMENOW - $vbulletin->options['markinglimit'] * 86400) . ")";
    } else {
        $issueview = max(intval(fetch_bbarray_cookie('issue_lastview', $issue['issueid'])), intval(fetch_bbarray_cookie('issue_lastview', $issue['projectid'] . $issue['issuetypeid'])));
        if (!$issueview) {
            $issueview = $vbulletin->userinfo['lastvisit'];
        }
        $issueview_sql = intval($issueview);
        $issueview_sql2 = '';
    }
    build_issue_private_lastpost_sql_all($vbulletin->userinfo, $private_lastpost_join, $private_lastpost_fields);
    $replycount_clause = fetch_private_replycount_clause($vbulletin->userinfo);
    $subscriptions = $vbulletin->db->query_read("\r\n\t\tSELECT issue.*, issuesubscribe.subscribetype,\r\n\t\t\tproject.title_clean\r\n\t\t\t" . ($marking ? ", issueread.readtime AS issueread, projectread.readtime AS projectread" : '') . "\r\n\t\t\t" . ($private_lastpost_fields ? ", {$private_lastpost_fields}" : '') . "\r\n\t\t\t" . ($replycount_clause ? ", {$replycount_clause} AS replycount" : '') . "\r\n\t\tFROM " . TABLE_PREFIX . "pt_issuesubscribe AS issuesubscribe\r\n\t\tINNER JOIN " . TABLE_PREFIX . "pt_issue AS issue ON (issue.issueid = issuesubscribe.issueid)\r\n\t\tINNER JOIN " . TABLE_PREFIX . "pt_project AS project ON (project.projectid = issue.projectid)\r\n\t\t" . ($marking ? "\r\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "pt_issueread AS issueread ON (issueread.issueid = issue.issueid AND issueread.userid = " . $vbulletin->userinfo['userid'] . ")\r\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "pt_projectread as projectread ON (projectread.projectid = issue.projectid AND projectread.userid = " . $vbulletin->userinfo['userid'] . " AND projectread.issuetypeid = issue.issuetypeid)\r\n\t\t" : '') . "\r\n\t\t{$private_lastpost_join}\r\n\t\tWHERE issuesubscribe.userid = " . $vbulletin->userinfo['userid'] . "\r\n\t\t\tAND (" . implode(' OR ', $perms_query) . ")\r\n\t\tHAVING lastpost > " . intval(TIMENOW - $vbulletin->options['markinglimit'] * 86400) . "\r\n\t\t\tAND lastpost > " . $issueview_sql . "\r\n\t\t\t" . (!empty($issueview_sql2) ? " AND lastpost > " . $issueview_sql2 : '') . "\r\n\t\tORDER BY lastpost DESC\r\n\t");
    $show['issuebit_project_title'] = true;
    $subscriptionbits = '';
    while ($issue = $vbulletin->db->fetch_array($subscriptions)) {
        $issue = prepare_issue($issue);
        eval('$subscriptionbits .= "' . fetch_template('pt_issuebit') . '";');
    }
    if (!$subscriptionbits) {
        return '';
    }
    eval('$return = "' . fetch_template('pt_usercp_subscriptions') . '";');
    return $return;
}
Exemplo n.º 2
0
    } else {
        eval(standard_error(fetch_error('invalidid', $idname, $vbulletin->options['contactuslink'])));
    }
}
if ($eventinfo['eventid'] and $eventinfo['userid'] != $vbulletin->userinfo['userid'] and !($vbulletin->userinfo['calendarpermissions']["{$eventinfo['calendarid']}"] & $vbulletin->bf_ugp_calendarpermissions['canviewothersevent'])) {
    print_no_permission();
}
$calendarinfo = verify_id('calendar', $vbulletin->GPC['calendarid'], 1, 1);
$getoptions = convert_bits_to_array($calendarinfo['options'], $_CALENDAROPTIONS);
$calendarinfo = array_merge($calendarinfo, $getoptions);
$geteaster = convert_bits_to_array($calendarinfo['holidays'], $_CALENDARHOLIDAYS);
$calendarinfo = array_merge($calendarinfo, $geteaster);
$calendarid =& $calendarinfo['calendarid'];
$calview = htmlspecialchars_uni(fetch_bbarray_cookie('calendar', 'calview' . $calendarinfo['calendarid']));
$calmonth = intval(fetch_bbarray_cookie('calendar', 'calmonth'));
$calyear = intval(fetch_bbarray_cookie('calendar', 'calyear'));
$show['neweventlink'] = $vbulletin->userinfo['calendarpermissions'][$calendarid] & $vbulletin->bf_ugp_calendarpermissions['canpostevent'] ? true : false;
if (empty($_REQUEST['do'])) {
    $defaultview = !empty($calendarinfo['weekly']) ? 'displayweek' : (!empty($calendarinfo['yearly']) ? 'displayyear' : 'displaymonth');
    $_REQUEST['do'] = !empty($calview) ? $calview : $defaultview;
}
if ($vbulletin->GPC['sb']) {
    // Allow showbirthdays to be turned on if they are off -- mainly for the birthday link from the front page
    $calendarinfo['showbirthdays'] = true;
}
// chande the start of week for invalid values or guests (which are currently forced to 1, Sunday)
if ($vbulletin->userinfo['startofweek'] > 7 or $vbulletin->userinfo['startofweek'] < 1 or $vbulletin->userinfo['userid'] == 0) {
    $vbulletin->userinfo['startofweek'] = $calendarinfo['startofweek'];
}
// Make first part of Calendar Nav Bar
$navbits = array('calendar.php' . $vbulletin->session->vars['sessionurl_q'] => $vbphrase['calendar']);
Exemplo n.º 3
0
 $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;
 }
Exemplo n.º 4
0
);
construct_quick_nav($navpopup);


/////////////////////////////////
if ($foruminfo['cancontainthreads'])
{
	/////////////////////////////////
	if ($vbulletin->options['threadmarking'] AND $vbulletin->userinfo['userid'])
	{
		$foruminfo['forumread'] = $vbulletin->forumcache["$foruminfo[forumid]"]['forumread'];
		$lastread = max($foruminfo['forumread'], TIMENOW - ($vbulletin->options['markinglimit'] * 86400));
	}
	else
	{
		$bbforumview = intval(fetch_bbarray_cookie('forum_view', $foruminfo['forumid']));
		$lastread = max($bbforumview, $vbulletin->userinfo['lastvisit']);
	}

	// Inline Moderation
	$show['movethread'] = (can_moderate($forumid, 'canmanagethreads')) ? true : false;
	$show['deletethread'] = (can_moderate($forumid, 'candeleteposts') OR can_moderate($forumid, 'canremoveposts')) ? true : false;
	$show['approvethread'] = (can_moderate($forumid, 'canmoderateposts')) ? true : false;
	$show['openthread'] = (can_moderate($forumid, 'canopenclose')) ? true : false;
	$show['inlinemod'] = ($show['movethread'] OR $show['deletethread'] OR $show['approvethread'] OR $show['openthread']) ? true : false;
	$show['spamctrls'] = ($show['inlinemod'] AND $show['deletethread']);
	$url = $show['inlinemod'] ? SCRIPTPATH : '';

	// fetch popup menu
	if ($show['popups'] AND $show['inlinemod'])
	{
/**
 * 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;
}
Exemplo n.º 6
0
	private static function renderResult($userinfo, $post_array, $permissions,
		$forumperms, $target_url, $nodeid)
	{

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

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

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

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

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



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


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

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

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

		$postcount = count($postid_array);

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

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

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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

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


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

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

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

		vB::$vbulletin->db->free_result($posts);
		unset($post);
		return $postbits;
	}
Exemplo n.º 7
0
function do_get_poll()
{
    global $vbulletin, $db, $foruminfo, $threadinfo, $postid, $vbphrase;
    if (empty($threadinfo['threadid'])) {
        json_error(ERR_INVALID_THREAD);
    }
    $threadid = $vbulletin->GPC['threadid'];
    $counter = 1;
    $pollid = $threadinfo['pollid'];
    if (!$pollid) {
        json_error(ERR_INVALID_THREAD);
    }
    $forumperms = fetch_permissions($threadinfo['forumid']);
    // get poll info
    $pollinfo = $db->query_first_slave("\n\tSELECT *\n\tFROM " . TABLE_PREFIX . "poll\n\tWHERE pollid = {$pollid}\n    ");
    require_once DIR . '/includes/class_bbcode.php';
    $bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list());
    $pollinfo['question'] = prepare_utf8_string(strip_tags(remove_bbcode(unhtmlspecialchars($pollinfo['question']), true, true)));
    $splitoptions = explode('|||', $pollinfo['options']);
    $splitoptions = array_map('rtrim', $splitoptions);
    $splitvotes = explode('|||', $pollinfo['votes']);
    $showresults = 0;
    $uservoted = 0;
    if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canvote'])) {
        $nopermission = 1;
    }
    if (!$pollinfo['active'] or !$threadinfo['open'] or $pollinfo['dateline'] + $pollinfo['timeout'] * 86400 < TIMENOW and $pollinfo['timeout'] != 0 or $nopermission) {
        //thread/poll is closed, ie show results no matter what
        $showresults = 1;
    } else {
        //get userid, check if user already voted
        $voted = intval(fetch_bbarray_cookie('poll_voted', $pollid));
        if ($voted) {
            $uservoted = 1;
        }
    }
    if ($pollinfo['timeout'] and !$showresults) {
        $pollendtime = vbdate($vbulletin->options['timeformat'], $pollinfo['dateline'] + $pollinfo['timeout'] * 86400);
        $pollenddate = vbdate($vbulletin->options['dateformat'], $pollinfo['dateline'] + $pollinfo['timeout'] * 86400);
        $show['pollenddate'] = true;
    } else {
        $show['pollenddate'] = false;
    }
    foreach ($splitvotes as $index => $value) {
        $pollinfo['numbervotes'] += $value;
    }
    if ($vbulletin->userinfo['userid'] > 0) {
        $pollvotes = $db->query_read_slave("\n\t    SELECT voteoption\n\t    FROM " . TABLE_PREFIX . "pollvote\n\t    WHERE userid = " . $vbulletin->userinfo['userid'] . " AND pollid = {$pollid}\n\t");
        if ($db->num_rows($pollvotes) > 0) {
            $uservoted = 1;
        }
    }
    if ($showresults or $uservoted) {
        if ($uservoted) {
            $uservote = array();
            while ($pollvote = $db->fetch_array($pollvotes)) {
                $uservote["{$pollvote['voteoption']}"] = 1;
            }
        }
    }
    $options = array();
    foreach ($splitvotes as $index => $value) {
        $arrayindex = $index + 1;
        if ($value <= 0) {
            $percent = 0;
        } else {
            $percent = vb_number_format($value < $pollinfo['numbervotes'] ? $value / $pollinfo['numbervotes'] * 100 : 100, 0);
        }
        $options[] = array('voted' => iif($uservote["{$arrayindex}"], true, false), 'percent' => $percent, 'title' => prepare_utf8_string(strip_tags(remove_bbcode(unhtmlspecialchars($splitoptions["{$index}"]), true, true)) . $titleadd), 'votes' => $value);
    }
    // Phrase parts below
    if ($nopermission) {
        $pollstatus = $vbphrase['you_may_not_vote_on_this_poll'];
    } else {
        if ($showresults) {
            $pollstatus = $vbphrase['this_poll_is_closed'];
        } else {
            if ($uservoted) {
                $pollstatus = $vbphrase['you_have_already_voted_on_this_poll'];
            }
        }
    }
    $out = array('title' => prepare_utf8_string($pollinfo['question']), 'pollstatus' => prepare_utf8_string($pollstatus), 'options' => $options, 'total' => $pollinfo['numbervotes'], 'canvote' => !$nopermission && !$uservoted);
    if ($pollinfo['multiple']) {
        $out['multiple'] = true;
    }
    return $out;
}
Exemplo n.º 8
0
function do_get_forum_data()
{
    global $vbulletin, $db, $show, $vbphrase;
    $vbulletin->input->clean_array_gpc('r', array('forumids' => TYPE_STR));
    if (!$vbulletin->GPC['forumids'] || strlen($vbulletin->GPC['forumids']) == 0) {
        return array('forums' => array());
    }
    cache_ordered_forums(1, 1);
    $forumids = split(',', $vbulletin->GPC['forumids']);
    $forum_data = array();
    foreach ($forumids as $forumid) {
        $foruminfo = fetch_foruminfo($forumid);
        $type = 'old';
        if (is_array($foruminfo) and !empty($foruminfo['link'])) {
            // see if it is a redirect
            $type = 'link';
        } else {
            if ($vbulletin->userinfo['lastvisitdate'] == -1) {
                $type = 'new';
            } else {
                if ($vbulletin->options['threadmarking'] and $vbulletin->userinfo['userid']) {
                    $userlastvisit = !empty($foruminfo['forumread']) ? $foruminfo['forumread'] : TIMENOW - $vbulletin->options['markinglimit'] * 86400;
                } else {
                    $forumview = intval(fetch_bbarray_cookie('forum_view', $foruminfo['forumid']));
                    //use which one produces the highest value, most likely cookie
                    $userlastvisit = $forumview > $vbulletin->userinfo['lastvisit'] ? $forumview : $vbulletin->userinfo['lastvisit'];
                }
                if ($foruminfo['lastpost'] and $userlastvisit < $foruminfo['lastpost']) {
                    $type = 'new';
                } else {
                    $type = 'old';
                }
            }
        }
        // If this forum has a password, check to see if we have
        // the proper cookie.  If so, don't prompt for one
        $password = false;
        if ($foruminfo['password']) {
            $pw_ok = verify_forum_password($foruminfo['forumid'], $foruminfo['password'], false);
            if (!$pw_ok) {
                $password = true;
            }
        }
        $out = array('id' => $foruminfo['forumid'], 'new' => $type == 'new' ? true : false, 'name' => prepare_utf8_string(strip_tags($foruminfo['title'])), 'password' => $password);
        $icon = fr_get_forum_icon($foruminfo['forumid'], $foruminfo == 'new');
        if ($icon) {
            $out['icon'] = $icon;
        }
        if ($foruminfo['link'] != '') {
            $link = fr_fix_url($foruminfo['link']);
            if (is_int($link)) {
                $out['id'] = $link;
            } else {
                $out['link'] = $link;
            }
            $linkicon = fr_get_forum_icon($foruminfo['forumid'], false, true);
            if ($linkicon) {
                $out['icon'] = $linkicon;
            }
        }
        if ($foruminfo['description'] != '') {
            $desc = prepare_utf8_string(strip_tags($foruminfo['description']));
            if (strlen($desc) > 0) {
                $out['desc'] = $desc;
            }
        }
        $forum_data[] = $out;
    }
    return array('forums' => $forum_data);
}
Exemplo n.º 9
0
		}

		// ### PREVIEW POST ###
		$postpreview = process_post_preview($newpost, 0, $postattach);
		$_REQUEST['do'] = 'newreply';
		$newpost['message'] = htmlspecialchars_uni($newpost['message']);
	}
	else
	{
		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'];
			}
		}
		// ### NOT PREVIEW - ACTUAL POST ###
		if ($vbulletin->GPC['ajax'])
		{
		// #############################################################################
		// #############################################################################
		// #############################################################################
		require_once(DIR . '/includes/class_postbit.php');
		require_once(DIR . '/includes/functions_bigthree.php');
		require_once(DIR . '/includes/class_xml.php');
Exemplo n.º 10
0
 /**
  * Sets up different display variables for the Group Message
  *
  * @access protected
  */
 function process_display()
 {
     global $show, $vbphrase;
     $this->item['canview'] = ($this->item['state'] == 'visible' or $this->item['state'] == 'deleted' and fetch_socialgroup_modperm('canundeletediscussions', $this->group) or $this->item['state'] == 'moderation' and fetch_socialgroup_modperm('canmoderatediscussions', $this->group));
     // Simplify moderation for templating
     if (fetch_socialgroup_modperm('canmoderategroupmessages', $this->group)) {
         $this->item['moderated_replies'] = ($this->item['moderation'] > 1 or $this->item['state'] != 'moderation' and $this->item['moderation'] == 1);
     } else {
         $this->item['moderated_replies'] = 0;
     }
     $this->item['moderated'] = $this->item['state'] == 'moderation';
     // Show inline selection tools
     if ($this->show_moderation_tools and !$this->force_inline_selection) {
         $this->item['inlinemod'] = ($this->item['state'] != 'deleted' and fetch_socialgroup_modperm('canmoderatediscussions', $this->group) or fetch_socialgroup_modperm('canundeletediscussions', $this->group) or fetch_socialgroup_modperm('canremovediscussions', $this->group));
         $show['inlinemod'] = ($show['inlinemod'] or $this->item['inlinemod']);
     } else {
         $show['inlinemod'] = $this->item['inlinemod'] = $this->force_inline_selection;
     }
     // Show edit links
     $this->item['edit'] = ($this->show_moderation_tools and can_edit_group_discussion($this->item, $this->group));
     $show['edit'] = $this->item['edit'];
     if ($this->check_read) {
         if (!$this->item['is_read']) {
             if (!$this->item['readtime']) {
                 $this->item['readtime'] = 0;
                 // no database marking, check cookie
                 if (!$this->registry->options['threadmarking'] or !$this->registry->userinfo['userid']) {
                     $this->item['readtime'] = max(fetch_bbarray_cookie('discussion_marking', $this->item['discussionid']), $this->registry->userinfo['lastvisit']);
                 }
             }
             // posts older than markinglimit days won't be highlighted as new
             $oldtime = TIMENOW - $this->registry->options['markinglimit'] * 24 * 60 * 60;
             $this->item['readtime'] = max($this->group['readtime'], $this->item['readtime'], $oldtime);
             $this->item['is_read'] = $this->item['readtime'] > $this->item['lastpost'];
             $this->item['goto_readtime'] = array('goto' => $this->item['readtime']);
         }
     } else {
         $this->item['is_read'] = true;
     }
     $this->item['readstate'] = $this->item['is_read'] ? 'old' : 'new';
     $this->item['replies'] = max(0, $this->item['visible'] - 1);
     if ($this->show_subscription) {
         $this->item['showsubsinfo'] = $this->show_subscription;
         $this->item['notification'] = $this->item['emailupdate'] ? $vbphrase['instant'] : $vbphrase['none'];
     } else {
         $this->item['showsubsinfo'] = false;
         $this->item['notification'] = "";
     }
 }
Exemplo n.º 11
0
	{
		cache_ordered_forums(1);
		$colspan = 5;
		$show['threadicons'] = false;

		// get last read info for each thread
		$lastread = array();
		foreach (array_keys($forumids) AS $forumid)
		{
			if ($vbulletin->options['threadmarking'])
			{
				$lastread["$forumid"] = max($vbulletin->forumcache["$forumid"]['forumread'], TIMENOW - ($vbulletin->options['markinglimit'] * 86400));
			}
			else
			{
				$lastread["$forumid"] = max(intval(fetch_bbarray_cookie('forum_view', $forumid)), $vbulletin->userinfo['lastvisit']);
			}
			if ($vbulletin->forumcache["$forumid"]['options'] & $vbulletin->bf_misc_forumoptions['allowicons'])
			{
				$show['threadicons'] = true;
				$colspan = 6;
			}
		}

		// get thread preview?
		if ($vbulletin->options['threadpreview'] > 0)
		{
			$previewfield = 'post.pagetext AS preview,';
			$previewjoin = "LEFT JOIN " . TABLE_PREFIX . "post AS post ON(post.postid = thread.firstpostid)";
		}
		else
Exemplo n.º 12
0
	/**
	 * Rate a node (ajax only)
	 *
	 * @return string
	 */
	public function actionRate()
	{
		global $bootstrap;

		$nodeid = intval($this->node->getNodeId());

		// Load the style
		$bootstrap->force_styleid($this->node->getStyleId());
		$bootstrap->load_style();

		vB::$vbulletin->input->clean_array_gpc('r', array(
			'vote' => vB_Input::TYPE_UINT
		));
		$vote = vB::$vbulletin->GPC['vote'];

		if ($vote < 0 OR $vote > 5)
		{
			die;
		}

		$rated = intval(fetch_bbarray_cookie('cms_rate', $nodeid));

		$update = false;
		if (vB::$vbulletin->userinfo['userid'])
		{
			if ($rating = vB::$db->query_first("
				SELECT *
				FROM " . TABLE_PREFIX . "cms_rate
				WHERE userid = " . vB::$vbulletin->userinfo['userid'] . "
					AND nodeid = $nodeid
			"))
			{
				if (vB::$vbulletin->options['votechange'])
				{
					if ($vote != $rating['vote'])
					{
						$rateitem = new vBCms_Item_Rate($rating['rateid']);
						$ratedm = new vBCms_DM_Rate($rateitem);
						$ratedm->set('nodeid', $nodeid);
						$ratedm->set('userid', vB::$vbulletin->userinfo['userid']);
						$ratedm->set('vote', intval($vote));
						$ratedm->save();
					}
					$update = true;
				}
			}
			else
			{
				$ratedm = new vBCms_DM_Rate();
				$ratedm->set('nodeid', $nodeid);
				$ratedm->set('userid', vB::$vbulletin->userinfo['userid']);
				$ratedm->set('vote', intval($vote));
				$ratedm->save();

				$update = true;
			}
		}
		else
		{
			// Check for cookie on user's computer for this blogid
			if ($rated AND !vB::$vbulletin->options['votechange'])
			{

			}
			else
			{
				// Check for entry in Database for this Ip Addr/blogid
				if ($rating = vB::$db->query_first("
					SELECT *
					FROM " . TABLE_PREFIX . "cms_rate
					WHERE ipaddress = '" . vB::$db->escape_string(IPADDRESS) . "'
						AND nodeid = $nodeid
				"))
				{
					if (vB::$vbulletin->options['votechange'])
					{
						if ($vote != $rating['vote'])
						{
							$rateitem = new vBCms_Item_Rate($rating['rateid']);
							$ratedm = new vBCms_DM_Rate($rateitem);
							$ratedm->set('nodeid', $nodeid);
							$ratedm->set('vote', intval($vote));
							$ratedm->save();
						}
						$update = true;
					}
				}
				else
				{
					$ratedm = new vBCms_DM_Rate();
					$ratedm->set('nodeid', $nodeid);
					$ratedm->set('userid', 0);
					$ratedm->set('vote', intval($vote));
					$ratedm->save();

					$update = true;

				}
			}
		}

		require_once(DIR . '/includes/class_xml.php');
		$xml = new vB_AJAX_XML_Builder(vB::$vbulletin, 'text/xml');
		$xml->add_group('threadrating');
		if ($update)
		{
			$node = vB::$db->query_first_slave("
				SELECT ratingtotal, ratingnum
				FROM " . TABLE_PREFIX . "cms_nodeinfo
				WHERE nodeid = $nodeid
			");

			if ($node['ratingnum'] > 0 AND $node['ratingnum'] >= vB::$vbulletin->options['showvotes'])
			{	// Show Voteavg
				$node['ratingavg'] = vb_number_format($node['ratingtotal'] / $node['ratingnum'], 2);
				$node['rating'] = intval(round($node['ratingtotal'] / $node['ratingnum']));
				$xml->add_tag('voteavg', "<img class=\"inlineimg\" src=\"" . vB_Template_Runtime::fetchStyleVar('imgdir_rating') . "/rating-15_$node[rating].png\" alt=\"" . construct_phrase($vbphrase['rating_x_votes_y_average'], $node['ratingnum'], $node['ratingavg']) . "\" border=\"0\" />");
			}
			else
			{
				$xml->add_tag('voteavg', '');
			}

			if (!function_exists('fetch_phrase'))
			{
				require_once(DIR . '/includes/functions_misc.php');
			}
			$xml->add_tag('message', fetch_phrase('redirect_blog_rate_add', 'frontredirect', 'redirect_'));
		}
		else	// Already voted error...
		{
			if (!empty($rating['nodeid']))
			{
				set_bbarray_cookie('cms_rate', $rating['nodeid'], $rating['vote'], 1);
			}
			$xml->add_tag('error', fetch_error('blog_rate_voted'));
		}
		$xml->close_group();
		$xml->print_xml();

	}
Exemplo n.º 13
0
/**
* Returns whether or not the visiting user can view the specified password-protected forum
*
* @param	integer	Forum ID
* @param	string	Provided password
* @param	boolean	If true, show error when access is denied
*
* @return	boolean
*/
function verify_forum_password($forumid, $password, $showerror = true)
{
    global $vbulletin;
    if (!$password or $vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel'] or $vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['ismoderator'] or can_moderate($forumid)) {
        return true;
    }
    $foruminfo = fetch_foruminfo($forumid);
    $parents = explode(',', $foruminfo['parentlist']);
    if (!VB_API) {
        foreach ($parents as $fid) {
            // get the pwd from any parent forums -- allows pwd cookies to cascade down
            if ($temp = fetch_bbarray_cookie('forumpwd', $fid) and $temp === md5($vbulletin->userinfo['userid'] . $password)) {
                return true;
            }
        }
    } else {
        $forumpwdmd5 = $vbulletin->input->clean_gpc('r', 'forumpwdmd5', TYPE_STR);
        if ($forumpwdmd5 === md5($vbulletin->userinfo['userid'] . $password)) {
            return true;
        }
    }
    // didn't match the password in any cookie
    if ($showerror) {
        require_once DIR . '/includes/functions_misc.php';
        $security_token_html = '<input type="hidden" name="securitytoken" value="' . $vbulletin->userinfo['securitytoken'] . '" />';
        // forum password is bad - show error
        //use the basic link here.  I'm not sure how the advanced link will play with the postvars in the form.
        require_once DIR . '/includes/class_friendly_url.php';
        $forumlink = vB_Friendly_Url::fetchLibrary($vbulletin, 'forum|nosession', $foruminfo, array('do' => 'doenterpwd'));
        $forumlink = $forumlink->get_url(FRIENDLY_URL_OFF);
        // TODO convert the 'forumpasswordmissoing' phrase to vB4
        eval(standard_error(fetch_error('forumpasswordmissing', $vbulletin->session->vars['sessionhash'], $vbulletin->scriptpath, $forumid, construct_post_vars_html() . $security_token_html, 10, 1, $forumlink)));
    } else {
        // forum password is bad - return false
        return false;
    }
}
Exemplo n.º 14
0
 /**
  * Does this forum allow icons
  *
  * @return boolean
  */
 public function get_last_read_by_current_user($user)
 {
     global $vbulletin;
     if ($vbulletin->options['threadmarking'] and !$user->isGuest()) {
         //deal with the fact that the forum cache (from which we likely loaded this object)
         //doesn't have the forumread field.
         //we should consider a query to just look the value up for this forum -- it will likely
         //be faster in actual use and will almost certainly be simpler
         if (!$this->has_field('forumread')) {
             if (array_key_exists('forumread', $vbulletin->forumcache[$this->get_field('forumid')])) {
                 $this->set_field('forumread', $vbulletin->forumcache[$this->get_field('forumid')]['forumread']);
             } else {
                 //if we don't have forum read in the cache, then reload the cache.
                 //this implicitly references the current
                 cache_ordered_forums(1);
                 $this->set_field('forumread', $vbulletin->forumcache[$this->get_field('forumid')]['forumread']);
             }
         }
         return max($this->get_field('forumread'), TIMENOW - $vbulletin->options['markinglimit'] * 86400);
     } else {
         $forumview = intval(fetch_bbarray_cookie('forum_view', $this->get_field('forumid')));
         //use which one produces the highest value, most likely cookie
         return $forumview > $vbulletin->userinfo['lastvisit'] ? $forumview : $vbulletin->userinfo['lastvisit'];
     }
 }
Exemplo n.º 15
0
// ######################## START MAIN SCRIPT ############################
// #######################################################################
$vbulletin->input->clean_array_gpc('p', array('vote' => TYPE_UINT, 'pagenumber' => TYPE_UINT, 'perpage' => TYPE_UINT, 'ajax' => TYPE_BOOL));
if ($vbulletin->GPC['vote'] < 1 or $vbulletin->GPC['vote'] > 5) {
    eval(standard_error(fetch_error('invalidvote')));
}
if (!$threadinfo['threadid'] or !$threadinfo['visible'] and !can_moderate($threadinfo['forumid'], 'canmoderateposts') or !$threadinfo['open'] and !can_moderate($threadinfo['forumid'], 'canopenclose') or $threadinfo['isdeleted'] and !can_moderate($threadinfo['forumid'], 'candeleteposts')) {
    eval(standard_error(fetch_error('threadrateclosed')));
}
$forumperms = fetch_permissions($threadinfo['forumid']);
if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads']) or !($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) or !($forumperms & $vbulletin->bf_ugp_forumpermissions['canthreadrate']) or !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers']) and $threadinfo['postuserid'] != $vbulletin->userinfo['userid']) {
    print_no_permission();
}
// check if there is a forum password and if so, ensure the user has it set
verify_forum_password($foruminfo['forumid'], $foruminfo['password']);
$rated = intval(fetch_bbarray_cookie('thread_rate', $threadinfo['threadid']));
($hook = vBulletinHook::fetch_hook('threadrate_start')) ? eval($hook) : false;
$update = false;
if ($vbulletin->userinfo['userid']) {
    if ($rating = $db->query_first("\n\t\tSELECT *\n\t\tFROM " . TABLE_PREFIX . "threadrate\n\t\tWHERE userid = " . $vbulletin->userinfo['userid'] . "\n\t\t\tAND threadid = {$threadinfo['threadid']}\n\t")) {
        if ($vbulletin->options['votechange']) {
            if ($vbulletin->GPC['vote'] != $rating['vote']) {
                $threadrate =& datamanager_init('ThreadRate', $vbulletin, ERRTYPE_STANDARD);
                $threadrate->set_info('thread', $threadinfo);
                $threadrate->set_existing($rating);
                $threadrate->set('vote', $vbulletin->GPC['vote']);
                ($hook = vBulletinHook::fetch_hook('threadrate_update')) ? eval($hook) : false;
                $threadrate->save();
            }
            $update = true;
            if (!$vbulletin->GPC['ajax']) {
Exemplo n.º 16
0
	/**
	 * Populates a view with the expected info from a content item.
	 *
	 * @param vB_View $view
	 * @param int $viewtype
	 */
	protected function populateViewContent(vB_View $view, $viewtype = self::VIEW_PAGE, $increment_count = true)
	{
		global $show;

		if (empty($this->config))
		{
			$this->content->requireInfo(vBCms_Item_Content::INFO_CONFIG);
			 $this->config = $this->content->getConfig();
		}

		if ($_REQUEST['do']== 'apply' OR $_REQUEST['do'] == 'update' OR $_REQUEST['do'] == 'movenode')
		{
			$this->saveData($view);
			$this->content->requireInfo(vBCms_Item_Content::INFO_BASIC);
			$this->content->requireInfo(vBCms_Item_Content::INFO_CONFIG);
			$this->content->requireInfo(vBCms_Item_Content::INFO_NODE);
			$this->content->requireInfo(vBCms_Item_Content::INFO_PARENTS);
			$this->content->requireInfo(vBCms_Item_Content::INFO_NAVIGATION);
			$this->config = $this->content->getConfig();
		}
		else
		{
			$this->content->requireInfo(vBCms_Item_Content::INFO_BASIC);
			$this->content->requireInfo(vBCms_Item_Content::INFO_NODE);
			$this->content->requireInfo(vBCms_Item_Content::INFO_PARENTS);
			$this->content->requireInfo(vBCms_Item_Content::INFO_NAVIGATION);
		}

		if ($_REQUEST['goto'] == 'newcomment')
		{
			require_once DIR . '/includes/functions_bigthree.php' ;

			$record = vB::$vbulletin->db->query_first("SELECT associatedthreadid
				FROM " . TABLE_PREFIX . "cms_nodeinfo WHERE nodeid = " . $this->getNodeId());
			$threadid = $record['associatedthreadid'];
			$threadinfo = verify_id('thread', $threadid, 1, 1);

			if (vB::$vbulletin->options['threadmarking'] AND vB::$vbulletin->userinfo['userid'])
			{
				vB::$vbulletin->userinfo['lastvisit'] = max($threadinfo['threadread'], $threadinfo['forumread'], TIMENOW - (vB::$vbulletin->options['markinglimit'] * 86400));
			}
			else if (($tview = intval(fetch_bbarray_cookie('thread_lastview', $threadid))) > vB::$vbulletin->userinfo['lastvisit'])
			{
				vB::$vbulletin->userinfo['lastvisit'] = $tview;
			}

			$coventry = fetch_coventry('string');
			$posts = vB::$vbulletin->db->query_first("
				SELECT MIN(postid) AS postid
				FROM " . TABLE_PREFIX . "post
				WHERE threadid = $threadinfo[threadid]
					AND visible = 1
					AND dateline > " . intval(vB::$vbulletin->userinfo['lastvisit']) . "
					". ($coventry ? "AND userid NOT IN ($coventry)" : "") . "
				LIMIT 1
			");

			$target_url = vB_Router::getURL();
			$join_char = strpos($target_url,'?') ? '&amp;' : '?';
			if ($posts['postid'])
			{
				exec_header_redirect($target_url . $join_char . "commentid=" . $posts['postid'] . "#post$posts[postid]");
			}
			else
			{
				exec_header_redirect($target_url . $join_char . "commentid=" . $threadinfo['lastpostid'] . "#post$threadinfo[lastpostid]");
			}
		}
		if ($_REQUEST['commentid'])
		{
			vB::$vbulletin->input->clean_array_gpc('r', array(
				'commentid' => vB_Input::TYPE_INT,
			));
			$postinfo = verify_id('post', vB::$vbulletin->GPC['commentid'], 1, 1);
			$record = vB::$vbulletin->db->query_first("SELECT associatedthreadid
				FROM " . TABLE_PREFIX . "cms_nodeinfo WHERE nodeid = " . $this->getNodeId());
			$threadid = $record['associatedthreadid'];

			// if comment id and node id do not match, we ignore commentid
			if ($postinfo['threadid'] == $threadid)
			{
				$getpagenum = vB::$vbulletin->db->query_first("
					SELECT COUNT(*) AS posts
					FROM " . TABLE_PREFIX . "post AS post
					WHERE threadid = $threadid AND visible = 1
					AND dateline <= $postinfo[dateline]
				");
				$_REQUEST['commentpage'] = ceil($getpagenum['posts'] / 20);
			}
		}

		if ($_REQUEST['do']== 'apply' OR $_REQUEST['do'] == 'update' OR $_REQUEST['do'] == 'movenode')
		{
			$this->saveData($view);
		}

		($hook = vBulletinHook::fetch_hook($this->startpopulatehook)) ? eval($hook) : false;

		//Now we need to get the settings for turning off content. There is the "settingsforboth" flag, which says whether we even apply
		// the settings to the current page, and there are the six "show" variables.

		if ($_REQUEST['do'] == 'delete' AND $this->content->canEdit())
		{
			$dm = $this->content->getDM();
			$dm->delete();
			$this->cleanContentCache();

			// Create route to redirect the user to
			$route = new vBCms_Route_Content();
			$route->node = $this->content->getParentId();
			$_REQUEST['do'] = '';
			throw (new vB_Exception_Reroute($route));
		}

		//When we come from the link to upgrade a blog post, blog, or forum post, the
		// router puts us here.
		$settings_for = $this->content->getSettingsForboth();
		$showfor_this = (((self::VIEW_PAGE == $viewtype)
			AND ($settings_for == 0)) OR ((self::VIEW_PREVIEW == $viewtype)
			AND ($settings_for == 2))) ? 0 : 1;

		$view->showtitle = (($showfor_this AND !$this->content->getShowTitle()))? 0 : 1;
		$view->showpreviewonly = (($showfor_this AND !$this->content->getShowPreviewonly()))? 0 : 1;
		$view->showuser = (($showfor_this AND !$this->content->getShowUser()))? 0 : 1;
		$view->showupdated = (($showfor_this AND !$this->content->getShowUpdated()))? 0 : 1;
		$view->showviewcount = (($showfor_this AND !$this->content->getShowViewcount()))? 0 : 1;
		$view->showpublishdate = (($showfor_this AND !$this->content->getShowPublishdate()))? 0 : 1;
		$view->lastupdated = $this->content->getLastUpdated();
		$view->previewtext = $this->config['previewtext'];

		if ((self::VIEW_PREVIEW != $viewtype) OR !$view->showpreviewonly)
		{
			$view->pagetext = $this->config['pagetext'];
		}
		$view->previewimage = $this->config['preview_image'];
		$view->nodeid = $this->content->getNodeId();

		parent::populateViewContent($view, $viewtype);

		$segments = array('node' => vBCms_Item_Content::buildUrlSegment($this->content->getNodeId(), $this->content->getUrl()), 'action' =>'view');
		$view->page_url =  vBCms_Route_Content::getURL($segments);
		$view->pagetext = $this->config['pagetext'];

		if (self::VIEW_PAGE == $viewtype)
		{
			if ($increment_count)
			{
				//update the view count
				vB::$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX .
						"cms_nodeinfo set viewcount = viewcount + 1 where nodeid = " . $this->content->getNodeId());
			}

			//tagging code
			require_once DIR . '/includes/class_taggablecontent.php';

			$taggable = vB_Taggable_Content_Item::create(vB::$vbulletin, $this->content->getContentTypeId(),
				$this->content->getNodeId(), $this->content);

			if ($taggable)
			{
				$view->tags = $taggable->fetch_rendered_tag_list();
				$view->tag_count = $taggable->fetch_existing_tag_count();
				$view->showtags = vB::$vbulletin->options['threadtagging'];
			}
			else
			{
				$view->showtags = false;
			}

			$view->comment_count = $this->content->getReplyCount();
			$join_char = strpos($view->page_url,'?') ? '&amp;' : '?';
			$view->newcomment_url = $view->page_url . "#new_comment";
			$view->authorid = ($this->content->getUserId());
			$view->authorname = ($this->content->getUsername());
			$view->viewcount = ($this->content->getViewCount());
			$view->replycount = ($this->content->getReplyCount());
			$view->can_edit = ($this->content->canEdit() OR $this->content->canPublish()) ? 1 : 0;
			$view->parentid = $this->content->getParentId();

			//check to see if there is an associated thread.
			if ($associatedthreadid = $this->content->getAssociatedThreadId()
				and $this->content->getComments_Enabled())
			{
				$comment_block = new vBCms_Comments();
				$view->comment_block = $comment_block->getPageView($this->content->getNodeId(),
					$view->page_url);
			}

		}
		else if (self::VIEW_PREVIEW == $viewtype)
		{

			if ($showpreviewonly)
			{
				$view->previewtext = isset($this->config['previewtext']) ? $this->config['previewtext'] :
					 substr(strip_tags( $this->config['pagetext'], '<br />'), 0, $this->config['previewlength']);
				$view->preview_chopped = 1;

			}
			else
			{
				$view->previewtext = $view->pagetext;
			}

			$segments = array('node' => $this->content->getNodeId() . '-' . $this->content->getUrl(), 'action' =>'edit');
			$view->edit_url =  vBCms_Route_Content::getURL($segments) ;
			$view->read_more_phrase = new vB_Phrase('vbcms', 'read_more');
			$view->parenttitle = $this->content->getParentTitle();
			$view->pagetext = $pagetext;
			$view->setpublish = $view->published = $this->content->getPublished();
			$view->publishdate = $this->content->getPublishDateLocal();
			$view->comment_count = $this->content->getReplyCount();
			$join_char = strpos($view->page_url,'?') ? '&amp;' : '?';
			$view->newcomment_url = $view->page_url . "#new_comment";
			$view->authorid = ($this->content->getUserId());
			$view->authorname = ($this->content->getUsername());
			$view->viewcount = ($this->content->getViewCount());
			$view->replycount = ($this->content->getReplyCount());
			$view->can_edit = ($this->content->canEdit() OR $this->content->canPublish()) ? 1 : 0;
			$view->parentid = $this->content->getParentId();

			if (($associatedthreadid = $this->content->getAssociatedThreadId())
				AND $this->content->getComments_Enabled() AND intval($this->content->getReplyCount()) > 0)
			{
				$view->echo_comments = 1;
				$view->comment_count = $this->content->getReplyCount();
			}
			else
			{
				$view->echo_comments = 0;
				$view->comment_count = 0;
			}
		}

		$view->setpublish = $this->content->getSetPublish();
		$view->publishdate = $this->content->getPublishDate();
		$view->published = $this->content->getPublished() ?
			1 : 0;

		$view->publishdatelocal = vbdate(vB::$vbulletin->options['dateformat'], $this->content->getPublishDate());
		$view->publishtimelocal = vbdate( vB::$vbulletin->options['timeformat'], $this->content->getPublishDate() );

		//Get links to the author, section, and categories search pages
		//categories- this comes as an array
		$view->categories = $this->content->getCategories();
		$route_info = 'author/' . $this->content->getUserid() .
			($this->content->getUsername() != '' ? '-' . str_replace(' ', '-',
				vB_Search_Searchtools::stripHtmlTags($this->content->getUsername())) : '');
		$view->author_url = vB_Route::create('vBCms_Route_List', "$route_info/1")->getCurrentURL();

		// prepare the member action drop-down menu
		$view->memberaction_dropdown = construct_memberaction_dropdown(fetch_userinfo($this->content->getUserId()));

		//Section
		$route_info = 'section/' .$this->content->getParentId() .
			($this->content->getParentURLSegment() != '' ? '-' . str_replace(' ', '-',
				vB_Search_Searchtools::stripHtmlTags($this->content->getParentURLSegment())) : '');
		$view->section_list_url = vB_Route::create('vBCms_Route_List', "$route_info")->getCurrentURL();
		//and the content
		$route_info = $this->content->getParentId() .
			($this->content->getParentURLSegment() != '' ? '-' . str_replace(' ', '-',
				vB_Search_Searchtools::stripHtmlTags($this->content->getParentURLSegment())) : '');
		$view->section_url = vB_Route::create('vBCms_Route_Content', $route_info)->getCurrentURL();

		$view->html_title = $this->content->getHtmlTitle();
		$view->title = $this->content->getTitle();
		$view->contenttypeid = vB_Types::instance()->getContentTypeID("vBCms_Article");
		$view->dateformat = vB::$vbulletin->options['dateformat'];
		$view->showrating = $this->content->getShowRating();
		($hook = vBulletinHook::fetch_hook($this->endpopulatehook)) ? eval($hook) : false;

		if (method_exists($this->content, 'cacheNow'))
		{
			$this->content->cacheNow();
		}
		return $view;
	}
Exemplo n.º 17
0
function get_article_comments($article, $associated_thread_id, $userinfo, &$pageno, &$perpage, &$total)
{
    require_once DIR . '/includes/functions_misc.php';
    require_once DIR . '/includes/functions.php';
    require_once DIR . '/includes/functions_databuild.php';
    require_once DIR . '/includes/functions_bigthree.php';
    $posts_out = array();
    fetch_phrase_group('posting');
    $threadinfo = verify_id('thread', $associated_thread_id, 0, 1);
    $foruminfo = verify_id('forum', $threadinfo['forumid'], 0, 1);
    //First let's see if we have forum/thread view permissions. If not,
    // we're done
    if (!($permissions = can_view_thread($article->getNodeId(), $userinfo))) {
        return array();
    }
    $forumperms = fetch_permissions($threadinfo['forumid']);
    //Normally this thread will be wide open, so let's get the list first
    // without checking. We'll verify each post anyway.
    //get our results
    $results = get_comments($permissions, $associated_thread_id);
    $record_count = count($results);
    if (!$results or !count($results)) {
        return array();
    }
    //we accept the parameter "last" for pageno.
    if ($pageno == FR_LAST_POST) {
        $pageno = intval(($record_count + $perpage - 1) / $perpage);
        $first = ($pageno - 1) * $perpage;
    } else {
        $pageno = max(1, intval($pageno));
        $first = $perpage * ($pageno - 1);
    }
    //Let's trim off the results we need.
    //This also tells us if we should show the "next" button.
    $post_array = array_slice($results, $first, $perpage, true);
    if (!$post_array) {
        return array();
    }
    $firstpostid = false;
    $displayed_dateline = 0;
    if (vB::$vbulletin->options['threadmarking'] and vB::$vbulletin->userinfo['userid']) {
        $threadview = max($threadinfo['threadread'], $threadinfo['forumread'], TIMENOW - vB::$vbulletin->options['markinglimit'] * 86400);
    } else {
        $threadview = intval(fetch_bbarray_cookie('thread_lastview', $thread['threadid']));
        if (!$threadview) {
            $threadview = vB::$vbulletin->userinfo['lastvisit'];
        }
    }
    require_once DIR . '/includes/functions_user.php';
    $show['inlinemod'] = false;
    $postids = array();
    $postids = ' post.postid in (' . implode(', ', $post_array) . ')';
    $posts = vB::$vbulletin->db->query_read($sql = "\n\tSELECT\n\tpost.*, post.username AS postusername, post.ipaddress AS ip, IF(post.visible = 2, 1, 0) AS isdeleted,\n\t    user.*, userfield.*, usertextfield.*,\n\t    " . iif($forum['allowicons'], 'icon.title as icontitle, icon.iconpath,') . "\n\t    " . iif(vB::$vbulletin->options['avatarenabled'], 'avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight,') . "\n\t    " . ((can_moderate($thread['forumid'], 'canmoderateposts') or can_moderate($thread['forumid'], 'candeleteposts')) ? 'spamlog.postid AS spamlog_postid,' : '') . "\n\t    " . iif($deljoin, 'deletionlog.userid AS del_userid, deletionlog.username AS del_username, deletionlog.reason AS del_reason,') . "\n\t    editlog.userid AS edit_userid, editlog.username AS edit_username, editlog.dateline AS edit_dateline,\n\t    editlog.reason AS edit_reason, editlog.hashistory,\n\t    postparsed.pagetext_html, postparsed.hasimages,\n\t    sigparsed.signatureparsed, sigparsed.hasimages AS sighasimages,\n\t    sigpic.userid AS sigpic, sigpic.dateline AS sigpicdateline, sigpic.width AS sigpicwidth, sigpic.height AS sigpicheight,\n\t    IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid, infractiongroupid,\n\t    customprofilepic.userid AS profilepic, customprofilepic.dateline AS profilepicdateline, customprofilepic.width AS ppwidth, customprofilepic.height AS ppheight\n\t    " . iif(!($permissions['genericpermissions'] & vB::$vbulletin->bf_ugp_genericpermissions['canseehiddencustomfields']), vB::$vbulletin->profilefield['hidden']) . "\n\t    {$hook_query_fields}\n\t    FROM " . TABLE_PREFIX . "post AS post\n\t    LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = post.userid)\n\t    LEFT JOIN " . TABLE_PREFIX . "userfield AS userfield ON(userfield.userid = user.userid)\n\t    LEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON(usertextfield.userid = user.userid)\n\t    " . iif($forum['allowicons'], "LEFT JOIN " . TABLE_PREFIX . "icon AS icon ON(icon.iconid = post.iconid)") . "\n\t    " . iif(vB::$vbulletin->options['avatarenabled'], "LEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON(avatar.avatarid = user.avatarid) LEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON(customavatar.userid = user.userid)") . "\n\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    {$deljoin}\n\t    LEFT JOIN " . TABLE_PREFIX . "editlog AS editlog ON(editlog.postid = post.postid)\n\t    LEFT JOIN " . TABLE_PREFIX . "postparsed AS postparsed ON(postparsed.postid = post.postid AND postparsed.styleid = " . intval(STYLEID) . " AND postparsed.languageid = " . intval(LANGUAGEID) . ")\n\t    LEFT JOIN " . TABLE_PREFIX . "sigparsed AS sigparsed ON(sigparsed.userid = user.userid AND sigparsed.styleid = " . intval(STYLEID) . " AND sigparsed.languageid = " . intval(LANGUAGEID) . ")\n\t    LEFT JOIN " . TABLE_PREFIX . "sigpic AS sigpic ON(sigpic.userid = post.userid)\n\t    LEFT JOIN " . TABLE_PREFIX . "customprofilepic AS customprofilepic ON (user.userid = customprofilepic.userid)\n\t    {$hook_query_joins}\n\t    WHERE {$postids}\n\t    ORDER BY post.dateline\n\t    ");
    if (!($forumperms & vB::$vbulletin->bf_ugp_forumpermissions['canseethumbnails']) and !($forumperms & vB::$vbulletin->bf_ugp_forumpermissions['cangetattachment'])) {
        vB::$vbulletin->options['attachthumbs'] = 0;
    }
    if (!($forumperms & vB::$vbulletin->bf_ugp_forumpermissions['cangetattachment'])) {
        vB::$vbulletin->options['viewattachedimages'] = 0;
    }
    $postcount = count($postid_array);
    $counter = 0;
    $postbits = '';
    vB::$vbulletin->noheader = true;
    while ($post = vB::$vbulletin->db->fetch_array($posts)) {
        if (!$privileges['can_moderate_forums']) {
            if ($privileges['is_coventry'] or $post['visible'] == 2) {
                continue;
            }
        }
        // post/thread is deleted by moderator and we don't have permission to see it
        if (!($post['visible'] or $privileges['can_moderate_posts'])) {
            continue;
        }
        if (!intval($post['userid'])) {
            $post['avatarid'] = false;
        } else {
            if (!$post['hascustomavatar']) {
                if ($post['profilepic']) {
                    $post['hascustomavatar'] = 1;
                    $post['avatarid'] = true;
                    $post['avatarpath'] = "./image.php?u=" . $post['userid'] . "&amp;dateline=" . $post['profilepicdateline'] . "&amp;type=profile";
                    $post['avwidth'] = $post['ppwidth'];
                    $post['avheight'] = $post['ppheight'];
                } else {
                    $post['hascustomavatar'] = 1;
                    $post['avatarid'] = true;
                    // explicity setting avatarurl to allow guests comments to show unknown avatar
                    $post['avatarurl'] = $post['avatarpath'] = vB_Template_Runtime::fetchStyleVar('imgdir_misc') . '/unknown.gif';
                    $post['avwidth'] = 60;
                    $post['avheight'] = 60;
                }
            }
        }
        if ($tachyuser = in_coventry($post['userid']) and !can_moderate($thread['forumid'])) {
            continue;
        }
        if ($post['visible'] == 1 and !$tachyuser) {
            ++$counter;
            if ($postorder) {
                $post['postcount'] = --$postcount;
            } else {
                $post['postcount'] = ++$postcount;
            }
        }
        if ($tachyuser) {
            $fetchtype = 'post_global_ignore';
        } else {
            if ($ignore["{$post['userid']}"]) {
                $fetchtype = 'post_ignore';
            } else {
                if ($post['visible'] == 2) {
                    $fetchtype = 'post_deleted';
                } else {
                    $fetchtype = 'post';
                }
            }
        }
        if (vB::$vbulletin->GPC['viewfull'] and $post['postid'] == $postinfo['postid'] and $fetchtype != 'post' and (can_moderate($threadinfo['forumid']) or !$post['isdeleted'])) {
            $fetchtype = 'post';
        }
        if (!$firstpostid) {
            $firstpostid = $post['postid'];
        }
        $post['islastshown'] = $post['postid'] == $lastpostid;
        $post['isfirstshown'] = ($counter == 1 and $fetchtype == 'post' and $post['visible'] == 1);
        $post['islastshown'] = $post['postid'] == $lastpostid;
        $post['attachments'] = $postattach["{$post['postid']}"];
        $canedit = false;
        if (!$threadinfo['isdeleted'] and !$post['isdeleted'] and (can_moderate($threadinfo['forumid'], 'caneditposts') or $threadinfo['open'] and $post['userid'] == vB::$vbulletin->userinfo['userid'] and $forumperms & vB::$vbulletin->bf_ugp_forumpermissions['caneditpost'] and ($post['dateline'] >= TIMENOW - vB::$vbulletin->options['edittimelimit'] * 60 or vB::$vbulletin->options['edittimelimit'] == 0))) {
            $canedit = true;
        }
        // Get post date/time
        $postdate = vbdate(vB::$vbulletin->options['dateformat'], $post['dateline'], 1);
        $posttime = vbdate(vB::$vbulletin->options['timeformat'], $post['dateline']);
        $attachments = array();
        $fr_images = array();
        // Attachments (images).
        if (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) {
                    $fr_images[] = array('img' => vB::$vbulletin->options['bburl'] . '/attachment.php?attachmentid=' . $attachment['attachmentid'], 'tmb' => vB::$vbulletin->options['bburl'] . '/attachment.php?attachmentid=' . $attachment['attachmentid'] . '&stc=1&thumb=1');
                }
            }
        }
        // Parse the post for quotes and inline images
        list($text, $nuked_quotes, $images) = parse_post($post['pagetext'], false);
        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 (vB::$vbulletin->options['avatarenabled']) {
            require_once DIR . '/includes/functions_user.php';
            $userinfo = fetch_userinfo($post['userid'], FETCH_USERINFO_AVATAR);
            fetch_avatar_from_userinfo($userinfo);
            if ($userinfo['avatarurl']) {
                $avatarurl = process_avatarurl($userinfo['avatarurl']);
            }
        }
        $tmp = array('post_id' => $post['postid'], 'thread_id' => $post['threadid'], 'forum_id' => $foruminfo['forumid'], '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'], 'userid' => $post['userid'], 'title' => prepare_utf8_string($post['title']), 'post_timestamp' => prepare_utf8_string(date_trunc($postdate) . ' ' . $posttime), 'fr_images' => $fr_images, 'image_thumbs' => array());
        // 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 ($canedit) {
                $tmp['canedit'] = true;
                $tmp['edittext'] = prepare_utf8_string($post['pagetext']);
            }
        }
        if ($avatarurl != '') {
            $tmp['avatarurl'] = $avatarurl;
        }
        $posts_out[] = $tmp;
    }
    if ($LASTPOST['dateline'] > $displayed_dateline) {
        $displayed_dateline = $LASTPOST['dateline'];
        if ($displayed_dateline <= $threadview) {
            $updatethreadcookie = true;
        }
    }
    // Set thread last view
    if ($displayed_dateline and $displayed_dateline > $threadview) {
        mark_thread_read($threadinfo, $foruminfo, vB::$vbulletin->userinfo['userid'], $displayed_dateline);
    }
    vB::$vbulletin->db->free_result($posts);
    unset($post);
    $total = $record_count;
    return $posts_out;
}
Exemplo n.º 18
0
	/**
	 * Populates a view with the expected info from a content item.
	 *
	 * @param vB_View $view
	 * @param int $viewtype
	 */
	protected function populateViewContent(vB_View $view, $viewtype = self::VIEW_PAGE, $increment_count = true)
	{
		global $show;
		$this->content->requireInfo(vBCms_Item_Content::INFO_BASIC);
		$this->content->requireInfo(vBCms_Item_Content::INFO_CONTENT);
		$this->content->requireInfo(vBCms_Item_Content::INFO_CONFIG);
		$this->content->requireInfo(vBCms_Item_Content::INFO_NODE);
		$this->content->requireInfo(vBCms_Item_Content::INFO_PARENTS);

		if ($_REQUEST['goto'] == 'newcomment')
		{
			require_once DIR . '/includes/functions_bigthree.php' ;

			$record = vB::$vbulletin->db->query_first("SELECT associatedthreadid
				FROM " . TABLE_PREFIX . "cms_nodeinfo WHERE nodeid = " . $this->getNodeId());
			$threadid = $record['associatedthreadid'];
			$threadinfo = verify_id('thread', $threadid, 1, 1);

			if (vB::$vbulletin->options['threadmarking'] AND vB::$vbulletin->userinfo['userid'])
			{
				vB::$vbulletin->userinfo['lastvisit'] = max($threadinfo['threadread'], $threadinfo['forumread'], TIMENOW - (vB::$vbulletin->options['markinglimit'] * 86400));
			}
			else if (($tview = intval(fetch_bbarray_cookie('thread_lastview', $threadid))) > vB::$vbulletin->userinfo['lastvisit'])
			{
				vB::$vbulletin->userinfo['lastvisit'] = $tview;
			}

			$coventry = fetch_coventry('string');
			$posts = vB::$vbulletin->db->query_first("
				SELECT MIN(postid) AS postid
				FROM " . TABLE_PREFIX . "post
				WHERE threadid = $threadinfo[threadid]
					AND visible = 1
					AND dateline > " . intval(vB::$vbulletin->userinfo['lastvisit']) . "
					". ($coventry ? "AND userid NOT IN ($coventry)" : "") . "
				LIMIT 1
			");

			$target_url = vB_Router::getURL();
			$join_char = strpos($target_url,'?') ? '&amp;' : '?';
			if ($posts['postid'])
			{
				exec_header_redirect($target_url . $join_char . "commentid=" . $posts['postid'] . "#post$posts[postid]");
			}
			else
			{
				exec_header_redirect($target_url . $join_char . "commentid=" . $threadinfo['lastpostid'] . "#post$threadinfo[lastpostid]");
			}
		}
		if ($_REQUEST['commentid'])
		{
			vB::$vbulletin->input->clean_array_gpc('r', array(
				'commentid' => vB_Input::TYPE_INT,
			));
			$postinfo = verify_id('post', vB::$vbulletin->GPC['commentid'], 1, 1);
			$record = vB::$vbulletin->db->query_first("SELECT associatedthreadid
				FROM " . TABLE_PREFIX . "cms_nodeinfo WHERE nodeid = " . $this->getNodeId());
			$threadid = $record['associatedthreadid'];

			// if comment id and node id do not match, we ignore commentid
			if ($postinfo['threadid'] == $threadid)
			{
				$getpagenum = vB::$vbulletin->db->query_first("
					SELECT COUNT(*) AS posts
					FROM " . TABLE_PREFIX . "post AS post
					WHERE threadid = $threadid AND visible = 1
					AND dateline <= $postinfo[dateline]
				");
				$_REQUEST['commentpage'] = ceil($getpagenum['posts'] / 20);
			}
		}

		if ($_REQUEST['do']== 'apply' OR $_REQUEST['do'] == 'update' OR $_REQUEST['do'] == 'movenode')
		{
			$this->SaveData($view);
		}

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

		//Now we need to get the settings for turning off content. There is the "settingsforboth" flag, which says whether we even apply
		// the settings to the current page, and there are the six "show" variables.

		if ($_REQUEST['do'] == 'delete' AND $this->content->canEdit())
		{
			$dm = $this->content->getDM();
			$dm->delete();
			$this->cleanContentCache();

			// Create route to redirect the user to
			$route = new vBCms_Route_Content();
			$route->node = $this->content->getParentId();
			$_REQUEST['do'] = '';
			throw (new vB_Exception_Reroute($route));
		}

		//When we come from the link to upgrade a blog post, blog, or forum post, the
		// router puts us here.
		$settings_for = $this->content->getSettingsForboth();
		$showfor_this = (((self::VIEW_PAGE == $viewtype)
			AND ($settings_for == 0)) OR ((self::VIEW_PREVIEW == $viewtype)
			AND ($settings_for == 2))) ? 0 : 1;

		$view->showtitle = (($showfor_this AND !$this->content->getShowTitle()))? 0 : 1;
		$view->showpreviewonly = (($showfor_this AND !$this->content->getShowPreviewonly()))? 0 : 1;
		$view->showuser = (($showfor_this AND !$this->content->getShowUser()))? 0 : 1;
		$view->showupdated = (($showfor_this AND !$this->content->getShowUpdated()))? 0 : 1;
		$view->showviewcount = (($showfor_this AND !$this->content->getShowViewcount()))? 0 : 1;
		$view->showpublishdate = (($showfor_this AND !$this->content->getShowPublishdate()))? 0 : 1;
		$view->lastupdated = $this->content->getLastUpdated();
		$showpreviewonly = (($showfor_this AND !$this->content->getShowPreviewonly()))? 0 : 1;

		parent::populateViewContent($view, $viewtype);

		$segments = array('node' => vBCms_Item_Content::buildUrlSegment($this->content->getNodeId(), $this->content->getUrl()), 'action' =>'view');
		$view->page_url =  vBCms_Route_Content::getURL($segments);

		if ($this->editing)
		{
			$view->pagetext = $this->content->getPageText();
		}
		else
		{
			$rendered = $this->content->getRendered($this->data_saved);
			$view->pagetext = $rendered['pages'][$this->parameters['page']];

			if ($this->content->canDownload())
			{
				$view->attachments = $rendered['attachments'];
				$view->showattachments = empty($rendered['viewinfo']) ? 0 : 1 ;


				if (!empty($rendered['viewinfo']))
				{
					foreach ($rendered['viewinfo'] as $key => $viewbit)
					{
						$view->$key = $viewbit;
					}
				}
			}

			$view->parenttitle = $this->content->getParentTitle();

			$view->showattachments = empty($view->attachments) ? 0 : 1 ;

			if (!empty($viewinfo))
			{
				foreach ($viewinfo as $key => $viewbit)
				{
					$view->$key = $viewbit;
				}
			}

			$view->pagelist = $rendered['pagelist'];
			$view->nodesegment = $this->content->getUrlSegment();
			$view->current_page = $this->parameters['page'];
			if ($this->content->canDownload())
			{
				$show['lightbox'] = (vB::$vbulletin->options['lightboxenabled'] AND vB::$vbulletin->options['usepopups']);
			}
		}

		// Only break pages for the page view
		if ((self::VIEW_PAGE == $viewtype) OR (self::VIEW_PREVIEW == $viewtype))
		{
			if (self::VIEW_PAGE == $viewtype)
			{
				if ($increment_count)
				{
					//update the view count
					vB::$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX .
							"cms_nodeinfo set viewcount = viewcount + 1 where nodeid = " . $this->content->getNodeId());
				}

				//tagging code
				require_once DIR . '/includes/class_taggablecontent.php';
				$taggable = vB_Taggable_Content_Item::create(vB::$vbulletin, $this->content->getContentTypeId(),
					$this->content->getContentId(), $this->content);
				$view->tags = $taggable->fetch_rendered_tag_list();
				$view->tag_count = $taggable->fetch_existing_tag_count();
				$view->showtags = vB::$vbulletin->options['threadtagging'];

				// promoted threadid
				if ($promoted_threadid = $this->content->getThreadId())
				{
					if ($promoted_threadid = verify_id('thread', $promoted_threadid, false))
					{
						// get threadinfo
						$threadinfo = fetch_threadinfo($promoted_threadid);
						$forumperms = fetch_permissions($threadinfo['forumid']);
						$view->threadinfo = $threadinfo;
						// check permissions
						if ($threadinfo['visible'] != 1)
						{
							$promoted_threadid = false;
						}
						else if (!($forumperms & vB::$vbulletin->bf_ugp_forumpermissions['canview'])
							OR !($forumperms & vB::$vbulletin->bf_ugp_forumpermissions['canviewthreads'])
							OR (!($forumperms & vB::$vbulletin->bf_ugp_forumpermissions['canviewothers'])
								AND ($threadinfo['postuserid'] != vB::$vbulletin->userinfo['userid'] OR vB::$vbulletin->userinfo['userid'] == 0)
							))
						{
							$promoted_threadid = false;
						}
						else
						{
							// check forum password
							$foruminfo = fetch_foruminfo($threadinfo['forumid']);

							if ($foruminfo['password'] AND !verify_forum_password($foruminfo['forumid'], $foruminfo['password'], false))
							{
								$promoted_threadid = false;
							}
						}

						$view->promoted_threadid = $promoted_threadid;
					}
				}

				// get pagelist for navigation
				$view->postitle = $this->content->getPostTitle();
				$view->poststarter = $this->content->getPostStarter();
				$view->postauthor = $this->content->getPostAuthor();
				$view->postid = ($this->content->getPostId());
				$view->threadid = $this->content->getThreadId();
				$view->blogpostid = ($this->content->getBlogPostId());
				$view->post_started = ($this->content->getPostStarted());
				$view->post_posted = ($this->content->getPostPosted());
				$view->promoted_blogid = $this->content->getBlogId();

				//make links to original post and/or blog if appropriate
				if ($view->promoted_blogid)
				{
					$view->blog_url = fetch_seo_url('blog',
						array('userid' => $this->content->getPostStarter(),
						'blog_title' => $this->content->getPostTitle()));
				}
				else if ($view->threadid)
				{
					$threadinfo = vB::$vbulletin->db->query_first("SELECT threadid, title FROM " .
						TABLE_PREFIX . "thread where threadid = " . $view->threadid);

					if ($threadinfo)
					{
						$post_url = fetch_seo_url('thread', $threadinfo);
						$post_url .= (strpos($post_url, '?' ) ? '&amp;p=' :  '?p=') . $view->postid .
							'#post' . $view->postid;
						$view->post_url = $post_url;
					}
				}

				$view->comment_count = $this->content->getReplyCount();
				$join_char = strpos($view->page_url,'?') ? '&amp;' : '?';
				$view->newcomment_url = $view->page_url . "#new_comment";
				$view->authorid = ($this->content->getUserId());
				$view->authorname = ($this->content->getUsername());
				$view->viewcount = ($this->content->getViewCount());
				$view->replycount = ($this->content->getReplyCount());
				$view->can_edit = ($this->content->canEdit() OR $this->content->canPublish()) ? 1 : 0;
				$view->parentid = $this->content->getParentId();

				// facebook options
				if (is_facebookenabled())
				{
					// display the like button for this article?
					$view->fblikebutton = construct_fblikebutton();
				}

				//check to see if there is an associated thread.
				if ($associatedthreadid = $this->content->getAssociatedThreadId()
					and $this->content->getComments_Enabled())
				{
					$comment_block = new vBCms_Comments();
					$view->comment_block = $comment_block->getPageView($this->content->getNodeId(),
						$view->page_url);
				}
			}
			else if (self::VIEW_PREVIEW == $viewtype)
			{
				if ($showpreviewonly)
				{
					$view->previewtext = $this->content->getPreviewText();
					$view->preview_chopped = 1;
				}
				else
				{
					$view->previewtext = $view->pagetext;

					if (count($view->pagelist) > 1)
					{
						$view->preview_chopped = 1;
					}
				}

				$segments = array('node' => $this->content->getNodeId() . '-' . $this->content->getUrl(), 'action' =>'edit');
				$view->edit_url =  vBCms_Route_Content::getURL($segments) ;
				$view->read_more_phrase = new vB_Phrase('vbcms', 'read_more');
				$view->parenttitle = $this->content->getParentTitle();
				$view->pagetext = $pagetext;
				$view->setpublish = $view->published = $this->content->getPublished();
				$view->publishdate = $this->content->getPublishDateLocal();
				$view->promoted_blogid = $this->content->getBlogId();
				$view->comment_count = $this->content->getReplyCount();
				$join_char = strpos($view->page_url,'?') ? '&amp;' : '?';
				$view->newcomment_url = $view->page_url . "#new_comment";
				$view->authorid = ($this->content->getUserId());
				$view->authorname = ($this->content->getUsername());
				$view->viewcount = ($this->content->getViewCount());
				$view->replycount = ($this->content->getReplyCount());
				$view->postid = ($this->content->getPostId());
				$view->blogpostid = $this->content->getBlogPostId();
				$view->can_edit = ($this->content->canEdit() OR $this->content->canPublish()) ? 1 : 0;
				$view->parentid = $this->content->getParentId();
				$view->post_started = $this->content->getPostStarted();
				$view->post_posted = $this->content->getPostPosted();


				//We need to check rights. If this user doesn't have download rights we hide the image.
				if ($this->content->canDownload())
				{
					if ($view->previewimage= $this->content->getPreviewImage())
					{
						$view->imagewidth= $this->content->getImageWidth();
						$view->imageheight= $this->content->getImageHeight();
					}

					if ($view->previewvideo= $this->content->getPreviewVideo())
					{
						$view->haspreviewvideo = true;
					}
				}
				else
				{
					$view->previewimage = false;
					$view->previewvideo = false;
				}

				if (($associatedthreadid = $this->content->getAssociatedThreadId())
					AND $this->content->getComments_Enabled() AND intval($this->content->getReplyCount()) > 0)
				{
					$view->echo_comments = 1;
					$view->comment_count = $this->content->getReplyCount();
				}
				else
				{
					$view->echo_comments = 0;
					$view->comment_count = 0;
				}
			}
		}

		//If this was promoted from a blog or post, we need to verify the permissions.
		if (intval($view->blogpostid))
		{
			$view->can_view_post =
				(!($vbulletin->userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_canviewothers'])) ?
				0 : 1 ;
		}
		else if (intval($view->postid))
		{
			$user = new vB_Legacy_CurrentUser();
			if ($post = vB_Legacy_Post::create_from_id($view->postid))
			{
				$view->can_view_post = $post->can_view($user) ? 1 : 0;
			}
		}

		$view->poststarter = array('userid' => $this->content->getPostStarter(),
			'username' => $this->content->getPostAuthor());
		$view->setpublish = $this->content->getSetPublish();
		$view->publishdate = $this->content->getPublishDate();
		$view->published = $this->content->getPublished() ?
			1 : 0;

		$view->publishdatelocal = vbdate(vB::$vbulletin->options['dateformat'], $this->content->getPublishDate());
		$view->publishtimelocal = vbdate( vB::$vbulletin->options['timeformat'], $this->content->getPublishDate() );

		//Get links to the author, section, and categories search pages
		//categories- this comes as an array
		$view->categories = $this->content->getCategories();
		$route_info = 'author/' . $this->content->getUserid() .
			($this->content->getUsername() != '' ? '-' . str_replace(' ', '-',
				vB_Search_Searchtools::stripHtmlTags($this->content->getUsername())) : '');
		$view->author_url = vB_Route::create('vBCms_Route_List', "$route_info/1")->getCurrentURL();

		// prepare the member action drop-down menu
		$view->memberaction_dropdown = construct_memberaction_dropdown(fetch_userinfo($this->content->getUserId()));

		//Section
		$route_info = 'section/' .$this->content->getParentId() .
			($this->content->getParentURLSegment() != '' ? '-' . str_replace(' ', '-',
				vB_Search_Searchtools::stripHtmlTags($this->content->getParentURLSegment())) : '');
		$view->section_list_url = vB_Route::create('vBCms_Route_List', "$route_info")->getCurrentURL();
		//and the content
		$route_info = $this->content->getParentId() .
			($this->content->getParentURLSegment() != '' ? '-' . str_replace(' ', '-',
				vB_Search_Searchtools::stripHtmlTags($this->content->getParentURLSegment())) : '');
		$view->section_url = vB_Route::create('vBCms_Route_Content', $route_info)->getCurrentURL();

		$view->html_title = $this->content->getHtmlTitle();
		$view->title = $this->content->getTitle();
		$view->contenttypeid = vB_Types::instance()->getContentTypeID("vBCms_Article");
		$view->dateformat = vB::$vbulletin->options['dateformat'];
		$view->showrating = $this->content->getShowRating();
		($hook = vBulletinHook::fetch_hook('vbcms_article_populate_end')) ? eval($hook) : false;
		$this->content->cacheNow();
		return $view;
	}
Exemplo n.º 19
0
/**
* Returns whether or not the visiting user can view the specified password-protected forum
*
* @param	integer	Forum ID
* @param	string	Provided password
* @param	boolean	If true, show error when access is denied
*
* @return	boolean
*/
function verify_forum_password($forumid, $password, $showerror = true)
{
	global $vbulletin;

	if (!$password OR ($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel']) OR ($vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['ismoderator']) OR can_moderate($forumid))
	{
		return true;
	}

	$foruminfo = fetch_foruminfo($forumid);
	$parents = explode(',', $foruminfo['parentlist']);
	foreach ($parents AS $fid)
	{ // get the pwd from any parent forums -- allows pwd cookies to cascade down
		if ($temp = fetch_bbarray_cookie('forumpwd', $fid) AND $temp === md5($vbulletin->userinfo['userid'] . $password))
		{
			return true;
		}
	}

	// didn't match the password in any cookie
	if ($showerror)
	{
		require_once(DIR . '/includes/functions_misc.php');

		$security_token_html = '<input type="hidden" name="securitytoken" value="' . $vbulletin->userinfo['securitytoken'] . '" />';

		// forum password is bad - show error
		// TODO convert the 'forumpasswordmissoing' phrase to vB4
		eval(standard_error(fetch_error('forumpasswordmissing',
			$vbulletin->session->vars['sessionhash'],
			$vbulletin->scriptpath,
			$forumid,
			construct_post_vars_html() . $security_token_html,
			10,
			1
		)));
	}
	else
	{
		// forum password is bad - return false
		return false;
	}
}
Exemplo n.º 20
0
/**
* Return the current issue_lastview for the issue using the appropriate method.
*
* @param	array	Array of data for the issue
*
* @return	integer	unix timestamp as issue_lastview
*/
function issue_lastview($issue)
{
    global $vbulletin;
    if ($vbulletin->options['threadmarking'] and $vbulletin->userinfo['userid']) {
        $issueview = max($issue['issueread'], $issue['projectread'], TIMENOW - $vbulletin->options['markinglimit'] * 86400);
    } else {
        $issueview = max(intval(fetch_bbarray_cookie('issue_lastview', $issue['issueid'])), intval(fetch_bbarray_cookie('project_lastview', $issue['projectid'] . $issue['issuetypeid'])), $vbulletin->userinfo['lastvisit']);
    }
    return intval($issueview);
}
Exemplo n.º 21
0
	/**
	* Processes the date information and determines whether the post is new or old
	*/
	function process_date_status()
	{
		global $vbphrase, $firstnew;

		// get new/old post statusicon
		// this is also needed by ignored and deleted posts as they should show read/unread status as well (if you can see them)
		if (!empty($this->thread))
		{
			if (isset($this->thread['threadview']))
			{
				$lastvisit = $this->thread['threadview'];
			}
			else if ($this->registry->options['threadmarking'] AND $this->registry->userinfo['userid'])
			{
				$threadview = max($this->thread['threadread'], $this->thread['forumread'], TIMENOW - ($this->registry->options['markinglimit'] * 86400));
				$lastvisit = $this->thread['threadview'] = intval($threadview);
			}
			else if (($tview = fetch_bbarray_cookie('thread_lastview', $threadid)) > $this->registry->userinfo['lastvisit'])
			{
				$lastvisit = $this->thread['threadview'] = intval($tview);
			}
			else
			{
				$lastvisit = $this->registry->userinfo['lastvisit'];
			}
		}
		else
		{
			$lastvisit = $this->registry->userinfo['lastvisit'];
		}

		if ($this->post['dateline'] > $lastvisit)
		{
			$this->post['statusicon'] = 'new';
			$this->post['statustitle'] = $vbphrase['unread_date'];
			if (!$firstnew)
			{
				$firstnew = $this->post['postid'];
				$this->post['firstnewinsert' ] = '<a name="newpost"></a>';
			}
			else
			{
				$this->post['firstnewinsert'] = '';
			}
		}
		else
		{
			$this->post['statusicon'] = 'old';
			$this->post['statustitle'] = $vbphrase['old'];
			$this->post['firstnewinsert'] = '';
		}

		// format date/time
		$this->post['postdate'] = vbdate($this->registry->options['dateformat'], $this->post['dateline'], true);
		$this->post['posttime'] = vbdate($this->registry->options['timeformat'], $this->post['dateline']);
	}
Exemplo n.º 22
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;
}
Exemplo n.º 23
0
function fetch_forum_lightbulb(&$forumid, &$lastpostinfo, &$foruminfo)
{
    global $bb_view_cache, $vbulletin;
    if (is_array($foruminfo) and !empty($foruminfo['link'])) {
        // see if it is a redirect
        return 'link';
    } else {
        if (!$vbulletin->userinfo['lastvisit']) {
            return 'new';
        } else {
            if ($vbulletin->options['threadmarking'] and $vbulletin->userinfo['userid']) {
                $userlastvisit = !empty($foruminfo['forumread']) ? $foruminfo['forumread'] : TIMENOW - $vbulletin->options['markinglimit'] * 86400;
            } else {
                $forumview = intval(fetch_bbarray_cookie('forum_view', $foruminfo['forumid']));
                //use which one produces the highest value, most likely cookie
                $userlastvisit = $forumview > $vbulletin->userinfo['lastvisit'] ? $forumview : $vbulletin->userinfo['lastvisit'];
            }
            if ($lastpostinfo['lastpost'] and $userlastvisit < $lastpostinfo['lastpost'] and $vbulletin->userinfo['forumpermissions'][$foruminfo['forumid']] & $vbulletin->bf_ugp_forumpermissions['canviewothers']) {
                return 'new';
            } else {
                return 'old';
            }
        }
    }
}
Exemplo n.º 24
0
 // now move on to actual display code
 $hook_query_fields = $hook_query_joins = '';
 ($hook = vBulletinHook::fetch_hook('tags_list_query_data')) ? eval($hook) : false;
 $thread_sql = $db->query_read_slave("\n\t\tSELECT\n\t\t\tthread.threadid, thread.title AS threadtitle, thread.forumid, pollid, open, postusername, postuserid, thread.iconid AS threadiconid,\n\t\t\tthread.dateline, notes, thread.visible, sticky, votetotal, thread.attach, {$tachy_columns},\n\t\t\tthread.prefixid, thread.taglist, hiddencount, deletedcount\n\t\t\t" . ($vbulletin->options['threadpreview'] > 0 ? ', post.pagetext AS preview' : '') . "\n\t\t\t" . (($vbulletin->options['threadsubscribed'] and $vbulletin->userinfo['userid']) ? ", NOT ISNULL(subscribethread.subscribethreadid) AS issubscribed" : "") . "\n\t\t\t" . (($vbulletin->options['threadmarking'] and $vbulletin->userinfo['userid']) ? ", threadread.readtime AS threadread" : "") . "\n\t\t\t{$hook_query_fields}\n\t\tFROM " . TABLE_PREFIX . "thread AS thread\n\t\t\t" . (($vbulletin->options['threadsubscribed'] and $vbulletin->userinfo['userid']) ? " LEFT JOIN " . TABLE_PREFIX . "subscribethread AS subscribethread ON(subscribethread.threadid = thread.threadid AND subscribethread.userid = " . $vbulletin->userinfo['userid'] . " AND canview = 1)" : "") . "\n\t\t\t" . (($vbulletin->options['threadmarking'] and $vbulletin->userinfo['userid']) ? " LEFT JOIN " . TABLE_PREFIX . "threadread AS threadread ON (threadread.threadid = thread.threadid AND threadread.userid = " . $vbulletin->userinfo['userid'] . ")" : "") . "\n\t\t\t" . ($vbulletin->options['threadpreview'] > 0 ? "LEFT JOIN " . TABLE_PREFIX . "post AS post ON(post.postid = thread.firstpostid)" : '') . "\n\t\t\t{$tachyjoin}\n\t\t\t{$hook_query_joins}\n\t\tWHERE thread.threadid IN (" . implode(',', $threadids) . ")\n\t");
 $threads = array();
 $lastread = array();
 $managethread = $movethread = $deletethread = $approvethread = $openthread = array();
 while ($thread = $db->fetch_array($thread_sql)) {
     $threads["{$thread['threadid']}"] = $thread;
     // get forum read times if needed
     if (!isset($lastread["{$thread['forumid']}"])) {
         if ($vbulletin->options['threadmarking'] and $vbulletin->userinfo['userid']) {
             $forum = $vbulletin->forumcache["{$thread['forumid']}"];
             $lastread["{$thread['forumid']}"] = max($forum['forumread'], TIMENOW - $vbulletin->options['markinglimit'] * 86400);
         } else {
             $forumview = intval(fetch_bbarray_cookie('forum_view', $thread['forumid']));
             $lastread["{$thread['forumid']}"] = $forumview > $vbulletin->userinfo['lastvisit'] ? $forumview : $vbulletin->userinfo['lastvisit'];
         }
     }
     // check inline mod stuff
     if (can_moderate($thread['forumid'], 'canmanagethreads')) {
         $movethread["{$thread['threadid']}"] = 1;
         $show['movethread'] = true;
     }
     if (can_moderate($thread['forumid'], 'candeleteposts') or can_moderate($thread['forumid'], 'canremoveposts')) {
         $deletethread["{$thread['threadid']}"] = 1;
         $show['deletethread'] = true;
     }
     if (can_moderate($thread['forumid'], 'canmoderateposts')) {
         $approvethread["{$thread['threadid']}"] = 1;
         $show['approvethread'] = true;
Exemplo n.º 25
0
         continue;
     }
     $fperms = $vbulletin->userinfo['forumpermissions']["{$forumid}"];
     $items = vb_number_format(sizeof($tmp["{$forumid}"]['self']) + sizeof($tmp["{$forumid}"]['other']));
     // check CANVIEW / CANSEARCH permission and forum password for current forum
     if (!($fperms & $vbulletin->bf_ugp_forumpermissions['canview']) or !($fperms & $vbulletin->bf_ugp_forumpermissions['cansearch']) or !verify_forum_password($forumid, $forum['password'], false) or $vbulletin->options['fulltextsearch'] and !($vbulletin->bf_misc_forumoptions['indexposts'] & $vbulletin->forumcache["{$forumid}"]['options']) and $display['options']['action'] != 'getnew' and $display['options']['action'] != 'getdaily') {
         // cannot view / search this forum, or does not have forum password
         unset($tmp["{$forumid}"]);
     } else {
         if (!($fperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads']) and ($search['showposts'] or $display['options']['action'] != 'getnew' and $display['options']['action'] != 'getdaily' and !$search['titleonly'])) {
             unset($tmp["{$forumid}"]);
         } else {
             if ($vbulletin->options['threadmarking'] and $vbulletin->userinfo['userid']) {
                 $lastread["{$forumid}"] = max($forum['forumread'], TIMENOW - $vbulletin->options['markinglimit'] * 86400);
             } else {
                 $forumview = intval(fetch_bbarray_cookie('forum_view', $forumid));
                 //use which one produces the highest value, most likely cookie
                 $lastread["{$forumid}"] = $forumview > $vbulletin->userinfo['lastvisit'] ? $forumview : $vbulletin->userinfo['lastvisit'];
             }
             // check CANVIEWOTHERS permission
             if (!($fperms & $vbulletin->bf_ugp_forumpermissions['canviewothers'])) {
                 // cannot view others' threads
                 unset($tmp["{$forumid}"]['other']);
             }
         }
     }
     $items = vb_number_format(sizeof($tmp["{$forumid}"]['self']) + sizeof($tmp["{$forumid}"]['other']));
 }
 // now get all threadids that still remain...
 $remaining = array();
 $i = 1;
Exemplo n.º 26
0
	/**
	 * Populates a view with the expected info from a content item.
	 *
	 * @param vB_View $view
	 * @param int $viewtype
	 */
	protected function populateViewContent(vB_View $view, $viewtype = self::VIEW_PAGE)
	{
		parent::populateViewContent($view, $viewtype);

		$view->node = $this->content->getNodeId();
		$view->type = new vB_Phrase('global', 'content');

		if (vB::$vbulletin->userinfo['userid'])
		{
			$view->published = $this->content->isPublished();
		}
		else
		{
			$view->published = true;
		}

		$view->page_url = $this->getPageUrl();
		//Let's pass an url for editing.
		$view->edit_url = $this->getEditUrl();

		if ($date = $this->content->getPublishDate())
		{
			$view->publishdate = $date;
		}

		$view->publish_phrase = new vB_Phrase('vbcms', 'page_not_published');

		// Get comments
		if ((self::VIEW_PAGE == $viewtype) AND (vB::$vbulletin->options['vbcmsforumid'] > 0) AND $this->content->isPublished() AND !$this->isSection())
		{
			try
			{
				$thread = $this->getAssociatedThread();
				$view->show_comments = ($thread AND $thread->can_view(new vB_Legacy_CurrentUser()));

				if ($view->show_comments)
				{
					$postids = $this->getCommentPosts($thread);
					require_once DIR . '/includes/functions_forumdisplay.php' ;
					$view->thread = process_thread_array($thread->get_record());
				}
			}
			catch (Exception $e)
			{
				if (vB::$vbulletin->config['debug'])
				{
					throw ($e);
				}
			}
		}


		// Check if the user has voted
		$check = true;
		if (vB::$vbulletin->userinfo['userid'])
		{
			$row = vB::$db->query_first("SELECT vote FROM " . TABLE_PREFIX . "cms_rate WHERE userid = " . vB::$vbulletin->userinfo['userid'] . " AND nodeid = " . $view->node);
			if ($row[0])
			{
				$check = false;
			}
		}
		$rated = intval(fetch_bbarray_cookie('cms_rate', $view->node));

		// voted already
		if ($row[0] OR $rated)
		{
			$rate_index = $rated;
			if ($row[0])
			{
				$rate_index = $row[0];
			}
			$view->voteselected["$rate_index"] = 'selected="selected"';
			$view->votechecked["$rate_index"] = 'checked="checked"';
		}
		else
		{
			$view->voteselected[0] = 'selected="selected"';
			$view->votechecked[0] = 'checked="checked"';
		}

		$view->showratenode =
		(
			(
				$check
			OR
				(!$rated AND !vB::$vbulletin->userinfo['userid'])
			)
			OR
				vB::$vbulletin->options['votechange']
		);

		// Get ratings
		if ($this->content->getRatingNum() >= vB::$vbulletin->options['showvotes'])
		{
			$view->ratingtotal = $this->content->getRatingTotal();
			$view->ratingnum = $this->content->getRatingNum();
			$view->ratingavg = vb_number_format($view->ratingtotal / $view->ratingnum, 2);
			$view->rating = intval(round($view->ratingtotal / $view->ratingnum));
			$view->showrating = true;
		}
		else
		{
			$view->showrating = false;
		}
		vB_Cache::instance()->event(vBCms_NavBar::getCacheEventId($this->content->getNodeId()));


	}
Exemplo n.º 27
0
 }
 if ($totalposts) {
     $hook_query_fields = $hook_query_joins = $hook_query_where = '';
     ($hook = vBulletinHook::fetch_hook('moderation_postsquery_postid')) ? eval($hook) : false;
     $lastread = array();
     $postids = array();
     // Fetch ids
     $posts = $db->query_read_slave("\n\t\t\tSELECT post.postid, thread.forumid\n\t\t\t\t{$hook_query_fields}\n\t\t\t\t{$postfrom}\n\t\t\t\t{$hook_query_joins}\n\t\t\tINNER JOIN " . TABLE_PREFIX . "thread AS thread ON (post.threadid = thread.threadid)\n\t\t\tWHERE type = '{$posttype}'\n\t\t\t\tAND forumid IN (" . implode(', ', $modforums) . ")\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 {$limitlower}, {$perpage}\n\t\t");
     while ($post = $db->fetch_array($posts)) {
         $postids[] = $post['postid'];
         // get last read info for each thread
         if (empty($lastread["{$post['forumid']}"])) {
             if ($vbulletin->options['threadmarking']) {
                 $lastread["{$post['forumid']}"] = max($vbulletin->forumcache["{$post['forumid']}"]['forumread'], TIMENOW - $vbulletin->options['markinglimit'] * 86400);
             } else {
                 $lastread["{$post['forumid']}"] = max(intval(fetch_bbarray_cookie('forum_view', $post['forumid'])), $vbulletin->userinfo['lastvisit']);
             }
         }
     }
     $limitlower++;
     $hasposts = true;
     $postbits = '';
     $pagenav = '';
     $counter = 0;
     $toread = 0;
     $vbulletin->options['showvotes'] = intval($vbulletin->options['showvotes']);
     $hook_query_fields = $hook_query_joins = $hook_query_where = '';
     ($hook = vBulletinHook::fetch_hook('moderation_postsquery')) ? eval($hook) : false;
     $posts = $db->query_read_slave("\n\t\t\tSELECT\n\t\t\t\tpost.postid, post.title AS posttitle, post.dateline AS postdateline,\n\t\t\t\tpost.iconid AS posticonid, post.pagetext, post.visible,\n\t\t\t\tIF(post.userid = 0, post.username, user.username) AS username,\n\t\t\t\tthread.threadid, thread.title AS threadtitle, thread.iconid AS threadiconid, thread.replycount,\n\t\t\t\tIF(thread.views = 0, thread.replycount + 1, thread.views) AS views, thread.firstpostid,\n\t\t\t\tthread.pollid, thread.sticky, thread.open, thread.lastpost, thread.forumid, thread.visible AS thread_visible,\n\t\t\t\tuser.userid\n\t\t\t\t{$postselect}\n\t\t\t\t" . iif($vbulletin->options['threadmarking'] and $vbulletin->userinfo['userid'], ', threadread.readtime AS threadread') . "\n\t\t\t\t{$hook_query_fields}\n\t\t\tFROM " . TABLE_PREFIX . "post AS post\n\t\t\tINNER JOIN " . TABLE_PREFIX . "thread AS thread ON (post.threadid = thread.threadid)\n\t\t\t{$postjoin}\n\t\t\t" . iif($vbulletin->options['threadmarking'] and $vbulletin->userinfo['userid'], " LEFT JOIN " . TABLE_PREFIX . "threadread AS threadread ON (threadread.threadid = thread.threadid AND threadread.userid = " . $vbulletin->userinfo['userid'] . ")") . "\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = post.userid)\n\t\t\t{$hook_query_joins}\n\t\t\tWHERE post.postid IN (" . implode(', ', $postids) . ")\n\t\t\t\t{$hook_query_where}\n\t\t\tORDER BY {$sqlsortfield} {$sqlsortorder}\n\t\t");
     unset($sqlsortfield, $sqlsortorder);
     require_once DIR . '/includes/functions_forumdisplay.php';
Exemplo n.º 28
0
    $templater->register('url', $url);
    $templater->register('usernamecode', $usernamecode);
    $content = $templater->render();
}
// #######################################################################
if ($_POST['do'] == 'rate') {
    $vbulletin->input->clean_array_gpc('p', array('vote' => TYPE_UINT, 'ajax' => TYPE_BOOL, 'blogid' => TYPE_UINT));
    $bloginfo = fetch_bloginfo($vbulletin->GPC['blogid']);
    track_blog_visit($bloginfo['userid']);
    if ($vbulletin->GPC['vote'] < 1 or $vbulletin->GPC['vote'] > 5) {
        standard_error(fetch_error('invalidvote'));
    }
    if ($bloginfo['state'] !== 'visible') {
        print_no_permission();
    }
    $rated = intval(fetch_bbarray_cookie('blog_rate', $bloginfo['blogid']));
    ($hook = vBulletinHook::fetch_hook('blog_rate_start')) ? eval($hook) : false;
    $update = false;
    if ($vbulletin->userinfo['userid']) {
        if ($rating = $db->query_first("\r\n\t\t\tSELECT *\r\n\t\t\tFROM " . TABLE_PREFIX . "blog_rate\r\n\t\t\tWHERE userid = " . $vbulletin->userinfo['userid'] . "\r\n\t\t\t\tAND blogid = {$bloginfo['blogid']}\r\n\t\t")) {
            if ($vbulletin->options['votechange']) {
                if ($vbulletin->GPC['vote'] != $rating['vote']) {
                    $blograte =& datamanager_init('Blog_Rate', $vbulletin, ERRTYPE_STANDARD);
                    $blograte->set_info('blog', $bloginfo);
                    $blograte->set_existing($rating);
                    $blograte->set('vote', $vbulletin->GPC['vote']);
                    ($hook = vBulletinHook::fetch_hook('blog_rate_update')) ? eval($hook) : false;
                    $blograte->save();
                }
                $update = true;
                if (!$vbulletin->GPC['ajax']) {
Exemplo n.º 29
0
function do_get_subscriptions()
{
    global $vbulletin, $db, $show, $vbphrase, $permissions, $subscribecounters;
    $vbulletin->options['threadpreview'] = FR_PREVIEW_LEN;
    if (!$vbulletin->userinfo['userid']) {
        json_error(ERR_NO_PERMISSION);
    }
    if (!$vbulletin->userinfo['userid'] and $_REQUEST['do'] != 'removesubscription' or $vbulletin->userinfo['userid'] and !($permissions['forumpermissions'] & $vbulletin->bf_ugp_forumpermissions['canview']) or $vbulletin->userinfo['usergroupid'] == 4 or !($permissions['genericoptions'] & $vbulletin->bf_ugp_genericoptions['isnotbannedgroup'])) {
        json_error(ERR_NO_PERMISSION);
    }
    $thread_data = array();
    $unread_subs = 0;
    // vbulletin expects folderid, but we will just get them all
    $vbulletin->input->clean_array_gpc('r', array('folderid' => TYPE_NOHTML, 'perpage' => TYPE_UINT, 'pagenumber' => TYPE_UINT, 'sortfield' => TYPE_NOHTML, 'sortorder' => TYPE_NOHTML, 'previewtype' => TYPE_INT));
    $previewtype = $vbulletin->GPC['previewtype'];
    if (!$previewtype) {
        $previewtype = 1;
    }
    $vbulletin->GPC['folderid'] = 'all';
    // Values that are reused in templates
    $sortfield =& $vbulletin->GPC['sortfield'];
    $perpage =& $vbulletin->GPC['perpage'];
    $pagenumber =& $vbulletin->GPC['pagenumber'];
    $folderid =& $vbulletin->GPC['folderid'];
    if ($folderid == 'all') {
        $getallfolders = true;
        $show['allfolders'] = true;
    } else {
        $folderid = intval($folderid);
    }
    $folderselect["{$folderid}"] = 'selected="selected"';
    // Build folder jump
    require_once DIR . '/includes/functions_misc.php';
    $folders = construct_folder_jump(1, $folderid, false, '', true);
    $templater = vB_Template::create('subscribe_folder_jump');
    $templater->register('folders', $folders);
    $folderjump = $templater->render();
    // look at sorting options:
    if ($vbulletin->GPC['sortorder'] != 'asc') {
        $vbulletin->GPC['sortorder'] = 'desc';
        $sqlsortorder = 'DESC';
        $order = array('desc' => 'selected="selected"');
    } else {
        $sqlsortorder = '';
        $order = array('asc' => 'selected="selected"');
    }
    switch ($sortfield) {
        case 'title':
        case 'lastpost':
        case 'replycount':
        case 'views':
        case 'postusername':
            $sqlsortfield = 'thread.' . $sortfield;
            break;
        default:
            $handled = false;
            if (!$handled) {
                $sqlsortfield = 'thread.lastpost';
                $sortfield = 'lastpost';
            }
    }
    $sort = array($sortfield => 'selected="selected"');
    if ($getallfolders) {
        $totalallthreads = array_sum($subscribecounters);
    } else {
        $totalallthreads = $subscribecounters["{$folderid}"];
    }
    // set defaults
    sanitize_pageresults($totalallthreads, $pagenumber, $perpage, 200, $vbulletin->options['maxthreads']);
    // display threads
    $limitlower = ($pagenumber - 1) * $perpage + 1;
    $limitupper = $pagenumber * $perpage;
    if ($limitupper > $totalallthreads) {
        $limitupper = $totalallthreads;
        if ($limitlower > $totalallthreads) {
            $limitlower = $totalallthreads - $perpage;
        }
    }
    if ($limitlower <= 0) {
        $limitlower = 1;
    }
    $hook_query_fields = $hook_query_joins = $hook_query_where = '';
    $getthreads = $db->query_read_slave("\n\t\tSELECT thread.threadid, emailupdate, subscribethreadid, thread.forumid, thread.postuserid\n\t\t\t{$hook_query_fields}\n\t\tFROM " . TABLE_PREFIX . "subscribethread AS subscribethread\n\t\tLEFT JOIN " . TABLE_PREFIX . "thread AS thread ON(thread.threadid = subscribethread.threadid)\n\t\t{$hook_query_joins}\n\t\tWHERE subscribethread.userid = " . $vbulletin->userinfo['userid'] . "\n\t\t\tAND thread.visible = 1\n\t\t\tAND canview = 1\n\t\t" . iif(!$getallfolders, "\tAND folderid = {$folderid}") . "\n\t\t\t{$hook_query_where}\n\t\tORDER BY {$sqlsortfield} {$sqlsortorder}\n\t\tLIMIT " . ($limitlower - 1) . ", {$perpage}\n\t");
    if ($totalthreads = $db->num_rows($getthreads)) {
        $forumids = array();
        $threadids = array();
        $emailupdate = array();
        $killthreads = array();
        while ($getthread = $db->fetch_array($getthreads)) {
            $forumperms = fetch_permissions($getthread['forumid']);
            if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) or !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads']) or $getthread['postuserid'] != $vbulletin->userinfo['userid'] and !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers'])) {
                $killthreads["{$getthread['subscribethreadid']}"] = $getthread['subscribethreadid'];
                $totalallthreads--;
                continue;
            }
            $forumids["{$getthread['forumid']}"] = true;
            $threadids[] = $getthread['threadid'];
            $emailupdate["{$getthread['threadid']}"] = $getthread['emailupdate'];
            $subscribethread["{$getthread['threadid']}"] = $getthread['subscribethreadid'];
        }
        $threadids = implode(',', $threadids);
    }
    unset($getthread);
    $db->free_result($getthreads);
    if (!empty($killthreads)) {
        // Update thread subscriptions
        $vbulletin->db->query_write("\n\t\t\tUPDATE " . TABLE_PREFIX . "subscribethread\n\t\t\tSET canview = 0\n\t\t\tWHERE subscribethreadid IN (" . implode(', ', $killthreads) . ")\n\t\t");
    }
    if (!empty($threadids)) {
        cache_ordered_forums(1);
        $colspan = 5;
        $show['threadicons'] = false;
        // get last read info for each thread
        $lastread = array();
        foreach (array_keys($forumids) as $forumid) {
            if ($vbulletin->options['threadmarking']) {
                $lastread["{$forumid}"] = max($vbulletin->forumcache["{$forumid}"]['forumread'], TIMENOW - $vbulletin->options['markinglimit'] * 86400);
            } else {
                $lastread["{$forumid}"] = max(intval(fetch_bbarray_cookie('forum_view', $forumid)), $vbulletin->userinfo['lastvisit']);
            }
            if ($vbulletin->forumcache["{$forumid}"]['options'] & $vbulletin->bf_misc_forumoptions['allowicons']) {
                $show['threadicons'] = true;
                $colspan = 6;
            }
        }
        if ($previewtype == 1) {
            $previewfield = "post.pagetext AS preview, post.username AS lastpost_username, post.userid AS lastpost_userid,";
            $previewjoin = "LEFT JOIN " . TABLE_PREFIX . "post AS post ON(post.postid = thread.firstpostid)";
        } else {
            $previewfield = "post.pagetext AS preview, post.username AS lastpost_username, post.userid AS lastpost_userid,";
            $previewjoin = "LEFT JOIN " . TABLE_PREFIX . "post AS post ON(post.postid = thread.lastpostid)";
        }
        $hasthreads = true;
        $threadbits = '';
        $pagenav = '';
        $counter = 0;
        $toread = 0;
        $vbulletin->options['showvotes'] = intval($vbulletin->options['showvotes']);
        if ($vbulletin->userinfo['userid'] and in_coventry($vbulletin->userinfo['userid'], true)) {
            $lastpost_info = "IF(tachythreadpost.userid IS NULL, thread.lastpost, tachythreadpost.lastpost) AS lastpost, " . "IF(tachythreadpost.userid IS NULL, thread.lastposter, tachythreadpost.lastposter) AS lastposter, " . "IF(tachythreadpost.userid IS NULL, thread.lastposterid, tachythreadpost.lastposterid) AS lastposterid, " . "IF(tachythreadpost.userid IS NULL, thread.lastpostid, tachythreadpost.lastpostid) AS lastpostid";
            $tachyjoin = "LEFT JOIN " . TABLE_PREFIX . "tachythreadpost AS tachythreadpost ON " . "(tachythreadpost.threadid = thread.threadid AND tachythreadpost.userid = " . $vbulletin->userinfo['userid'] . ')';
        } else {
            $lastpost_info = 'thread.lastpost, thread.lastposter, thread.lastposterid, thread.lastpostid';
            $tachyjoin = '';
        }
        $hook_query_fields = $hook_query_joins = $hook_query_where = '';
        $threads = $db->query_read_slave("\n\t\t\tSELECT\n\t\t\t\tIF(thread.votenum >= " . $vbulletin->options['showvotes'] . ", thread.votenum, 0) AS votenum,\n\t\t\t\tIF(thread.votenum >= " . $vbulletin->options['showvotes'] . " AND thread.votenum > 0, thread.votetotal / thread.votenum, 0) AS voteavg,\n\t\t\t\tthread.votetotal,\n\t\t\t\t{$previewfield} thread.threadid, thread.title AS threadtitle, thread.forumid, thread.pollid,\n\t\t\t\tthread.open, thread.replycount, thread.postusername, thread.prefixid,\n\t\t\t\t{$lastpost_info}, thread.postuserid, thread.dateline, thread.views, thread.iconid AS threadiconid,\n\t\t\t\tthread.notes, thread.visible, thread.attach, thread.taglist\n\t\t\t\t" . ($vbulletin->options['threadmarking'] ? ", threadread.readtime AS threadread" : '') . "\n\t\t\t\t{$hook_query_fields}\n\t\t\tFROM " . TABLE_PREFIX . "thread AS thread\n\t\t\t{$previewjoin}\n\t\t\t" . ($vbulletin->options['threadmarking'] ? " LEFT JOIN " . TABLE_PREFIX . "threadread AS threadread ON (threadread.threadid = thread.threadid AND threadread.userid = " . $vbulletin->userinfo['userid'] . ")" : '') . "\n\t\t\t{$tachyjoin}\n\t\t\t{$hook_query_joins}\n\t\t\tWHERE thread.threadid IN ({$threadids})\n\t\t\tORDER BY {$sqlsortfield} {$sqlsortorder}\n\t\t");
        unset($sqlsortfield, $sqlsortorder);
        require_once DIR . '/includes/functions_forumdisplay.php';
        // Get Dot Threads
        $dotthreads = fetch_dot_threads_array($threadids);
        if ($vbulletin->options['showdots'] and $vbulletin->userinfo['userid']) {
            $show['dotthreads'] = true;
        } else {
            $show['dotthreads'] = false;
        }
        if ($vbulletin->options['threadpreview'] and $vbulletin->userinfo['ignorelist']) {
            // Get Buddy List
            $buddy = array();
            if (trim($vbulletin->userinfo['buddylist'])) {
                $buddylist = preg_split('/( )+/', trim($vbulletin->userinfo['buddylist']), -1, PREG_SPLIT_NO_EMPTY);
                foreach ($buddylist as $buddyuserid) {
                    $buddy["{$buddyuserid}"] = 1;
                }
            }
            DEVDEBUG('buddies: ' . implode(', ', array_keys($buddy)));
            // Get Ignore Users
            $ignore = array();
            if (trim($vbulletin->userinfo['ignorelist'])) {
                $ignorelist = preg_split('/( )+/', trim($vbulletin->userinfo['ignorelist']), -1, PREG_SPLIT_NO_EMPTY);
                foreach ($ignorelist as $ignoreuserid) {
                    if (!$buddy["{$ignoreuserid}"]) {
                        $ignore["{$ignoreuserid}"] = 1;
                    }
                }
            }
            DEVDEBUG('ignored users: ' . implode(', ', array_keys($ignore)));
        }
        $foruminfo['allowratings'] = true;
        $show['notificationtype'] = true;
        $show['threadratings'] = true;
        $show['threadrating'] = true;
        while ($thread = $db->fetch_array($threads)) {
            $threadid = $thread['threadid'];
            // build thread data
            $thread = process_thread_array($thread, $lastread["{$thread['forumid']}"]);
            switch ($emailupdate["{$thread['threadid']}"]) {
                case 0:
                    $thread['notification'] = $vbphrase['none'];
                    break;
                case 1:
                    $thread['notification'] = $vbphrase['instant'];
                    break;
                case 2:
                    $thread['notification'] = $vbphrase['daily'];
                    break;
                case 3:
                    $thread['notification'] = $vbphrase['weekly'];
                    break;
                default:
                    $thread['notification'] = $vbphrase['n_a'];
            }
            $avatarurl = '';
            if ($thread['lastpost_userid'] > 0) {
                $userinfoavatar = fetch_userinfo($thread['lastpost_userid'], FETCH_USERINFO_AVATAR);
                fetch_avatar_from_userinfo($userinfoavatar, true, false);
                if ($userinfoavatar['avatarurl'] != '') {
                    $avatarurl = process_avatarurl($userinfoavatar['avatarurl']);
                }
                unset($userinfoavatar);
            }
            $tmp = array('thread_id' => $thread['threadid'], 'new_posts' => $show['gotonewpost'] ? true : false, 'forum_id' => $thread['forumid'], 'total_posts' => $thread['totalposts'] ? $thread['totalposts'] : 0, 'forum_title' => prepare_utf8_string($thread['forumtitle']), 'thread_title' => prepare_utf8_string($thread['threadtitle']), 'thread_preview' => prepare_utf8_string(preview_chop(html_entity_decode($thread['preview']), FR_PREVIEW_LEN)), 'post_userid' => $thread['lastpost_userid'], 'post_lastposttime' => prepare_utf8_string(date_trunc($thread['lastpostdate']) . ' ' . $thread['lastposttime']), 'post_username' => prepare_utf8_string(strip_tags($thread['lastpost_username'])));
            if ($avatarurl != '') {
                $tmp['avatarurl'] = $avatarurl;
            }
            if ($thread['attach']) {
                $tmp['attach'] = true;
            }
            if ($thread['pollid']) {
                $tmp['poll'] = true;
            }
            $thread_data[] = $tmp;
        }
        $db->free_result($threads);
        unset($threadids);
    } else {
        $totalallthreads = 0;
    }
    $out = array('threads' => $thread_data, 'total_threads' => $totalallthreads);
    return $out;
}
Exemplo n.º 30
0
function process_thread_array($thread, $lastread = -1, $allowicons = -1, $fetchavatar = false)
{
    global $vbphrase, $foruminfo, $vbulletin;
    global $newthreads, $dotthreads, $perpage, $ignore, $show;
    static $pperpage, $perm_cache;
    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 (!$vbulletin->options['editthreadtitlelimit'] or $thread['dateline'] + $vbulletin->options['editthreadtitlelimit'] * 60 > TIMENOW)) {
        $thread['title_editable'] = true;
        $show['ajax_js'] = true;
    }
    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'] = true;
        $show['ajax_js'] = true;
    }
    /*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 ($fetchavatar) {
        require_once DIR . '/includes/functions_user.php';
        $avatar = fetch_avatar_from_record($thread, true, 'userid', 'api_');
        $thread['avatarurl'] = $avatar[0];
        $avatarinfo = parse_subsstring_array($thread, 'api_');
        $avatarinfo['adminavatar'] = $avatarinfo['adminoptions'] & $vbulletin->bf_misc_adminoptions['adminavatar'];
        if (!isset($perm_cache["{$avatarinfo['userid']}"])) {
            $perm_cache["{$avatarinfo['userid']}"] = cache_permissions($avatarinfo, false);
        } else {
            $avatarinfo['permissions'] =& $perm_cache["{$avatarinfo['userid']}"];
        }
        if (empty($thread['avatarurl']) or $vbulletin->userinfo['userid'] > 0 and !$vbulletin->userinfo['showavatars'] or !$avatarinfo['avatarid'] and !($perm_cache["{$avatarinfo['userid']}"]['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canuseavatar']) and !$avatarinfo['adminavatar']) {
            $show['avatar'] = false;
        } else {
            $show['avatar'] = true;
        }
    }
    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'];
    }
    $thread['forumtitleclean'] = $vbulletin->forumcache["{$thread['forumid']}"]['title_clean'];
    // 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'])) {
            if ($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, true, true), $vbulletin->options['threadpreview'])));
            } else {
                unset($thread['preview']);
            }
        }
    }
    // 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'] = '';
    }
    // get the thread starting date and time if applicable
    if ($thread['dateline']) {
        $thread['startdate'] = vbdate($vbulletin->options['dateformat'], $thread['dateline'], true);
        $thread['starttime'] = vbdate($vbulletin->options['timeformat'], $thread['dateline']);
    } else {
        $thread['startdate'] = '';
        $thread['starttime'] = '';
    }
    // non magical thread status
    if (2 == $thread['visible']) {
        $thread['status']['deleted'] = 'deleted';
    } else {
        if (!$thread['visible']) {
            $thread['status']['moderated'] = 'moderated';
        }
    }
    // 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);
            #$address2 = "$thread[highlight]";
            $curpage = 0;
            $thread['pagenav'] = '';
            $show['pagenavmore'] = false;
            while ($curpage++ < $thread['totalpages']) {
                if ($vbulletin->options['maxmultipage'] and $curpage > $vbulletin->options['maxmultipage']) {
                    $lastpageinfo = array('page' => $thread['totalpages']);
                    if ($thread['highlight']) {
                        $lastpageinfo['highlight'] = urlencode(implode(' ', $thread['highlight']));
                    }
                    $thread['lastpagelink'] = fetch_seo_url('thread', $thread, $lastpageinfo, 'threadid', 'threadtitle');
                    $show['pagenavmore'] = true;
                    break;
                }
                $pageinfo = array('page' => $curpage);
                if ($thread['highlight']) {
                    $pageinfo['highlight'] = urlencode(implode(' ', $thread['highlight']));
                }
                $pagenumbers = fetch_start_end_total_array($curpage, $pperpage, $thread['totalposts']);
                $templater = vB_Template::create('threadbit_pagelink');
                $templater->register('curpage', $curpage);
                $templater->register('pageinfo', $pageinfo);
                $templater->register('thread', $thread);
                $thread['pagenav'] .= ' ' . $templater->render();
            }
        } 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'] = vB_Template_Runtime::fetchStyleVar('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['status'] = array();
        // show dot folder?
        if ($vbulletin->userinfo['userid'] and $vbulletin->options['showdots'] and $dotthreads["{$thread['threadid']}"]) {
            $thread['status']['dot'] = '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['status']['hot'] = 'hot';
        }
        // show locked folder?
        if (!$thread['open']) {
            $thread['status']['lock'] = '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['status']['new'] = '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['status'] = array();
        // VB_API relies on thread redirects to fully reflect the read status of the redirected thread
        if ($vbulletin->options['threadmarking'] and $vbulletin->userinfo['userid'] and defined('VB_API') and VB_API === true) {
            if ($lastpost = $vbulletin->db->query_first("\n\t\t\t\tSELECT thread.forumid, thread.lastpost, threadread.readtime AS threadread\n\t\t\t\tFROM " . TABLE_PREFIX . "thread AS thread\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "threadread AS threadread ON (threadread.threadid = thread.threadid AND threadread.userid = {$vbulletin->userinfo['userid']})\n\t\t\t\tWHERE thread.threadid = {$thread['pollid']}\n\t\t\t")) {
                $forumread = $vbulletin->forumcache["{$lastpost['forumid']}"]['forumread'];
                $lastread = max($forumread, TIMENOW - $vbulletin->options['markinglimit'] * 86400);
                if ($lastpost['lastpost'] > $lastread) {
                    if ($lastpost['threadread']) {
                        $threadview = $lastpost['threadread'];
                    }
                    if ($lastpost['lastpost'] > $threadview) {
                        $thread['status']['new'] = 'new';
                    }
                }
            } else {
                $thread['status']['new'] = $thread['lastpost'] > $lastread ? 'new' : false;
            }
        } else {
            $thread['status']['new'] = $thread['lastpost'] > $lastread ? 'new' : false;
        }
        $thread['status']['moved'] = 'moved';
        $thread['pagenav'] = '';
        $thread['movedprefix'] = $vbphrase['moved_thread_prefix'];
        $thread['rating'] = 0;
        $thread['votenum'] = 0;
        $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;
    $thread['statusstring'] = implode(' ', $thread['status']);
    return $thread;
}