Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Show last Posts
- if (isset($_COOKIE[$cookieprefix.'hidelastpost'])) {
- $hidelastpost = decode_cookie($_COOKIE[$cookieprefix.'hidelastpost']);
- } else {
- $hidelastpost = 0;
- }
- //Show last Announces
- if (isset($_COOKIE[$cookieprefix.'hidelastannounce'])) {
- $hidelastannounce = decode_cookie($_COOKIE[$cookieprefix.'hidelastannounce']);
- } else {
- $hidelastannounce = 0;
- }
- //Show last Posts
- if (isset($_GET['hidelastposts'])) {
- $hidelastpost = 1;
- if ($wbbuserdata['usecookies'] == 1) encode_cookie("hidelastpost", time()+3600*24*365);
- else encode_cookie("hidelastpost");
- }
- if (isset($_GET['showlastposts'])) {
- $hidelastpost = 0;
- if ($wbbuserdata['usecookies'] == 1) encode_cookie("hidelastpost", time()+3600*24*365);
- else encode_cookie("hidelastpost");
- }
- //Show last Announces
- if (isset($_GET['hidelastannounces'])) {
- $hidelastannounce = 1;
- if ($wbbuserdata['usecookies'] == 1) encode_cookie("hidelastannounce", time()+3600*24*365);
- else encode_cookie("hidelastannounce");
- }
- if (isset($_GET['showlastannounces'])) {
- $hidelastannounce = 0;
- if ($wbbuserdata['usecookies'] == 1) encode_cookie("hidelastannounce", time()+3600*24*365);
- else encode_cookie("hidelastannounce");
- }
- //last Announces
- if($hidelastannounce == 0) {
- $lang->load('BOARD');
- $fromdays = "";
- $diffdays = "";
- if($showlastannouncedays > 0) {
- $diff = time() - ($showlastannouncedays * 86400);
- $diffdays = "AND starttime >= ".$diff."";
- eval ("\$fromdays = \"".$lang->get("LANG_START_LASTANNOUNCES_2")."\";");
- }
- $res = $db->query("SELECT DISTINCT t.*, tv.lastvisit, i.*, p.userid
- FROM bb".$n."_threads t
- LEFT JOIN bb".$n."_icons i ON (t.iconid=i.iconid)
- LEFT JOIN bb".$n."_threadvisit tv ON (tv.threadid=t.threadid AND tv.userid = '".$wbbuserdata['userid']."')
- LEFT JOIN bb".$n."_posts p ON (t.threadid = p.threadid AND p.userid = '$wbbuserdata[userid]')
- WHERE t.closed != 3 AND t.important = 2 ".$diffdays."
- AND t.boardid IN (0".getSearchableBoards().")
- ORDER BY t.lastposttime DESC, t.threadid DESC
- LIMIT 0,".$showlastannounce."");
- $count_announces = $db->num_rows($res);
- if($count_announces > 0) {
- $lastannounce_bit = get_last_posts($res, 1);
- } else {
- eval ("\$lastannounce_bit = \"".$tpl->get("index_lastpost_noannounce_bit")."\";");
- }
- //$lastannounce_bit = get_last_posts($res);
- }
- //last Posts
- if($hidelastpost == 0) {
- $lang->load('BOARD');
- if($showlastannounce > 0) $la = "AND t.important != 2";
- else $la = "";
- $res = $db->query("SELECT DISTINCT t.*, tv.lastvisit, tv.userid, i.*, p.userid
- FROM bb".$n."_threads t
- LEFT JOIN bb".$n."_icons i ON (t.iconid=i.iconid)
- LEFT JOIN bb".$n."_threadvisit tv ON (tv.threadid=t.threadid AND tv.userid = '".$wbbuserdata['userid']."')
- LEFT JOIN bb".$n."_posts p ON (t.threadid = p.threadid AND p.userid = '$wbbuserdata[userid]')
- WHERE t.closed != 3 ".$la."
- AND t.boardid IN (0".getSearchableBoards().")
- ORDER BY t.lastposttime DESC, t.threadid DESC
- LIMIT 0,".$showlastpost."");
- $lastpost_bit = get_last_posts($res);
- }
- eval ("\$lang->items['LANG_START_DEACTIVATE_LASTANNOUNCE'] = \"".$lang->get("LANG_START_DEACTIVATE_LASTANNOUNCE")."\";");
- eval ("\$lang->items['LANG_START_LASTANNOUNCES'] = \"".$lang->get("LANG_START_LASTANNOUNCES")."\";");
- eval ("\$lang->items['LANG_START_SHOWLASTANNOUNCE'] = \"".$lang->get("LANG_START_SHOWLASTANNOUNCE")."\";");
- eval ("\$lang->items['LANG_START_DEACTIVATE_LASTPOST'] = \"".$lang->get("LANG_START_DEACTIVATE_LASTPOST")."\";");
- eval ("\$lang->items['LANG_START_LASTPOSTS'] = \"".$lang->get("LANG_START_LASTPOSTS")."\";");
- eval ("\$lang->items['LANG_START_SHOWLASTPOST'] = \"".$lang->get("LANG_START_SHOWLASTPOST")."\";");
- eval("\$lastposts = \"".$tpl->get("index_lastposts")."\";");
- //eval("\$lastannounces = \"".$tpl->get("index_lastannounces")."\";");
- /**
- *
- *
- */
- function get_last_posts($result, $announce = 0) {
- global $db, $n, $wbbuserdata, $lang, $tpl, $style;
- $lastpostsbit = "";
- while($lastposts = $db->fetch_array($result)) {
- $stylefolder = "{$style['imagefolder']}";
- $board = getBoardAccessData($lastposts['boardid']);
- $board['title'] = getlangvar($board['title'], $lang);
- $lastposts['topic'] = htmlconverter(textwrap($lastposts['topic'], 35));
- $lastposts['lastposter'] = htmlconverter(textwrap($lastposts['lastposter'], 25));
- $lastposts['prefix'] = htmlconverter($lastposts['prefix']);
- if ($wbbuserdata['lastvisit'] > $board['lastvisit']) $board['lastvisit'] = $wbbuserdata['lastvisit'];
- $lastp_title = $lastposts['topic'];
- $board_title = $board['title'];
- if(strlen($lastposts['topic']) > 35) $lastposts['topic'] = substr($lastposts['topic'], 0, 35)."...";
- if(strlen($board['title']) > 30) $board['title'] = substr($board['title'], 0, 30)."...";
- if($lastposts['attachments'] > 0) {
- $LANG_BOARD_ATTACHMENTS = $lang->get("LANG_BOARD_ATTACHMENTS", array('$attachments' => $lastposts['attachments']));
- }
- if ($lastposts['lastposttime'] > $board['lastvisit'] && $lastposts['lastposttime'] > $lastposts['lastvisit']) $firstnew = 1;
- else $firstnew = 0;
- if ($board['hotthread_reply'] == 0) $board['hotthread_reply'] = $default_hotthread_reply;
- if ($board['hotthread_view'] == 0) $board['hotthread_view'] = $default_hotthread_view;
- if ($lastposts['important'] == 2) $foldericon = 'announce';
- else $foldericon = ((isset($lastposts['userid']) && $lastposts['userid']) ? ('dot') : ('')).(($lastposts['lastposttime'] > $board['lastvisit'] && $lastposts['lastposttime'] > $lastposts['lastvisit']) ? ('new') : ('')).(($lastposts['replycount'] >= $board['hotthread_reply'] || $lastposts['views'] >= $board['hotthread_view']) ? ('hot') : ('')).(($lastposts['closed'] != 0) ? ('lock') : ('')).'folder';
- $date = formatdate($wbbuserdata['dateformat'], $lastposts['lastposttime'],1);
- $time = formatdate($wbbuserdata['timeformat'], $lastposts['lastposttime']);
- if ($lastposts['replycount'] >= 1000) $lastposts['replycount'] = number_format($lastposts['replycount'], 0, "", $lang->get("LANG_GLOBAL_THOUSANDS_SEP"));
- if ($lastposts['views'] >= 1000) $lastposts['views'] = number_format($lastposts['views'], 0, "", $lang->get("LANG_GLOBAL_THOUSANDS_SEP"));
- if($lastposts['iconid']) {
- $iconpath = "$lastposts[iconpath]";
- $iconpath = str_replace("{imagefolder}","$stylefolder",$iconpath);
- $threadicon = makeimgtag($iconpath,getlangvar($lastposts['icontitle'], $lang),0);
- } else {
- $threadicon = makeimgtag($stylefolder."/icons/icon14.gif");
- }
- if($announce == 0) {
- eval ("\$lastpostsbit .= \"".$tpl->get("index_lastpost_bit")."\";");
- } else {
- eval ("\$lastpostsbit .= \"".$tpl->get("index_lastannounce_bit")."\";");
- }
- }
- return $lastpostsbit;
- }
- /**
- * @return boardids string
- * @desc returns the boards to which the current user has access.
- */
- function getSearchableBoards() {
- global $db, $n, $wbbuserdata, $boardcache;
- if (!isset($boardcache) || !is_array($boardcache)) $boardcache = array();
- $result = $db->query("SELECT boardid,boardorder,parentid,parentlist FROM bb".$n."_boards where boardid = '1' ORDER BY parentid ASC, boardorder ASC");
- while ($row = $db->fetch_array($result)) {
- $boardcache[$row['parentid']][$row['boardorder']][$row['boardid']] = $row;
- }
- $boardpermissions = getPermissions();
- $boardids = '';
- foreach ($boardcache as $key => $val) {
- foreach ($val as $key2 => $val2) {
- foreach ($val2 as $row) if (!isset($boardpermissions[$row['boardid']]['can_use_search']) || $boardpermissions[$row['boardid']]['can_use_search'] != 0) $boardids .= ",".$row['boardid'];
- }
- }
- return $boardids;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement