/** * Fetches the array of posts * * @return array - the post information */ private function getPosts() { require_once DIR . "/includes/functions_user.php"; require_once DIR . "/includes/class_bbcode.php"; $datecut = TIMENOW - ($this->config['days'] * 86400); if (empty(vB::$vbulletin->userinfo['forumpermissions'])) { require_once DIR . "/includes/functions.php"; cache_permissions($userinfo); } $postarray = array(); //we have some existing settings with config['forumchoice'] set to 0=> ''; That's no good if (empty($this->config['forumchoice'])) { $this->config['forumchoice'] = array(); } else if (is_array($this->config['forumchoice']) AND ($this->config['forumchoice'][0] == '') ) { unset($this->config['forumchoice'][0]); } if (is_array($this->config['forumchoice']) AND in_array('subscribed', $this->config['forumchoice'])) { $subscribejoin = " LEFT JOIN " . TABLE_PREFIX . "subscribeforum AS subscribeforum ON (subscribeforum.forumid = forum.forumid AND subscribeforum.userid = " . vB::$vbulletin->userinfo['userid'] . " ) "; } else { $subscribejoin = ''; } $forumids = array_keys(vB::$vbulletin->forumcache); foreach ($forumids AS $forumid) { $forumperms =& vB::$vbulletin->userinfo['forumpermissions']["$forumid"]; if ($forumperms & vB::$vbulletin->bf_ugp_forumpermissions['canview'] AND ($forumperms & vB::$vbulletin->bf_ugp_forumpermissions['canviewothers']) AND (($forumperms & vB::$vbulletin->bf_ugp_forumpermissions['canviewthreads'])) AND verify_forum_password($forumid, vB::$vbulletin->forumcache["$forumid"]['password'], false) ) { //Don't include the comments forum. if (vB::$vbulletin->options['vbcmsforumid'] AND (intval(vB::$vbulletin->options['vbcmsforumid']) == intval($forumid))) { continue; } //Or, if the user selected forums, anything not on the list. else if (! empty($this->config['forumchoice']) AND !in_array($forumid, $this->config['forumchoice'])) { continue; } $forumchoice[] = $forumid; } } if (!empty($forumchoice) ) { $forumsql = " AND (" . (empty($subscribejoin) ? '' : "subscribeforum.forumid IS NOT NULL OR ") . " thread.forumid IN(" . implode(',', $forumchoice) . ")"; $associatedthread = (vB::$vbulletin->options['vbcmsforumid'] ? " AND (thread.forumid <> " . vB::$vbulletin->options['vbcmsforumid'] . ") )" : ''); } else if (! empty($subscribejoin)) { $forumsql = " AND subscribeforum.forumid IS NOT NULL "; } else { return $postarray; } $posts = vB::$vbulletin->db->query_read_slave($sql = " SELECT post.dateline, post.pagetext, post.allowsmilie, post.postid, thread.threadid, thread.title, thread.prefixid, post.attach, thread.replycount, forum.forumid, post.title AS posttitle, post.dateline AS postdateline, user.userid, user.username " . (vB::$vbulletin->options['avatarenabled'] ? ",avatar.avatarpath, (customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline, customavatar.width AS avwidth,customavatar.height AS avheight" : "") . " FROM " . TABLE_PREFIX . "post AS post JOIN " . TABLE_PREFIX . "thread AS thread ON (thread.threadid = post.threadid) JOIN " . TABLE_PREFIX . "forum AS forum ON(forum.forumid = thread.forumid) LEFT JOIN " . TABLE_PREFIX . "user AS user ON (post.userid = user.userid) " . (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)" : "") . " $subscribejoin WHERE 1=1 $forumsql $associatedthread AND thread.visible = 1 AND post.visible = 1 AND thread.open <> 10 AND post.dateline > $datecut $globalignore " . ($this->userinfo['ignorelist'] ? "AND post.userid NOT IN (" . implode(',', explode(' ', $this->userinfo['ignorelist'])) . ")": '') . " ORDER BY post.dateline DESC LIMIT 0," . intval($this->config['count']) . " "); $parser = new vB_BbCodeParser(vB::$vbulletin, fetch_tag_list()); $optionval = vB::$vbulletin->bf_misc_forumoptions['allowhtml']; while ($post = vB::$vbulletin->db->fetch_array($posts)) { $post['title'] = fetch_trimmed_title($post['title'], $this->config['newposts_titlemaxchars']); $allow_html = ((vB::$vbulletin->forumcache[$post['forumid']]['options'] & $optionval) AND $this->config['allow_html'] ? 1 : 0); $post['previewtext'] = fetch_censored_text($parser->get_preview($post['pagetext'], $this->default_previewlen, $allow_html)); $post['pagetext'] = fetch_censored_text($parser->do_parse($post['pagetext'], $allow_html)); $post['url'] = fetch_seo_url('thread', $post, array('p' => $post['postid'])) . '#post' . $post['postid']; $post['newposturl'] = fetch_seo_url('thread', $post, array('goto' => 'newpost')); $post['date'] = vbdate(vB::$vbulletin->options['dateformat'], $post['dateline'], true); $post['time'] = vbdate(vB::$vbulletin->options['timeformat'], $post['dateline']); if (intval($post['userid']) AND vB::$vbulletin->options['avatarenabled']) { $avatar = fetch_avatar_from_record($post); } else { $avatar = false; } $post['avatarurl'] = isset($avatar[0]) ? $avatar[0] : false; unset($avatar); $postarray[$post['postid']] = $post; } return $postarray; }
private function getThreads() { $datecut = TIMENOW - ($this->config['days'] * 86400); if (empty(vB::$vbulletin->userinfo['forumpermissions'])) { require_once DIR . "/includes/functions.php"; cache_permissions($userinfo); } 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; } //we have some existing settings with config['forumchoice'] set to 0=> ''; That's no good if (empty($this->config['forumchoice'])) { $this->config['forumchoice'] = array(); } else if (is_array($this->config['forumchoice']) AND ($this->config['forumchoice'][0] == '') ) { unset($this->config['forumchoice'][0]); } $subscribejoin = ''; if (in_array('subscribed', $this->config['forumchoice'])) { $subscribejoin = " INNER JOIN " . TABLE_PREFIX . "subscribeforum AS subscribeforum ON (subscribeforum.forumid = forum.forumid AND subscribeforum.userid = " . vB::$vbulletin->userinfo['userid'] . " ) "; } $forumsql = ''; $forumids = array_keys(vB::$vbulletin->forumcache); $forumchoice = array(); foreach ($forumids AS $forumid) { $forumperms =& vB::$vbulletin->userinfo['forumpermissions']["$forumid"]; if ($forumperms & vB::$vbulletin->bf_ugp_forumpermissions['canview'] AND ($forumperms & vB::$vbulletin->bf_ugp_forumpermissions['canviewothers']) AND (($forumperms & vB::$vbulletin->bf_ugp_forumpermissions['canviewthreads'])) AND verify_forum_password($forumid, vB::$vbulletin->forumcache["$forumid"]['password'], false) ) { //Don't include the comments forum. if (vB::$vbulletin->options['vbcmsforumid'] AND (intval(vB::$vbulletin->options['vbcmsforumid']) == intval($forumid))) { continue; } //Or, if the user selected forums, anything not on the list. else if (! empty($this->config['forumchoice']) AND !in_array($forumid, $this->config['forumchoice'])) { continue; } $forumchoice[] = $forumid; } } $threadarray = array(); if (!empty($forumchoice) ) { $forumsql = " AND (" . (empty($subscribejoin) ? '' : "subscribeforum.forumid IS NOT NULL OR ") . " thread.forumid IN(" . implode(',', $forumchoice) . ")"; $associatedthread = (vB::$vbulletin->options['vbcmsforumid'] ? " AND (thread.forumid <> " . vB::$vbulletin->options['vbcmsforumid'] . ") )" : ''); } else if (! empty($subscribejoin)) { $forumsql = " AND subscribeforum.forumid IS NOT NULL "; } else { return $threadarray; } // remove threads from users on the global ignore list if user is not a moderator $globalignore = ''; if (trim(vB::$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 = vB::$vbulletin->db->query_read_slave($sql = " SELECT thread.threadid, thread.title, thread.prefixid, post.attach, post.userid AS postuserid, post.username AS postusername, 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.userid, user.username, thread.lastposter AS lastpostername " . (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 . "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) " . (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)" : "") . " $subscribejoin WHERE 1=1 $forumsql AND thread.visible = 1 AND post.visible = 1 AND open <> 10 $datecutoffsql $globalignore $associatedthread " . ($this->userinfo['ignorelist'] ? "AND thread.postuserid NOT IN (" . implode(',', explode(' ', $this->userinfo['ignorelist'])) . ")": '') . " ORDER BY $ordersql LIMIT 0," . intval($this->config['count']) . " "); require_once(DIR . '/includes/class_bbcode.php'); $parser = new vB_BbCodeParser(vB::$vbulletin, fetch_tag_list()); $optionval = vB::$vbulletin->bf_misc_forumoptions['allowhtml']; while ($thread = vB::$vbulletin->db->fetch_array($threads)) { $thread['title'] = fetch_trimmed_title($thread['title'], $this->config['threads_titlemaxchars']); $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']; $thread['date'] = vbdate(vB::$vbulletin->options['dateformat'], $thread['dateline'], true); $thread['time'] = vbdate(vB::$vbulletin->options['timeformat'], $thread['dateline']); $thread['lastpostdate'] = vbdate(vB::$vbulletin->options['dateformat'], $thread['lastpost'], true); $thread['lastposttime'] = vbdate(vB::$vbulletin->options['timeformat'], $thread['lastpost']); $forumid = $thread['forumid']; $allow_html = ((vB::$vbulletin->forumcache[$forumid]['options'] & $optionval) AND $this->config['allow_html'] ? 1 : 0); $thread['previewtext'] = fetch_censored_text($parser->get_preview($thread['message'], $this->default_previewlen, $allow_html)); $thread['pagetext'] = fetch_censored_text($parser->do_parse($thread['message'], $allow_html)); // get avatar if (intval($thread['userid']) AND vB::$vbulletin->options['avatarenabled']) { $avatar = fetch_avatar_from_record($thread); } if (!isset($avatar)) { $avatar = false; } $thread['avatarurl'] = isset($avatar[0]) ?$avatar[0] : false; unset($avatar); $threadarray[$thread['threadid']] = $thread; } return $threadarray; }