Advertisement
Guest User

lastposts.php

a guest
Sep 28th, 2011
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.31 KB | None | 0 0
  1. <?php
  2. //Show last Posts
  3. if (isset($_COOKIE[$cookieprefix.'hidelastpost'])) {
  4. $hidelastpost = decode_cookie($_COOKIE[$cookieprefix.'hidelastpost']);
  5. } else {
  6. $hidelastpost = 0;
  7. }
  8. //Show last Announces
  9. if (isset($_COOKIE[$cookieprefix.'hidelastannounce'])) {
  10. $hidelastannounce = decode_cookie($_COOKIE[$cookieprefix.'hidelastannounce']);
  11. } else {
  12. $hidelastannounce = 0;
  13. }
  14. //Show last Posts
  15. if (isset($_GET['hidelastposts'])) {
  16. $hidelastpost = 1;
  17. if ($wbbuserdata['usecookies'] == 1) encode_cookie("hidelastpost", time()+3600*24*365);
  18. else encode_cookie("hidelastpost");
  19. }
  20. if (isset($_GET['showlastposts'])) {
  21. $hidelastpost = 0;
  22. if ($wbbuserdata['usecookies'] == 1) encode_cookie("hidelastpost", time()+3600*24*365);
  23. else encode_cookie("hidelastpost");
  24. }
  25.  
  26. //Show last Announces
  27. if (isset($_GET['hidelastannounces'])) {
  28. $hidelastannounce = 1;
  29. if ($wbbuserdata['usecookies'] == 1) encode_cookie("hidelastannounce", time()+3600*24*365);
  30. else encode_cookie("hidelastannounce");
  31. }
  32. if (isset($_GET['showlastannounces'])) {
  33. $hidelastannounce = 0;
  34. if ($wbbuserdata['usecookies'] == 1) encode_cookie("hidelastannounce", time()+3600*24*365);
  35. else encode_cookie("hidelastannounce");
  36. }
  37.  
  38.  
  39. //last Announces
  40. if($hidelastannounce == 0) {
  41. $lang->load('BOARD');
  42. $fromdays = "";
  43. $diffdays = "";
  44.  
  45. if($showlastannouncedays > 0) {
  46. $diff = time() - ($showlastannouncedays * 86400);
  47. $diffdays = "AND starttime >= ".$diff."";
  48.  
  49. eval ("\$fromdays = \"".$lang->get("LANG_START_LASTANNOUNCES_2")."\";");
  50. }
  51.  
  52. $res = $db->query("SELECT DISTINCT t.*, tv.lastvisit, i.*, p.userid
  53. FROM bb".$n."_threads t
  54. LEFT JOIN bb".$n."_icons i ON (t.iconid=i.iconid)
  55. LEFT JOIN bb".$n."_threadvisit tv ON (tv.threadid=t.threadid AND tv.userid = '".$wbbuserdata['userid']."')
  56. LEFT JOIN bb".$n."_posts p ON (t.threadid = p.threadid AND p.userid = '$wbbuserdata[userid]')
  57. WHERE t.closed != 3 AND t.important = 2 ".$diffdays."
  58. AND t.boardid IN (0".getSearchableBoards().")
  59. ORDER BY t.lastposttime DESC, t.threadid DESC
  60. LIMIT 0,".$showlastannounce."");
  61.  
  62. $count_announces = $db->num_rows($res);
  63.  
  64. if($count_announces > 0) {
  65. $lastannounce_bit = get_last_posts($res, 1);
  66. } else {
  67. eval ("\$lastannounce_bit = \"".$tpl->get("index_lastpost_noannounce_bit")."\";");
  68. }
  69.  
  70. //$lastannounce_bit = get_last_posts($res);
  71. }
  72.  
  73. //last Posts
  74. if($hidelastpost == 0) {
  75. $lang->load('BOARD');
  76. if($showlastannounce > 0) $la = "AND t.important != 2";
  77. else $la = "";
  78.  
  79. $res = $db->query("SELECT DISTINCT t.*, tv.lastvisit, tv.userid, i.*, p.userid
  80. FROM bb".$n."_threads t
  81. LEFT JOIN bb".$n."_icons i ON (t.iconid=i.iconid)
  82. LEFT JOIN bb".$n."_threadvisit tv ON (tv.threadid=t.threadid AND tv.userid = '".$wbbuserdata['userid']."')
  83. LEFT JOIN bb".$n."_posts p ON (t.threadid = p.threadid AND p.userid = '$wbbuserdata[userid]')
  84. WHERE t.closed != 3 ".$la."
  85. AND t.boardid IN (0".getSearchableBoards().")
  86. ORDER BY t.lastposttime DESC, t.threadid DESC
  87. LIMIT 0,".$showlastpost."");
  88.  
  89. $lastpost_bit = get_last_posts($res);
  90. }
  91.  
  92. eval ("\$lang->items['LANG_START_DEACTIVATE_LASTANNOUNCE'] = \"".$lang->get("LANG_START_DEACTIVATE_LASTANNOUNCE")."\";");
  93. eval ("\$lang->items['LANG_START_LASTANNOUNCES'] = \"".$lang->get("LANG_START_LASTANNOUNCES")."\";");
  94. eval ("\$lang->items['LANG_START_SHOWLASTANNOUNCE'] = \"".$lang->get("LANG_START_SHOWLASTANNOUNCE")."\";");
  95.  
  96. eval ("\$lang->items['LANG_START_DEACTIVATE_LASTPOST'] = \"".$lang->get("LANG_START_DEACTIVATE_LASTPOST")."\";");
  97. eval ("\$lang->items['LANG_START_LASTPOSTS'] = \"".$lang->get("LANG_START_LASTPOSTS")."\";");
  98. eval ("\$lang->items['LANG_START_SHOWLASTPOST'] = \"".$lang->get("LANG_START_SHOWLASTPOST")."\";");
  99.  
  100. eval("\$lastposts = \"".$tpl->get("index_lastposts")."\";");
  101. //eval("\$lastannounces = \"".$tpl->get("index_lastannounces")."\";");
  102.  
  103.  
  104. /**
  105. *
  106. *
  107. */
  108. function get_last_posts($result, $announce = 0) {
  109. global $db, $n, $wbbuserdata, $lang, $tpl, $style;
  110. $lastpostsbit = "";
  111. while($lastposts = $db->fetch_array($result)) {
  112.  
  113. $stylefolder = "{$style['imagefolder']}";
  114. $board = getBoardAccessData($lastposts['boardid']);
  115. $board['title'] = getlangvar($board['title'], $lang);
  116. $lastposts['topic'] = htmlconverter(textwrap($lastposts['topic'], 35));
  117. $lastposts['lastposter'] = htmlconverter(textwrap($lastposts['lastposter'], 25));
  118. $lastposts['prefix'] = htmlconverter($lastposts['prefix']);
  119.  
  120. if ($wbbuserdata['lastvisit'] > $board['lastvisit']) $board['lastvisit'] = $wbbuserdata['lastvisit'];
  121.  
  122. $lastp_title = $lastposts['topic'];
  123. $board_title = $board['title'];
  124. if(strlen($lastposts['topic']) > 35) $lastposts['topic'] = substr($lastposts['topic'], 0, 35)."...";
  125. if(strlen($board['title']) > 30) $board['title'] = substr($board['title'], 0, 30)."...";
  126.  
  127. if($lastposts['attachments'] > 0) {
  128. $LANG_BOARD_ATTACHMENTS = $lang->get("LANG_BOARD_ATTACHMENTS", array('$attachments' => $lastposts['attachments']));
  129. }
  130.  
  131. if ($lastposts['lastposttime'] > $board['lastvisit'] && $lastposts['lastposttime'] > $lastposts['lastvisit']) $firstnew = 1;
  132. else $firstnew = 0;
  133.  
  134. if ($board['hotthread_reply'] == 0) $board['hotthread_reply'] = $default_hotthread_reply;
  135. if ($board['hotthread_view'] == 0) $board['hotthread_view'] = $default_hotthread_view;
  136. if ($lastposts['important'] == 2) $foldericon = 'announce';
  137. 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';
  138.  
  139. $date = formatdate($wbbuserdata['dateformat'], $lastposts['lastposttime'],1);
  140. $time = formatdate($wbbuserdata['timeformat'], $lastposts['lastposttime']);
  141. if ($lastposts['replycount'] >= 1000) $lastposts['replycount'] = number_format($lastposts['replycount'], 0, "", $lang->get("LANG_GLOBAL_THOUSANDS_SEP"));
  142. if ($lastposts['views'] >= 1000) $lastposts['views'] = number_format($lastposts['views'], 0, "", $lang->get("LANG_GLOBAL_THOUSANDS_SEP"));
  143.  
  144. if($lastposts['iconid']) {
  145. $iconpath = "$lastposts[iconpath]";
  146. $iconpath = str_replace("{imagefolder}","$stylefolder",$iconpath);
  147. $threadicon = makeimgtag($iconpath,getlangvar($lastposts['icontitle'], $lang),0);
  148. } else {
  149. $threadicon = makeimgtag($stylefolder."/icons/icon14.gif");
  150. }
  151.  
  152. if($announce == 0) {
  153. eval ("\$lastpostsbit .= \"".$tpl->get("index_lastpost_bit")."\";");
  154. } else {
  155. eval ("\$lastpostsbit .= \"".$tpl->get("index_lastannounce_bit")."\";");
  156. }
  157. }
  158. return $lastpostsbit;
  159. }
  160.  
  161. /**
  162. * @return boardids string
  163. * @desc returns the boards to which the current user has access.
  164. */
  165. function getSearchableBoards() {
  166. global $db, $n, $wbbuserdata, $boardcache;
  167.  
  168. if (!isset($boardcache) || !is_array($boardcache)) $boardcache = array();
  169. $result = $db->query("SELECT boardid,boardorder,parentid,parentlist FROM bb".$n."_boards where boardid = '1' ORDER BY parentid ASC, boardorder ASC");
  170. while ($row = $db->fetch_array($result)) {
  171. $boardcache[$row['parentid']][$row['boardorder']][$row['boardid']] = $row;
  172. }
  173.  
  174. $boardpermissions = getPermissions();
  175. $boardids = '';
  176. foreach ($boardcache as $key => $val) {
  177. foreach ($val as $key2 => $val2) {
  178. foreach ($val2 as $row) if (!isset($boardpermissions[$row['boardid']]['can_use_search']) || $boardpermissions[$row['boardid']]['can_use_search'] != 0) $boardids .= ",".$row['boardid'];
  179. }
  180. }
  181. return $boardids;
  182. }
  183. ?>
  184.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement