<?php
define("IN_MYBB", 1);
define("IN_PORTAL", 1);
define('THIS_SCRIPT', 'browse.php');
$forumdir = "./";
$change_dir = "./";
if(!@chdir($forumdir) && !empty($forumdir))
{
if(@is_dir($forumdir))
{
$change_dir = $forumdir;
}
else
{
die("\$forumdir is invalid!");
}
}
$templatelist = "portal_announcement,browseportal";
$templatelist .= ",multipage_prevpage,multipage_nextpage,multipage_page_current,multipage_page,multipage_start,multipage_end,multipage";
require_once $change_dir."/global.php";
require_once MYBB_ROOT."inc/functions_post.php";
require_once MYBB_ROOT."inc/functions_user.php";
require_once MYBB_ROOT."inc/class_parser.php";
$parser = new postParser;
$browse_url = get_current_location();
add_breadcrumb("Downloads", $mybb->settings['bburl']."/browse.php");
$mybb->settings['portal_announcementsfid'] = '7,14,22,28,53,55,73,78';
$mybb->settings['portal_numannouncements'] = '18';
$query_add = '';
if($mybb->input['filtertf_prefix']) $query_add .= ' AND tfd.prefix="'.$db->escape_string($mybb->input['filtertf_prefix']).'"';
$plugins->run_hooks("portal_start");
$unviewable = get_unviewable_forums(true);
if($unviewable)
{
$unviewwhere = " AND fid NOT IN ($unviewable)";
}
$announcementsfids = explode(',', $mybb->settings['portal_announcementsfid']);
if(is_array($announcementsfids))
{
foreach($announcementsfids as $fid)
{
$fid_array[] = intval($fid);
}
$announcementsfids = implode(',', $fid_array);
}
$query = $db->simple_select("forums", "*", "fid IN (".$announcementsfids.")");
while($forumrow = $db->fetch_array($query))
{
$forum[$forumrow['fid']] = $forumrow;
}
$pids = '';
$tids = '';
$comma = '';
$page = intval($mybb->input['page']);
if($page < 1) $page = 1;
$numann = $db->fetch_field($db->simple_select('threads', 'COUNT(*) AS numann', "fid IN (".$mybb->settings['portal_announcementsfid'].") AND visible='1' AND closed NOT LIKE 'moved|%'"), 'numann');
$perpage = intval($mybb->settings['portal_numannouncements']);
$multipage = multipage($numann, $perpage, $page, $_SERVER['PHP_SELF'].'?paged=1');
$query = $db->query("
SELECT p.pid, p.message, p.tid, tfd.prefix
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
LEFT JOIN ".TABLE_PREFIX."threadfields_data tfd ON (tfd.tid = t.tid)
WHERE t.fid IN (".$mybb->settings['portal_announcementsfid'].") AND t.visible='1' AND t.closed NOT LIKE 'moved|%' AND t.firstpost=p.pid
ORDER BY t.dateline DESC
LIMIT ".(($page-1)*$perpage).", ".$perpage.
$query_add);
while($getid = $db->fetch_array($query))
{
$pids .= ",'{$getid['pid']}'";
$tids .= ",'{$getid['tid']}'";
$posts[$getid['tid']] = $getid;
}
$pids = "pid IN(0{$pids})";
if(is_array($forum))
{
foreach($forum as $fid => $forumrow)
{
$forumpermissions[$fid] = forum_permissions($fid);
}
}
$icon_cache = $cache->read("posticons");
$announcements = '';
$query = $db->query("
SELECT t.*, t.username AS threadusername, u.username, u.avatar
FROM ".TABLE_PREFIX."threads t
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid = t.uid)
WHERE fid IN (".$mybb->settings['portal_announcementsfid'].") AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
ORDER BY t.dateline DESC
LIMIT ".(($page-1)*$perpage).", ".$perpage
);
while($announcement = $db->fetch_array($query))
{
$announcement['pid'] = $posts[$announcement['tid']]['pid'];
$announcement['threadlink'] = get_thread_link($announcement['tid']);
if($announcement['uid'] == 0)
{
$profilelink = htmlspecialchars_uni($announcement['threadusername']);
}
else
{
$profilelink = build_profile_link($announcement['username'], $announcement['uid']);
}
if(!$announcement['username'])
{
$announcement['username'] = $announcement['threadusername'];
}
$announcement['subject'] = htmlspecialchars_uni($parser->parse_badwords($announcement['subject']));
if($announcement['icon'] > 0 && $icon_cache[$announcement['icon']])
{
$icon = $icon_cache[$announcement['icon']];
$icon = "<img src=\"{$icon['path']}\" alt=\"{$icon['name']}\" />";
}
else
{
$icon = " ";
}
$anndate = my_date($mybb->settings['dateformat'], $announcement['dateline']);
$anntime = my_date($mybb->settings['timeformat'], $announcement['dateline']);
$annname = $announcement['forumname'];
$plugins->run_hooks("portal_announcement");
eval("\$announcements .= \"".$templates->get("portal_announcement")."\";");
unset($post);
}
$plugins->run_hooks("portal_end");
eval("\$browse = \"".$templates->get("browseportal")."\";");
output_page($browse);
?>
|