public function getData() { if ($this->config['newposts_forumids']) { if (in_array(-1, $this->config['newposts_forumids'])) { $forumids = array_keys($this->registry->forumcache); } else { $forumids = $this->config['newposts_forumids']; } } else { $forumids = array_keys($this->registry->forumcache); } foreach ($forumids as $forumid) { $forumperms =& $this->registry->userinfo['forumpermissions']["{$forumid}"]; if ($forumperms & $this->registry->bf_ugp_forumpermissions['canview'] and $forumperms & $this->registry->bf_ugp_forumpermissions['canviewothers'] and $forumperms & $this->registry->bf_ugp_forumpermissions['canviewthreads'] and verify_forum_password($forumid, $this->registry->forumcache["{$forumid}"]['password'], false)) { $forumchoice[] = $forumid; } } if (!empty($forumchoice)) { $forumsql = "AND thread.forumid IN(" . implode(',', $forumchoice) . ")"; // remove threads from users on the global ignore list if user is not a moderator $globalignore = ''; if (trim($this->registry->options['globalignore']) != '') { require_once DIR . '/includes/functions_bigthree.php'; if ($Coventry = fetch_coventry('string')) { $globalignore = "AND post.userid NOT IN ({$Coventry}) "; } } $datecut = TIMENOW - $this->config['datecut'] * 86400; $posts = $this->registry->db->query_read_slave("\n\t\t\t\tSELECT post.dateline, post.pagetext AS message, post.allowsmilie, post.postid,\n\t\t\t\t\tthread.threadid, thread.title, thread.prefixid, post.attach,\n\t\t\t\t\tforum.forumid,\n\t\t\t\t\tuser.*\n\t\t\t\t\t" . ($this->registry->options['avatarenabled'] ? ",avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight" : "") . "\n\t\t\t\tFROM " . TABLE_PREFIX . "post AS post\n\t\t\t\tJOIN " . TABLE_PREFIX . "thread AS thread ON (thread.threadid = post.threadid)\n\t\t\t\tJOIN " . TABLE_PREFIX . "forum AS forum ON(forum.forumid = thread.forumid)\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "user AS user ON (post.userid = user.userid)\n\t\t\t\t" . ($this->registry->products['vbcms'] ? " LEFT JOIN " . TABLE_PREFIX . "cms_nodeinfo AS info ON info.associatedthreadid = thread.threadid \n" : '') . ($this->registry->options['avatarenabled'] ? "LEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON(avatar.avatarid = user.avatarid) LEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON(customavatar.userid = user.userid)" : "") . "\n\t\t\tWHERE 1=1\n\t\t\t\t{$forumsql}\n\t\t\t\tAND thread.visible = 1\n\t\t\t\tAND post.visible = 1\n\t\t\t\tAND thread.open <> 10\n\t\t\t\tAND post.dateline > {$datecut}\n\t\t\t\t{$globalignore}\n\t\t\t\t" . ($this->userinfo['ignorelist'] ? "AND post.userid NOT IN (" . implode(',', explode(' ', $this->userinfo['ignorelist'])) . ")" : '') . ($this->registry->products['vbcms'] ? " AND info.associatedthreadid IS NULL " : '') . "\n\t\t\tORDER BY post.dateline DESC\n\t\t\tLIMIT 0," . intval($this->config['newposts_limit']) . "\n\t\t\t"); while ($post = $this->registry->db->fetch_array($posts)) { //$post['url'] = fetch_seo_url('thread', $post, array('p' => $post['postid'])) . '#post' . $post['postid']; //$post['newposturl'] = fetch_seo_url('thread', $post, array('goto' => 'newpost')); // trim the title after fetching the urls //$post['title'] = fetch_trimmed_title($post['title'], $this->config['newposts_titlemaxchars']); //still need to censor the title $post['title'] = fetch_censored_text($post['title']); $post['date'] = vbdate($this->registry->options['dateformat'], $post['dateline'], true); $post['time'] = vbdate($this->registry->options['timeformat'], $post['dateline']); $post['message'] = $this->get_summary($post['message'], $this->config['newposts_messagemaxchars']); // get avatar $this->fetch_avatarinfo($post); $postarray[$post['postid']] = $post; } return $postarray; } }
public function output() { global $vbulletin, $threadid, $postid, $db, $VB_API_WHITELIST; require_once DIR . '/includes/functions_bigthree.php'; $threadinfo = verify_id('thread', $threadid, 1, 1); if ($vbulletin->options['threadmarking'] and $vbulletin->userinfo['userid']) { $vbulletin->userinfo['lastvisit'] = max($threadinfo['threadread'], $threadinfo['forumread'], TIMENOW - $vbulletin->options['markinglimit'] * 86400); } $coventry = fetch_coventry('string'); $posts = $db->query_first("\n\t\t\tSELECT MIN(postid) AS postid\n\t\t\tFROM " . TABLE_PREFIX . "post\n\t\t\tWHERE threadid = {$threadinfo['threadid']}\n\t\t\t\tAND visible = 1\n\t\t\t\tAND dateline > " . intval($vbulletin->userinfo['lastvisit']) . "\n\t\t\t\t" . ($coventry ? "AND userid NOT IN ({$coventry})" : "") . "\n\t\t\tLIMIT 1\n\t\t"); if ($posts['postid']) { $postid = $posts['postid']; } else { $postid = $threadinfo['lastpostid']; } loadAPI('showthread'); include DIR . '/showthread.php'; }
private function getThreads($type) { global $vbulletin, $VB_API_REQUESTS; if ($vbulletin->options['mobilehomethreadforumids']) { $forumids = $this->verifycommaoption($vbulletin->options['mobilehomethreadforumids']); } if (!$forumids) { $forumids = array_keys($vbulletin->forumcache); } if ($type != 'last') { $datecut = TIMENOW - $vbulletin->options['mobilehomethreaddatecut'] * 86400; } else { $datecut = $vbulletin->userinfo['lastvisit']; } switch ($type) { case 'top': $ordersql = " thread.views DESC"; $datecutoffsql = " AND thread.dateline > {$datecut}"; break; case 'new': $ordersql = " thread.dateline DESC"; $datecutoffsql = " AND thread.dateline > {$datecut}"; break; case 'last': $ordersql = " thread.lastpost DESC"; $datecutoffsql = " AND thread.lastpost > {$datecut}"; break; default: return null; } foreach ($forumids as $forumid) { $forumperms =& $vbulletin->userinfo['forumpermissions']["{$forumid}"]; if ($forumperms & $vbulletin->bf_ugp_forumpermissions['canview'] and $forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers'] and $forumperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads'] and verify_forum_password($forumid, $vbulletin->forumcache["{$forumid}"]['password'], false)) { $forumchoice[] = $forumid; } } if (!empty($forumchoice)) { $forumsql = "AND thread.forumid IN(" . implode(',', $forumchoice) . ")"; // remove threads from users on the global ignore list if user is not a moderator $globalignore = ''; if (trim($vbulletin->options['globalignore']) != '') { require_once DIR . '/includes/functions_bigthree.php'; if ($Coventry = fetch_coventry('string')) { $globalignore = "AND thread.postuserid NOT IN ({$Coventry}) "; } } // query last threads from visible / chosen forums $threads = $vbulletin->db->query_read_slave("\n\t\t\t\tSELECT thread.threadid, thread.title, thread.prefixid, post.attach,\n\t\t\t\t\tthread.postusername, thread.dateline, thread.lastpostid, thread.lastpost AS threadlastpost, thread.lastposterid, thread.lastposter, thread.replycount, thread.views,\n\t\t\t\t\tforum.forumid, forum.title_clean as forumtitle,\n\t\t\t\t\tpost.pagetext AS message, post.allowsmilie, post.postid,\n\t\t\t\t\tuser.*\n\t\t\t\t\t" . ($vbulletin->options['avatarenabled'] ? ",avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight" : "") . "\n\t\t\t\tFROM " . TABLE_PREFIX . "thread AS thread\n\t\t\t\tINNER JOIN " . TABLE_PREFIX . "forum AS forum ON(forum.forumid = thread.forumid)\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "post AS post ON (post.postid = thread.firstpostid)\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "user AS user ON (thread.postuserid = user.userid)\n\t\t\t\t" . ($vbulletin->products['vbcms'] ? " LEFT JOIN " . TABLE_PREFIX . "cms_nodeinfo AS info ON info.associatedthreadid = thread.threadid \n" : '') . ($vbulletin->options['avatarenabled'] ? "LEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON(avatar.avatarid = user.avatarid) LEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON(customavatar.userid = user.userid)" : "") . "\n\t\t\tWHERE 1=1\n\t\t\t\t{$forumsql}\n\t\t\t\tAND thread.visible = 1\n\t\t\t\tAND post.visible = 1\n\t\t\t\tAND open <> 10\n\t\t\t\t{$datecutoffsql}\n\t\t\t\t{$globalignore}\n\t\t\t\t" . ($vbulletin->userinfo['ignorelist'] ? "AND thread.postuserid NOT IN (" . implode(',', explode(' ', $vbulletin->userinfo['ignorelist'])) . ")" : '') . ($vbulletin->products['vbcms'] ? " AND info.associatedthreadid IS NULL " : '') . "\n\t\t\tORDER BY{$ordersql}\n\t\t\tLIMIT 0, " . $vbulletin->options['mobilehomemaxitems'] . "\n\t\t\t"); $i = 0; while ($thread = $vbulletin->db->fetch_array($threads)) { // still need to censor the title $thread['title'] = fetch_censored_text($thread['title']); // get avatar $this->fetch_avatarinfo($thread); $array[$i] = array('id' => $thread['threadid'], 'title' => $thread['title'], 'replycount' => $thread['replycount'], 'viewcount' => $thread['views'], 'userid' => $thread['userid'], 'username' => $thread['postusername'], 'avatarurl' => $thread['avatarurl'], 'type' => 'thread', 'time' => $thread['lastpost']); if ($VB_API_REQUESTS['api_version'] > 1) { $array[$i]['lastposttime'] = $thread['threadlastpost']; } else { $array[$i]['lastpostdate'] = date($vbulletin->options['dateformat'], $thread['threadlastpost']); $array[$i]['lastposttime'] = date($vbulletin->options['timeformat'], $thread['threadlastpost']); } $i++; } } return $array; }
/** * 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,'?') ? '&' : '?'; 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,'?') ? '&' : '?'; $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,'?') ? '&' : '?'; $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; }
public static function canViewThread($nodeid, $user) { require_once DIR . '/vb/legacy/thread.php'; if (! $row = vB::$vbulletin->db->query_first("SELECT nodeinfo.associatedthreadid AS threadid, thread.forumid FROM " . TABLE_PREFIX . "cms_nodeinfo AS nodeinfo LEFT JOIN " . TABLE_PREFIX . "thread AS thread ON thread.threadid = nodeinfo.associatedthreadid WHERE nodeinfo.nodeid = $nodeid;" )) { return false; } //we have to worry about people deleting the thread or the forum. Annoying. if (intval($row['associatedthreadid']) AND ! intval($row['forumid'])) { $this->repaircomments($record['associatedthreadid']); return false; } // Trust me, it's just a temp fix -- Xiaoyu global $thread; $thread = vB_Legacy_Thread::create_from_id($row['threadid']); if (!$thread) { return false; } if (!$thread->can_view($user)) { return false; } $can_moderate_forums = $user->canModerateForum($thread->get_field('forumid')); $can_moderate_posts = $user->canModerateForum($thread->get_field('forumid'), 'canmoderateposts'); $is_coventry = false; if (!$can_moderate_forums) { //this is cached. Should be fast. require_once (DIR . '/includes/functions_bigthree.php'); $conventry = fetch_coventry(); $is_coventry = (in_array($user->get_field('userid'), $conventry)); } if (! $can_moderate_forums AND $is_coventry) { return false; } // If we got here, the user can at least see the thread. We still have // to check the individual records; return array('can_moderate_forums' => $can_moderate_forums, 'is_coventry' => $is_coventry, 'can_moderate_posts' => $can_moderate_posts); }
/** * Prepares the User's Visitor Message Statistics * * @param array The Latest Visitor Message */ function prepare_visitor_message_stats($vminfo) { global $vbphrase; if ((!isset($this->prepared['vm_total']) or !isset($this->prepared['lastvm_date']) or !isset($this->prepared['lastvm_time'])) and $this->registry->options['socnet'] & $this->registry->bf_misc_socnet['enable_visitor_messaging'] and (!$this->userinfo['vm_contactonly'] or can_moderate(0, 'canmoderatevisitormessages') or $this->userinfo['userid'] == $this->registry->userinfo['userid'] or $this->userinfo['bbuser_iscontact_of_user']) and ($this->userinfo['vm_enable'] or can_moderate(0, 'canmoderatevisitormessages') and $this->registry->userinfo['userid'] != $this->userinfo['userid'])) { require_once DIR . '/includes/functions_visitormessage.php'; $state = array('visible'); if (fetch_visitor_message_perm('canmoderatevisitormessages', $this->userinfo)) { $state[] = 'moderation'; } if (can_moderate(0, 'canmoderatevisitormessages') or $this->registry->userinfo['userid'] == $this->userinfo['userid'] and $this->registry->userinfo['permissions']['visitormessagepermissions'] & $this->registry->bf_ugp_visitormessagepermissions['canmanageownprofile']) { $state[] = 'deleted'; $deljoinsql = "LEFT JOIN " . TABLE_PREFIX . "deletionlog AS deletionlog ON (visitormessage.vmid = deletionlog.primaryid AND deletionlog.type = 'visitormessage')"; } else { $deljoinsql = ''; } $state_or = array("visitormessage.state IN ('" . implode("','", $state) . "')"); if (!fetch_visitor_message_perm('canmoderatevisitormessages', $this->userinfo)) { $state_or[] = "(visitormessage.postuserid = " . $this->registry->userinfo['userid'] . " AND state = 'moderation')"; } $coventry = ''; if ($this->registry->options['globalignore'] != '') { if (!can_moderate(0, 'candeletevisitormessages') and !can_moderate(0, 'canremovevisitormessages')) { require_once DIR . '/includes/functions_bigthree.php'; $coventry = fetch_coventry('string'); } } if (empty($vminfo)) { $vminfo = $this->registry->db->query_first("\n\t\t\t\t\tSELECT COUNT(*) AS messages, MAX(visitormessage.dateline) AS dateline\n\t\t\t\t\tFROM " . TABLE_PREFIX . "visitormessage AS visitormessage\n\t\t\t\t\t{$deljoinsql}\n\t\t\t\t\tWHERE visitormessage.userid = " . $this->prepared['userid'] . "\n\t\t\t\t\t\tAND (" . implode(" OR ", $state_or) . ")\n\t\t\t\t\t" . ($coventry ? "AND visitormessage.postuserid NOT IN (" . $coventry . ")" : '') . "\n\t\t\t\t"); } $this->prepared['vm_total'] = intval($vminfo['messages']); if ($vminfo['dateline']) { $this->prepared['lastvm_time'] = vbdate($this->registry->options['timeformat'], $vminfo['dateline'], true); $this->prepared['lastvm_date'] = vbdate($this->registry->options['dateformat'], $vminfo['dateline'], true); } else { $this->prepared['lastvm_date'] = $vbphrase['never']; $this->prepared['lastvm_time'] = ''; } } }
function goto_nextthread($threadid, $throwerror = true) { global $vbulletin; $thread = verify_id('thread', $threadid, $throwerror, 1); $forumperms = fetch_permissions($thread['forumid']); // remove threads from users on the global ignore list if user is not a moderator if ($coventry = fetch_coventry('string') and !can_moderate($thread['forumid'])) { $globalignore = "AND postuserid NOT IN ({$coventry})"; } else { $globalignore = ''; } if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers'])) { $limitothers = "AND postuserid = " . $vbulletin->userinfo['userid'] . " AND " . $vbulletin->userinfo['userid'] . " <> 0"; } else { $limitothers = ''; } if ($vbulletin->userinfo['userid'] and in_coventry($vbulletin->userinfo['userid'], true)) { $lastpost_info = ",IF(tachythreadpost.userid IS NULL, thread.lastpost, tachythreadpost.lastpost) AS lastpost"; $tachyjoin = "LEFT JOIN " . TABLE_PREFIX . "tachythreadpost AS tachythreadpost ON " . "(tachythreadpost.threadid = thread.threadid AND tachythreadpost.userid = " . $vbulletin->userinfo['userid'] . ')'; $lastpost_having = "HAVING lastpost > {$thread['lastpost']}"; } else { $lastpost_info = ""; $tachyjoin = ""; $lastpost_having = "AND lastpost > {$thread['lastpost']}"; } if ($getnextnewest = $vbulletin->db->query_first_slave("\n\t\tSELECT thread.threadid, thread.title\n\t\t\t{$lastpost_info}\n\t\tFROM " . TABLE_PREFIX . "thread AS thread\n\t\t{$tachyjoin}\n\t\tWHERE forumid = {$thread['forumid']}\n\t\t\tAND visible = 1\n\t\t\tAND open <> 10\n\t\t\t{$globalignore}\n\t\t\t{$limitothers}\n\t\t{$lastpost_having}\n\t\tORDER BY lastpost\n\t\tLIMIT 1\n\t")) { $threadid = $getnextnewest['threadid']; unset($thread); } else { if ($throwerror) { eval(standard_error(fetch_error('nonextnewest'))); } } return $getnextnewest; }
} if ($pda and $vbulletin->userinfo['userid'] > 0 and $vbulletin->GPC['message'] and false) { $do = 'message'; } $output .= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" dir=\"{$stylevar['textdirection']}\" lang=\"{$stylevar['languagecode']}\">\n<head>\n\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset={$stylevar['charset']}\" />\n\t{$metatags}\n\t<title>{$title}</title>\n\t<link rel=\"stylesheet\" type=\"text/css\" href=\"" . $vbulletin->options['bburl'] . "/archive/archive.css\" />\n</head>\n<body>\n<div class=\"pagebody\">\n"; ($hook = vBulletinHook::fetch_hook('archive_postheader')) ? eval($hook) : false; // ******************************************************************************************** // display board if ($do == 'index') { $output .= print_archive_navigation(array()); $output .= "<p class=\"largefont\">{$vbphrase['view_full_version']}: <a href=\"" . $vbulletin->options['bburl'] . '/' . $vbulletin->options['forumhome'] . '.php">' . $vbulletin->options['bbtitle'] . "</a></p>\n"; $output .= "<div id=\"content\">\n"; $output .= print_archive_forum_list(); $output .= "</div>\n"; } if ($Coventry = fetch_coventry('string')) { $globalignore = "AND " . iif($do == 'forum', 'thread.post', 'post.') . "userid NOT IN ({$Coventry}) "; } else { $globalignore = ''; } // ******************************************************************************************** // display forum if ($do == 'forum') { // list threads $output .= print_archive_navigation($foruminfo); $output .= "<p class=\"largefont\">{$vbphrase['view_full_version']} : <a href=\"" . $vbulletin->options['bburl'] . "/forumdisplay.php?f={$foruminfo['forumid']}\">{$foruminfo['title_clean']}</a></p>\n<hr />\n"; if ($foruminfo['cancontainthreads']) { if (!$p) { $p = 1; } $output .= print_archive_page_navigation($foruminfo['threadcount'], $vbulletin->options['archive_threadsperpage'], "f-{$foruminfo['forumid']}");
/** * Can the user view this post * * @param vB_Legacy_CurrentUser $user * @return boolean */ public function can_view($user) { $thread = $this->get_thread(); if (!$thread) { return false; } if (!$thread->can_view($user)) { return false; } if (!$user->canModerateForum($thread->get_field('forumid'))) { //this is cached. Should be fast. require_once DIR . "/includes/functions_bigthree.php"; $conventry = fetch_coventry(); if (in_array($this->get_field('userid'), $conventry)) { return false; } // post/thread is deleted and we don't have permission to see it if ($this->get_field('visible') == 2) { return false; } } // post/thread is deleted by moderator and we don't have permission to see it if (!$this->get_field('visible') and !$user->canModerateForum($thread->get_field('forumid'), 'canmoderateposts')) { return false; } return true; }
/** * Prepare any data needed for the output * * @param string The id of the block * @param array Options specific to the block */ function prepare_output($id = '', $options = array()) { global $show, $vbphrase, $messagearea, $vBeditTemplate; require_once DIR . '/includes/functions_visitormessage.php'; require_once DIR . '/includes/class_bbcode.php'; require_once DIR . '/includes/class_visitormessage.php'; if (is_array($options)) { $options = array_merge($this->option_defaults, $options); } else { $options = $this->option_defaults; } if ($options['vmid']) { $messageinfo = verify_visitormessage($options['vmid'], false); } $state = array('visible'); if (fetch_visitor_message_perm('canmoderatevisitormessages', $this->profile->userinfo)) { $state[] = 'moderation'; } if (can_moderate(0, 'canmoderatevisitormessages') or $this->registry->userinfo['userid'] == $this->profile->userinfo['userid'] and $this->registry->userinfo['permissions']['visitormessagepermissions'] & $this->registry->bf_ugp_visitormessagepermissions['canmanageownprofile']) { $state[] = 'deleted'; $deljoinsql = "LEFT JOIN " . TABLE_PREFIX . "deletionlog AS deletionlog ON (visitormessage.vmid = deletionlog.primaryid AND deletionlog.type = 'visitormessage')"; } else { $deljoinsql = ''; } $state_or = array("visitormessage.state IN ('" . implode("','", $state) . "')"); // Get the viewing user's moderated posts if ($this->registry->userinfo['userid'] and !fetch_visitor_message_perm('canmoderatevisitormessages', $this->profile->userinfo)) { $state_or[] = "(visitormessage.postuserid = " . $this->registry->userinfo['userid'] . " AND state = 'moderation')"; } $perpage = (!$options['perpage'] or $options['perpage'] > $this->registry->options['vm_maxperpage']) ? $this->registry->options['vm_perpage'] : $options['perpage']; if ($messageinfo['vmid']) { $getpagenum = $this->registry->db->query_first("\n\t\t\t\tSELECT COUNT(*) AS comments\n\t\t\t\tFROM " . TABLE_PREFIX . "visitormessage AS visitormessage\n\t\t\t\tWHERE userid = " . $this->profile->userinfo['userid'] . "\n\t\t\t\t\tAND (" . implode(" OR ", $state_or) . ")\n\t\t\t\t\tAND dateline >= {$messageinfo['dateline']}\n\t\t\t"); $options['pagenumber'] = ceil($getpagenum['comments'] / $perpage); } $pagenumber = $options['pagenumber']; do { if (!$pagenumber or $options['tab'] != $id and $options['tab'] != '') { $pagenumber = 1; } $start = ($pagenumber - 1) * $perpage; $hook_query_fields = $hook_query_joins = $hook_query_where = ''; ($hook = vBulletinHook::fetch_hook('member_profileblock_visitormessage_query')) ? eval($hook) : false; if ($this->registry->options['globalignore'] != '') { if (!can_moderate(0, 'candeletevisitormessages') and !can_moderate(0, 'canremovevisitormessages')) { require_once DIR . '/includes/functions_bigthree.php'; $coventry = fetch_coventry('string'); } } $messagebits = ''; $messages = $this->registry->db->query_read("\n\t\t\t\tSELECT " . (!isset($this->profile->prepared['vm_total']) ? "SQL_CALC_FOUND_ROWS" : "") . "\n\t\t\t\t\tvisitormessage.*, user.*, visitormessage.ipaddress AS messageipaddress\n\t\t\t\t\t" . ($this->registry->userinfo['userid'] ? ",IF(userlist.userid IS NOT NULL, 1, 0) AS bbuser_iscontact_of_user" : "") . "\n\t\t\t\t\t" . ($deljoinsql ? ",deletionlog.userid AS del_userid, deletionlog.username AS del_username, deletionlog.reason AS del_reason" : "") . "\n\t\t\t\t\t" . ($this->registry->options['avatarenabled'] ? ",avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight, customavatar.width_thumb AS avwidth_thumb, customavatar.height_thumb AS avheight_thumb, filedata_thumb, NOT ISNULL(customavatar.userid) AS hascustom" : "") . "\n\t\t\t\t\t{$hook_query_fields}\n\t\t\t\tFROM " . TABLE_PREFIX . "visitormessage AS visitormessage\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "user AS user ON (visitormessage.postuserid = user.userid)\n\t\t\t\t" . ($this->registry->userinfo['userid'] ? "LEFT JOIN " . TABLE_PREFIX . "userlist AS userlist ON (userlist.userid = user.userid AND userlist.type = 'buddy' AND userlist.relationid = " . $this->registry->userinfo['userid'] . ")" : "") . "\n\t\t\t\t" . ($this->registry->options['avatarenabled'] ? "LEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON(avatar.avatarid = user.avatarid) LEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON(customavatar.userid = user.userid)" : "") . "\n\t\t\t\t{$deljoinsql}\n\t\t\t\t{$hook_query_joins}\n\t\t\t\tWHERE visitormessage.userid = " . $this->profile->userinfo['userid'] . "\n\t\t\t\t\tAND (" . implode(" OR ", $state_or) . ")\n\t\t\t\t" . ($coventry ? "AND visitormessage.postuserid NOT IN (" . $coventry . ")" : '') . "\n\t\t\t\t\t{$hook_query_where}\n\t\t\t\tORDER BY visitormessage.dateline DESC\n\t\t\t\tLIMIT {$start}, {$perpage}\n\t\t\t"); if (!isset($this->profile->prepared['vm_total'])) { list($messagetotal) = $this->registry->db->query_first("SELECT FOUND_ROWS()", DBARRAY_NUM); } else { $messagetotal = $this->profile->prepared['vm_total']; } if ($start >= $messagetotal) { $pagenumber = ceil($messagetotal / $perpage); } } while ($start >= $messagetotal and $messagetotal); $this->block_data['messagestart'] = $start + 1; $this->block_data['messageend'] = min($start + $perpage, $messagetotal); $bbcode = new vB_BbCodeParser($this->registry, fetch_tag_list()); $factory = new vB_Visitor_MessageFactory($this->registry, $bbcode, $this->profile->userinfo); $messagebits = ''; if ($this->registry->userinfo['userid'] and empty($options['showignored'])) { $ignorelist = preg_split('/( )+/', trim($this->registry->userinfo['ignorelist']), -1, PREG_SPLIT_NO_EMPTY); } else { $ignorelist = array(); } $firstrecord = array(); $read_ids = array(); while ($message = $this->registry->db->fetch_array($messages)) { // Process user.options $message = array_merge($message, convert_bits_to_array($message['options'], $this->registry->bf_misc_useroptions)); if (!$firstrecord) { $firstrecord = $message; } if ($ignorelist and in_array($message['postuserid'], $ignorelist)) { $message['ignored'] = true; } if (empty($options['showignored']) and in_coventry($message['postuserid'])) { $message['ignored'] = true; } $response_handler =& $factory->create($message); $response_handler->converse = true; if (!$message['vm_enable'] and (!can_moderate(0, 'canmoderatevisitormessages') or $this->registry->userinfo['userid'] == $message['postuserid']) or $message['vm_contactonly'] and !can_moderate(0, 'canmoderatevisitormessages') and $message['postuserid'] != $this->registry->userinfo['userid'] and !$message['bbuser_iscontact_of_user']) { $response_handler->converse = false; } $response_handler->cachable = false; $messagebits .= $response_handler->construct(); if (!$message['messageread'] and $message['state'] == 'visible') { $read_ids[] = $message['vmid']; } $lastcomment = !$lastcomment ? $message['dateline'] : $lastcomment; } $readvms = 0; // If it's our profile and the visible or default tab then we hope they've read it // if ($this->profile->userinfo['userid'] == $this->registry->userinfo['userid'] AND ($options['tab'] == $id OR $options['tab'] == '') AND !empty($read_ids)) if ($this->profile->userinfo['userid'] == $this->registry->userinfo['userid']) { if (!empty($read_ids)) { $readvms = sizeof($read_ids); $this->registry->db->query_write("UPDATE " . TABLE_PREFIX . "visitormessage SET messageread = 1 WHERE vmid IN (" . implode(',', $read_ids) . ")"); } if ($this->profile->userinfo['vmunreadcount'] - $readvms > 0 and $this->registry->options['globalignore'] != '') { // We still have unread VMs somewhere, and Tachy is enabled build_visitor_message_counters($this->profile->userinfo['userid']); } else { if ($readvms) { // This is more than likely on the second page $this->registry->db->query_write("\n\t\t\t\t\tUPDATE " . TABLE_PREFIX . "user\n\t\t\t\t\tSET vmunreadcount = IF(vmunreadcount >= {$readvms}, vmunreadcount - {$readvms}, 0)\n\t\t\t\t\tWHERE userid = " . $this->registry->userinfo['userid']); } } } if ($pagenumber == 1 and (!isset($this->profile->prepared['vm_total']) or !isset($this->profile->prepared['lastvm_time']) or !isset($this->profile->prepared['lastvm_date']))) { $pminfo = array('dateline' => $firstrecord['dateline'], 'messages' => $messagetotal); } else { $pminfo = null; } $this->profile->prepare('vm_total', $pminfo); $this->block_data['messagebits'] = $messagebits; $this->block_data['lastcomment'] = $lastcomment; $show['delete'] = fetch_visitor_message_perm('candeletevisitormessages', $this->profile->userinfo); $show['undelete'] = fetch_visitor_message_perm('canundeletevisitormessages', $this->profile->userinfo); $show['approve'] = fetch_visitor_message_perm('canmoderatevisitormessages', $this->profile->userinfo); $show['inlinemod'] = ($show['delete'] or $show['undelete'] or $show['approve']); // Only allow AJAX QC on the first page $show['quickcomment'] = $show['post_visitor_message']; $show['allow_ajax_qc'] = ($pagenumber == 1 and $messagetotal) ? 1 : 0; $pageinfo = array('tab' => $id); if ($options['perpage'] != $this->registry->options['vm_perpage']) { $pageindo['pp'] = $options['perpage']; } if (!empty($options['showignored'])) { $pageinfo['showignored'] = 1; } $this->block_data['pagenav'] = construct_page_nav($pagenumber, $perpage, $messagetotal, '', '', $id, 'member', $this->profile->userinfo, $pageinfo); $this->block_data['messagetotal'] = $messagetotal; $show['view_conversation'] = (!$this->profile->prepared['myprofile'] and THIS_SCRIPT != 'converse' and $this->registry->userinfo['vm_enable']); if ($show['quickcomment']) { require_once DIR . '/includes/functions_editor.php'; $this->block_data['editorid'] = construct_edit_toolbar('', false, 'visitormessage', $this->registry->options['allowsmilies'], true, false, 'qr_small', '', array(), 'content', 'vBForum_VisitorMessage', 0, $this->profile->userinfo['userid']); $this->block_data['messagearea'] = $messagearea; $this->block_data['clientscript'] = $vBeditTemplate['clientscript']; } }
function do_get_thread() { global $vbulletin, $db, $foruminfo, $threadinfo, $postid, $vault, $vbphrase; $vbulletin->input->clean_array_gpc('r', array('pagenumber' => TYPE_UINT, 'perpage' => TYPE_UINT, 'password' => TYPE_STR, 'signature' => TYPE_BOOL)); if (empty($threadinfo['threadid'])) { json_error(ERR_INVALID_THREAD); } $threadedmode = 0; $threadid = $vbulletin->GPC['threadid']; // Goto first unread post? if ($vbulletin->GPC['pagenumber'] == FR_LAST_POST) { $threadinfo = verify_id('thread', $threadid, 1, 1); if ($vbulletin->options['threadmarking'] and $vbulletin->userinfo['userid']) { $vbulletin->userinfo['lastvisit'] = max($threadinfo['threadread'], $threadinfo['forumread'], TIMENOW - $vbulletin->options['markinglimit'] * 86400); } else { if (($tview = intval(fetch_bbarray_cookie('thread_lastview', $threadid))) > $vbulletin->userinfo['lastvisit']) { $vbulletin->userinfo['lastvisit'] = $tview; } } $coventry = fetch_coventry('string'); $posts = $db->query_first("\n\t SELECT MIN(postid) AS postid\n\t FROM " . TABLE_PREFIX . "post\n\t WHERE threadid = {$threadinfo['threadid']}\n\t AND visible = 1\n\t AND dateline > " . intval($vbulletin->userinfo['lastvisit']) . "\n\t " . ($coventry ? "AND userid NOT IN ({$coventry})" : "") . "\n\t LIMIT 1\n\t"); if ($posts['postid']) { $postid = $posts['postid']; } else { $postid = $threadinfo['lastpostid']; } } // ********************************************************************************* // workaround for header redirect issue from forms with enctype in IE // (use a scrollIntoView javascript call in the <body> onload event) $onload = ''; // ********************************************************************************* // set $perpage $perpage = max(FR_MIN_PERPAGE, min($vbulletin->GPC['perpage'], FR_MAX_PERPAGE)); // FRNR //$perpage = sanitize_maxposts($vbulletin->GPC['perpage']); // ********************************************************************************* // set post order if ($vbulletin->userinfo['postorder'] == 0) { $postorder = ''; } else { $postorder = 'DESC'; } // ********************************************************************************* // get thread info $thread = verify_id('thread', $threadid, 1, 1); $threadinfo =& $thread; ($hook = vBulletinHook::fetch_hook('showthread_getinfo')) ? eval($hook) : false; // ********************************************************************************* // check for visible / deleted thread if (!$thread['visible'] and !can_moderate($thread['forumid'], 'canmoderateposts') or $thread['isdeleted'] and !can_moderate($thread['forumid'])) { json_error(ERR_INVALID_THREAD); } // ********************************************************************************* // Tachy goes to coventry if (in_coventry($thread['postuserid']) and !can_moderate($thread['forumid'])) { json_error(ERR_INVALID_THREAD); } // FRNR Start // Check the forum password (set necessary cookies) if ($vbulletin->GPC['password'] && $foruminfo['password'] == $vbulletin->GPC['password']) { // set a temp cookie for guests if (!$vbulletin->userinfo['userid']) { set_bbarray_cookie('forumpwd', $foruminfo['forumid'], md5($vbulletin->userinfo['userid'] . $vbulletin->GPC['password'])); } else { set_bbarray_cookie('forumpwd', $foruminfo['forumid'], md5($vbulletin->userinfo['userid'] . $vbulletin->GPC['password']), 1); } } // FRNR End // ********************************************************************************* // do word wrapping for the thread title if ($vbulletin->options['wordwrap'] != 0) { $thread['title'] = fetch_word_wrapped_string($thread['title']); } $thread['title'] = fetch_censored_text($thread['title']); $thread['meta_description'] = strip_bbcode(strip_quotes($thread['description']), false, true); $thread['meta_description'] = htmlspecialchars_uni(fetch_censored_text(fetch_trimmed_title($thread['meta_description'], 500, false))); // ********************************************************************************* // words to highlight from the search engine if (!empty($vbulletin->GPC['highlight'])) { $highlight = preg_replace('#\\*+#s', '*', $vbulletin->GPC['highlight']); if ($highlight != '*') { $regexfind = array('\\*', '\\<', '\\>'); $regexreplace = array('[\\w.:@*/?=]*?', '<', '>'); $highlight = preg_quote(strtolower($highlight), '#'); $highlight = explode(' ', $highlight); $highlight = str_replace($regexfind, $regexreplace, $highlight); foreach ($highlight as $val) { if ($val = trim($val)) { $replacewords[] = htmlspecialchars_uni($val); } } } } // ********************************************************************************* // make the forum jump in order to fill the forum caches $navpopup = array('id' => 'showthread_navpopup', 'title' => $foruminfo['title_clean'], 'link' => fetch_seo_url('thread', $threadinfo)); construct_quick_nav($navpopup); // ********************************************************************************* // get forum info $forum = fetch_foruminfo($thread['forumid']); $foruminfo =& $forum; // ********************************************************************************* // check forum permissions $forumperms = fetch_permissions($thread['forumid']); if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) or !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads'])) { json_error(ERR_NO_PERMISSION); } if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers']) and ($thread['postuserid'] != $vbulletin->userinfo['userid'] or $vbulletin->userinfo['userid'] == 0)) { json_error(ERR_NO_PERMISSION); } // ********************************************************************************* // check if there is a forum password and if so, ensure the user has it set if (!verify_forum_password($foruminfo['forumid'], $foruminfo['password'])) { // FRNR json_error(ERR_NEED_PASSWORD, RV_NEED_FORUM_PASSWORD); } // verify that we are at the canonical SEO url // and redirect to this if not //verify_seo_url('thread|js', $threadinfo, array('pagenumber' => $_REQUEST['pagenumber'])); // ********************************************************************************* // jump page if thread is actually a redirect if ($thread['open'] == 10) { $destthreadinfo = fetch_threadinfo($threadinfo['pollid']); exec_header_redirect(fetch_seo_url('thread|js', $destthreadinfo, $pageinfo)); } // ********************************************************************************* // get ignored users $ignore = array(); if (trim($vbulletin->userinfo['ignorelist'])) { $ignorelist = preg_split('/( )+/', trim($vbulletin->userinfo['ignorelist']), -1, PREG_SPLIT_NO_EMPTY); foreach ($ignorelist as $ignoreuserid) { $ignore["{$ignoreuserid}"] = 1; } } DEVDEBUG('ignored users: ' . implode(', ', array_keys($ignore))); // ********************************************************************************* // filter out deletion notices if can't be seen if ($forumperms & $vbulletin->bf_ugp_forumpermissions['canseedelnotice'] or can_moderate($threadinfo['forumid'])) { $deljoin = "LEFT JOIN " . TABLE_PREFIX . "deletionlog AS deletionlog ON(post.postid = deletionlog.primaryid AND deletionlog.type = 'post')"; } else { $deljoin = ''; } $show['viewpost'] = can_moderate($threadinfo['forumid']) ? true : false; $show['managepost'] = iif(can_moderate($threadinfo['forumid'], 'candeleteposts') or can_moderate($threadinfo['forumid'], 'canremoveposts'), true, false); $show['approvepost'] = can_moderate($threadinfo['forumid'], 'canmoderateposts') ? true : false; $show['managethread'] = can_moderate($threadinfo['forumid'], 'canmanagethreads') ? true : false; $show['approveattachment'] = can_moderate($threadinfo['forumid'], 'canmoderateattachments') ? true : false; $show['inlinemod'] = (!$show['threadedmode'] and ($show['managethread'] or $show['managepost'] or $show['approvepost'])) ? true : false; $show['spamctrls'] = ($show['inlinemod'] and $show['managepost']); $url = $show['inlinemod'] ? SCRIPTPATH : ''; // build inline moderation popup if ($show['popups'] and $show['inlinemod']) { $threadadmin_imod_menu_post = vB_Template::create('threadadmin_imod_menu_post')->render(); } else { $threadadmin_imod_menu_post = ''; } // ********************************************************************************* // find the page that we should be on to display this post if (!empty($postid) and $threadedmode == 0) { $postinfo = verify_id('post', $postid, 1, 1); $threadid = $postinfo['threadid']; $getpagenum = $db->query_first("\n \t\tSELECT COUNT(*) AS posts\n \t\tFROM " . TABLE_PREFIX . "post AS post\n \t\tWHERE threadid = {$threadid} AND visible = 1\n \t\tAND dateline " . iif(!$postorder, '<=', '>=') . " {$postinfo['dateline']}\n \t"); $vbulletin->GPC['pagenumber'] = ceil($getpagenum['posts'] / $perpage); } // ********************************************************************************* // update views counter if ($vbulletin->options['threadviewslive']) { // doing it as they happen; for optimization purposes, this cannot use a DM! $db->shutdown_query("\n \t\tUPDATE " . TABLE_PREFIX . "thread\n \t\tSET views = views + 1\n \t\tWHERE threadid = " . intval($threadinfo['threadid'])); } else { // or doing it once an hour $db->shutdown_query("\n \t\tINSERT INTO " . TABLE_PREFIX . "threadviews (threadid)\n \t\tVALUES (" . intval($threadinfo['threadid']) . ')'); } // ********************************************************************************* // display ratings if enabled $show['rating'] = false; if ($forum['allowratings'] == 1) { if ($thread['votenum'] > 0) { $thread['voteavg'] = vb_number_format($thread['votetotal'] / $thread['votenum'], 2); $thread['rating'] = intval(round($thread['votetotal'] / $thread['votenum'])); if ($thread['votenum'] >= $vbulletin->options['showvotes']) { $show['rating'] = true; } } devdebug("threadinfo[vote] = {$threadinfo['vote']}"); if ($threadinfo['vote']) { $voteselected["{$threadinfo['vote']}"] = 'selected="selected"'; $votechecked["{$threadinfo['vote']}"] = 'checked="checked"'; } else { $voteselected[0] = 'selected="selected"'; $votechecked[0] = 'checked="checked"'; } } // ********************************************************************************* // set page number if ($vbulletin->GPC['pagenumber'] < 1) { $vbulletin->GPC['pagenumber'] = 1; } else { if ($vbulletin->GPC['pagenumber'] > ceil(($thread['replycount'] + 1) / $perpage)) { $vbulletin->GPC['pagenumber'] = ceil(($thread['replycount'] + 1) / $perpage); } } // ********************************************************************************* // initialise some stuff... $limitlower = ($vbulletin->GPC['pagenumber'] - 1) * $perpage; $limitupper = $vbulletin->GPC['pagenumber'] * $perpage; $counter = 0; if ($vbulletin->options['threadmarking'] and $vbulletin->userinfo['userid']) { $threadview = max($threadinfo['threadread'], $threadinfo['forumread'], TIMENOW - $vbulletin->options['markinglimit'] * 86400); } else { $threadview = intval(fetch_bbarray_cookie('thread_lastview', $thread['threadid'])); if (!$threadview) { $threadview = $vbulletin->userinfo['lastvisit']; } } $threadinfo['threadview'] = intval($threadview); $displayed_dateline = 0; ################################################################################ ############################### SHOW POLL ###################################### ################################################################################ $poll = ''; if ($thread['pollid']) { $pollbits = ''; $counter = 1; $pollid = $thread['pollid']; $show['editpoll'] = iif(can_moderate($threadinfo['forumid'], 'caneditpoll'), true, false); // get poll info $pollinfo = $db->query_first_slave("\n \t\tSELECT *\n \t\tFROM " . TABLE_PREFIX . "poll\n \t\tWHERE pollid = {$pollid}\n \t"); require_once DIR . '/includes/class_bbcode.php'; $bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list()); $pollinfo['question'] = $bbcode_parser->parse(unhtmlspecialchars($pollinfo['question']), $forum['forumid'], true); $splitoptions = explode('|||', $pollinfo['options']); $splitoptions = array_map('rtrim', $splitoptions); $splitvotes = explode('|||', $pollinfo['votes']); $showresults = 0; $uservoted = 0; if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canvote'])) { $nopermission = 1; } if (!$pollinfo['active'] or !$thread['open'] or $pollinfo['dateline'] + $pollinfo['timeout'] * 86400 < TIMENOW and $pollinfo['timeout'] != 0 or $nopermission) { //thread/poll is closed, ie show results no matter what $showresults = 1; } else { //get userid, check if user already voted $voted = intval(fetch_bbarray_cookie('poll_voted', $pollid)); if ($voted) { $uservoted = 1; } } ($hook = vBulletinHook::fetch_hook('showthread_poll_start')) ? eval($hook) : false; if ($pollinfo['timeout'] and !$showresults) { $pollendtime = vbdate($vbulletin->options['timeformat'], $pollinfo['dateline'] + $pollinfo['timeout'] * 86400); $pollenddate = vbdate($vbulletin->options['dateformat'], $pollinfo['dateline'] + $pollinfo['timeout'] * 86400); $show['pollenddate'] = true; } else { $show['pollenddate'] = false; } foreach ($splitvotes as $index => $value) { $pollinfo['numbervotes'] += $value; } if ($vbulletin->userinfo['userid'] > 0) { $pollvotes = $db->query_read_slave("\n \t\t\tSELECT voteoption\n \t\t\tFROM " . TABLE_PREFIX . "pollvote\n \t\t\tWHERE userid = " . $vbulletin->userinfo['userid'] . " AND pollid = {$pollid}\n \t\t"); if ($db->num_rows($pollvotes) > 0) { $uservoted = 1; } } if ($showresults or $uservoted) { if ($uservoted) { $uservote = array(); while ($pollvote = $db->fetch_array($pollvotes)) { $uservote["{$pollvote['voteoption']}"] = 1; } } } $left = vB_Template_Runtime::fetchStyleVar('left'); $right = vB_Template_Runtime::fetchStyleVar('right'); $option['open'] = $left[0]; $option['close'] = $right[0]; foreach ($splitvotes as $index => $value) { $arrayindex = $index + 1; $option['uservote'] = iif($uservote["{$arrayindex}"], true, false); $option['question'] = $bbcode_parser->parse($splitoptions["{$index}"], $forum['forumid'], true); // public link if ($pollinfo['public'] and $value) { $option['votes'] = '<a href="poll.php?' . $vbulletin->session->vars['sessionurl'] . 'do=showresults&pollid=' . $pollinfo['pollid'] . '">' . vb_number_format($value) . '</a>'; } else { $option['votes'] = vb_number_format($value); //get the vote count for the option } $option['number'] = $counter; //number of the option //Now we check if the user has voted or not if ($showresults or $uservoted) { // user did vote or poll is closed if ($value <= 0) { $option['percentraw'] = 0; } else { if ($pollinfo['multiple']) { $option['percentraw'] = $value < $pollinfo['voters'] ? $value / $pollinfo['voters'] * 100 : 100; } else { $option['percentraw'] = $value < $pollinfo['numbervotes'] ? $value / $pollinfo['numbervotes'] * 100 : 100; } } $option['percent'] = vb_number_format($option['percentraw'], 2); $option['graphicnumber'] = $option['number'] % 6 + 1; $option['barnumber'] = round($option['percent']) * 2; $option['remainder'] = 201 - $option['barnumber']; // Phrase parts below if ($nopermission) { $pollstatus = $vbphrase['you_may_not_vote_on_this_poll']; } else { if ($showresults) { $pollstatus = $vbphrase['this_poll_is_closed']; } else { if ($uservoted) { $pollstatus = $vbphrase['you_have_already_voted_on_this_poll']; } } } ($hook = vBulletinHook::fetch_hook('showthread_polloption')) ? eval($hook) : false; $templater = vB_Template::create('pollresult'); $templater->register('names', $names); $templater->register('option', $option); $pollbits .= $templater->render(); } else { ($hook = vBulletinHook::fetch_hook('showthread_polloption')) ? eval($hook) : false; if ($pollinfo['multiple']) { $templater = vB_Template::create('polloption_multiple'); $templater->register('option', $option); $pollbits .= $templater->render(); } else { $templater = vB_Template::create('polloption'); $templater->register('option', $option); $pollbits .= $templater->render(); } } $counter++; } if ($pollinfo['multiple']) { $pollinfo['numbervotes'] = $pollinfo['voters']; $show['multiple'] = true; } if ($pollinfo['public']) { $show['publicwarning'] = true; } else { $show['publicwarning'] = false; } $displayed_dateline = $threadinfo['lastpost']; ($hook = vBulletinHook::fetch_hook('showthread_poll_complete')) ? eval($hook) : false; if ($showresults or $uservoted) { $templater = vB_Template::create('pollresults_table'); $templater->register('pollbits', $pollbits); $templater->register('pollenddate', $pollenddate); $templater->register('pollendtime', $pollendtime); $templater->register('pollinfo', $pollinfo); $templater->register('pollstatus', $pollstatus); $poll = $templater->render(); } else { $templater = vB_Template::create('polloptions_table'); $templater->register('pollbits', $pollbits); $templater->register('pollenddate', $pollenddate); $templater->register('pollendtime', $pollendtime); $templater->register('pollinfo', $pollinfo); $poll = $templater->render(); } } // work out if quickreply should be shown or not if ($vbulletin->options['quickreply'] and !$thread['isdeleted'] and !is_browser('netscape') and $vbulletin->userinfo['userid'] and ($vbulletin->userinfo['userid'] == $threadinfo['postuserid'] and $forumperms & $vbulletin->bf_ugp_forumpermissions['canreplyown'] or $vbulletin->userinfo['userid'] != $threadinfo['postuserid'] and $forumperms & $vbulletin->bf_ugp_forumpermissions['canreplyothers']) and ($thread['open'] or can_moderate($threadinfo['forumid'], 'canopenclose')) and !fetch_require_hvcheck('post')) { $show['quickreply'] = true; } else { $show['quickreply'] = false; $show['wysiwyg'] = 0; $quickreply = ''; } $show['largereplybutton'] = (!$thread['isdeleted'] and !$show['threadedmode'] and $forum['allowposting'] and !$show['search_engine']); if (!$forum['allowposting']) { $show['quickreply'] = false; } $show['multiquote_global'] = ($vbulletin->options['multiquote'] and $vbulletin->userinfo['userid']); if ($show['multiquote_global']) { $vbulletin->input->clean_array_gpc('c', array('vbulletin_multiquote' => TYPE_STR)); $vbulletin->GPC['vbulletin_multiquote'] = explode(',', $vbulletin->GPC['vbulletin_multiquote']); } // post is cachable if option is enabled, last post is newer than max age, and this user // isn't showing a sessionhash $post_cachable = ($vbulletin->options['cachemaxage'] > 0 and TIMENOW - $vbulletin->options['cachemaxage'] * 60 * 60 * 24 <= $thread['lastpost'] and $vbulletin->session->vars['sessionurl'] == ''); $saveparsed = ''; $save_parsed_sigs = ''; ($hook = vBulletinHook::fetch_hook('showthread_post_start')) ? eval($hook) : false; ################################################################################ ####################### SHOW THREAD IN LINEAR MODE ############################# ################################################################################ if ($threadedmode == 0) { // allow deleted posts to not be counted in number of posts displayed on the page; // prevents issue with page count on forum display being incorrect $ids = array(); $lastpostid = 0; $hook_query_joins = $hook_query_where = ''; ($hook = vBulletinHook::fetch_hook('showthread_query_postids')) ? eval($hook) : false; if (empty($deljoin) and !$show['approvepost']) { $totalposts = $threadinfo['replycount'] + 1; if (can_moderate($thread['forumid'])) { $coventry = ''; } else { $coventry = fetch_coventry('string'); } $getpostids = $db->query_read("\n \t\t\tSELECT post.postid\n \t\t\tFROM " . TABLE_PREFIX . "post AS post\n \t\t\t{$hook_query_joins}\n \t\t\tWHERE post.threadid = {$threadid}\n \t\t\t\tAND post.visible = 1\n \t\t\t\t" . ($coventry ? "AND post.userid NOT IN ({$coventry})" : '') . "\n \t\t\t\t{$hook_query_where}\n \t\t\tORDER BY post.dateline {$postorder}\n \t\t\tLIMIT {$limitlower}, {$perpage}\n \t\t"); while ($post = $db->fetch_array($getpostids)) { if (!isset($qrfirstpostid)) { $qrfirstpostid = $post['postid']; } $qrlastpostid = $post['postid']; $ids[] = $post['postid']; } $db->free_result($getpostids); $lastpostid = $qrlastpostid; } else { $getpostids = $db->query_read("\n \t\t\tSELECT post.postid, post.visible, post.userid\n \t\t\tFROM " . TABLE_PREFIX . "post AS post\n \t\t\t{$hook_query_joins}\n \t\t\tWHERE post.threadid = {$threadid}\n \t\t\t\tAND post.visible IN (1\n \t\t\t\t" . (!empty($deljoin) ? ",2" : "") . "\n \t\t\t\t" . ($show['approvepost'] ? ",0" : "") . "\n \t\t\t\t)\n \t\t\t\t{$hook_query_where}\n \t\t\tORDER BY post.dateline {$postorder}\n \t\t"); $totalposts = 0; if ($limitlower != 0) { $limitlower++; } while ($post = $db->fetch_array($getpostids)) { if (!isset($qrfirstpostid)) { $qrfirstpostid = $post['postid']; } $qrlastpostid = $post['postid']; if ($post['visible'] == 1 and !in_coventry($post['userid']) and !$ignore[$post['userid']]) { $totalposts++; } if ($totalposts < $limitlower or $totalposts > $limitupper) { continue; } // remember, these are only added if they're going to be displayed $ids[] = $post['postid']; $lastpostid = $post['postid']; } $db->free_result($getpostids); } // '0' inside parenthesis in unlikely case we have no ids for this page // (this could happen if the replycount is wrong in the db) $postids = "post.postid IN (0" . implode(',', $ids) . ")"; // load attachments if ($thread['attach']) { require_once DIR . '/packages/vbattach/attach.php'; $attach = new vB_Attach_Display_Content($vbulletin, 'vBForum_Post'); $postattach = $attach->fetch_postattach(0, $ids); } $hook_query_fields = $hook_query_joins = ''; ($hook = vBulletinHook::fetch_hook('showthread_query')) ? eval($hook) : false; $posts = $db->query_read("\n \t\tSELECT\n \t\t\tpost.*, post.username AS postusername, post.ipaddress AS ip, IF(post.visible = 2, 1, 0) AS isdeleted,\n \t\t\tuser.*, userfield.*, usertextfield.*,\n \t\t\t" . iif($forum['allowicons'], 'icon.title as icontitle, icon.iconpath,') . "\n \t\t\t" . iif($vbulletin->options['avatarenabled'], 'avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight,') . "\n \t\t\t" . ((can_moderate($thread['forumid'], 'canmoderateposts') or can_moderate($thread['forumid'], 'candeleteposts')) ? 'spamlog.postid AS spamlog_postid,' : '') . "\n \t\t\t" . iif($deljoin, 'deletionlog.userid AS del_userid, deletionlog.username AS del_username, deletionlog.reason AS del_reason,') . "\n \t\t\teditlog.userid AS edit_userid, editlog.username AS edit_username, editlog.dateline AS edit_dateline,\n \t\t\teditlog.reason AS edit_reason, editlog.hashistory,\n \t\t\tpostparsed.pagetext_html, postparsed.hasimages,\n \t\t\tsigparsed.signatureparsed, sigparsed.hasimages AS sighasimages,\n \t\t\tsigpic.userid AS sigpic, sigpic.dateline AS sigpicdateline, sigpic.width AS sigpicwidth, sigpic.height AS sigpicheight,\n \t\t\tIF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid, infractiongroupid\n \t\t\t" . iif(!($permissions['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canseehiddencustomfields']), $vbulletin->profilefield['hidden']) . "\n \t\t\t{$hook_query_fields}\n \t\tFROM " . TABLE_PREFIX . "post AS post\n \t\tLEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = post.userid)\n \t\tLEFT JOIN " . TABLE_PREFIX . "userfield AS userfield ON(userfield.userid = user.userid)\n \t\tLEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON(usertextfield.userid = user.userid)\n \t\t" . iif($forum['allowicons'], "LEFT JOIN " . TABLE_PREFIX . "icon AS icon ON(icon.iconid = post.iconid)") . "\n \t\t" . iif($vbulletin->options['avatarenabled'], "LEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON(avatar.avatarid = user.avatarid) LEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON(customavatar.userid = user.userid)") . "\n \t\t" . ((can_moderate($thread['forumid'], 'canmoderateposts') or can_moderate($thread['forumid'], 'candeleteposts')) ? "LEFT JOIN " . TABLE_PREFIX . "spamlog AS spamlog ON(spamlog.postid = post.postid)" : '') . "\n \t\t\t{$deljoin}\n \t\tLEFT JOIN " . TABLE_PREFIX . "editlog AS editlog ON(editlog.postid = post.postid)\n \t\tLEFT JOIN " . TABLE_PREFIX . "postparsed AS postparsed ON(postparsed.postid = post.postid AND postparsed.styleid = " . intval(STYLEID) . " AND postparsed.languageid = " . intval(LANGUAGEID) . ")\n \t\tLEFT JOIN " . TABLE_PREFIX . "sigparsed AS sigparsed ON(sigparsed.userid = user.userid AND sigparsed.styleid = " . intval(STYLEID) . " AND sigparsed.languageid = " . intval(LANGUAGEID) . ")\n \t\tLEFT JOIN " . TABLE_PREFIX . "sigpic AS sigpic ON(sigpic.userid = post.userid)\n \t\t\t{$hook_query_joins}\n \t\tWHERE {$postids}\n \t\tORDER BY post.dateline {$postorder}\n \t"); if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canseethumbnails']) and !($forumperms & $vbulletin->bf_ugp_forumpermissions['cangetattachment'])) { $vbulletin->options['attachthumbs'] = 0; } if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['cangetattachment'])) { $vbulletin->options['viewattachedimages'] = 0; } $postcount = ($vbulletin->GPC['pagenumber'] - 1) * $perpage; if ($postorder) { // Newest first $postcount = $totalposts - $postcount + 1; } $counter = 0; $postbits = ''; $postbit_factory = new vB_Postbit_Factory(); $postbit_factory->registry =& $vbulletin; $postbit_factory->forum =& $foruminfo; $postbit_factory->thread =& $thread; $postbit_factory->cache = array(); $postbit_factory->bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list()); while ($post = $db->fetch_array($posts)) { if ($tachyuser = in_coventry($post['userid']) and !can_moderate($thread['forumid'])) { continue; } if ($post['visible'] == 1 and !$tachyuser) { ++$counter; if ($postorder) { $post['postcount'] = --$postcount; } else { $post['postcount'] = ++$postcount; } } if ($tachyuser) { $fetchtype = 'post_global_ignore'; } else { if ($ignore["{$post['userid']}"]) { $fetchtype = 'post_ignore'; } else { if ($post['visible'] == 2) { $fetchtype = 'post_deleted'; } else { $fetchtype = 'post'; } } } if ($vbulletin->GPC['viewfull'] and $post['postid'] == $postinfo['postid'] and $fetchtype != 'post' and (can_moderate($threadinfo['forumid']) or !$post['isdeleted'])) { $fetchtype = 'post'; } if ($fetchtype != 'post' && $fetchtype != 'post_deleted') { continue; } ($hook = vBulletinHook::fetch_hook('showthread_postbit_create')) ? eval($hook) : false; $postbit_obj =& $postbit_factory->fetch_postbit($fetchtype); if ($fetchtype == 'post') { $postbit_obj->highlight =& $replacewords; } $postbit_obj->cachable = $post_cachable; $post['islastshown'] = $post['postid'] == $lastpostid; $post['isfirstshown'] = ($counter == 1 and $fetchtype == 'post' and $post['visible'] == 1); $post['islastshown'] = $post['postid'] == $lastpostid; $post['attachments'] = $postattach["{$post['postid']}"]; $parsed_postcache = array('text' => '', 'images' => 1, 'skip' => false); $postbits .= $postbit_obj->construct_postbit($post); // Only show after the first post, counter isn't incremented for deleted/moderated posts if ($post['isfirstshown']) { $postbits .= vB_Template::create('ad_showthread_firstpost')->render(); } if ($post_cachable and $post['pagetext_html'] == '') { if (!empty($saveparsed)) { $saveparsed .= ','; } $saveparsed .= "({$post['postid']}, " . intval($thread['lastpost']) . ', ' . intval($postbit_obj->post_cache['has_images']) . ", '" . $db->escape_string($postbit_obj->post_cache['text']) . "', " . intval(STYLEID) . ", " . intval(LANGUAGEID) . ")"; } if (!empty($postbit_obj->sig_cache) and $post['userid']) { if (!empty($save_parsed_sigs)) { $save_parsed_sigs .= ','; } $save_parsed_sigs .= "({$post['userid']}, " . intval(STYLEID) . ", " . intval(LANGUAGEID) . ", '" . $db->escape_string($postbit_obj->sig_cache['text']) . "', " . intval($postbit_obj->sig_cache['has_images']) . ")"; } // get first and last post ids for this page (for big reply buttons) if (!isset($FIRSTPOSTID)) { $FIRSTPOSTID = $post['postid']; } $LASTPOSTID = $post['postid']; if ($post['dateline'] > $displayed_dateline) { $displayed_dateline = $post['dateline']; if ($displayed_dateline <= $threadview) { $updatethreadcookie = true; } } // FRNR Start // find out if first post $getpost = $db->query_first("\n SELECT firstpostid\n FROM " . TABLE_PREFIX . "thread\n WHERE threadid = {$threadinfo['threadid']}\n "); $isfirstpost = $getpost['firstpostid'] == $post['postid']; $candelete = false; if ($isfirstpost and can_moderate($threadinfo['forumid'], 'canmanagethreads')) { $candelete = true; } else { if (!$isfirstpost and can_moderate($threadinfo['forumid'], 'candeleteposts')) { $candelete = true; } else { if (($forumperms & $vbulletin->bf_ugp_forumpermissions['candeletepost'] and !$isfirstpost or $forumperms & $vbulletin->bf_ugp_forumpermissions['candeletethread'] and $isfirstpost) and $vbulletin->userinfo['userid'] == $post['userid']) { $candelete = true; } } } // Get post date/time $postdate = vbdate($vbulletin->options['dateformat'], $post['dateline'], 1); $posttime = vbdate($vbulletin->options['timeformat'], $post['dateline']); $fr_images = array(); $docattach = array(); // Attachments (images). if (is_array($post['attachments']) && count($post['attachments']) > 0) { foreach ($post['attachments'] as $attachment) { $lfilename = strtolower($attachment['filename']); if (strpos($lfilename, '.jpe') !== false || strpos($lfilename, '.png') !== false || strpos($lfilename, '.gif') !== false || strpos($lfilename, '.jpg') !== false || strpos($lfilename, '.jpeg') !== false) { $tmp = array('img' => $vbulletin->options['bburl'] . '/attachment.php?attachmentid=' . $attachment['attachmentid']); if ($vbulletin->options['attachthumbs']) { $tmp['tmb'] = $vbulletin->options['bburl'] . '/attachment.php?attachmentid=' . $attachment['attachmentid'] . '&stc=1&thumb=1'; } $fr_images[] = $tmp; } if (strpos($lfilename, '.pdf') !== false) { $docattach[] = $vbulletin->options['bburl'] . '/attachment.php?attachmentid=' . $attachment['attachmentid']; } } } // Parse the post for quotes and inline images list($text, $nuked_quotes, $images) = parse_post($post['pagetext'], $post['allowsmilie'] && $usesmilies); if (count($fr_images) > 0) { $text .= "<br/>"; foreach ($fr_images as $attachment) { $text .= "<img src=\"{$attachment['img']}\"/>"; } } foreach ($images as $image) { $fr_images[] = array('img' => $image); } $avatarurl = ''; // Avatar work if ($post['avatarurl']) { $avatarurl = process_avatarurl($post['avatarurl']); } $tmp = array('post_id' => $post['postid'], 'thread_id' => $post['threadid'], 'forum_id' => $foruminfo['forumid'], 'forum_title' => prepare_utf8_string($foruminfo['title_clean']), 'username' => prepare_utf8_string(strip_tags($post['username'])), 'joindate' => prepare_utf8_string($post['joindate']), 'usertitle' => prepare_utf8_string(strip_tags($post['usertitle'])), 'numposts' => $post['posts'] ? (string) $post['posts'] : '0', 'userid' => $post['userid'], 'title' => prepare_utf8_string($post['title']), 'online' => fetch_online_status(fetch_userinfo($post['userid']), false), 'post_timestamp' => prepare_utf8_string(date_trunc($postdate) . ' ' . $posttime), 'fr_images' => $fr_images); if ($candelete) { $tmp['candelete'] = true; } // Soft Deleted if ($post['visible'] == 2) { $tmp['deleted'] = true; $tmp['del_username'] = prepare_utf8_string($post['del_username']); if ($post['del_reason']) { $tmp['del_reason'] = prepare_utf8_string($post['del_reason']); } } else { $tmp['text'] = $text; $tmp['quotable'] = $nuked_quotes; if ($post['editlink']) { $tmp['canedit'] = true; $tmp['edittext'] = prepare_utf8_string($post['pagetext']); } } if ($avatarurl != '') { $tmp['avatarurl'] = $avatarurl; } if (count($docattach) > 0) { $tmp['docattach'] = $docattach; } if ($vbulletin->GPC['signature']) { $sig = trim(remove_bbcode(strip_tags($post['signatureparsed']), true, true), '<a>'); $sig = str_replace(array("\t", "\r"), array('', ''), $sig); $sig = str_replace("\n\n", "\n", $sig); $tmp['sig'] = prepare_utf8_string($sig); } // Begin Support for Post Thanks Hack - http://www.vbulletin.org/forum/showthread.php?t=122944 if ($vbulletin->userinfo['userid'] && function_exists('post_thanks_off') && function_exists('can_thank_this_post') && function_exists('thanked_already') && function_exists('fetch_thanks')) { if (!post_thanks_off($thread['forumid'], $post, $thread['firstpostid'], THIS_SCRIPT)) { global $ids; if (can_thank_this_post($post, $thread['isdeleted'])) { $tmp['canlike'] = true; } if (thanked_already($post, 0, true)) { $tmp['likes'] = true; if (!$vbulletin->options['post_thanks_delete_own']) { $tmp['canlike'] = $tmp['likes'] = false; } } $thanks = fetch_thanks($post['postid']); $thank_users = array(); if (is_array($thanks)) { foreach ($thanks as $thank) { $thank_users[] = $thank['username']; } } if (count($thank_users)) { $tmp['likestext'] = prepare_utf8_string($vbphrase['fr_thanked_by'] . ': ' . join(', ', $thank_users)); $tmp['likesusers'] = join(', ', $thank_users); } } } // End Support for Post Thanks Hack $posts_out[] = $tmp; // FRNR End } $db->free_result($posts); unset($post); if ($postbits == '' and $vbulletin->GPC['pagenumber'] > 1) { $pageinfo = array('page' => $vbulletin->GPC['pagenumber'] - 1); if (!empty($vbulletin->GPC['perpage'])) { $pageinfo['pp'] = $perpage; } if (!empty($vbulletin->GPC['highlight'])) { $pageinfo['highlight'] = urlencode($vbulletin->GPC['highlight']); } exec_header_redirect(fetch_seo_url('thread|js', $threadinfo, $pageinfo)); } DEVDEBUG("First Post: {$FIRSTPOSTID}; Last Post: {$LASTPOSTID}"); $pageinfo = array(); if ($vbulletin->GPC['highlight']) { $pageinfo['highlight'] = urlencode($vbulletin->GPC['highlight']); } if (!empty($vbulletin->GPC['perpage'])) { $pageinfo['pp'] = $perpage; } $pagenav = construct_page_nav($vbulletin->GPC['pagenumber'], $perpage, $totalposts, 'showthread.php?' . $vbulletin->session->vars['sessionurl'] . "t={$threadinfo['threadid']}", '', '', 'thread', $threadinfo, $pageinfo); if ($thread['lastpost'] > $threadview) { if ($firstnew) { $firstunread = fetch_seo_url('thread', $threadinfo, array('page' => $vbulletin->GPC['pagenumber'])) . '#post' . $firstnew; $show['firstunreadlink'] = true; } else { $firstunread = fetch_seo_url('thread', $threadinfo, array('goto' => 'newpost')); $show['firstunreadlink'] = true; } } else { $firstunread = ''; $show['firstunreadlink'] = false; } if ($vbulletin->userinfo['postorder']) { // disable ajax qr when displaying linear newest first $show['allow_ajax_qr'] = 0; } else { // only allow ajax on the last page of a thread when viewing oldest first $show['allow_ajax_qr'] = $vbulletin->GPC['pagenumber'] == ceil($totalposts / $perpage) ? 1 : 0; } ################################################################################ ################ SHOW THREAD IN THREADED OR HYBRID MODE ######################## ################################################################################ } else { // ajax qr doesn't work with threaded controls $show['allow_ajax_qr'] = 0; require_once DIR . '/includes/functions_threadedmode.php'; // save data $ipostarray = array(); $postarray = array(); $userarray = array(); $postparent = array(); $postorder = array(); $hybridposts = array(); $deletedparents = array(); $totalposts = 0; $links = ''; $cache_postids = ''; $hook_query_fields = $hook_query_joins = $hook_query_where = ''; ($hook = vBulletinHook::fetch_hook('showthread_query_postids_threaded')) ? eval($hook) : false; // get all posts $listposts = $db->query_read("\n \t\tSELECT\n \t\t\tpost.*, post.username AS postusername, post.ipaddress AS ip, IF(post.visible = 2, 1, 0) AS isdeleted,\n \t\t\tuser.*, userfield.*\n \t\t\t" . iif(!($permissions['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canseehiddencustomfields']), $vbulletin->profilefield['hidden']) . "\n \t\t\t{$hook_query_fields}\n \t\tFROM " . TABLE_PREFIX . "post AS post\n \t\tLEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = post.userid)\n \t\tLEFT JOIN " . TABLE_PREFIX . "userfield AS userfield ON(userfield.userid = user.userid)\n \t\t{$hook_query_joins}\n \t\tWHERE threadid = {$threadid}\n \t\t\t{$hook_query_where}\n \t\tORDER BY postid\n \t"); // $toppostid is the first post in the thread // $curpostid is the postid passed from the URL, or if not specified, the first post in the thread $ids = array(); while ($post = $db->fetch_array($listposts)) { if ($post['visible'] == 2 and !$deljoin or $post['visible'] == 0 and !$show['approvepost'] or in_coventry($post['userid']) and !can_moderate($thread['forumid'])) { $deletedparents["{$post['postid']}"] = iif(isset($deletedparents["{$post['parentid']}"]), $deletedparents["{$post['parentid']}"], $post['parentid']); continue; } if (empty($toppostid)) { $toppostid = $post['postid']; } if (empty($postid)) { if (empty($curpostid)) { $curpostid = $post['postid']; if ($threadedmode == 2 and empty($vbulletin->GPC['postid'])) { $vbulletin->GPC['postid'] = $curpostid; } $curpostparent = $post['parentid']; } } else { if ($post['postid'] == $postid) { $curpostid = $post['postid']; $curpostparent = $post['parentid']; } } $postparent["{$post['postid']}"] = $post['parentid']; $ipostarray["{$post['parentid']}"][] = $post['postid']; $postarray["{$post['postid']}"] = $post; $userarray["{$post['userid']}"] = $db->escape_string($post['username']); $totalposts++; $ids[] = $post['postid']; } $db->free_result($listposts); // hooks child posts up to new parent if actual parent has been deleted or hidden if (count($deletedparents) > 0) { foreach ($deletedparents as $dpostid => $dparentid) { if (is_array($ipostarray[$dpostid])) { foreach ($ipostarray[$dpostid] as $temppostid) { $postparent[$temppostid] = $dparentid; $ipostarray[$dparentid][] = $temppostid; $postarray[$temppostid]['parentid'] = $dparentid; } unset($ipostarray[$dpostid]); } if ($curpostparent == $dpostid) { $curpostparent = $dparentid; } } } unset($post, $listposts, $deletedparents); if ($thread['attach']) { require_once DIR . '/packages/vbattach/attach.php'; $attach = new vB_Attach_Display_Content($vbulletin, 'vBForum_Post'); $postattach = $attach->fetch_postattach(0, $ids); } // get list of usernames from post list $userjs = ''; foreach ($userarray as $userid => $username) { if ($userid) { $userjs .= "pu[{$userid}] = \"" . addslashes_js($username) . "\";\n"; } } unset($userarray, $userid, $username); $parent_postids = fetch_post_parentlist($curpostid); if (!$parent_postids) { $currentdepth = 0; } else { $currentdepth = sizeof(explode(',', $parent_postids)); } sort_threaded_posts(); if (empty($curpostid)) { eval(standard_error(fetch_error('invalidid', $vbphrase['post'], $vbulletin->options['contactuslink']))); } if ($threadedmode == 2) { $numhybrids = sizeof($hybridposts); if ($vbulletin->GPC['pagenumber'] < 1) { $vbulletin->GPC['pagenumber'] = 1; } $startat = ($vbulletin->GPC['pagenumber'] - 1) * $perpage; if ($startat > $numhybrids) { $vbulletin->GPC['pagenumber'] = 1; $startat = 0; } $endat = $startat + $perpage; for ($i = $startat; $i < $endat; $i++) { if (isset($hybridposts["{$i}"])) { if (!isset($FIRSTPOSTID)) { $FIRSTPOSTID = $hybridposts["{$i}"]; } $cache_postids .= ",{$hybridposts[$i]}"; $LASTPOSTID = $hybridposts["{$i}"]; } } $pageinfo = array('p' => $vbulletin->GPC['postid']); if ($vbulletin->GPC['highlight']) { $pageinfo['highlight'] = urlencode($vbulletin->GPC['highlight']); } if (!empty($vbulletin->GPC['perpage'])) { $pageinfo['pp'] = $perpage; } $pagenav = construct_page_nav($vbulletin->GPC['pagenumber'], $perpage, $numhybrids, 'showthread.php?' . $vbulletin->session->vars['sessionurl'] . "t={$threadinfo['threadid']}", '', '', 'thread', $threadinfo, $pageinfo); } else { $FIRSTPOSTID = $curpostid; $LASTPOSTID = $curpostid; // sort out which posts to cache: if (!$vbulletin->options['threaded_maxcache']) { $vbulletin->options['threaded_maxcache'] = 999999; } // cache $vbulletin->options['threaded_maxcache'] posts // take 0.25 from above $curpostid // and take 0.75 below if (sizeof($postorder) <= $vbulletin->options['threaded_maxcache']) { $startat = 0; } else { if ($curpostidkey + $vbulletin->options['threaded_maxcache'] * 0.75 > sizeof($postorder)) { $startat = sizeof($postorder) - $vbulletin->options['threaded_maxcache']; } else { if ($curpostidkey - $vbulletin->options['threaded_maxcache'] * 0.25 < 0) { $startat = 0; } else { $startat = intval($curpostidkey - $vbulletin->options['threaded_maxcache'] * 0.25); } } } unset($curpostidkey); foreach ($postorder as $postkey => $pid) { if ($postkey > $startat + $vbulletin->options['threaded_maxcache']) { break; } if ($postkey >= $startat and empty($morereplies["{$pid}"])) { $cache_postids .= ',' . $pid; } } // get next/previous posts for each post in the list // key: NAVJS[postid][0] = prev post, [1] = next post $NAVJS = array(); $prevpostid = 0; foreach ($postorder as $pid) { $NAVJS["{$pid}"][0] = $prevpostid; $NAVJS["{$prevpostid}"][1] = $pid; $prevpostid = $pid; } $NAVJS["{$toppostid}"][0] = $pid; //prev button for first post $NAVJS["{$pid}"][1] = $toppostid; //next button for last post $navjs = ''; foreach ($NAVJS as $pid => $info) { $navjs .= "pn[{$pid}] = \"{$info['0']},{$info['1']}\";\n"; } } unset($ipostarray, $postparent, $postorder, $NAVJS, $postid, $info, $prevpostid, $postkey); $cache_postids = substr($cache_postids, 1); if (empty($cache_postids)) { // umm... something weird happened. Just prevent an error. eval(standard_error(fetch_error('invalidid', $vbphrase['post'], $vbulletin->options['contactuslink']))); } $hook_query_fields = $hook_query_joins = $hook_query_where = ''; ($hook = vBulletinHook::fetch_hook('showthread_query')) ? eval($hook) : false; $cacheposts = $db->query_read("\n \t\tSELECT\n \t\t\tpost.*, post.username AS postusername, post.ipaddress AS ip, IF(post.visible = 2, 1, 0) AS isdeleted,\n \t\t\tuser.*, userfield.*, usertextfield.*,\n \t\t\t" . iif($forum['allowicons'], 'icon.title as icontitle, icon.iconpath,') . "\n \t\t\t" . iif($vbulletin->options['avatarenabled'], 'avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,') . "\n \t\t\t" . ((can_moderate($thread['forumid'], 'canmoderateposts') or can_moderate($thread['forumid'], 'candeleteposts')) ? 'spamlog.postid AS spamlog_postid,' : '') . "\n \t\t\t" . iif($deljoin, "deletionlog.userid AS del_userid, deletionlog.username AS del_username, deletionlog.reason AS del_reason,") . "\n \t\t\teditlog.userid AS edit_userid, editlog.username AS edit_username, editlog.dateline AS edit_dateline,\n \t\t\teditlog.reason AS edit_reason, editlog.hashistory,\n \t\t\tpostparsed.pagetext_html, postparsed.hasimages,\n \t\t\tsigparsed.signatureparsed, sigparsed.hasimages AS sighasimages,\n \t\t\tsigpic.userid AS sigpic, sigpic.dateline AS sigpicdateline, sigpic.width AS sigpicwidth, sigpic.height AS sigpicheight,\n \t\t\tIF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid, infractiongroupid\n \t\t\t" . iif(!($permissions['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canseehiddencustomfields']), $vbulletin->profilefield['hidden']) . "\n \t\t\t{$hook_query_fields}\n \t\tFROM " . TABLE_PREFIX . "post AS post\n \t\tLEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = post.userid)\n \t\tLEFT JOIN " . TABLE_PREFIX . "userfield AS userfield ON(userfield.userid = user.userid)\n \t\tLEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON(usertextfield.userid = user.userid)\n \t\t" . iif($forum['allowicons'], "LEFT JOIN " . TABLE_PREFIX . "icon AS icon ON(icon.iconid = post.iconid)") . "\n \t\t" . iif($vbulletin->options['avatarenabled'], "LEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON(avatar.avatarid = user.avatarid) LEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON(customavatar.userid = user.userid)") . "\n \t\t" . ((can_moderate($thread['forumid'], 'canmoderateposts') or can_moderate($thread['forumid'], 'candeleteposts')) ? "LEFT JOIN " . TABLE_PREFIX . "spamlog AS spamlog ON(spamlog.postid = post.postid)" : '') . "\n \t\t\t{$deljoin}\n \t\tLEFT JOIN " . TABLE_PREFIX . "editlog AS editlog ON(editlog.postid = post.postid)\n \t\tLEFT JOIN " . TABLE_PREFIX . "postparsed AS postparsed ON(postparsed.postid = post.postid AND postparsed.styleid = " . intval(STYLEID) . " AND postparsed.languageid = " . intval(LANGUAGEID) . ")\n \t\tLEFT JOIN " . TABLE_PREFIX . "sigparsed AS sigparsed ON(sigparsed.userid = user.userid AND sigparsed.styleid = " . intval(STYLEID) . " AND sigparsed.languageid = " . intval(LANGUAGEID) . ")\n \t\tLEFT JOIN " . TABLE_PREFIX . "sigpic AS sigpic ON(sigpic.userid = post.userid)\n \t\t\t{$hook_query_joins}\n \t\tWHERE post.postid IN (" . $cache_postids . ") {$hook_query_where}\n \t"); // re-initialise the $postarray variable $postarray = array(); while ($post = $db->fetch_array($cacheposts)) { $postarray["{$post['postid']}"] = $post; } if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['cangetattachment'])) { $vbulletin->options['viewattachedimages'] = 0; $vbulletin->options['attachthumbs'] = 0; } // init $postcount = 0; $postbits = ''; $saveparsed = ''; $jspostbits = ''; $postbit_factory = new vB_Postbit_Factory(); $postbit_factory->registry =& $vbulletin; $postbit_factory->forum =& $foruminfo; $postbit_factory->thread =& $thread; $postbit_factory->cache = array(); $postbit_factory->bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list()); foreach (explode(',', $cache_postids) as $id) { // get the post from the post array if (!isset($postarray["{$id}"])) { continue; } $post = $postarray["{$id}"]; if ($tachyuser = in_coventry($post['userid']) and !can_moderate($thread['forumid'])) { continue; } if ($tachyuser) { $fetchtype = 'post_global_ignore'; } else { if ($ignore["{$post['userid']}"]) { $fetchtype = 'post_ignore'; } else { if ($post['visible'] == 2) { $fetchtype = 'post_deleted'; } else { $fetchtype = 'post'; } } } if ($vbulletin->GPC['viewfull'] and $post['postid'] == $postinfo['postid'] and $fetchtype != 'post' and (can_moderate($threadinfo['forumid']) or !$post['isdeleted'])) { $fetchtype = 'post'; } ($hook = vBulletinHook::fetch_hook('showthread_postbit_create')) ? eval($hook) : false; $postbit_obj =& $postbit_factory->fetch_postbit($fetchtype); if ($fetchtype == 'post') { $postbit_obj->highlight =& $replacewords; } $postbit_obj->cachable = $post_cachable; $post['postcount'] = ++$postcount; $post['attachments'] =& $postattach["{$post['postid']}"]; $parsed_postcache = array('text' => '', 'images' => 1); $bgclass = 'alt2'; if ($threadedmode == 2) { $postbits .= $postbit_obj->construct_postbit($post); } else { $postbit = $postbit_obj->construct_postbit($post); if ($curpostid == $post['postid']) { $curpostdateline = $post['dateline']; $curpostbit = $postbit; } $postbit = preg_replace('#</script>#i', "<\\/scr' + 'ipt>", addslashes_js($postbit)); $jspostbits .= "pd[{$post['postid']}] = '{$postbit}';\n"; } // end threaded mode if ($post_cachable and $post['pagetext_html'] == '') { if (!empty($saveparsed)) { $saveparsed .= ','; } $saveparsed .= "({$post['postid']}, " . intval($thread['lastpost']) . ', ' . intval($postbit_obj->post_cache['has_images']) . ", '" . $db->escape_string($postbit_obj->post_cache['text']) . "'," . intval(STYLEID) . ", " . intval(LANGUAGEID) . ")"; } if (!empty($postbit_obj->sig_cache) and $post['userid']) { if (!empty($save_parsed_sigs)) { $save_parsed_sigs .= ','; } $save_parsed_sigs .= "({$post['userid']}, " . intval(STYLEID) . ", " . intval(LANGUAGEID) . ", '" . $db->escape_string($postbit_obj->sig_cache['text']) . "', " . intval($postbit_obj->sig_cache['has_images']) . ")"; } if ($post['dateline'] > $displayed_dateline) { $displayed_dateline = $post['dateline']; if ($displayed_dateline <= $threadview) { $updatethreadcookie = true; } } } // end while ($post) $db->free_result($cacheposts); if ($threadedmode == 1) { $postbits = $curpostbit; } $templater = vB_Template::create('showthread_list'); $templater->register('curpostid', $curpostid); $templater->register('highlightwords', $highlightwords); $templater->register('jspostbits', $jspostbits); $templater->register('links', $links); $templater->register('navjs', $navjs); $templater->register('threadedmode', $threadedmode); $templater->register('userjs', $userjs); $threadlist = $templater->render(); unset($curpostbit, $post, $cacheposts, $parsed_postcache, $postbit); } ################################################################################ ########################## END LINEAR / THREADED ############################### ################################################################################ $effective_lastpost = max($displayed_dateline, $thread['lastpost']); // ********************************************************************************* //set thread last view if ($thread['pollid'] and $vbulletin->options['updatelastpost'] and ($displayed_dateline == $thread['lastpost'] or $threadview == $thread['lastpost']) and $pollinfo['lastvote'] > $thread['lastpost']) { $displayed_dateline = $pollinfo['lastvote']; } if ((!$vbulletin->GPC['posted'] or $updatethreadcookie) and $displayed_dateline and $displayed_dateline > $threadview) { mark_thread_read($threadinfo, $foruminfo, $vbulletin->userinfo['userid'], $displayed_dateline); } // FRNR Below fr_update_subsent($threadinfo['threadid'], $displayed_dateline); if (!is_array($posts_out)) { $posts_out = array(); } // Figure out if we can post $canpost = true; if ($threadinfo['isdeleted'] or !$threadinfo['visible'] and !can_moderate($threadinfo['forumid'], 'canmoderateposts')) { $canpost = false; } if (!$foruminfo['allowposting'] or $foruminfo['link'] or !$foruminfo['cancontainthreads']) { $canpost = false; } if (!$threadinfo['open']) { if (!can_moderate($threadinfo['forumid'], 'canopenclose')) { $canpost = false; } } if (($vbulletin->userinfo['userid'] != $threadinfo['postuserid'] or !$vbulletin->userinfo['userid']) and (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers']) or !($forumperms & $vbulletin->bf_ugp_forumpermissions['canreplyothers']))) { $canpost = false; } if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) or !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads']) or !($forumperms & $vbulletin->bf_ugp_forumpermissions['canreplyown']) and $vbulletin->userinfo['userid'] == $threadinfo['postuserid']) { $canpost = false; } $mod = 0; if (can_moderate($threadinfo['forumid'], 'candeleteposts') or can_moderate($threadinfo['forumid'], 'canremoveposts')) { $mod |= MOD_DELETEPOST; } if (can_moderate($threadinfo['forumid'], 'canmanagethreads')) { if ($threadinfo['sticky']) { $mod |= MOD_UNSTICK; } else { $mod |= MOD_STICK; } } if ($threadinfo['visible'] != 2 and can_moderate($threadinfo['forumid'], 'candeleteposts') or can_moderate($threadinfo['forumid'], 'canremoveposts') or $forumperms & $vbulletin->bf_ugp_forumpermissions['candeletepost'] and $forumperms & $vbulletin->bf_ugp_forumpermissions['candeletethread'] and $vbulletin->userinfo['userid'] == $threadinfo['postuserid'] and ($vbulletin->options['edittimelimit'] == 0 or $threadinfo['dateline'] > TIMENOW - $vbulletin->options['edittimelimit'] * 60)) { $mod |= MOD_DELETETHREAD; } if (can_moderate($threadinfo['forumid'], 'canopenclose') or $forumperms & $vbulletin->bf_ugp_forumpermissions['canopenclose'] and $threadinfo['postuserid'] == $vbulletin->userinfo['userid']) { if ($threadinfo['open']) { $mod |= MOD_CLOSE; } else { $mod |= MOD_OPEN; } } if (can_moderate($threadinfo['forumid'], 'canmanagethreads') or $forumperms & $vbulletin->bf_ugp_forumpermissions['canmove'] and $threadinfo['postuserid'] == $vbulletin->userinfo['userid']) { $mod |= MOD_MOVETHREAD; } if ($show['spamctrls']) { $mod |= MOD_SPAM_CONTROLS; } $out = array('posts' => $posts_out, 'total_posts' => $totalposts, 'page' => $vbulletin->GPC['pagenumber'], 'canpost' => $canpost ? 1 : 0, 'mod' => $mod, 'pollid' => $thread['pollid'], 'subscribed' => $threadinfo['issubscribed'] ? 1 : 0, 'title' => prepare_utf8_string($thread['title']), 'canattach' => $forumperms & $vbulletin->bf_ugp_forumpermissions['canpostattachment'] and $vbulletin->userinfo['userid']); if ($postid) { $out['gotopostid'] = $postid; } return $out; }
/** * Constructor. * * @param vB_Registry */ function vB_Blog_SearchGenerator(&$registry) { $this->registry = $registry; $this->tachy = fetch_coventry('string'); }
function build_thread_counters($threadid) { global $vbulletin; $threadid = intval($threadid); require_once DIR . '/includes/functions_bigthree.php'; $coventry = fetch_coventry('string', true); $firstpost = $vbulletin->db->query_first("\n\t\tSELECT post.postid, post.userid, user.username, post.username AS postuser, post.dateline\n\t\tFROM " . TABLE_PREFIX . "post AS post\n\t\tLEFT JOIN " . TABLE_PREFIX . "user AS user ON (user.userid = post.userid)\n\t\tWHERE post.threadid = {$threadid} AND\n\t\t\tpost.visible = 1\n\t\tORDER BY dateline\n\t\tLIMIT 1\n\t"); if (!$firstpost) { // sanity -- this should never happen; one post should always be visible return; } $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "tachythreadcounter WHERE threadid = {$threadid}"); $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "tachythreadpost WHERE threadid = {$threadid}"); $replies = $vbulletin->db->query_first("\n\t\tSELECT\n\t\t\tCOUNT(DISTINCT(userid)) AS postercount,\n\t\t\tSUM(IF(visible = 1, attach, 0)) AS attachsum,\n\t\t\tSUM(IF(visible = 1, 1, 0)) AS visible,\n\t\t\tSUM(IF(visible = 0, 1, 0)) AS hidden,\n\t\t\tSUM(IF(visible = 2, 1, 0)) AS deleted\n\t\tFROM " . TABLE_PREFIX . "post AS post\n\t\tWHERE threadid = {$threadid}\n\t\t\t" . ($coventry ? "AND post.userid NOT IN ({$coventry})" : '') . "\n\t"); if ($coventry) { // Build Tachy Counters $tachy_db = $vbulletin->db->query_read("\n\t\t\tSELECT post.userid, COUNT(*) AS replycount\n\t\t\tFROM " . TABLE_PREFIX . "post AS post\n\t\t\tWHERE post.userid IN ({$coventry})\n\t\t\t\tAND post.visible = 1\n\t\t\t\tAND post.threadid = {$threadid}\n\t\t\t\tAND post.postid <> {$firstpost['postid']}\n\t\t\tGROUP BY userid\n\t\t"); $tachystats = array(); while ($tachycounter = $vbulletin->db->fetch_array($tachy_db)) { $tachystats["{$tachycounter['userid']}"]['replycount'] = $tachycounter['replycount']; } if ($tachystats) { foreach ($tachystats as $user => $stats) { $vbulletin->db->query_write("\n\t\t\t\t\tINSERT INTO " . TABLE_PREFIX . "tachythreadcounter\n\t\t\t\t\t\t(userid, threadid, replycount)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t(" . intval($user) . ",\n\t\t\t\t\t\t" . intval($threadid) . ",\n\t\t\t\t\t\t" . intval($stats['replycount']) . ")\n\t\t\t\t"); } } } $lastpost = $vbulletin->db->query_first("\n\t\tSELECT\n\t\t\tuser.username,\n\t\t\tpost.userid,\n\t\t\tpost.username AS postuser,\n\t\t\tpost.dateline,\n\t\t\tpost.postid\n\t\tFROM " . TABLE_PREFIX . "post AS post\n\t\tLEFT JOIN " . TABLE_PREFIX . "user AS user ON (user.userid = post.userid)\n\t\tWHERE post.threadid = {$threadid}\n\t\t\tAND post.visible = 1\n\t\t\t" . ($coventry ? "AND post.userid NOT IN ({$coventry})" : '') . "\n\t\tORDER BY dateline DESC\n\t\tLIMIT 1\n\t"); $uniques = $vbulletin->db->query_first("\n\t\tSELECT COUNT(DISTINCT(userid)) AS total\n\t\tFROM " . TABLE_PREFIX . "post\n\t\tWHERE\n\t\t\tthreadid = {$threadid}\n\t\t\t\tAND\n\t\t\tvisible = 1\n\t\t\t" . ($coventry ? "AND userid NOT IN ({$coventry})" : "") . "\n\t"); if (!$uniques['total']) { $uniques['total'] = 1; } if ($lastpost and $coventry) { // if we have a last post (by a non-tachy user) and coventry users, // look for a newer last post by a coventry user $tachy_db = $vbulletin->db->query_read("\n\t\t\tSELECT\n\t\t\t\tuser.username,\n\t\t\t\tpost.userid,\n\t\t\t\tpost.username AS postuser,\n\t\t\t\tpost.dateline,\n\t\t\t\tpost.postid\n\t\t\tFROM " . TABLE_PREFIX . "post AS post\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "user AS user ON (user.userid = post.userid)\n\t\t\tWHERE post.threadid = {$threadid}\n\t\t\t\tAND post.visible = 1\n\t\t\t\tAND post.userid IN ({$coventry})\n\t\t\t\tAND post.dateline > {$lastpost['dateline']}\n\t\t\tORDER BY dateline DESC\n\t\t"); $tachy_posts = array(); while ($tachy = $vbulletin->db->fetch_array($tachy_db)) { if (!isset($tachy_posts["{$tachy['userid']}"])) { $tachy_posts["{$tachy['userid']}"] = $tachy; } } if ($tachy_posts) { $tachy_replace = array(); foreach ($tachy_posts as $tachy) { $tachy_replace[] = "\n\t\t\t\t\t({$tachy['userid']}, {$threadid}, " . intval($tachy['dateline']) . ",\n\t\t\t\t\t'" . $vbulletin->db->escape_string($tachy['postuser']) . "',\n\t\t\t\t\t{$tachy['userid']},\n\t\t\t\t\t'" . $vbulletin->db->escape_string($tachy['postid']) . "')\n\t\t\t\t"; } if ($tachy_replace) { $vbulletin->db->query_write("\n\t\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "tachythreadpost\n\t\t\t\t\t\t(userid, threadid, lastpost, lastposter, lastposterid, lastpostid)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t" . implode(', ', $tachy_replace)); } } } if ($lastpost) { $lastposter = empty($lastpost['username']) ? $lastpost['postuser'] : $lastpost['username']; $lastposterid = $lastpost['userid']; $lastposttime = intval($lastpost['dateline']); $lastpostid = intval($lastpost['postid']); } else { // this will occur on a thread posted by a tachy user. // since only they will see the thread, the lastpost info can say their name $lastposter = empty($firstpost['username']) ? $firstpost['postuser'] : $firstpost['username']; $lastposter = $firstpost['userid']; $lastposttime = intval($firstpost['dateline']); $lastpostid = intval($firstpost['postid']); } $firstposter = empty($firstpost['username']) ? $firstpost['postuser'] : $firstpost['username']; $firstposterid = intval($firstpost['userid']); $firstpostid = intval($firstpost['postid']); $threadcreation = $firstpost['dateline']; $ratings = $vbulletin->db->query_first("\n\t\tSELECT\n\t\t\tCOUNT(*) AS votenum,\n\t\t\tSUM(vote) AS votetotal\n\t\tFROM " . TABLE_PREFIX . "threadrate\n\t\tWHERE threadid = {$threadid}\n\t"); $threadinfo = array('threadid' => $threadid); $threadman =& datamanager_init('Thread', $vbulletin, ERRTYPE_SILENT, 'threadpost'); $threadman->set_existing($threadinfo); $threadman->set_info('rebuild', true); $threadman->set('firstpostid', $firstpostid, true, false); $threadman->set('postuserid', $firstposterid, true, false); $threadman->set('postusername', $firstposter, true, false); $threadman->set('lastpost', $lastposttime, true, false); $threadman->set('replycount', $replies['visible'] - 1, true, false); $threadman->set('hiddencount', $replies['hidden'], true, false); $threadman->set('deletedcount', $replies['deleted'], true, false); $threadman->set('attach', $replies['attachsum'], true, false); $threadman->set('dateline', $threadcreation, true, false); $threadman->set('lastposter', $lastposter, true, false); $threadman->set('lastposterid', $lastposterid, true, false); $threadman->set('lastpostid', $lastpostid, true, false); $threadman->set('votenum', $ratings['votenum'], true, false); $threadman->set('votetotal', intval($ratings['votetotal']), true, false); $threadman->set('postercount', $uniques['total']); $threadman->save(); }
public function can_view($user) { global $vbulletin; if (in_array($this->get_field('forumid'), $user->getHiddenForums())) { return false; } // permission check to see if user can view other's threads in this forum, // and if not to make sure this thread was started by current user if (!$user->hasForumPermission($this->get_field('forumid'), 'canviewothers') and ($this->get_field('postuserid') != $user->get_field('userid') or $user->get_field('userid') == 0)) { return false; } if (!$user->canModerateForum($this->get_field('forumid'))) { //this is cached. Should be fast. require_once DIR . "/includes/functions_bigthree.php"; $conventry = fetch_coventry(); if (in_array($this->get_field('postuserid'), $conventry)) { return false; } // thread is deleted and we don't have permission to see it if ($this->get_field('visible') == 2) { return false; } } // thread is deleted by moderator and we don't have permission to see it if (!$this->get_field('visible') and !$user->canModerateForum($this->get_field('forumid'), 'canmoderateposts')) { return false; } return true; }
public function getData() { if ($this->config['threads_forumids']) { if (in_array(-1, $this->config['threads_forumids'])) { $forumids = array_keys($this->registry->forumcache); } else { $forumids = $this->config['threads_forumids']; } } else { $forumids = array_keys($this->registry->forumcache); } $datecut = TIMENOW - ($this->config['datecut'] * 86400); switch (intval($this->config['threads_type'])) { case 0: $ordersql = " thread.dateline DESC"; $datecutoffsql = " AND thread.dateline > $datecut"; break; case 1: $ordersql = " thread.lastpost DESC"; $datecutoffsql = " AND thread.lastpost > $datecut"; break; case 2: $ordersql = " thread.replycount DESC"; $datecutoffsql = " AND thread.dateline > $datecut"; break; case 3: $ordersql = " thread.views DESC"; $datecutoffsql = " AND thread.dateline > $datecut"; break; } foreach ($forumids AS $forumid) { $forumperms =& $this->registry->userinfo['forumpermissions']["$forumid"]; if ($forumperms & $this->registry->bf_ugp_forumpermissions['canview'] AND ($forumperms & $this->registry->bf_ugp_forumpermissions['canviewothers']) AND (($forumperms & $this->registry->bf_ugp_forumpermissions['canviewthreads'])) AND verify_forum_password($forumid, $this->registry->forumcache["$forumid"]['password'], false) ) { $forumchoice[] = $forumid; } } if (!empty($forumchoice)) { $forumsql = "AND thread.forumid IN(" . implode(',', $forumchoice) . ")"; // remove threads from users on the global ignore list if user is not a moderator $globalignore = ''; if (trim($this->registry->options['globalignore']) != '') { require_once(DIR . '/includes/functions_bigthree.php'); if ($Coventry = fetch_coventry('string')) { $globalignore = "AND thread.postuserid NOT IN ($Coventry) "; } } // query last threads from visible / chosen forums $threads = $this->registry->db->query_read_slave(" SELECT thread.threadid, thread.title, thread.prefixid, post.attach, thread.postusername, thread.dateline, thread.lastpostid, thread.lastpost, thread.lastposterid, thread.lastposter, thread.replycount, forum.forumid, forum.title_clean as forumtitle, post.pagetext AS message, post.allowsmilie, post.postid, user.* " . ($this->registry->options['avatarenabled'] ? ",avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight" : "") . " FROM " . TABLE_PREFIX . "thread AS thread INNER JOIN " . TABLE_PREFIX . "forum AS forum ON(forum.forumid = thread.forumid) LEFT JOIN " . TABLE_PREFIX . "post AS post ON (post.postid = thread.firstpostid) LEFT JOIN " . TABLE_PREFIX . "user AS user ON (thread.postuserid = user.userid) " . ($this->registry->products['vbcms'] ? " LEFT JOIN " . TABLE_PREFIX . "cms_nodeinfo AS info ON info.associatedthreadid = thread.threadid \n" : '') . ($this->registry->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)" : "") . " WHERE 1=1 $forumsql AND thread.visible = 1 AND post.visible = 1 AND open <> 10 $datecutoffsql $globalignore " . ($this->userinfo['ignorelist'] ? "AND thread.postuserid NOT IN (" . implode(',', explode(' ', $this->userinfo['ignorelist'])) . ")": '') . ($this->registry->products['vbcms'] ? " AND info.associatedthreadid IS NULL " : '') . " ORDER BY$ordersql LIMIT 0," . intval($this->config['threads_limit']) . " "); while ($thread = $this->registry->db->fetch_array($threads)) { // $thread['url'] = fetch_seo_url('thread', $thread); // $thread['newposturl'] = fetch_seo_url('thread', $thread, array('goto' => 'newpost')); // $thread['lastposturl'] = fetch_seo_url('thread', $thread, array('p' => $thread['lastpostid'])) . '#post' . $thread['lastpostid']; // trim the title after fetching the urls //$thread['title'] = fetch_trimmed_title($thread['title'], $this->config['threads_titlemaxchars']); $thread['date'] = vbdate($this->registry->options['dateformat'], $thread['dateline'], true); $thread['time'] = vbdate($this->registry->options['timeformat'], $thread['dateline']); $thread['lastpostdate'] = vbdate($this->registry->options['dateformat'], $thread['lastpost'], true); $thread['lastposttime'] = vbdate($this->registry->options['timeformat'], $thread['lastpost']); // get avatar $this->fetch_avatarinfo($thread); $threadarray[$thread['threadid']] = $thread; } } return $threadarray; }
function post_save_each($doquery = true) { $postid = intval($this->fetch_field('postid')); if (!$this->condition and $this->fetch_field('dateline') == TIMENOW) { $this->insert_dupehash($this->fetch_field('threadid')); } $this->post_save_each_post($doquery); if ($this->info['thread'] and ($attach = intval($this->info['newattach']) or !$this->condition)) { $thread =& datamanager_init('Thread', $this->registry, ERRTYPE_SILENT, 'threadpost'); $thread->set_existing($this->info['thread']); if ($attach) { $thread->set('attach', "attach + {$attach}", false); } } if ($this->info['thread'] and $this->info['thread']['firstpostid'] == $this->fetch_field('postid')) { if (!is_object($thread)) { $thread =& datamanager_init('Thread', $this->registry, ERRTYPE_SILENT, 'threadpost'); $thread->set_existing($this->info['thread']); } $thread->set_info('pagetext', $this->fetch_field('pagetext')); $thread->rebuild_keywords(); } if (!$this->condition) { if ($this->fetch_field('dateline') == TIMENOW) { $this->insert_postlog_data(); } if ($this->fetch_field('visible') == 1 and $this->info['thread']) { if (in_coventry($this->fetch_field('userid'), true)) { $thread->set_info('coventry', array('in_coventry' => 1, 'userid' => $this->fetch_field('userid'))); } if ($this->fetch_field('dateline') == TIMENOW) { $thread->set('lastpost', TIMENOW); $thread->set('lastposter', $this->fetch_field('username')); $thread->set('lastposterid', $this->fetch_field('userid')); $thread->set('lastpostid', $postid); } // update last post info for this thread if ($this->info['thread']['replycount'] % 10 == 0) { require_once DIR . '/includes/functions_bigthree.php'; $coventry = fetch_coventry('string'); $replies = $this->registry->db->query_first("\n\t\t\t\t\t\tSELECT COUNT(*) - 1 AS replies\n\t\t\t\t\t\tFROM " . TABLE_PREFIX . "post AS post\n\t\t\t\t\t\tWHERE threadid = " . intval($this->info['thread']['threadid']) . "\n\t\t\t\t\t\tAND\tpost.visible = 1\n\t\t\t\t\t\t" . ($coventry ? "AND userid NOT IN ({$coventry})" : "") . "\n\t\t\t\t\t"); $thread->set('replycount', $replies['replies']); } else { $thread->set('replycount', 'replycount + 1', false); } /* * Yes this will miss one unqiue user if this very post is their * first. I choose to take this over running this query after the save * which means I have to run a second update query on thread. This value * is only used for the activity stream popularity where exactness * is not required. */ if (!in_coventry($this->fetch_field('userid'), true)) { require_once DIR . '/includes/functions_bigthree.php'; $coventry = fetch_coventry('string'); $uniques = $this->registry->db->query_first("\n\t\t\t\t\t\tSELECT COUNT(DISTINCT(userid)) AS total\n\t\t\t\t\t\tFROM " . TABLE_PREFIX . "post\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tthreadid = " . intval($this->info['thread']['threadid']) . "\n\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\tvisible = 1\n\t\t\t\t\t\t\t" . ($coventry ? "AND userid NOT IN ({$coventry})" : "") . "\n\t\t\t\t\t"); if (!$uniques['total']) { $uniques['total'] = 1; } $thread->set('postercount', $uniques['total']); } } else { if ($this->fetch_field('visible') == 0 and $this->info['thread']) { $thread->set('hiddencount', 'hiddencount + 1', false); } } if (!$this->info['skip_activitystream']) { if ($this->info['nodeid']) { $activity = new vB_ActivityStream_Manage('cms', 'comment'); } else { $activity = new vB_ActivityStream_Manage('forum', 'post'); } $activity->set('contentid', $this->fetch_field('postid')); $activity->set('userid', $this->fetch_field('userid')); $activity->set('dateline', $this->fetch_field('dateline')); $activity->set('action', 'create'); $activity->save(); } } else { if ($this->info['dpflag']) { if (!is_object($thread)) { $thread =& datamanager_init('Thread', $this->registry, ERRTYPE_SILENT, 'threadpost'); } $thread->set_existing($this->info['thread']); $thread->set('lastpost', $this->fetch_field('dateline')); } } if (is_object($thread)) { $thread->save(); } if ($this->post['visible'] === 0) { $postid = intval($this->fetch_field('postid')); /*insert query*/ $this->dbobject->query_write("INSERT IGNORE INTO " . TABLE_PREFIX . "moderation (primaryid, type, dateline) VALUES ({$postid}, 'reply', " . TIMENOW . ")"); } if ($this->info['forum']['podcast'] and $this->info['thread']['firstpostid'] == $postid) { $this->dbobject->query_write("\n\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "podcastitem\n\t\t\t\t\t(postid, url, length, explicit, author, keywords, subtitle)\n\t\t\t\tVALUES\n\t\t\t\t\t(\n\t\t\t\t\t\t{$postid},\n\t\t\t\t\t\t'" . $this->dbobject->escape_string($this->info['podcasturl']) . "',\n\t\t\t\t\t\t" . intval($this->info['podcastsize']) . ",\n\t\t\t\t\t\t" . intval($this->info['podcastexplicit']) . ",\n\t\t\t\t\t\t'" . $this->dbobject->escape_string($this->info['podcastauthor']) . "',\n\t\t\t\t\t\t'" . $this->dbobject->escape_string($this->info['podcastkeywords']) . "',\n\t\t\t\t\t\t'" . $this->dbobject->escape_string($this->info['podcastsubtitle']) . "'\n\t\t\t\t\t)\n\t\t\t"); // reset rss cache for this forum $this->dbobject->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "externalcache\n\t\t\t\tWHERE forumid = " . intval($this->info['forum']['forumid']) . "\n\t\t\t"); } if (!$this->condition) { $this->email_moderators('newpostemail'); } ($hook = vBulletinHook::fetch_hook('postdata_postsave')) ? eval($hook) : false; }
/** * This function composes and executes the SQL query to generate the * blog data. * * @return array */ private function getComments() { require_once DIR . "/includes/functions_user.php"; if (!isset($this->config['days']) OR (! intval($this->config['days'])) ) { $this->config['days'] = 7; } if (!isset($this->config['count']) OR (! intval($this->config['count'])) ) { $this->config['count'] = 10; } if (!isset($this->config['messagemaxchars']) OR (! intval($this->config['messagemaxchars'])) ) { $this->config['messagemaxchars'] = 200; } //handle authors $useridsql = empty($this->config['postuserid']) ? '' : " AND(blog.userid IN (" . implode(',', array_keys($this->config['postuserid'])) . "))"; $useridsql .= empty($this->config['commentuserid']) ? '' : " AND(blog_text.userid IN (" . implode(',', array_keys($this->config['commentuserid'])) . "))"; //categories if (empty($this->config['categories'])) { $catjoin = ''; $categorysql = ''; } else { $catjoin = "LEFT JOIN " . TABLE_PREFIX . "blog_categoryuser AS cu ON (cu.blogid = blog.blogid)"; $categorysql = " AND cu.blogcategoryid IN (" . implode(',', array_keys($this->config['categories'])) . ")"; } //and tags if (empty($this->config['taglist'])) { $tagjoin = ''; $tagsql = ''; } else { $tagjoin = "LEFT JOIN " . TABLE_PREFIX . "tagcontent AS tc ON (tc.contentid = blog.blogid AND tc.contenttypeid= " . vb_Types::instance()->getContentTypeID("vBBlog_BlogEntry") . ")"; $tagsql = " AND tc.tagid IN (" . implode(',', array_keys($this->config['taglist'])) . ")"; } $datecutoffsql = "AND (blog.dateline > " . (TIMENOW - (86400 * $this->config['days']) ). ")" ; require_once(DIR . '/includes/blog_functions_shared.php'); prepare_blog_category_permissions(vB::$vbulletin->userinfo); if (!(vB::$vbulletin->userinfo['permissions']['vbblog_general_permissions'] & vB::$vbulletin->bf_ugp_vbblog_general_permissions['blog_canviewothers'])) { $sql_and[] = "blog.userid = " . vB::$vbulletin->userinfo['userid']; } $state = array('visible'); if (can_moderate_blog('canmoderateentries')) { $state[] = 'moderation'; } $sql_and[] = "blog.state IN('" . implode("', '", $state) . "')"; $sql_and[] = "blog.dateline <= " . TIMENOW; $sql_and[] = "blog.pending = 0"; $sql_join = array(); $sql_or = array(); if (!can_moderate_blog()) { if (vB::$vbulletin->userinfo['userid']) { $sql_or[] = "blog.userid = " . vB::$vbulletin->userinfo['userid']; $sql_or[] = "(options_ignore & " . vB::$vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " AND ignored.relationid IS NOT NULL)"; $sql_or[] = "(options_buddy & " . vB::$vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " AND buddy.relationid IS NOT NULL)"; $sql_or[] = "(options_member & " . vB::$vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " AND (options_buddy & " . vB::$vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " OR buddy.relationid IS NULL) AND (options_ignore & " . vB::$vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " OR ignored.relationid IS NULL))"; $sql_and[] = "(" . implode(" OR ", $sql_or) . ")"; $sql_join[] = "LEFT JOIN " . TABLE_PREFIX . "userlist AS buddy ON (buddy.userid = blog.userid AND buddy.relationid = " . vB::$vbulletin->userinfo['userid'] . " AND buddy.type = 'buddy')"; $sql_join[] = "LEFT JOIN " . TABLE_PREFIX . "userlist AS ignored ON (ignored.userid = blog.userid AND ignored.relationid = " . vB::$vbulletin->userinfo['userid'] . " AND ignored.type = 'ignore')"; $sql_and[] = " (blog.userid = " . vB::$vbulletin->userinfo['userid'] . " OR ~blog.options & " . vB::$vbulletin->bf_misc_vbblogoptions['private'] . " OR (options_buddy & " . vB::$vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " AND buddy.relationid IS NOT NULL))"; } else { $sql_and[] = "options_guest & " . vB::$vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog']; $sql_and[] = "~blog.options & " . vB::$vbulletin->bf_misc_vbblogoptions['private']; } } $globalignore = ''; if (trim(vB::$vbulletin->options['globalignore']) != '') { require_once(DIR . '/includes/functions_bigthree.php'); if ($Coventry = fetch_coventry('string')) { $globalignore = "AND blog.userid NOT IN ($Coventry) "; } } $sql = "SELECT blog.blogid, blog.comments_visible as replycount, blog.title, blog.lastcomment, blog.lastcommenter, blog.postedby_userid, blog.postedby_username, blog.dateline, blog_text.blogtextid, blog_text.pagetext AS message, blog.ratingnum, blog.ratingtotal, blog.rating, blog.views, blog.postedby_userid AS userid, blog.postedby_username AS username, blog_user.title as blogtitle, blog_user.description as blogdescription, blog.trackback_visible, user.* " . (vB::$vbulletin->options['avatarenabled'] ? ",avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight" : "") . " FROM " . TABLE_PREFIX . "blog AS blog INNER JOIN " . TABLE_PREFIX . "blog_text AS blog_text ON ((blog_text.blogid = blog.blogid) AND (blog_text.blogtextid <> blog.firstblogtextid)) INNER JOIN " . TABLE_PREFIX . "blog_user AS blog_user ON (blog_user.bloguserid = blog.userid) LEFT JOIN " . TABLE_PREFIX . "user AS user ON (blog_text.userid = user.userid) " . implode("\r\n\t ", $sql_join) . " $catjoin $tagjoin " . (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)" : "") . " WHERE 1=1 $useridsql $categorysql $tagsql $datecutoffsql $globalignore AND " . implode("\r\n\tAND ", $sql_and) . " ORDER BY blog_text.dateline DESC LIMIT 0," . $this->config['count'] ; $results = vB::$db->query_read($sql); $array = array(); $parser = new vBCms_BBCode_HTML(vB::$vbulletin, vBCms_BBCode_HTML::fetchCmsTags()); while ($blogcomment = vB::$db->fetch_array($results)) { $blogcomment['title'] = fetch_trimmed_title($blogcomment['title'], $this->config['blogentries_titlemaxchars']); $urlinfo = array('blogid' => $blogcomment['blogid'], 'blog_title' => $blogcomment['title']); $blogcomment['url'] = fetch_seo_url('entry', $urlinfo, array('bt' => $blogcomment['blogtextid'])) . "#comment" . $blogcomment['blogtextid'] ; $blogcomment['blogtitle'] = $blogcomment['blogtitle'] ? $blogcomment['blogtitle'] : $blogcomment['username']; $blogcomment['date'] = vbdate(vB::$vbulletin->options['dateformat'], $blogcomment['dateline'], true); $blogcomment['time'] = vbdate(vB::$vbulletin->options['timeformat'], $blogcomment['dateline']); $thread['lastpostdate'] = vbdate(vB::$vbulletin->options['dateformat'], $thread['lastcomment'], true); $thread['lastposttime'] = vbdate(vB::$vbulletin->options['timeformat'], $thread['lastcomment']); $blogcomment['message'] = $this->getSummary($blogcomment['message'], $this->config['messagemaxchars']); //get the avatar if (vB::$vbulletin->options['avatarenabled']) { $blogcomment['avatar'] = fetch_avatar_url($blogcomment['userid']); } else { $blogcomment['avatar'] = 0; } $blogcomment['tags'] = array(); $array[$blogcomment['blogtextid']] = $blogcomment; } //let's get the tags; if (!empty($array)) { $sql = "SELECT tag.tagid, tc.contentid, tag.tagtext FROM " . TABLE_PREFIX . "tagcontent AS tc INNER JOIN " . TABLE_PREFIX . "tag AS tag ON tag.tagid = tc.tagid WHERE tc.contentid IN (" . implode(',', array_keys($array)) . ") AND tc.contenttypeid= " . vb_Types::instance()->getContentTypeID("vBBlog_BlogEntry") ; if ($rst = vB::$db->query_read($sql)) { while ($record = vB::$db->fetch_array($rst)) { $array[$record['contentid']]['tags'][$record['tagid']] = $record['tagtext']; } } } return $array; }
/** * 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,'?') ? '&' : '?'; 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, '?' ) ? '&p=' : '?p=') . $view->postid . '#post' . $view->postid; $view->post_url = $post_url; } } $view->comment_count = $this->content->getReplyCount(); $join_char = strpos($view->page_url,'?') ? '&' : '?'; $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,'?') ? '&' : '?'; $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; }
public function getData() { //the user can't see socialgroups, abort now. if ( !($this->registry->options['socnet'] & $this->registry->bf_misc_socnet['enable_groups']) OR !($this->registry->userinfo['permissions']['socialgrouppermissions'] & $this->registry->bf_ugp_socialgrouppermissions['canviewgroups']) ) { return ""; } if ($this->config['sgdiscussions_groupids']) { $groupids = explode(',', $this->config['sgdiscussions_groupids']); $groupidsql = ''; if (intval($groupids[0])) { $groupidsql = " AND socialgroup.groupid IN (-1"; foreach ((array)$groupids as $groupid) { $groupidsql .= "," . intval($groupid); } $groupidsql .= ")"; } } if ($this->config['sgdiscussions_catids']) { $catidsql = ''; if (!in_array(-1, $this->config['sgdiscussions_catids'])) { $catidsql = " AND socialgroup.socialgroupcategoryid IN (-1"; foreach ($this->config['sgdiscussions_catids'] AS $catid) { $catidsql .= ",$catid"; } $catidsql .= ")"; } } $datecut = TIMENOW - ($this->config['datecut'] * 86400); switch (intval($this->config['sgdiscussions_type'])) { case 0: $ordersql = " groupmessage.dateline DESC"; $datecutoffsql = " AND groupmessage.dateline > $datecut"; break; case 1: $ordersql = " discussion.lastpost DESC"; $datecutoffsql = " AND discussion.lastpost > $datecut"; break; case 2: $ordersql = " discussion.visible DESC"; $datecutoffsql = " AND groupmessage.dateline > $datecut"; break; } // remove threads from users on the global ignore list if user is not a moderator $globalignore = ''; if (trim($this->registry->options['globalignore']) != '') { require_once(DIR . '/includes/functions_bigthree.php'); if ($Coventry = fetch_coventry('string')) { $globalignore = "AND groupmessage.postuserid NOT IN ($Coventry) "; } } require_once(DIR . '/includes/functions_socialgroup.php'); $canviewprivate = ( //don't allow groups to be hidden from non members !$this->registry->options['sg_allow_join_to_view'] OR //can see hidden groups can_moderate(0, 'canmoderategroupmessages') OR can_moderate(0, 'canremovegroupmessages') OR can_moderate(0, 'candeletegroupmessages') OR fetch_socialgroup_perm('canalwayspostmessage') OR fetch_socialgroup_perm('canalwascreatediscussion') ); $membertypejoin = ""; $memberfilter = ""; if (!$canviewprivate) { $memberfilter = "AND ( !(socialgroup.options & " . $this->registry->bf_misc_socialgroupoptions["join_to_view"] . ")"; if ($this->registry->userinfo['userid']) { $membertypejoin = "LEFT JOIN " . TABLE_PREFIX . "socialgroupmember AS socialgroupmember ON (socialgroupmember.userid = " . $this->registry->userinfo['userid'] . " AND socialgroupmember.groupid = socialgroup.groupid)"; $memberfilter .= " OR socialgroupmember.type = 'member' "; } $memberfilter.= ")"; } $gms = $this->registry->db->query_read_slave(" SELECT discussion.discussionid, discussion.groupid, discussion.lastpostid, discussion.lastpost, discussion.lastposter, discussion.lastposterid, discussion.visible, groupmessage.gmid, groupmessage.postuserid, groupmessage.postusername, groupmessage.dateline, groupmessage.title, groupmessage.pagetext as message, socialgroup.name as groupname, socialgroup.description as groupdescription, user.* " . ($this->registry->options['avatarenabled'] ? ",avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight" : "") . " FROM " . TABLE_PREFIX . "discussion AS discussion INNER JOIN " . TABLE_PREFIX . "socialgroup AS socialgroup ON(discussion.groupid = socialgroup.groupid) INNER JOIN " . TABLE_PREFIX . "groupmessage AS groupmessage ON (discussion.firstpostid = groupmessage.gmid) LEFT JOIN " . TABLE_PREFIX . "user AS user ON (groupmessage.postuserid = user.userid) " . ($this->registry->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)" : "") . " $membertypejoin WHERE 1=1 $groupidsql $catidsql $memberfilter AND discussion.visible > 0 AND groupmessage.state = 'visible' $datecutoffsql $globalignore ORDER BY$ordersql LIMIT 0," . intval($this->config['sgdiscussions_limit']) . " "); while ($gm = $this->registry->db->fetch_array($gms)) { $gm['title'] = fetch_trimmed_title($gm['title'], $this->config['sgdiscussions_titlemaxchars']); $gm['groupname'] = htmlspecialchars_uni($gm['groupname']); $gm['groupdescription'] = htmlspecialchars_uni($gm['groupdescription']); //$gm['url'] = 'group.php?' . $this->registry->session->vars['sessionurl'] . 'do=discuss&discussionid=' . $gm['discussionid']; //$gm['groupurl'] = 'group.php?' . $this->registry->session->vars['sessionurl'] . 'groupid=' . $gm['groupid']; $gm['date'] = vbdate($this->registry->options['dateformat'], $gm['dateline'], true); $gm['time'] = vbdate($this->registry->options['timeformat'], $gm['dateline']); $gm['lastpostdate'] = vbdate($this->registry->options['dateformat'], $gm['lastpost'], true); $gm['lastposttime'] = vbdate($this->registry->options['timeformat'], $gm['lastpost']); $gm['message'] = $this->get_summary($gm['message'], $this->config['sgdiscussions_messagemaxchars']); // we need to count replies so $gm['replycount'] = $gm['visible'] - 1; // get avatar $this->fetch_avatarinfo($gm); $gmarray[$gm['discussionid']] = $gm; return($gmarray); } }
public function getData() { $vbulletin =& $this->registry; if ($this->config['blogentries_userids']) { $userids = explode(',', $this->config['blogentries_userids']); $useridsql = ''; if (intval($userids[0])) { $useridsql = " AND blog.userid IN (-1"; foreach ((array) $userids as $userid) { $useridsql .= "," . intval($userid); } $useridsql .= ")"; } } require_once DIR . '/includes/blog_functions_shared.php'; prepare_blog_category_permissions($this->registry->userinfo); $catjoin = "LEFT JOIN " . TABLE_PREFIX . "blog_categoryuser AS cu ON (cu.blogid = blog.blogid)"; if ($this->config['blogentries_catids']) { $catidsql = ''; if (!in_array(-2, $this->config['blogentries_catids'])) { if (in_array(-1, $this->config['blogentries_catids'])) { $catidsql .= " AND (cu.blogcategoryid IS NULL OR cu.blogcategoryid IN (-1"; } else { $catidsql .= " AND (cu.blogcategoryid IN (-1"; } foreach ($this->config['blogentries_catids'] as $catid) { $catidsql .= ",{$catid}"; } $catidsql .= "))"; if (!empty($this->registry->userinfo['blogcategorypermissions']['cantview'])) { $catidsql .= " AND cu.blogcategoryid NOT IN (" . implode(", ", $this->registry->userinfo['blogcategorypermissions']['cantview']) . ")"; } } } if (!($vbulletin->userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_canviewothers'])) { $sql_and[] = "blog.userid = " . $vbulletin->userinfo['userid']; } if (!($vbulletin->userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_canviewown']) and $vbulletin->userinfo['userid']) { $sql_and[] = "blog.userid <> " . $vbulletin->userinfo['userid']; } $state = array('visible'); if (can_moderate_blog('canmoderateentries')) { $state[] = 'moderation'; } $sql_and[] = "blog.state IN('" . implode("', '", $state) . "')"; $sql_and[] = "blog.dateline <= " . TIMENOW; $sql_and[] = "blog.pending = 0"; $sql_join = array(); $sql_or = array(); if (!can_moderate_blog()) { if ($vbulletin->userinfo['userid']) { $sql_or[] = "blog.userid = " . $vbulletin->userinfo['userid']; $sql_or[] = "(options_ignore & " . $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " AND ignored.relationid IS NOT NULL)"; $sql_or[] = "(options_buddy & " . $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " AND buddy.relationid IS NOT NULL)"; $sql_or[] = "(options_member & " . $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " AND (options_buddy & " . $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " OR buddy.relationid IS NULL) AND (options_ignore & " . $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " OR ignored.relationid IS NULL))"; $sql_and[] = "(" . implode(" OR ", $sql_or) . ")"; $sql_join[] = "LEFT JOIN " . TABLE_PREFIX . "userlist AS buddy ON (buddy.userid = blog.userid AND buddy.relationid = " . $vbulletin->userinfo['userid'] . " AND buddy.type = 'buddy')"; $sql_join[] = "LEFT JOIN " . TABLE_PREFIX . "userlist AS ignored ON (ignored.userid = blog.userid AND ignored.relationid = " . $vbulletin->userinfo['userid'] . " AND ignored.type = 'ignore')"; $sql_and[] = "\n\t\t\t\t\t(blog.userid = " . $vbulletin->userinfo['userid'] . "\n\t\t\t\t\t\tOR\n\t\t\t\t\t~blog.options & " . $vbulletin->bf_misc_vbblogoptions['private'] . "\n\t\t\t\t\t\tOR\n\t\t\t\t\t(options_buddy & " . $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " AND buddy.relationid IS NOT NULL))"; } else { $sql_and[] = "options_guest & " . $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog']; $sql_and[] = "~blog.options & " . $vbulletin->bf_misc_vbblogoptions['private']; } } $datecut = TIMENOW - $this->config['datecut'] * 86400; switch (intval($this->config['blogentries_type'])) { case 0: $ordersql = " blog.dateline DESC"; $datecutoffsql = " AND blog.dateline > {$datecut}"; break; case 1: $ordersql = " blog.lastcomment DESC"; $datecutoffsql = " AND blog.lastcomment > {$datecut}"; break; case 2: $ordersql = " blog.comments_visible DESC"; $datecutoffsql = " AND blog.dateline > {$datecut}"; break; case 3: $ordersql = " blog.views DESC"; $datecutoffsql = " AND blog.dateline > {$datecut}"; break; } // remove threads from users on the global ignore list if user is not a moderator $globalignore = ''; if (trim($this->registry->options['globalignore']) != '') { require_once DIR . '/includes/functions_bigthree.php'; if ($Coventry = fetch_coventry('string')) { $globalignore = "AND blog.userid NOT IN ({$Coventry}) "; } } $results = $this->registry->db->query_read_slave("\n\t\t\tSELECT blog.blogid, blog.comments_visible as replycount, blog.title, blog.lastcomment, blog.lastcommenter, blog.postedby_userid, blog.postedby_username, blog.dateline,\n\t\t\t\tblog_text.blogtextid, blog_text.pagetext AS message,\n\t\t\t\tblog_user.title as blogtitle, blog_user.description as blogdescription,\n\t\t\t\tuser.*\n\t\t\t\t" . ($this->registry->options['avatarenabled'] ? ",avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight" : "") . "\n\t\t\tFROM " . TABLE_PREFIX . "blog AS blog\n\t\t\tINNER JOIN " . TABLE_PREFIX . "blog_text AS blog_text ON (blog_text.blogtextid = blog.firstblogtextid)\n\t\t\tINNER JOIN " . TABLE_PREFIX . "blog_user AS blog_user ON (blog_user.bloguserid = blog.userid)\n\t\t\tINNER JOIN " . TABLE_PREFIX . "user AS user ON (blog.userid = user.userid)\n\t\t\t{$catjoin}\n\t\t\t" . (!empty($sql_join) ? implode("\r\n", $sql_join) : "") . "\n\t\t\t" . ($this->registry->options['avatarenabled'] ? "LEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON(avatar.avatarid = user.avatarid) LEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON(customavatar.userid = user.userid)" : "") . "\n\t\t\tWHERE 1=1\n\t\t\t\t{$useridsql}\n\t\t\t\t{$catidsql}\n\t\t\t\t{$datecutoffsql}\n\t\t\t\t{$globalignore}\n\t\t\t\tAND " . implode("\r\n\tAND ", $sql_and) . "\n\t\t\tORDER BY{$ordersql}\n\t\t\tLIMIT 0," . intval($this->config['blogentries_limit']) . "\n\t\t"); while ($row = $this->registry->db->fetch_array($results)) { //$row['url'] = fetch_seo_url('entry', $row); // trim the title after fetching the url //$row['title'] = fetch_trimmed_title($row['title'], $this->config['blogentries_titlemaxchars']); //still need to censor the title $row['title'] = fetch_censored_text($row['title']); $row['blogtitle'] = $row['blogtitle'] ? $row['blogtitle'] : $row['username']; $row['date'] = vbdate($this->registry->options['dateformat'], $row['dateline'], true); $row['time'] = vbdate($this->registry->options['timeformat'], $row['dateline']); $row['lastpostdate'] = vbdate($this->registry->options['dateformat'], $row['lastcomment'], true); $row['lastposttime'] = vbdate($this->registry->options['timeformat'], $row['lastcomment']); $row['message'] = $this->get_summary($row['message'], $this->config['blogentries_messagemaxchars']); // get avatar $this->fetch_avatarinfo($row); $array[$row['blogid']] = $row; } return $array; }
} // filter out deletion notices if can't be seen if ($forumperms & $vbulletin->bf_ugp_forumpermissions['canseedelnotice'] OR can_moderate($foruminfo['forumid'])) { $canseedelnotice = true; $deljoin = "LEFT JOIN " . TABLE_PREFIX . "deletionlog AS deletionlog ON(thread.threadid = deletionlog.primaryid AND deletionlog.type = 'thread')"; } else { $canseedelnotice = false; $deljoin = ''; } // remove threads from users on the global ignore list if user is not a moderator if ($Coventry = fetch_coventry('string') AND !can_moderate($foruminfo['forumid'])) { $globalignore = "AND postuserid NOT IN ($Coventry) "; } else { $globalignore = ''; } // look at thread limiting options $stickyids = ''; $stickycount = 0; if ($daysprune != -1) { if ($vbulletin->userinfo['userid'] AND in_coventry($vbulletin->userinfo['userid'], true)) {
/** * Prepare any data needed for the output * * @param string The id of the block * @param array Options specific to the block */ function prepare_output($id = '', $options = array()) { global $show, $vbphrase; if (!$this->registry->userinfo['userid']) { prepare_blog_category_permissions($this->registry->userinfo); } $show['lastentry'] = true; $this->block_data['entries'] = vb_number_format($this->profile->userinfo['entries']); $this->block_data['lastblogtitle'] = ''; $this->block_data['lastblogdate'] = $vbphrase['never']; $this->block_data['lastblogtime'] = ''; $memberblogs = explode(',', $this->profile->userinfo['memberblogids']); if (count($memberblogs) > 1) { $sqland = array( "bu.bloguserid IN (" . $this->profile->userinfo['memberblogids'] . ")" ); if (!($this->registry->userinfo['permissions']['vbblog_general_permissions'] & $this->registry->bf_ugp_vbblog_general_permissions['blog_canviewothers'])) { $sqland[] = "bu.bloguserid = " . $this->registry->userinfo['userid']; } if (!($this->registry->userinfo['permissions']['vbblog_general_permissions'] & $this->registry->bf_ugp_vbblog_general_permissions['blog_canviewown']) AND $this->registry->userinfo['userid']) { $sqland[] = "bu.bloguserid <> " . $this->registry->userinfo['userid']; } if (trim($this->registry->options['globalignore']) != '') { require_once(DIR . '/includes/functions_bigthree.php'); if ($coventry = fetch_coventry('string') AND !can_moderate_blog()) { $sqland[] = "bu.bloguserid NOT IN ($coventry)"; } } $sqlor = array(); $sqljoin = array(); if (!can_moderate_blog()) { if ($this->registry->userinfo['userid']) { $sqlor[] = "bu.bloguserid IN (" . $this->registry->userinfo['memberblogids'] . ")"; $sqlor[] = "(options_ignore & " . $this->registry->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " AND ignored.relationid IS NOT NULL)"; $sqlor[] = "(options_buddy & " . $this->registry->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " AND buddy.relationid IS NOT NULL)"; $sqlor[] = "(options_member & " . $this->registry->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " AND (options_buddy & " .$this->registry->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " OR buddy.relationid IS NULL) AND (options_ignore & " . $this->registry->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " OR ignored.relationid IS NULL))"; $sqland[] = "(" . implode(" OR ", $sqlor) . ")"; $sqljoin[] = "LEFT JOIN " . TABLE_PREFIX . "userlist AS buddy ON (buddy.userid = bu.bloguserid AND buddy.relationid = " . $this->registry->userinfo['userid'] . " AND buddy.type = 'buddy')"; $sqljoin[] = "LEFT JOIN " . TABLE_PREFIX . "userlist AS ignored ON (ignored.userid = bu.bloguserid AND ignored.relationid = " . $this->registry->userinfo['userid'] . " AND ignored.type = 'ignore')"; } else { $sqland[] = "options_guest & " . $this->registry->bf_misc_vbblogsocnetoptions['canviewmyblog']; $sqland[] = "~blog.options & " . $this->registry->bf_misc_vbblogoptions['private']; } } if ($this->registry->userinfo['userid'] AND in_coventry($this->registry->userinfo['userid'], true)) { $sqlfields[] = "IF(blog_tachyentry.userid IS NULL, blog.lastcomment, blog_tachyentry.lastcomment) AS lastcomment"; $sqlfields[] = "IF(blog_tachyentry.userid IS NULL, blog.lastcommenter, blog_tachyentry.lastcommenter) AS lastcommenter"; $sqlfields[] = "IF(blog_tachyentry.userid IS NULL, blog.lastblogtextid, blog_tachyentry.lastblogtextid) AS lastblogtextid"; $sqljoin[] = "LEFT JOIN " . TABLE_PREFIX . "blog_tachyentry AS blog_tachyentry ON (blog_tachyentry.blogid = bu.lastblogid AND blog_tachyentry.userid = " . $this->registry->userinfo['userid'] . ")"; $sqljoin[] = "LEFT JOIN " . TABLE_PREFIX . "blog_text AS blog_text ON (blog_text.blogtextid = IF(blog_tachyentry.userid IS NULL, blog.lastblogtextid, blog_tachyentry.lastblogtextid))"; } else { $sqljoin[] = "LEFT JOIN " . TABLE_PREFIX . "blog_text AS blog_text ON (blog_text.blogtextid = bu.lastblogtextid)"; } $temp = $show['inlinemod']; $show['inlinemod'] = false; $blogs = $this->registry->db->query_read_slave(" SELECT user.*, IF(bu.title, bu.title, user.username) AS blogtitle, user.userid, user.username, bu.lastblog, bu.lastblogid AS lastblogid, bu.lastblogtitle, bu.lastcomment, bu.lastblogtextid AS lastblogtextid, bu.lastcommenter, bu.options_member, bu.options_buddy, bu.ratingnum, bu.ratingtotal, bu.title, bu.entries, bu.comments, bu.title, blog.categories, blog2.categories AS categories_lastcomment FROM " . TABLE_PREFIX . "blog_user AS bu LEFT JOIN " . TABLE_PREFIX . "user AS user ON (user.userid = bu.bloguserid) LEFT JOIN " . TABLE_PREFIX . "blog AS blog ON (blog.blogid = bu.lastblogid) " . (!empty($sqljoin) ? implode("\r\n", $sqljoin) : "") . " LEFT JOIN " . TABLE_PREFIX . "blog AS blog2 ON (blog2.blogid = blog_text.blogid) WHERE " . implode("\r\n\tAND ", $sqland) . " "); while ($blog = $this->registry->db->fetch_array($blogs)) { $blog = array_merge($blog, convert_bits_to_array($blog['options'], $this->registry->bf_misc_useroptions)); $blog = array_merge($blog, convert_bits_to_array($blog['adminoptions'], $this->registry->bf_misc_adminoptions)); $show['private'] = false; if (can_moderate() AND $blog['userid'] != $this->registry->userinfo['userid']) { $membercanview = $blog['options_member'] & $this->registry->bf_misc_vbblogsocnetoptions['canviewmyblog']; $buddiescanview = $blog['options_buddy'] & $this->registry->bf_misc_vbblogsocnetoptions['canviewmyblog']; if (!$membercanview AND (!$blog['buddyid'] OR !$buddiescanview)) { $show['private'] = true; } } $blog['entries'] = vb_number_format($blog['entries']); $blog['comments'] = vb_number_format($blog['comments']); $blog['lastentrydate'] = vbdate($this->registry->options['dateformat'], $blog['lastblog'], true); $blog['lastentrytime'] = vbdate($this->registry->options['timeformat'], $blog['lastblog']); $blog['entrytitle'] = fetch_trimmed_title($blog['lastblogtitle'], 20); if ($blog['title']) { $blog['title'] = fetch_trimmed_title($blog['title'], 50); } $lastentrycats = explode(',', $blog['categories']); $lastcommentcats = explode(',', $blog['categories_lastcomment']); $show['lastentry'] = array_intersect($this->registry->userinfo['blogcategorypermissions']['cantview'], $lastentrycats) ? false : true; $show['lastcomment'] = array_intersect($this->registry->userinfo['blogcategorypermissions']['cantview'], $lastcommentcats) ? false : true; $templater = vB_Template::create('blog_blog_row'); $templater->register('blog', $blog); $templater->register('thread', $thread); $groupbits .= $templater->render(); } $this->block_data['groupblogs'] = $groupbits; $show['inlinemod'] = $temp; } if (!in_coventry($this->profile->userinfo['userid']) AND ($this->profile->userinfo['lastblog'])) { $sql_and = array(); $state = array('visible'); $sql_and[] = "blog.state IN('" . implode("', '", $state) . "')"; $sql_and[] = "blog.dateline <= " . TIMENOW; $sql_and[] = "blog.pending = 0"; $sql_and[] = "blog.userid = " . $this->profile->userinfo['userid']; if (!can_moderate_blog() AND $this->profile->userinfo['userid'] != $this->registry->userinfo['userid'] AND !$bloginfo['buddyid']) { $sql_and[] = "~blog.options & " . $this->registry->bf_misc_vbblogoptions['private']; } if (!empty($this->registry->userinfo['blogcategorypermissions']['cantview']) AND $this->profile->userinfo['userid'] != $this->registry->userinfo['userid']) { $joinsql = "LEFT JOIN " . TABLE_PREFIX . "blog_categoryuser AS cu ON (cu.blogid = blog.blogid AND cu.blogcategoryid IN (" . implode(", ", $this->registry->userinfo['blogcategorypermissions']['cantview']) . "))"; $sql_and[] = "cu.blogcategoryid IS NULL"; } $blogids = array(); $blogs = $this->registry->db->query_read_slave(" SELECT blog.blogid, blog.attach FROM " . TABLE_PREFIX . "blog AS blog $joinsql WHERE " . implode("\r\n\tAND ", $sql_and) . " ORDER BY blog.dateline DESC LIMIT 5 "); while ($blog = $this->registry->db->fetch_array($blogs)) { $blogids[] = $blog['blogid']; $attachcount += $blog['attach']; } if ($blogids) { // Query Attachments if ($attachcount) { require_once(DIR . '/packages/vbattach/attach.php'); $attach = new vB_Attach_Display_Content($this->registry, 'vBBlog_BlogEntry'); $postattach = $attach->fetch_postattach(0, $blogids); } $this->block_data['lastblogtitle'] = $this->profile->userinfo['lastblogtitle']; $this->block_data['lastblogdate'] = vbdate($this->registry->options['dateformat'], $this->profile->userinfo['lastblog']); $this->block_data['lastblogtime'] = vbdate($this->registry->options['timeformat'], $this->profile->userinfo['lastblog'], true); $categories = array(); $cats = $this->registry->db->query_read_slave(" SELECT blogid, title, blog_category.blogcategoryid, blog_categoryuser.userid, blog_category.userid AS creatorid FROM " . TABLE_PREFIX . "blog_categoryuser AS blog_categoryuser LEFT JOIN " . TABLE_PREFIX . "blog_category AS blog_category ON (blog_category.blogcategoryid = blog_categoryuser.blogcategoryid) WHERE blogid IN (" . implode(',', $blogids) . ") ORDER BY blogid, displayorder "); while ($cat = $this->registry->db->fetch_array($cats)) { $categories["$cat[blogid]"][] = $cat; } require_once(DIR . '/includes/class_bbcode_blog.php'); require_once(DIR . '/includes/class_blog_entry.php'); $bbcode = new vB_BbCodeParser_Blog_Snippet($this->registry, fetch_tag_list()); $factory = new vB_Blog_EntryFactory($this->registry, $bbcode, $categories); $first = true; // Last Five Entries $entries = $this->registry->db->query_read_slave(" SELECT blog.*, blog.options AS blogoptions, blog_text.pagetext, blog_text.allowsmilie, blog_text.ipaddress, blog_text.reportthreadid, blog_text.ipaddress AS blogipaddress, user.*, userfield.*, usertextfield.* " . (($this->registry->options['threadvoted'] AND $this->registry->userinfo['userid']) ? ', blog_rate.vote' : '') . " " . (!($this->registry->userinfo['permissions']['genericpermissions'] & $this->registry->bf_ugp_genericpermissions['canseehiddencustomfields']) ? $this->registry->profilefield['hidden'] : "") . " " . (($this->registry->options['threadmarking'] AND $this->registry->userinfo['userid']) ? ", blog_read.readtime AS blogread, blog_userread.readtime AS bloguserread" : "") . " FROM " . TABLE_PREFIX . "blog AS blog INNER JOIN " . TABLE_PREFIX . "blog_text AS blog_text ON (blog_text.blogtextid = blog.firstblogtextid) LEFT JOIN " . TABLE_PREFIX . "user AS user ON (blog.userid = user.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) " . (($this->registry->options['threadmarking'] AND $this->registry->userinfo['userid']) ? " LEFT JOIN " . TABLE_PREFIX . "blog_read AS blog_read ON (blog_read.blogid = blog.blogid AND blog_read.userid = " . $this->registry->userinfo['userid'] . ") LEFT JOIN " . TABLE_PREFIX . "blog_userread AS blog_userread ON (blog_userread.bloguserid = blog.userid AND blog_userread.userid = " . $this->registry->userinfo['userid'] . ") " : "") . " " . (($this->registry->options['threadvoted'] AND $this->registry->userinfo['userid']) ? "LEFT JOIN " . TABLE_PREFIX . "blog_rate AS blog_rate ON (blog_rate.blogid = blog.blogid AND blog_rate.userid = " . $this->registry->userinfo['userid'] . ")" : '') . " WHERE blog.blogid IN (" . implode(',', $blogids) . ") ORDER BY blog.dateline DESC LIMIT 5 "); while ($blog = $this->registry->db->fetch_array($entries)) { if ($first) { $show['latestentry'] = true; $first = false; } else { $show['latestentry'] = false; } $entry_handler =& $factory->create($blog, '_Profile'); $entry_handler->cachable = false; $entry_handler->excerpt = true; $entry_handler->attachments = $postattach["$blog[blogid]"]; $this->block_data['latestentries'] .= $entry_handler->construct(); } // Comments $state = array('visible'); $commentstate = array('visible'); $sql_and = array(); $sql_and[] = "blog.state IN('" . implode("', '", $state) . "')"; $sql_and[] = "blog.dateline <= " . TIMENOW; $sql_and[] = "blog.pending = 0"; $sql_and[] = "blog_text.state IN('" . implode("', '", $commentstate) . "')"; $sql_and[] = "blog.firstblogtextid <> blog_text.blogtextid"; $sql_and[] = "blog_text.bloguserid = " . $this->profile->userinfo['userid']; if (!can_moderate_blog() AND !is_member_of_blog($this->registry->userinfo, $this->profile->userinfo) AND !$bloginfo['buddyid']) { $sql_and[] = "~blog.options & " . $this->registry->bf_misc_vbblogoptions['private']; } if (!empty($this->registry->userinfo['blogcategorypermissions']['cantview']) AND $this->profile->userinfo['userid'] != $this->registry->userinfo['userid']) { $joinsql = "LEFT JOIN " . TABLE_PREFIX . "blog_categoryuser AS cu ON (cu.blogid = blog.blogid AND cu.blogcategoryid IN (" . implode(", ", $this->registry->userinfo['blogcategorypermissions']['cantview']) . "))"; $sql_and[] = "cu.blogcategoryid IS NULL"; } $this->registry->options['vbblog_snippet'] = 20; require_once(DIR . '/includes/class_blog_response.php'); $bbcode = new vB_BbCodeParser_Blog_Snippet_Featured($this->registry, fetch_tag_list()); $factory = new vB_Blog_ResponseFactory($this->registry, $bbcode, $bloginfo); $comments = $this->registry->db->query_read_slave(" SELECT blog_text.username AS postusername, blog_text.ipaddress AS blogipaddress, blog_text.state, blog_text.blogtextid, blog_text.title, blog_text.dateline, blog_text.pagetext, blog_text.allowsmilie, blog.userid AS blog_userid, blog.blogid, blog.title AS entrytitle, blog.state AS blog_state, blog.firstblogtextid, blog.options AS blogoptions, blog_user.memberids, blog_user.memberblogids, blog.postedby_userid, blog.postedby_username, user2.usergroupid AS blog_usergroupid, user2.infractiongroupids AS blog_inractiongroupids, user2.membergroupids AS blog_membergroupids, user.*, blog_user.title AS blogtitle, IF(user.displaygroupid = 0, user.usergroupid, user.displaygroupid) AS displaygroupid, user.infractiongroupid, options_ignore, options_buddy, options_member, options_guest, blog.userid AS blog_userid, blog.state AS blog_state, blog.firstblogtextid " . ($this->registry->options['avatarenabled'] ? ",avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight" : "") . " " . (($this->registry->options['threadmarking'] AND $this->registry->userinfo['userid']) ? ", blog_read.readtime AS blogread, blog_userread.readtime AS bloguserread" : "") . " " . ($vbulletin->userinfo['userid'] ? ", gm.permissions AS grouppermissions" : "") . " FROM " . TABLE_PREFIX . "blog_text AS blog_text LEFT JOIN " . TABLE_PREFIX . "blog AS blog ON (blog.blogid = blog_text.blogid) LEFT JOIN " . TABLE_PREFIX . "user AS user ON (user.userid = blog_text.userid) LEFT JOIN " . TABLE_PREFIX . "user AS user2 ON (user2.userid = blog.userid) LEFT JOIN " . TABLE_PREFIX . "blog_user AS blog_user ON (blog_user.bloguserid = blog.userid) " . (($this->registry->options['threadmarking'] AND $this->registry->userinfo['userid']) ? " LEFT JOIN " . TABLE_PREFIX . "blog_read AS blog_read ON (blog_read.blogid = blog.blogid AND blog_read.userid = " . $this->registry->userinfo['userid'] . ") LEFT JOIN " . TABLE_PREFIX . "blog_userread AS blog_userread ON (blog_userread.bloguserid = blog.userid AND blog_userread.userid = " . $this->registry->userinfo['userid'] . ") " : "") . " " . ($vbulletin->userinfo['userid'] ? "LEFT JOIN " . TABLE_PREFIX . "blog_groupmembership AS gm ON (blog.userid = gm.bloguserid AND gm.userid = " . $vbulletin->userinfo['userid'] . ")" : '') . " " . ($this->registry->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)" : "") . " $joinsql WHERE " . implode("\r\n\tAND ", $sql_and) . " ORDER BY blog_text.dateline DESC LIMIT 5 "); while ($comment = $this->registry->db->fetch_array($comments)) { $bloginfo = array( 'blogid' => $comment['blogid'], 'userid' => $comment['blog_userid'], 'state' => $comment['blog_state'], 'firstblogtextid' => $comment['firstblogtextid'], 'blogread' => $comment['blogread'], 'bloguserread' => $comment['bloguserread'], 'usergroupid' => $comment['blog_usergroupid'], 'infractiongroupids' => $comment['blog_infractiongroupids'], 'membergroupids' => $comment['blog_membergroupids'], 'memberids' => $comment['memberids'], 'memberblogids' => $comment['memberblogids'], 'postedby_userid' => $comment['postedby_userid'], 'postedby_username' => $comment['postedby_username'], 'grouppermissions' => $comment['grouppermissions'], ); cache_permissions($bloginfo, false); $response_handler->bloginfo =& $bloginfo; $response_handler =& $factory->create($comment, 'Comment_Profile'); $response_handler->cachable = false; $response_handler->linkblog = true; $this->block_data['commentsreceived'] .= $response_handler->construct(); } } } }
($hook = vBulletinHook::fetch_hook('album_moderated_complete')) ? eval($hook) : false; // navbar and final output $navbits = construct_navbits(array('member.php?' . $vbulletin->session->vars['sessionurl'] . "u={$userinfo['userid']}" => construct_phrase($vbphrase['xs_profile'], $userinfo['username']), 'album.php?' . $vbulletin->session->vars['sessionurl'] . "u={$userinfo['userid']}" => construct_phrase($vbphrase['xs_albums'], $userinfo['username']), '' => $vbphrase['picture_comments_awaiting_approval'])); eval('$navbar = "' . fetch_template('navbar') . '";'); eval('print_output("' . fetch_template('album_moderatedcomments') . '");'); } // ####################################################################### if ($_REQUEST['do'] == 'unread') { if (!$vbulletin->options['pc_enabled']) { print_no_permission(); } if ($userinfo['userid'] != $vbulletin->userinfo['userid']) { print_no_permission(); } require_once DIR . '/includes/functions_bigthree.php'; $coventry = fetch_coventry('string'); $pictures = $db->query_read_slave("\n\t\tSELECT picture.pictureid, picture.caption, picture.extension, picture.filesize, picture.idhash,\n\t\t\tpicture.thumbnail_filesize, picture.thumbnail_dateline, picture.thumbnail_width, picture.thumbnail_height,\n\t\t\talbumpicture.albumid, MIN(picturecomment.commentid) AS unreadcommentid, COUNT(*) AS unreadcomments\n\t\tFROM " . TABLE_PREFIX . "picture AS picture\n\t\tINNER JOIN " . TABLE_PREFIX . "albumpicture AS albumpicture ON (albumpicture.pictureid = picture.pictureid)\n\t\tINNER JOIN " . TABLE_PREFIX . "picturecomment AS picturecomment ON\n\t\t\t(picturecomment.pictureid = picture.pictureid AND picturecomment.state = 'visible' AND picturecomment.messageread = 0)\n\t\tWHERE picture.userid = " . $vbulletin->userinfo['userid'] . "\n\t\t\t" . ($coventry ? "AND picturecomment.postuserid NOT IN ({$coventry})" : '') . "\n\t\tGROUP BY picture.pictureid\n\t\tORDER BY unreadcommentid ASC\n\t"); // work out the effective picturebit height/width including any borders and paddings; the +4 works around an IE float issue $picturebit_height = $vbulletin->options['album_thumbsize'] + (($usercss ? $stylevar['cellspacing'] : 0) + $stylevar['cellpadding']) * 2 + 4; $picturebit_width = $vbulletin->options['album_thumbsize'] + (($usercss ? $stylevar['cellspacing'] : 0) + $stylevar['cellpadding']) * 2; $picturebits = ''; $unread_count = 0; while ($picture = $db->fetch_array($pictures)) { // $comment contains picture and album info $picture = prepare_pictureinfo_thumb($picture, $picture); $picture['unreadcomments'] = vb_number_format($picture['unreadcomments']); ($hook = vBulletinHook::fetch_hook('album_unread_picturebit')) ? eval($hook) : false; eval('$picturebits .= "' . fetch_template('album_picturebit_unread') . '";'); } if ($moderated_count != $vbulletin->userinfo['pcunreadcount']) { // back counter -- likely tachy based, rebuild all counters
/** * Gets the posts for the comments thread. * Note: Deleted and moderated comments are simply skipped. Admins can use the * forum moderation to view / manage them. * @TODO: Move this to an item or property of Item_Content or XData * * @return array int */ protected function getCommentPosts($thread) { $threadid = $thread->get_field('threadid'); if (!$threadid) { return array(); } $hook_query_joins = $hook_query_where = ''; ($hook = vBulletinHook::fetch_hook('showthread_query_postids')) ? eval($hook) : false; require_once DIR . '/includes/functions_bigthree.php' ; $coventry = fetch_coventry('string'); $getpostids = vB::$db->query_read(" SELECT post.postid FROM " . TABLE_PREFIX . "post AS post JOIN " . TABLE_PREFIX . "thread AS thread ON post.threadid = thread.threadid $hook_query_joins WHERE post.threadid = $threadid AND post.visible = 1 AND thread.visible = 1 AND thread.firstpostid <> post.postid " . ($coventry ? "AND post.userid NOT IN ($coventry)" : '') . " $hook_query_where ORDER BY post.dateline DESC LIMIT 5 "); $posts = array(); while ($row = vB::$db->fetch_row($getpostids)) { $posts[] = $row[0]; } return $posts; }
IF(tachythreadpost.userid IS NULL, thread.lastposter, tachythreadpost.lastposter) AS lastposter, IF(tachythreadpost.userid IS NULL, thread.lastpostid, tachythreadpost.lastpostid) AS lastpostid '; } else { $tachyjoin = ''; $tachycolumns = ' replycount, IF(views<=replycount, replycount+1, views) AS views, thread.lastpost, thread.lastposter, thread.lastpostid '; } $hook_query_fields = $hook_query_joins = ""; ($hook = vBulletinHook::fetch_hook('search_results_query_threads')) ? eval($hook) : false; // query thread data $dataQuery = "\n\t\t\tSELECT {$previewfield}\n\t\t\t\tthread.threadid, thread.threadid AS postid, thread.title AS threadtitle, thread.iconid AS threadiconid, thread.dateline, thread.forumid,\n\t\t\t\tthread.sticky, thread.prefixid, thread.taglist, thread.pollid, thread.open, thread.lastpost AS postdateline, thread.visible,\n\t\t\t\tthread.hiddencount, thread.deletedcount, thread.attach, thread.postusername, thread.forumid,\n\t\t\t\t{$tachycolumns},\n\t\t\t\t" . (can_moderate() ? "deletionlog.userid AS del_userid, deletionlog.username AS del_username, deletionlog.reason AS del_reason," : "") . "\n\t\t\t\tuser.userid AS postuserid\n\t\t\t\t" . iif($vbulletin->options['threadsubscribed'] and $vbulletin->userinfo['userid'], ", NOT ISNULL(subscribethread.subscribethreadid) AS issubscribed") . "\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 . "thread AS thread\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = thread.postuserid)\n\n\t\t\t" . (can_moderate() ? "LEFT JOIN " . TABLE_PREFIX . "deletionlog AS deletionlog ON(thread.threadid = deletionlog.primaryid AND deletionlog.type = 'thread')" : "") . "\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\t" . iif($vbulletin->options['threadsubscribed'] and $vbulletin->userinfo['userid'], " LEFT JOIN " . TABLE_PREFIX . "subscribethread AS subscribethread\n\t\t\t\tON(subscribethread.threadid = thread.threadid AND subscribethread.userid = " . $vbulletin->userinfo['userid'] . " AND canview = 1)") . "\n\t\t\t{$previewjoin}\n\t\t\t{$tachyjoin}\n\t\t\t{$hook_query_joins}\n\t\t\tWHERE thread.threadid IN\n\t\t"; } $Coventry_array = fetch_coventry(); $tmp = array(); $items = $db->query_read_slave($permQuery); unset($permQuery); while ($item = $db->fetch_array($items)) { if (!can_moderate($item['forumid']) and (in_array($item['userid'], $Coventry_array) or in_array($item['postuserid'], $Coventry_array))) { continue; } if (!$search['showposts']) { // fake post_visible since we aren't looking for it in thread results $item['post_visible'] = 1; } if ((!$item['post_visible'] or !$item['thread_visible']) and !can_moderate($item['forumid'], 'canmoderateposts')) { // post/thread is moderated and we don't have permission to see it continue; } else {
function build_thread_counters($threadid) { global $vbulletin; $threadid = intval($threadid); require_once(DIR . '/includes/functions_bigthree.php'); $coventry = fetch_coventry('string', true); $firstpost = $vbulletin->db->query_first(" SELECT post.postid, post.userid, user.username, post.username AS postuser, post.dateline FROM " . TABLE_PREFIX . "post AS post LEFT JOIN " . TABLE_PREFIX . "user AS user ON (user.userid = post.userid) WHERE post.threadid = $threadid AND post.visible = 1 ORDER BY dateline, postid LIMIT 1 "); if (!$firstpost) { // sanity -- this should never happen; one post should always be visible return; } $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "tachythreadcounter WHERE threadid = $threadid"); $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "tachythreadpost WHERE threadid = $threadid"); $replies = $vbulletin->db->query_first(" SELECT SUM(IF(visible = 1, attach, 0)) AS attachsum, SUM(IF(visible = 1, 1, 0)) AS visible, SUM(IF(visible = 0, 1, 0)) AS hidden, SUM(IF(visible = 2, 1, 0)) AS deleted FROM " . TABLE_PREFIX . "post AS post WHERE threadid = $threadid " . ($coventry ? "AND post.userid NOT IN ($coventry)" : '') . " "); if ($coventry) { // Build Tachy Counters $tachy_db = $vbulletin->db->query_read(" SELECT post.userid, COUNT(*) AS replycount FROM " . TABLE_PREFIX . "post AS post WHERE post.userid IN ($coventry) AND post.visible = 1 AND post.threadid = $threadid AND post.postid <> $firstpost[postid] GROUP BY userid "); $tachystats = array(); while ($tachycounter = $vbulletin->db->fetch_array($tachy_db)) { $tachystats["$tachycounter[userid]"]['replycount'] = $tachycounter['replycount']; } if ($tachystats) { foreach ($tachystats as $user => $stats) { $vbulletin->db->query_write(" INSERT INTO ". TABLE_PREFIX . "tachythreadcounter (userid, threadid, replycount) VALUES (" . intval($user) . ", " . intval($threadid) . ", " . intval($stats['replycount']) . ") "); } } } $lastpost = $vbulletin->db->query_first(" SELECT user.username, post.userid, post.username AS postuser, post.dateline, post.postid FROM " . TABLE_PREFIX . "post AS post LEFT JOIN " . TABLE_PREFIX . "user AS user ON (user.userid = post.userid) WHERE post.threadid = $threadid AND post.visible = 1 " . ($coventry ? "AND post.userid NOT IN ($coventry)" : '') . " ORDER BY dateline DESC LIMIT 1 "); if ($lastpost AND $coventry) { // if we have a last post (by a non-tachy user) and coventry users, // look for a newer last post by a coventry user $tachy_db = $vbulletin->db->query_read(" SELECT user.username, post.userid, post.username AS postuser, post.dateline, post.postid FROM " . TABLE_PREFIX . "post AS post LEFT JOIN " . TABLE_PREFIX ."user AS user ON (user.userid = post.userid) WHERE post.threadid = $threadid AND post.visible = 1 AND post.userid IN ($coventry) AND post.dateline > $lastpost[dateline] ORDER BY dateline DESC "); $tachy_posts = array(); while ($tachy = $vbulletin->db->fetch_array($tachy_db)) { if (!isset($tachy_posts["$tachy[userid]"])) { $tachy_posts["$tachy[userid]"] = $tachy; } } if ($tachy_posts) { $tachy_replace = array(); foreach ($tachy_posts as $tachy) { $tachy_replace[] = " ($tachy[userid], $threadid, " . intval($tachy['dateline']) . ", '" . $vbulletin->db->escape_string($tachy['postuser']) . "', $tachy[userid], '" . $vbulletin->db->escape_string($tachy['postid']) . "') "; } if ($tachy_replace) { $vbulletin->db->query_write(" REPLACE INTO " . TABLE_PREFIX . "tachythreadpost (userid, threadid, lastpost, lastposter, lastposterid, lastpostid) VALUES " . implode(', ', $tachy_replace) ); } } } if ($lastpost) { $lastposter = (empty($lastpost['username']) ? $lastpost['postuser'] : $lastpost['username']); $lastposterid = $lastpost['userid']; $lastposttime = intval($lastpost['dateline']); $lastpostid = intval($lastpost['postid']); } else { // this will occur on a thread posted by a tachy user. // since only they will see the thread, the lastpost info can say their name $lastposter = (empty($firstpost['username']) ? $firstpost['postuser'] : $firstpost['username']); $lastposter = $firstpost['userid']; $lastposttime = intval($firstpost['dateline']); $lastpostid = intval($firstpost['postid']); } $firstposter = (empty($firstpost['username']) ? $firstpost['postuser'] : $firstpost['username']); $firstposterid = intval($firstpost['userid']); $firstpostid = intval($firstpost['postid']); $threadcreation = $firstpost['dateline']; $ratings = $vbulletin->db->query_first(" SELECT COUNT(*) AS votenum, SUM(vote) AS votetotal FROM " . TABLE_PREFIX . "threadrate WHERE threadid = $threadid "); $threadinfo = array('threadid' => $threadid); $threadman =& datamanager_init('Thread', $vbulletin, ERRTYPE_SILENT, 'threadpost'); $threadman->set_existing($threadinfo); $threadman->set_info('rebuild', true); $threadman->set('firstpostid', $firstpostid, true, false); $threadman->set('postuserid', $firstposterid, true, false); $threadman->set('postusername', $firstposter, true, false); $threadman->set('lastpost', $lastposttime, true, false); $threadman->set('replycount', $replies['visible'] - 1, true, false); $threadman->set('hiddencount', $replies['hidden'], true, false); $threadman->set('deletedcount', $replies['deleted'], true, false); $threadman->set('attach', $replies['attachsum'], true, false); $threadman->set('dateline', $threadcreation, true, false); $threadman->set('lastposter', $lastposter, true, false); $threadman->set('lastposterid', $lastposterid, true, false); $threadman->set('lastpostid', $lastpostid, true, false); $threadman->set('votenum', $ratings['votenum'], true, false); $threadman->set('votetotal', intval($ratings['votetotal']), true, false); $threadman->save(); }
/** * Rebuild the unviewed and unmoderated messages * * @param integer Userid of visitor message data to rebuild * * @return void */ function build_visitor_message_counters($userid) { global $vbulletin; $userid = intval($userid); if ($userid) { $coventry = ''; if ($vbulletin->options['globalignore'] != '') { require_once DIR . '/includes/functions_bigthree.php'; $coventry = fetch_coventry('string', true); $vbulletin->db->query_write("\n\t\t\t\tUPDATE " . TABLE_PREFIX . "visitormessage\n\t\t\t\tSET messageread = 1\n\t\t\t\tWHERE userid = {$userid}\n\t\t\t\tAND postuserid IN ({$coventry})\n\t\t\t"); } list($unread) = $vbulletin->db->query_first("\n\t\t\tSELECT COUNT(*) AS unread\n\t\t\tFROM " . TABLE_PREFIX . "visitormessage\n\t\t\tWHERE userid = {$userid}\n\t\t\t\tAND state = 'visible'\n\t\t\t\tAND messageread = 0", DBARRAY_NUM); list($moderated) = $vbulletin->db->query_first("\n\t\t\tSELECT COUNT(*) AS moderation\n\t\t\tFROM " . TABLE_PREFIX . "visitormessage\n\t\t\tWHERE userid = {$userid}\n\t\t\t\tAND state = 'moderation'\n\t\t\t" . ($coventry ? "AND (postuserid NOT IN ({$coventry}) OR postuserid = {$userid})" : ''), DBARRAY_NUM); $vbulletin->db->query_write("\n\t\t\tUPDATE " . TABLE_PREFIX . "user\n\t\t\tSET vmunreadcount = " . intval($unread) . ", vmmoderatedcount = " . intval($moderated) . "\n\t\t\tWHERE userid = {$userid}\n\t\t"); ($hook = vBulletinHook::fetch_hook('visitor_message_build_counters')) ? eval($hook) : false; } }
} $xml->add_tag('error', fetch_error('blog_rate_voted')); } $xml->close_group(); $xml->print_xml(); } // ############################### start random blog ############################### if ($_REQUEST['do'] == 'random') { $sql = array("state = 'visible'", "dateline <= " . TIMENOW, "blog.pending = 0"); if (!($vbulletin->userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_canviewown'])) { $sql[] = "blog.userid <> " . $vbulletin->userinfo['userid']; } if (!($vbulletin->userinfo['permissions']['vbblog_general_permissions'] & $vbulletin->bf_ugp_vbblog_general_permissions['blog_canviewothers'])) { $sql[] = "blog.userid = " . $vbulletin->userinfo['userid']; } if ($coventry = fetch_coventry('string') and !can_moderate_blog()) { $sql[] = "blog.userid NOT IN ({$coventry})"; } $sql1join = array(); if (!can_moderate_blog()) { $sql1join[] = "LEFT JOIN " . TABLE_PREFIX . "blog_user AS blog_user ON (blog_user.bloguserid = blog.userid)"; if ($vbulletin->userinfo['userid']) { $userlist_sql = array(); $userlist_sql[] = "blog.userid = " . $vbulletin->userinfo['userid']; $userlist_sql[] = "(options_ignore & " . $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " AND ignored.relationid IS NOT NULL)"; $userlist_sql[] = "(options_buddy & " . $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " AND buddy.relationid IS NOT NULL)"; $userlist_sql[] = "(options_member & " . $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " AND (options_buddy & " . $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " OR buddy.relationid IS NULL) AND (options_ignore & " . $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " OR ignored.relationid IS NULL))"; $sql[] = "(" . implode(" OR ", $userlist_sql) . ")"; $sql1join[] = "LEFT JOIN " . TABLE_PREFIX . "userlist AS buddy ON (buddy.userid = blog.userid AND buddy.relationid = " . $vbulletin->userinfo['userid'] . " AND buddy.type = 'buddy')"; $sql1join[] = "LEFT JOIN " . TABLE_PREFIX . "userlist AS ignored ON (ignored.userid = blog.userid AND ignored.relationid = " . $vbulletin->userinfo['userid'] . " AND ignored.type = 'ignore')"; $wheresql[] = "\r\n\t\t\t\t(blog.userid = " . $vbulletin->userinfo['userid'] . "\r\n\t\t\t\t\tOR\r\n\t\t\t\t~blog.options & " . $vbulletin->bf_misc_vbblogoptions['private'] . "\r\n\t\t\t\t\tOR\r\n\t\t\t\t(options_buddy & " . $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " AND buddy.relationid IS NOT NULL))";
public function setWhereFilter($filtertype, $value = null, $argument = 0) { $this->setFilters[$filtertype] = 1; switch ($filtertype) { case 'ignoredusers': require_once DIR . '/includes/functions_bigthree.php'; $coventry = fetch_coventry(); $ignorelist = array(); if (trim(vB::$vbulletin->userinfo['ignorelist'])) { $ignorelist = preg_split('/( )+/', trim(vB::$vbulletin->userinfo['ignorelist']), -1, PREG_SPLIT_NO_EMPTY); } if ($ignored = array_merge($coventry, $ignorelist)) { $this->wheresql[] = "stream.userid NOT IN (" . implode(",", $ignored) . ")"; } break; case 'minscore': if (!$value) { return; } $this->wheresql[] = "stream.score <= {$value}"; break; case 'mindateline': if (!$value) { return; } $this->wheresql[] = "stream.dateline <= " . intval($value); break; case 'maxdateline': if (!$value) { return; } /* Don't put >= here */ $this->wheresql[] = "stream.dateline > " . intval($value); break; case 'excludeid': if (!$value) { return; } $ids = explode(',', $value); $ids = array_map('intval', $ids); if ($ids) { $this->wheresql[] = "stream.activitystreamid NOT IN (" . implode(',', $ids) . ")"; } break; case 'userid': if (!$value) { return; } if (!is_array($value)) { $value = array($value); } $value = array_map('intval', $value); $this->wheresql[] = "stream.userid IN (" . implode(",", $value) . ")"; break; case 'type': // this only supports photo .. if (!$value) { return; } if ($photos = vB::$vbulletin->activitystream['photo']) { $this->wheresql[] = "stream.typeid IN (" . implode(", ", $photos) . ")"; } else { $this->wheresql[] = "stream.typeid = 0"; } break; case 'section': if (!$value) { return; } if ($sections = vB::$vbulletin->activitystream['enabled'][$value]) { $this->wheresql[] = "stream.typeid IN (" . implode(", ", $sections) . ")"; } else { $this->wheresql[] = "stream.typeid = 0"; } break; case 'friends': if (!$value) { return; } if ($this->fetchFriends and vB::$vbulletin->options['socnet'] & vB::$vbulletin->bf_misc_socnet['enable_friends'] and $friends = $this->fetchFriends($value)) { if (!$friends) { $this->wheresql[] = "stream.userid = 0"; return false; } else { $this->wheresql[] = "stream.userid IN (" . implode(",", $friends) . ")"; return true; } } else { $this->wheresql[] = "stream.userid = 0"; return false; } break; case 'all': if (!$value) { return; } if (!is_array($value)) { $value = array($value); } $value = array_map('intval', $value); if ($this->fetchFriends and vB::$vbulletin->options['socnet'] & vB::$vbulletin->bf_misc_socnet['enable_friends']) { $friends = $this->fetchFriends($value); $value = array_merge($value, $friends); } $this->wheresql[] = "stream.userid IN (" . implode(",", $value) . ")"; break; } }
/** * Rebuild the unviewed and unmoderated picture comment counters * * @param integer Userid of visitor message data to rebuild * * @return void */ function build_picture_comment_counters($userid) { global $vbulletin; $userid = intval($userid); if ($userid) { require_once(DIR . '/includes/class_bootstrap_framework.php'); require_once(DIR . '/vb/types.php'); vB_Bootstrap_Framework::init(); $types = vB_Types::instance(); $contenttypeid = intval($types->getContentTypeID('vBForum_Album')); $coventry = ''; if ($vbulletin->options['globalignore'] != '') { require_once(DIR . '/includes/functions_bigthree.php'); $coventry = fetch_coventry('string', true); $vbulletin->db->query_write(" UPDATE " . TABLE_PREFIX . "attachment AS attachment INNER JOIN " . TABLE_PREFIX . "picturecomment AS picturecomment ON (attachment.filedataid = picturecomment.filedataid AND attachment.userid = picturecomment.userid) SET picturecomment.messageread = 1 WHERE attachment.contenttypeid = $contenttypeid AND attachment.userid = $userid AND picturecomment.postuserid IN ($coventry) "); } list($unread) = $vbulletin->db->query_first(" SELECT COUNT(*) AS unread FROM " . TABLE_PREFIX . "attachment AS attachment INNER JOIN " . TABLE_PREFIX . "picturecomment AS picturecomment ON (attachment.filedataid = picturecomment.filedataid AND attachment.userid = picturecomment.userid) WHERE attachment.contenttypeid = $contenttypeid AND attachment.userid = $userid AND picturecomment.state = 'visible' AND picturecomment.messageread = 0", DBARRAY_NUM ); list($moderated) = $vbulletin->db->query_first(" SELECT COUNT(*) AS moderation FROM " . TABLE_PREFIX . "attachment AS attachment INNER JOIN " . TABLE_PREFIX . "picturecomment AS picturecomment ON (attachment.filedataid = picturecomment.filedataid AND attachment.userid = picturecomment.userid) WHERE attachment.contenttypeid = $contenttypeid AND attachment.userid = $userid AND picturecomment.state = 'moderation' " . ($coventry ? "AND (picturecomment.postuserid NOT IN ($coventry) OR picturecomment.postuserid = $userid)" : '') , DBARRAY_NUM ); $vbulletin->db->query_write(" UPDATE " . TABLE_PREFIX . "user SET pcunreadcount = " . intval($unread) . ", pcmoderatedcount = " . intval($moderated) . " WHERE userid = $userid "); ($hook = vBulletinHook::fetch_hook('picture_comment_build_counters')) ? eval($hook) : false; } }