PageRenderTime 124ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/source/module/forum/forum_forumdisplay.php

https://github.com/kuaileshike/upload
PHP | 873 lines | 853 code | 14 blank | 6 comment | 18 complexity | bbf48bcbe9c77e5a3bae13118412be3f MD5 | raw file
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: forum_forumdisplay.php 31822 2012-10-12 06:24:42Z zhangjie $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. require_once libfile('function/forumlist');
  12. if($_G['forum']['redirect']) {
  13. dheader("Location: {$_G[forum][redirect]}");
  14. } elseif($_G['forum']['type'] == 'group') {
  15. dheader("Location: forum.php?gid=$_G[fid]");
  16. } elseif(empty($_G['forum']['fid'])) {
  17. showmessage('forum_nonexistence', NULL);
  18. } elseif($_G['fid'] == $_G['setting']['followforumid'] && $_G['adminid'] != 1) {
  19. dheader("Location: home.php?mod=follow");
  20. }
  21. $_G['action']['fid'] = $_G['fid'];
  22. $_GET['specialtype'] = isset($_GET['specialtype']) ? $_GET['specialtype'] : '';
  23. $_GET['dateline'] = isset($_GET['dateline']) ? intval($_GET['dateline']) : 0;
  24. $_GET['digest'] = isset($_GET['digest']) ? 1 : '';
  25. $_GET['archiveid'] = isset($_GET['archiveid']) ? intval($_GET['archiveid']) : 0;
  26. $showoldetails = isset($_GET['showoldetails']) ? $_GET['showoldetails'] : '';
  27. switch($showoldetails) {
  28. case 'no': dsetcookie('onlineforum', ''); break;
  29. case 'yes': dsetcookie('onlineforum', 1, 31536000); break;
  30. }
  31. if(!isset($_G['cookie']['atarget'])) {
  32. if($_G['setting']['targetblank']) {
  33. dsetcookie('atarget', 1, 2592000);
  34. $_G['cookie']['atarget'] = 1;
  35. }
  36. }
  37. $_G['forum']['name'] = strip_tags($_G['forum']['name']) ? strip_tags($_G['forum']['name']) : $_G['forum']['name'];
  38. $_G['forum']['extra'] = empty($_G['forum']['extra']) ? array() : dunserialize($_G['forum']['extra']);
  39. if(!is_array($_G['forum']['extra'])) {
  40. $_G['forum']['extra'] = array();
  41. }
  42. $threadtable_info = !empty($_G['cache']['threadtable_info']) ? $_G['cache']['threadtable_info'] : array();
  43. $forumarchive = array();
  44. if($_G['forum']['archive']) {
  45. foreach(C::t('forum_forum_threadtable')->fetch_all_by_fid($_G['fid']) as $archive) {
  46. $forumarchive[$archive['threadtableid']] = array(
  47. 'displayname' => dhtmlspecialchars($threadtable_info[$archive['threadtableid']]['displayname']),
  48. 'threads' => $archive['threads'],
  49. 'posts' => $archive['posts'],
  50. );
  51. if(empty($forumarchive[$archive['threadtableid']]['displayname'])) {
  52. $forumarchive[$archive['threadtableid']]['displayname'] = lang('forum/thread', 'forum_archive').' '.$archive['threadtableid'];
  53. }
  54. }
  55. }
  56. $forum_up = $_G['cache']['forums'][$_G['forum']['fup']];
  57. if($_G['forum']['type'] == 'forum') {
  58. $fgroupid = $_G['forum']['fup'];
  59. if(empty($_GET['archiveid'])) {
  60. $navigation = ' <em>&rsaquo;</em> <a href="forum.php?gid='.$forum_up['fid'].'">'.$forum_up['name'].'</a><em>&rsaquo;</em> <a href="forum.php?mod=forumdisplay&fid='.$_G['forum']['fid'].'">'.$_G['forum']['name'].'</a>';
  61. } else {
  62. $navigation = ' <em>&rsaquo;</em> '.'<a href="forum.php?mod=forumdisplay&fid='.$_G['fid'].'">'.$_G['forum']['name'].'</a> <em>&rsaquo;</em> '.$forumarchive[$_GET['archiveid']]['displayname'];
  63. }
  64. $seodata = array('forum' => $_G['forum']['name'], 'fgroup' => $forum_up['name'], 'page' => intval($_GET['page']));
  65. } else {
  66. $fgroupid = $forum_up['fup'];
  67. if(empty($_GET['archiveid'])) {
  68. $forum_top = $_G['cache']['forums'][$forum_up[fup]];
  69. $navigation = ' <em>&rsaquo;</em> <a href="forum.php?gid='.$forum_top['fid'].'">'.$forum_top['name'].'</a><em>&rsaquo;</em> <a href="forum.php?mod=forumdisplay&fid='.$forum_up['fid'].'">'.$forum_up['name'].'</a><em>&rsaquo;</em> '.$_G['forum']['name'];
  70. } else {
  71. $navigation = ' <em>&rsaquo;</em> <a href="forum.php?mod=forumdisplay&fid='.$_G['forum']['fup'].'">'.$forum_up['name'].'</a> <em>&rsaquo;</em> '.'<a href="forum.php?mod=forumdisplay&fid='.$_G['fid'].'">'.$_G['forum']['name'].'</a> <em>&rsaquo;</em> '.$forumarchive[$_GET['archiveid']]['displayname'];
  72. }
  73. $seodata = array('forum' => $_G['forum']['name'], 'fup' => $forum_up['name'], 'fgroup' => $forum_top['name'], 'page' => intval($_GET['page']));
  74. }
  75. $rssauth = $_G['rssauth'];
  76. $rsshead = $_G['setting']['rssstatus'] ? ('<link rel="alternate" type="application/rss+xml" title="'.$_G['setting']['bbname'].' - '.$navtitle.'" href="'.$_G['siteurl'].'forum.php?mod=rss&fid='.$_G['fid'].'&amp;auth='.$rssauth."\" />\n") : '';
  77. $forumseoset = array(
  78. 'seotitle' => $_G['forum']['seotitle'],
  79. 'seokeywords' => $_G['forum']['keywords'],
  80. 'seodescription' => $_G['forum']['seodescription']
  81. );
  82. $seotype = 'threadlist';
  83. if($_G['forum']['status'] == 3) {
  84. $navtitle = helper_seo::get_title_page($_G['forum']['name'], $_G['page']).' - '.$_G['setting']['navs'][3]['navname'];
  85. $metakeywords = $_G['forum']['metakeywords'];
  86. $metadescription = $_G['forum']['description'];
  87. $_G['seokeywords'] = $_G['setting']['seokeywords']['group'];
  88. $_G['seodescription'] = $_G['setting']['seodescription']['group'];
  89. $action = getgpc('action') ? $_GET['action'] : 'list';
  90. require_once libfile('function/group');
  91. $status = groupperm($_G['forum'], $_G['uid']);
  92. if($status == -1) {
  93. showmessage('forum_not_group', 'group.php');
  94. } elseif($status == 1) {
  95. showmessage('forum_group_status_off');
  96. } elseif($status == 2) {
  97. showmessage('forum_group_noallowed', 'forum.php?mod=group&fid='.$_G['fid']);
  98. } elseif($status == 3) {
  99. showmessage('forum_group_moderated', 'forum.php?mod=group&fid='.$_G['fid']);
  100. }
  101. $_G['forum']['icon'] = get_groupimg($_G['forum']['icon'], 'icon');
  102. $_G['grouptypeid'] = $_G['forum']['fup'];
  103. $_G['forum']['dateline'] = dgmdate($_G['forum']['dateline'], 'd');
  104. $nav = get_groupnav($_G['forum']);
  105. $groupnav = $nav['nav'];
  106. $onlinemember = grouponline($_G['fid']);
  107. $groupmanagers = $_G['forum']['moderators'];
  108. $groupcache = getgroupcache($_G['fid'], array('replies', 'views', 'digest', 'lastpost', 'ranking', 'activityuser', 'newuserlist'));
  109. $seotype = 'grouppage';
  110. $seodata['first'] = $nav['first']['name'];
  111. $seodata['second'] = $nav['second']['name'];
  112. $seodata['gdes'] = $_G['forum']['description'];
  113. $forumseoset = array();
  114. }
  115. $_G['forum']['banner'] = get_forumimg($_G['forum']['banner']);
  116. list($navtitle, $metadescription, $metakeywords) = get_seosetting($seotype, $seodata, $forumseoset);
  117. if(!$navtitle) {
  118. $navtitle = helper_seo::get_title_page($_G['forum']['name'], $_G['page']);
  119. $nobbname = false;
  120. } else {
  121. $nobbname = true;
  122. }
  123. if(!empty($_GET['typeid']) && !empty($_G['forum']['threadtypes']['types'][$_GET['typeid']])) {
  124. $navtitle = strip_tags($_G['forum']['threadtypes']['types'][$_GET['typeid']]).' - '.$navtitle;
  125. }
  126. if(!$metakeywords) {
  127. $metakeywords = $_G['forum']['name'];
  128. }
  129. if(!$metadescription) {
  130. $metadescription = $_G['forum']['name'];
  131. }
  132. if($_G['forum']['viewperm'] && !forumperm($_G['forum']['viewperm']) && !$_G['forum']['allowview']) {
  133. showmessagenoperm('viewperm', $_G['fid'], $_G['forum']['formulaperm']);
  134. } elseif($_G['forum']['formulaperm']) {
  135. formulaperm($_G['forum']['formulaperm']);
  136. }
  137. if($_G['forum']['password']) {
  138. if($_GET['action'] == 'pwverify') {
  139. if($_GET['pw'] != $_G['forum']['password']) {
  140. showmessage('forum_passwd_incorrect', NULL);
  141. } else {
  142. dsetcookie('fidpw'.$_G['fid'], $_GET['pw']);
  143. showmessage('forum_passwd_correct', "forum.php?mod=forumdisplay&fid=$_G[fid]");
  144. }
  145. } elseif($_G['forum']['password'] != $_G['cookie']['fidpw'.$_G['fid']]) {
  146. include template('forum/forumdisplay_passwd');
  147. exit();
  148. }
  149. }
  150. if(!isset($_G['cookie']['collapse']) || strpos($_G['cookie']['collapse'], 'forum_rules_'.$_G['fid']) === FALSE) {
  151. $collapse['forum_rules'] = '';
  152. $collapse['forum_rulesimg'] = 'no';
  153. } else {
  154. $collapse['forum_rules'] = 'display: none';
  155. $collapse['forum_rulesimg'] = 'yes';
  156. }
  157. $forumlastvisit = 0;
  158. if(empty($_G['forum']['picstyle']) && isset($_G['cookie']['forum_lastvisit']) && strexists($_G['cookie']['forum_lastvisit'], 'D_'.$_G['fid'])) {
  159. preg_match('/D\_'.$_G['fid'].'\_(\d+)/', $_G['cookie']['forum_lastvisit'], $a);
  160. $forumlastvisit = $a[1];
  161. unset($a);
  162. }
  163. dsetcookie('forum_lastvisit', preg_replace("/D\_".$_G['fid']."\_\d+/", '', $_G['cookie']['forum_lastvisit']).'D_'.$_G['fid'].'_'.TIMESTAMP, 604800);
  164. $threadtableids = !empty($_G['cache']['threadtableids']) ? $_G['cache']['threadtableids'] : array();
  165. $tableid = $_GET['archiveid'] && in_array($_GET['archiveid'], $threadtableids) ? intval($_GET['archiveid']) : 0;
  166. if($_G['setting']['allowmoderatingthread'] && $_G['uid']) {
  167. $threadmodcount = C::t('forum_thread')->count_by_fid_displayorder_authorid($_G['fid'], -2, $_G['uid'], $tableid);
  168. }
  169. $optionadd = $filterurladd = $searchsorton = '';
  170. $quicksearchlist = array();
  171. if(!empty($_G['forum']['threadsorts']['types'])) {
  172. require_once libfile('function/threadsort');
  173. $showpic = intval($_GET['showpic']);
  174. $templatearray = $sortoptionarray = array();
  175. foreach($_G['forum']['threadsorts']['types'] as $stid => $sortname) {
  176. loadcache(array('threadsort_option_'.$stid, 'threadsort_template_'.$stid));
  177. sortthreadsortselectoption($stid);
  178. $templatearray[$stid] = $_G['cache']['threadsort_template_'.$stid]['subject'];
  179. $sortoptionarray[$stid] = $_G['cache']['threadsort_option_'.$stid];
  180. }
  181. if(!empty($_G['forum']['threadsorts']['defaultshow']) && empty($_GET['sortid']) && empty($_GET['sortall'])) {
  182. $_GET['sortid'] = $_G['forum']['threadsorts']['defaultshow'];
  183. $_GET['filter'] = 'sortid';
  184. $_SERVER['QUERY_STRING'] = $_SERVER['QUERY_STRING'] ? $_SERVER['QUERY_STRING'].'&sortid='.$_GET['sortid'] : 'sortid='.$_GET['sortid'];
  185. $filterurladd = '&amp;filter=sort';
  186. }
  187. $_GET['sortid'] = $_GET['sortid'] ? $_GET['sortid'] : $_GET['searchsortid'];
  188. if(isset($_GET['sortid']) && $_G['forum']['threadsorts']['types'][$_GET['sortid']]) {
  189. $searchsortoption = $sortoptionarray[$_GET['sortid']];
  190. $quicksearchlist = quicksearch($searchsortoption);
  191. $_G['forum_optionlist'] = $_G['cache']['threadsort_option_'.$_GET['sortid']];
  192. $forum_optionlist = getsortedoptionlist();
  193. }
  194. }
  195. $moderatedby = $_G['forum']['status'] != 3 ? moddisplay($_G['forum']['moderators'], 'forumdisplay') : '';
  196. $_GET['highlight'] = empty($_GET['highlight']) ? '' : dhtmlspecialchars($_GET['highlight']);
  197. if($_G['forum']['autoclose']) {
  198. $closedby = $_G['forum']['autoclose'] > 0 ? 'dateline' : 'lastpost';
  199. $_G['forum']['autoclose'] = abs($_G['forum']['autoclose']) * 86400;
  200. }
  201. $subexists = 0;
  202. foreach($_G['cache']['forums'] as $sub) {
  203. if($sub['type'] == 'sub' && $sub['fup'] == $_G['fid'] && (!$_G['setting']['hideprivate'] || !$sub['viewperm'] || forumperm($sub['viewperm']) || strstr($sub['users'], "\t$_G[uid]\t"))) {
  204. if(!$sub['status']) {
  205. continue;
  206. }
  207. $subexists = 1;
  208. $sublist = array();
  209. $query = C::t('forum_forum')->fetch_all_info_by_fids(0, 'available', 0, $_G['fid'], 1, 0, 0, 'sub');
  210. if(!empty($_G['member']['accessmasks'])) {
  211. $fids = array_keys($query);
  212. $accesslist = C::t('forum_access')->fetch_all_by_fid_uid($fids, $_G['uid']);
  213. foreach($query as $key => $val) {
  214. $query[$key]['allowview'] = $accesslist[$key];
  215. }
  216. }
  217. foreach($query as $sub) {
  218. $sub['extra'] = dunserialize($sub['extra']);
  219. if(!is_array($sub['extra'])) {
  220. $sub['extra'] = array();
  221. }
  222. if(forum($sub)) {
  223. $sub['orderid'] = count($sublist);
  224. $sublist[] = $sub;
  225. }
  226. }
  227. break;
  228. }
  229. }
  230. if(!empty($_GET['archiveid']) && in_array($_GET['archiveid'], $threadtableids)) {
  231. $subexists = 0;
  232. }
  233. if($subexists) {
  234. if($_G['forum']['forumcolumns']) {
  235. $_G['forum']['forumcolwidth'] = (floor(100 / $_G['forum']['forumcolumns']) - 0.1).'%';
  236. $_G['forum']['subscount'] = count($sublist);
  237. $_G['forum']['endrows'] = '';
  238. if($colspan = $_G['forum']['subscount'] % $_G['forum']['forumcolumns']) {
  239. while(($_G['forum']['forumcolumns'] - $colspan) > 0) {
  240. $_G['forum']['endrows'] .= '<td>&nbsp;</td>';
  241. $colspan ++;
  242. }
  243. $_G['forum']['endrows'] .= '</tr>';
  244. }
  245. }
  246. if(empty($_G['cookie']['collapse']) || strpos($_G['cookie']['collapse'], 'subforum_'.$_G['fid']) === FALSE) {
  247. $collapse['subforum'] = '';
  248. $collapseimg['subforum'] = 'collapsed_no.gif';
  249. } else {
  250. $collapse['subforum'] = 'display: none';
  251. $collapseimg['subforum'] = 'collapsed_yes.gif';
  252. }
  253. }
  254. $page = $_G['page'];
  255. $subforumonly = $_G['forum']['simple'] & 1;
  256. $simplestyle = !$_G['forum']['allowside'] || $page > 1 ? true : false;
  257. if($subforumonly) {
  258. $_G['setting']['fastpost'] = false;
  259. $_GET['orderby'] = '';
  260. if(!defined('IN_ARCHIVER')) {
  261. include template('diy:forum/forumdisplay:'.$_G['fid']);
  262. } else {
  263. include loadarchiver('forum/forumdisplay');
  264. }
  265. exit();
  266. }
  267. $page = $_G['setting']['threadmaxpages'] && $page > $_G['setting']['threadmaxpages'] ? 1 : $page;
  268. if($_G['forum']['modrecommend'] && $_G['forum']['modrecommend']['open']) {
  269. $_G['forum']['recommendlist'] = recommendupdate($_G['fid'], $_G['forum']['modrecommend'], '', 1);
  270. }
  271. $recommendgroups = array();
  272. if($_G['forum']['status'] != 3 && helper_access::check_module('group')) {
  273. loadcache('forumrecommend');
  274. $recommendgroups = $_G['cache']['forumrecommend'][$_G['fid']];
  275. }
  276. if($recommendgroups) {
  277. if(empty($_G['cookie']['collapse']) || strpos($_G['cookie']['collapse'], 'recommendgroups_'.$_G['fid']) === FALSE) {
  278. $collapse['recommendgroups'] = '';
  279. $collapseimg['recommendgroups'] = 'collapsed_no.gif';
  280. } else {
  281. $collapse['recommendgroups'] = 'display: none';
  282. $collapseimg['recommendgroups'] = 'collapsed_yes.gif';
  283. }
  284. }
  285. if(!$simplestyle || !$_G['forum']['allowside'] && $page == 1) {
  286. if($_G['cache']['announcements_forum'] && (!$_G['cache']['announcements_forum']['endtime'] || $_G['cache']['announcements_forum']['endtime'] > TIMESTAMP)) {
  287. $announcement = $_G['cache']['announcements_forum'];
  288. $announcement['starttime'] = dgmdate($announcement['starttime'], 'd');
  289. } else {
  290. $announcement = NULL;
  291. }
  292. }
  293. $filteradd = $sortoptionurl = $sp = '';
  294. $sorturladdarray = $selectadd = array();
  295. $forumdisplayadd = array('orderby' => '');
  296. $specialtype = array('poll' => 1, 'trade' => 2, 'reward' => 3, 'activity' => 4, 'debate' => 5);
  297. $filterfield = array('digest', 'recommend', 'sortall', 'typeid', 'sortid', 'dateline', 'page', 'orderby', 'specialtype', 'author', 'view', 'reply', 'lastpost');
  298. foreach($filterfield as $v) {
  299. $forumdisplayadd[$v] = '';
  300. }
  301. $filter = isset($_GET['filter']) && in_array($_GET['filter'], $filterfield) ? $_GET['filter'] : '';
  302. $filterarr = $multiadd = array();
  303. if($filter) {
  304. if($query_string = $_SERVER['QUERY_STRING']) {
  305. $query_string = substr($query_string, (strpos($query_string, "&") + 1));
  306. parse_str($query_string, $geturl);
  307. $geturl = daddslashes($geturl, 1);
  308. if($geturl && is_array($geturl)) {
  309. $issort = isset($_GET['sortid']) && isset($_G['forum']['threadsorts']['types'][$_GET['sortid']]) && $quicksearchlist ? TRUE : FALSE;
  310. $selectadd = $issort ? $geturl : array();
  311. foreach($filterfield as $option) {
  312. foreach($geturl as $field => $value) {
  313. if(in_array($field, $filterfield) && $option != $field && $field != 'page' && ($field != 'orderby' || !in_array($option, array('author', 'reply', 'view', 'lastpost', 'heat')))) {
  314. if(!(in_array($option, array('digest', 'recommend')) && in_array($field, array('digest', 'recommend')))) {
  315. $forumdisplayadd[$option] .= '&'.$field.'='.rawurlencode($value);
  316. }
  317. }
  318. }
  319. if($issort) {
  320. $sfilterfield = array_merge(array('filter', 'sortid', 'orderby', 'fid'), $filterfield);
  321. foreach($geturl as $soption => $value) {
  322. $forumdisplayadd[$soption] .= !in_array($soption, $sfilterfield) ? "&$soption=".rawurlencode($value) : '';
  323. }
  324. }
  325. }
  326. if($issort && is_array($quicksearchlist)) {
  327. foreach($quicksearchlist as $option) {
  328. $identifier = $option['identifier'];
  329. foreach($geturl as $option => $value) {
  330. $sorturladdarray[$identifier] .= !in_array($option, array('filter', 'sortid', 'orderby', 'fid', 'searchsort', $identifier)) ? "&amp;$option=$value" : '';
  331. }
  332. }
  333. }
  334. foreach($geturl as $field => $value) {
  335. if($field != 'page' && $field != 'fid' && $field != 'searchoption') {
  336. $multiadd[] = $field.'='.rawurlencode($value);
  337. if(in_array($field, $filterfield)) {
  338. $filteradd .= $sp;
  339. if($field == 'digest') {
  340. $filteradd .= "AND digest>'0'";
  341. $filterarr['digest'] = 1;
  342. } elseif($field == 'recommend') {
  343. $filteradd .= "AND recommends>'".intval($_G['setting']['recommendthread']['iconlevels'][0])."'";
  344. $filterarr['recommends'] = intval($_G['setting']['recommendthread']['iconlevels'][0]);
  345. } elseif($field == 'specialtype') {
  346. $filteradd .= "AND special='$specialtype[$value]'";
  347. $filterarr['special'] = $specialtype[$value];
  348. $filterarr['specialthread'] = 1;
  349. if($value == 'reward') {
  350. if($_GET['rewardtype'] == 1) {
  351. $filteradd .= "AND price>0";
  352. $filterarr['pricemore'] = 0;
  353. } elseif($_GET['rewardtype'] == 2) {
  354. $filteradd .= "AND price<0";
  355. $filterarr['pricesless'] = 0;
  356. }
  357. }
  358. } elseif($field == 'dateline') {
  359. $filteradd .= $value ? "AND lastpost>='".(TIMESTAMP - $value)."'" : '';
  360. if($value) {
  361. $filterarr['lastpostmore'] = TIMESTAMP - $value;
  362. }
  363. } elseif($field == 'typeid' || $field == 'sortid') {
  364. $filteradd .= "AND $field='$value'";
  365. $fieldstr = $field == 'typeid' ? 'intype' : 'insort';
  366. $filterarr[$fieldstr] = $value;
  367. }
  368. $sp = ' ';
  369. }
  370. }
  371. }
  372. }
  373. }
  374. $simplestyle = true;
  375. }
  376. if(!empty($_GET['orderby']) && !$_G['setting']['closeforumorderby'] && in_array($_GET['orderby'], array('lastpost', 'dateline', 'replies', 'views', 'recommends', 'heats'))) {
  377. $forumdisplayadd['orderby'] .= '&orderby='.$_GET['orderby'];
  378. } else {
  379. $_GET['orderby'] = isset($_G['cache']['forums'][$_G['fid']]['orderby']) ? $_G['cache']['forums'][$_G['fid']]['orderby'] : 'lastpost';
  380. }
  381. $_GET['ascdesc'] = isset($_G['cache']['forums'][$_G['fid']]['ascdesc']) ? $_G['cache']['forums'][$_G['fid']]['ascdesc'] : 'DESC';
  382. $check = array();
  383. $check[$filter] = $check[$_GET['orderby']] = $check[$_GET['ascdesc']] = 'selected="selected"';
  384. if(($_G['forum']['status'] != 3 && $_G['forum']['allowside']) || !empty($_G['forum']['threadsorts']['templatelist'])) {
  385. updatesession();
  386. $onlinenum = C::app()->session->count_by_fid($_G['fid']);
  387. if(!IS_ROBOT && ($_G['setting']['whosonlinestatus'] == 2 || $_G['setting']['whosonlinestatus'] == 3)) {
  388. $_G['setting']['whosonlinestatus'] = 1;
  389. $detailstatus = $showoldetails == 'yes' || (((!isset($_G['cookie']['onlineforum']) && !$_G['setting']['whosonline_contract']) || $_G['cookie']['onlineforum']) && !$showoldetails);
  390. if($detailstatus) {
  391. $actioncode = lang('forum/action');
  392. $whosonline = array();
  393. $forumname = strip_tags($_G['forum']['name']);
  394. $whosonline = C::app()->session->fetch_all_by_fid($_G['fid'], 12);
  395. $_G['setting']['whosonlinestatus'] = 1;
  396. }
  397. } else {
  398. $_G['setting']['whosonlinestatus'] = 0;
  399. }
  400. }
  401. if($_G['forum']['threadsorts']['types'] && $sortoptionarray && ($_GET['searchoption'] || $_GET['searchsort'])) {
  402. $sortid = intval($_GET['sortid']);
  403. if($_GET['searchoption']){
  404. $forumdisplayadd['page'] = '&sortid='.$sortid;
  405. foreach($_GET['searchoption'] as $optionid => $option) {
  406. $optionid = intval($optionid);
  407. $searchoption = '';
  408. if(is_array($option['value'])) {
  409. foreach($option['value'] as $v) {
  410. $v = rawurlencode((string)$v);
  411. $searchoption .= "&searchoption[$optionid][value][$v]=$v";
  412. }
  413. } else {
  414. $option['value'] = rawurlencode((string)$option['value']);
  415. $option['value'] && $searchoption = "&searchoption[$optionid][value]=$option[value]";
  416. }
  417. $option['type'] = rawurlencode((string)$option['type']);
  418. $identifier = $sortoptionarray[$sortid][$optionid]['identifier'];
  419. $forumdisplayadd['page'] .= $searchoption ? "$searchoption&searchoption[$optionid][type]=$option[type]" : '';
  420. }
  421. }
  422. $searchsorttids = sortsearch($_GET['sortid'], $sortoptionarray, $_GET['searchoption'], $selectadd, $_G['fid']);
  423. $filteradd .= "AND t.tid IN (".dimplode($searchsorttids).")";
  424. $filterarr['intids'] = $searchsorttids ? $searchsorttids : array(0);
  425. }
  426. if(isset($_GET['searchoption'])) {
  427. $_GET['searchoption'] = dhtmlspecialchars($_GET['searchoption']);
  428. }
  429. if($_G['forum']['relatedgroup']) {
  430. $relatedgroup = explode(',', $_G['forum']['relatedgroup']);
  431. $relatedgroup[] = $_G['fid'];
  432. $filterarr['inforum'] = $relatedgroup;
  433. } else {
  434. $filterarr['inforum'] = $_G['fid'];
  435. }
  436. if(empty($filter) && empty($_GET['sortid']) && empty($_G['forum']['relatedgroup'])) {
  437. if($forumarchive) {
  438. if($_GET['archiveid']) {
  439. $_G['forum_threadcount'] = $forumarchive[$_GET['archiveid']]['threads'];
  440. } else {
  441. $primarytabthreads = $_G['forum']['threads'];
  442. foreach($forumarchive as $arcid => $avalue) {
  443. if($arcid) {
  444. $primarytabthreads = $primarytabthreads - $avalue['threads'];
  445. }
  446. }
  447. $_G['forum_threadcount'] = $primarytabthreads;
  448. }
  449. } else {
  450. $_G['forum_threadcount'] = $_G['forum']['threads'];
  451. }
  452. } else {
  453. $filterarr['sticky'] = 0;
  454. $_G['forum_threadcount'] = C::t('forum_thread')->count_search($filterarr, $tableid);
  455. }
  456. $thisgid = $_G['forum']['type'] == 'forum' ? $_G['forum']['fup'] : (!empty($_G['cache']['forums'][$_G['forum']['fup']]['fup']) ? $_G['cache']['forums'][$_G['forum']['fup']]['fup'] : 0);
  457. $forumstickycount = $stickycount = 0;
  458. $stickytids = '';
  459. if($_G['setting']['globalstick'] && $_G['forum']['allowglobalstick']) {
  460. $stickytids = explode(',', str_replace("'", '', $_G['cache']['globalstick']['global']['tids']));
  461. if(!empty($_G['cache']['globalstick']['categories'][$thisgid]['count'])) {
  462. $stickytids = array_merge($stickytids, explode(',', str_replace("'", '', $_G['cache']['globalstick']['categories'][$thisgid]['tids'])));
  463. }
  464. if($_G['forum']['status'] != 3) {
  465. $stickycount = $_G['cache']['globalstick']['global']['count'];
  466. if(!empty($_G['cache']['globalstick']['categories'][$thisgid])) {
  467. $stickycount += $_G['cache']['globalstick']['categories'][$thisgid]['count'];
  468. }
  469. }
  470. }
  471. $forumstickytids = array();
  472. if($_G['forum']['allowglobalstick']) {
  473. $forumstickycount = 0;
  474. $forumstickfid = $_G['forum']['status'] != 3 ? $_G['fid'] : $_G['forum']['fup'];
  475. if(isset($_G['cache']['forumstick'][$forumstickfid])) {
  476. $forumstickycount = count($_G['cache']['forumstick'][$forumstickfid]);
  477. $forumstickytids = $_G['cache']['forumstick'][$forumstickfid];
  478. }
  479. if(!empty($forumstickytids)) {
  480. $stickytids = array_merge($stickytids, $forumstickytids);
  481. }
  482. $stickycount += $forumstickycount;
  483. }
  484. if($_G['forum']['picstyle']) {
  485. $forumdefstyle = isset($_GET['forumdefstyle']) ? $_GET['forumdefstyle'] : '';
  486. if($forumdefstyle) {
  487. switch($forumdefstyle) {
  488. case 'no': dsetcookie('forumdefstyle', ''); break;
  489. case 'yes': dsetcookie('forumdefstyle', 1, 31536000); break;
  490. }
  491. }
  492. if(empty($_G['cookie']['forumdefstyle'])) {
  493. if(!empty($_G['setting']['forumpicstyle']['thumbnum'])) {
  494. $_G['tpp'] = $_G['setting']['forumpicstyle']['thumbnum'];
  495. }
  496. $stickycount = 0;
  497. }
  498. }
  499. $filterbool = !empty($filter) && in_array($filter, $filterfield);
  500. $_G['forum_threadcount'] += $filterbool ? 0 : $stickycount;
  501. if(@ceil($_G['forum_threadcount']/$_G['tpp']) < $page) {
  502. $page = 1;
  503. }
  504. $start_limit = ($page - 1) * $_G['tpp'];
  505. $forumdisplayadd['page'] = !empty($forumdisplayadd['page']) ? $forumdisplayadd['page'] : '';
  506. $multipage_archive = $_GET['archiveid'] && in_array($_GET['archiveid'], $threadtableids) ? "&archiveid={$_GET['archiveid']}" : '';
  507. $multipage = multi($_G['forum_threadcount'], $_G['tpp'], $page, "forum.php?mod=forumdisplay&fid=$_G[fid]".$forumdisplayadd['page'].($multiadd ? '&'.implode('&', $multiadd) : '')."$multipage_archive", $_G['setting']['threadmaxpages']);
  508. $extra = rawurlencode(!IS_ROBOT ? 'page='.$page.($forumdisplayadd['page'] ? '&filter='.$filter.$forumdisplayadd['page'] : '').($forumdisplayadd['orderby'] ? $forumdisplayadd['orderby'] : '') : 'page=1');
  509. $separatepos = 0;
  510. $_G['forum_threadlist'] = $threadids = array();
  511. $_G['forum_colorarray'] = array('', '#EE1B2E', '#EE5023', '#996600', '#3C9D40', '#2897C5', '#2B65B7', '#8F2A90', '#EC1282');
  512. $displayorderadd = !$filterbool && $stickycount ? 't.displayorder IN (0, 1)' : 't.displayorder IN (0, 1, 2, 3, 4)';
  513. $filterarr['sticky'] = 4;
  514. $filterarr['displayorder'] = !$filterbool && $stickycount ? array(0, 1) : array(0, 1, 2, 3, 4);
  515. if(($start_limit && $start_limit > $stickycount) || !$stickycount || $filterbool) {
  516. $indexadd = '';
  517. if(strexists($filteradd, "t.digest>'0'")) {
  518. $indexadd = " FORCE INDEX (digest) ";
  519. }
  520. $querysticky = '';
  521. $start = $filterbool ? $start_limit : $start_limit - $stickycount;
  522. $threadlist = C::t('forum_thread')->fetch_all_search($filterarr, $tableid, $start, $_G['tpp'], "displayorder DESC, $_GET[orderby] $_GET[ascdesc]", '', $indexadd);
  523. } else {
  524. $filterarr1 = $filterarr;
  525. $filterarr1['inforum'] = '';
  526. $filterarr1['intids'] = $stickytids;
  527. $limit = $stickycount - $start_limit < $_G['tpp'] ? $stickycount - $start_limit : $_G['tpp'];
  528. $filterarr1['displayorder'] = array(2, 3, 4);
  529. $threadlist = C::t('forum_thread')->fetch_all_search($filterarr1, $tableid, $start_limit, $limit, "displayorder DESC,$_GET[orderby] $_GET[ascdesc]", '');
  530. if($_G['tpp'] - $stickycount + $start_limit > 0) {
  531. $limit = $_G['tpp'] - $stickycount + $start_limit;
  532. $otherthread = C::t('forum_thread')->fetch_all_search($filterarr, $tableid, 0, $limit, "displayorder DESC, $_GET[orderby] $_GET[ascdesc]", '');
  533. $threadlist = array_merge($threadlist, $otherthread);
  534. unset($otherthread);
  535. } else {
  536. $query = '';
  537. }
  538. }
  539. if(empty($threadlist) && $page <= ceil($_G['forum_threadcount'] / $_G['tpp'])) {
  540. require_once libfile('function/post');
  541. updateforumcount($_G['fid']);
  542. }
  543. $_G['ppp'] = $_G['forum']['threadcaches'] && !$_G['uid'] ? $_G['setting']['postperpage'] : $_G['ppp'];
  544. $page = $_G['page'];
  545. $todaytime = strtotime(dgmdate(TIMESTAMP, 'Ymd'));
  546. $verify = $verifyuids = $grouptids = array();
  547. $threadindex = 0;
  548. foreach($threadlist as $thread) {
  549. $thread['ordertype'] = getstatus($thread['status'], 4);
  550. if($_G['forum']['picstyle'] && empty($_G['cookie']['forumdefstyle'])) {
  551. if($thread['fid'] != $_G['fid'] && empty($thread['cover'])) {
  552. continue;
  553. }
  554. $thread['coverpath'] = getthreadcover($thread['tid'], $thread['cover']);
  555. $thread['cover'] = abs($thread['cover']);
  556. }
  557. $thread['forumstick'] = in_array($thread['tid'], $forumstickytids);
  558. $thread['related_group'] = 0;
  559. if($_G['forum']['relatedgroup'] && $thread['fid'] != $_G['fid']) {
  560. if($thread['closed'] > 1) continue;
  561. $thread['related_group'] = 1;
  562. $grouptids[] = $thread['tid'];
  563. }
  564. $thread['lastposterenc'] = rawurlencode($thread['lastposter']);
  565. if($thread['typeid'] && !empty($_G['forum']['threadtypes']['prefix']) && isset($_G['forum']['threadtypes']['types'][$thread['typeid']])) {
  566. if($_G['forum']['threadtypes']['prefix'] == 1) {
  567. $thread['typehtml'] = '<em>[<a href="forum.php?mod=forumdisplay&fid='.$_G['fid'].'&amp;filter=typeid&amp;typeid='.$thread['typeid'].'">'.$_G['forum']['threadtypes']['types'][$thread['typeid']].'</a>]</em>';
  568. } elseif($_G['forum']['threadtypes']['icons'][$thread['typeid']] && $_G['forum']['threadtypes']['prefix'] == 2) {
  569. $thread['typehtml'] = '<em><a title="'.$_G['forum']['threadtypes']['types'][$thread['typeid']].'" href="forum.php?mod=forumdisplay&fid='.$_G['fid'].'&amp;filter=typeid&amp;typeid='.$thread['typeid'].'">'.'<img style="vertical-align: middle;padding-right:4px;" src="'.$_G['forum']['threadtypes']['icons'][$thread['typeid']].'" alt="'.$_G['forum']['threadtypes']['types'][$thread['typeid']].'" /></a></em>';
  570. }
  571. $thread['typename'] = $_G['forum']['threadtypes']['types'][$thread['typeid']];
  572. } else {
  573. $thread['typename'] = $thread['typehtml'] = '';
  574. }
  575. $thread['sorthtml'] = $thread['sortid'] && !empty($_G['forum']['threadsorts']['prefix']) && isset($_G['forum']['threadsorts']['types'][$thread['sortid']]) ?
  576. '<em>[<a href="forum.php?mod=forumdisplay&fid='.$_G['fid'].'&amp;filter=sortid&amp;sortid='.$thread['sortid'].'">'.$_G['forum']['threadsorts']['types'][$thread['sortid']].'</a>]</em>' : '';
  577. $thread['multipage'] = '';
  578. $topicposts = $thread['special'] ? $thread['replies'] : $thread['replies'] + 1;
  579. $multipate_archive = $_GET['archiveid'] && in_array($_GET['archiveid'], $threadtableids) ? "archiveid={$_GET['archiveid']}" : '';
  580. if($topicposts > $_G['ppp']) {
  581. $pagelinks = '';
  582. $thread['pages'] = ceil($topicposts / $_G['ppp']);
  583. $realtid = $_G['forum']['status'] != 3 && $thread['isgroup'] == 1 ? $thread['closed'] : $thread['tid'];
  584. for($i = 2; $i <= 6 && $i <= $thread['pages']; $i++) {
  585. $pagelinks .= "<a href=\"forum.php?mod=viewthread&tid=$realtid&amp;".(!empty($multipate_archive) ? "$multipate_archive&amp;" : '')."extra=$extra&amp;page=$i\">$i</a>";
  586. }
  587. if($thread['pages'] > 6) {
  588. $pagelinks .= "..<a href=\"forum.php?mod=viewthread&tid=$realtid&amp;".(!empty($multipate_archive) ? "$multipate_archive&amp;" : '')."extra=$extra&amp;page=$thread[pages]\">$thread[pages]</a>";
  589. }
  590. $thread['multipage'] = '&nbsp;...'.$pagelinks;
  591. }
  592. if($thread['highlight']) {
  593. $string = sprintf('%02d', $thread['highlight']);
  594. $stylestr = sprintf('%03b', $string[0]);
  595. $thread['highlight'] = ' style="';
  596. $thread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';
  597. $thread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';
  598. $thread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';
  599. $thread['highlight'] .= $string[1] ? 'color: '.$_G['forum_colorarray'][$string[1]] : '';
  600. $thread['highlight'] .= '"';
  601. } else {
  602. $thread['highlight'] = '';
  603. }
  604. $thread['recommendicon'] = '';
  605. if(!empty($_G['setting']['recommendthread']['status']) && $thread['recommends']) {
  606. foreach($_G['setting']['recommendthread']['iconlevels'] as $k => $i) {
  607. if($thread['recommends'] > $i) {
  608. $thread['recommendicon'] = $k+1;
  609. break;
  610. }
  611. }
  612. }
  613. $thread['moved'] = $thread['heatlevel'] = $thread['new'] = 0;
  614. if($_G['forum']['status'] != 3 && ($thread['closed'] || ($_G['forum']['autoclose'] && $thread['fid'] == $_G['fid'] && TIMESTAMP - $thread[$closedby] > $_G['forum']['autoclose']))) {
  615. if($thread['isgroup'] == 1) {
  616. $thread['folder'] = 'common';
  617. $grouptids[] = $thread['closed'];
  618. } else {
  619. if($thread['closed'] > 1) {
  620. $thread['moved'] = $thread['tid'];
  621. $thread['replies'] = '-';
  622. $thread['views'] = '-';
  623. }
  624. $thread['folder'] = 'lock';
  625. }
  626. } elseif($_G['forum']['status'] == 3 && $thread['closed'] == 1) {
  627. $thread['folder'] = 'lock';
  628. } else {
  629. $thread['folder'] = 'common';
  630. $thread['weeknew'] = TIMESTAMP - 604800 <= $thread['dbdateline'];
  631. if($thread['replies'] > $thread['views']) {
  632. $thread['views'] = $thread['replies'];
  633. }
  634. if($_G['setting']['heatthread']['iconlevels']) {
  635. foreach($_G['setting']['heatthread']['iconlevels'] as $k => $i) {
  636. if($thread['heats'] > $i) {
  637. $thread['heatlevel'] = $k + 1;
  638. break;
  639. }
  640. }
  641. }
  642. }
  643. $thread['icontid'] = $thread['forumstick'] || !$thread['moved'] && $thread['isgroup'] != 1 ? $thread['tid'] : $thread['closed'];
  644. if(!$thread['forumstick'] && ($thread['isgroup'] == 1 || $thread['fid'] != $_G['fid'])) {
  645. $thread['icontid'] = $thread['closed'] > 1 ? $thread['closed'] : $thread['tid'];
  646. }
  647. $thread['istoday'] = $thread['dateline'] > $todaytime ? 1 : 0;
  648. $thread['dbdateline'] = $thread['dateline'];
  649. $thread['dateline'] = dgmdate($thread['dateline'], 'u', '9999', getglobal('setting/dateformat'));
  650. $thread['dblastpost'] = $thread['lastpost'];
  651. $thread['lastpost'] = dgmdate($thread['lastpost'], 'u');
  652. if(in_array($thread['displayorder'], array(1, 2, 3, 4))) {
  653. $thread['id'] = 'stickthread_'.$thread['tid'];
  654. $separatepos++;
  655. } else {
  656. $thread['id'] = 'normalthread_'.$thread['tid'];
  657. if($thread['folder'] == 'common' && $thread['dblastpost'] >= $forumlastvisit || !$forumlastvisit) {
  658. $thread['new'] = 1;
  659. $thread['folder'] = 'new';
  660. $thread['weeknew'] = TIMESTAMP - 604800 <= $thread['dbdateline'];
  661. }
  662. }
  663. if(isset($_G['setting']['verify']['enabled']) && $_G['setting']['verify']['enabled']) {
  664. $verifyuids[$thread['authorid']] = $thread['authorid'];
  665. }
  666. $thread['mobile'] = base_convert(getstatus($thread['status'], 13).getstatus($thread['status'], 12).getstatus($thread['status'], 11), 2, 10);
  667. $thread['rushreply'] = getstatus($thread['status'], 3);
  668. $threadids[$threadindex] = $thread['tid'];
  669. $_G['forum_threadlist'][$threadindex] = $thread;
  670. $threadindex++;
  671. }
  672. if(!empty($threadids)) {
  673. $indexlist = array_flip($threadids);
  674. foreach(C::t('forum_threadaddviews')->fetch_all($threadids) as $tidkey => $value) {
  675. $index = $indexlist[$tidkey];
  676. $threadlist[$index]['views'] += $value['addviews'];
  677. $_G['forum_threadlist'][$index]['views'] += $value['addviews'];
  678. }
  679. }
  680. if($_G['setting']['verify']['enabled'] && $verifyuids) {
  681. foreach(C::t('common_member_verify')->fetch_all($verifyuids) as $value) {
  682. foreach($_G['setting']['verify'] as $vid => $vsetting) {
  683. if($vsetting['available'] && $vsetting['showicon'] && $value['verify'.$vid] == 1) {
  684. $srcurl = '';
  685. if(!empty($vsetting['icon'])) {
  686. $srcurl = $vsetting['icon'];
  687. }
  688. $verify[$value['uid']] .= "<a href=\"home.php?mod=spacecp&ac=profile&op=verify&vid=$vid\" target=\"_blank\">".(!empty($srcurl) ? '<img src="'.$srcurl.'" class="vm" alt="'.$vsetting['title'].'" title="'.$vsetting['title'].'" />' : $vsetting['title']).'</a>';
  689. }
  690. }
  691. }
  692. }
  693. $_G['forum_threadnum'] = count($_G['forum_threadlist']) - $separatepos;
  694. if(!empty($grouptids)) {
  695. $groupfids = array();
  696. foreach(C::t('forum_thread')->fetch_all_by_tid($grouptids) as $row) {
  697. $groupnames[$row['tid']]['fid'] = $row['fid'];
  698. $groupnames[$row['tid']]['views'] = $row['views'];
  699. $groupfids[] = $row['fid'];
  700. }
  701. $forumsinfo = C::t('forum_forum')->fetch_all($groupfids);
  702. foreach($groupnames as $gtid => $value) {
  703. $gfid = $groupnames[$gtid]['fid'];
  704. $groupnames[$gtid]['name'] = $forumsinfo[$gfid]['name'];
  705. }
  706. }
  707. $stemplate = null;
  708. if($_G['forum']['threadsorts']['types'] && $sortoptionarray && $templatearray && $threadids) {
  709. $sortid = intval($_GET['sortid']);
  710. if(!strexists($templatearray[$sortid], '{subject_url}') && !strexists($templatearray[$sortid], '{tid}')) {
  711. $sortlistarray = showsorttemplate($sortid, $_G['fid'], $sortoptionarray, $templatearray, $_G['forum_threadlist'], $threadids);
  712. $stemplate = $sortlistarray['template'];
  713. } else {
  714. $sorttemplate = showsortmodetemplate($sortid, $_G['fid'], $sortoptionarray, $templatearray, $_G['forum_threadlist'], $threadids, $verify);
  715. $_G['forum']['sortmode'] = 1;
  716. }
  717. if(($_GET['searchoption'] || $_GET['searchsort']) && empty($searchsorttids)) {
  718. $_G['forum_threadlist'] = $multipage = '';
  719. }
  720. }
  721. $separatepos = $separatepos ? $separatepos + 1 : 0;
  722. $_G['setting']['visitedforums'] = $_G['setting']['visitedforums'] && $_G['forum']['status'] != 3 ? visitedforums() : '';
  723. $_G['group']['allowpost'] = (!$_G['forum']['postperm'] && $_G['group']['allowpost']) || ($_G['forum']['postperm'] && forumperm($_G['forum']['postperm'])) || (isset($_G['forum']['allowpost']) && $_G['forum']['allowpost'] == 1 && $_G['group']['allowpost']);
  724. $fastpost = $_G['setting']['fastpost'] && !$_G['forum']['allowspecialonly'] && !$_G['forum']['threadsorts']['required'] && !$_G['forum']['picstyle'];
  725. $allowfastpost = $fastpost && $_G['group']['allowpost'];
  726. $_G['group']['allowpost'] = isset($_G['forum']['allowpost']) && $_G['forum']['allowpost'] == -1 ? false : $_G['group']['allowpost'];
  727. $_G['forum']['allowpostattach'] = isset($_G['forum']['allowpostattach']) ? $_G['forum']['allowpostattach'] : '';
  728. $allowpostattach = $fastpost && ($_G['forum']['allowpostattach'] != -1 && ($_G['forum']['allowpostattach'] == 1 || (!$_G['forum']['postattachperm'] && $_G['group']['allowpostattach']) || ($_G['forum']['postattachperm'] && forumperm($_G['forum']['postattachperm']))));
  729. if($fastpost) {
  730. if(!$_G['adminid'] && (!cknewuser(1) || $_G['setting']['newbiespan'] && (!getuserprofile('lastpost') || TIMESTAMP - getuserprofile('lastpost') < $_G['setting']['newbiespan'] * 60) && TIMESTAMP - $_G['member']['regdate'] < $_G['setting']['newbiespan'] * 60)) {
  731. $allowfastpost = false;
  732. }
  733. $usesigcheck = $_G['uid'] && $_G['group']['maxsigsize'];
  734. $seccodecheck = ($_G['setting']['seccodestatus'] & 4) && (!$_G['setting']['seccodedata']['minposts'] || getuserprofile('posts') < $_G['setting']['seccodedata']['minposts']);
  735. $secqaacheck = $_G['setting']['secqaa']['status'] & 2 && (!$_G['setting']['secqaa']['minposts'] || getuserprofile('posts') < $_G['setting']['secqaa']['minposts']);
  736. } elseif(!$_G['uid']) {
  737. $fastpostdisabled = true;
  738. }
  739. $showpoll = $showtrade = $showreward = $showactivity = $showdebate = 0;
  740. if($_G['forum']['allowpostspecial']) {
  741. $showpoll = $_G['forum']['allowpostspecial'] & 1;
  742. $showtrade = $_G['forum']['allowpostspecial'] & 2;
  743. $showreward = isset($_G['setting']['extcredits'][$_G['setting']['creditstransextra'][2]]) && ($_G['forum']['allowpostspecial'] & 4);
  744. $showactivity = $_G['forum']['allowpostspecial'] & 8;
  745. $showdebate = $_G['forum']['allowpostspecial'] & 16;
  746. }
  747. if($_G['group']['allowpost']) {
  748. $_G['group']['allowpostpoll'] = $_G['group']['allowpostpoll'] && $showpoll;
  749. $_G['group']['allowposttrade'] = $_G['group']['allowposttrade'] && $showtrade;
  750. $_G['group']['allowpostreward'] = $_G['group']['allowpostreward'] && $showreward;
  751. $_G['group']['allowpostactivity'] = $_G['group']['allowpostactivity'] && $showactivity;
  752. $_G['group']['allowpostdebate'] = $_G['group']['allowpostdebate'] && $showdebate;
  753. }
  754. $_G['forum']['threadplugin'] = $_G['group']['allowpost'] && $_G['setting']['threadplugins'] ? dunserialize($_G['forum']['threadplugin']) : array();
  755. $allowleftside = !$subforumonly && $_G['setting']['leftsidewidth'] && !$_G['forum']['allowside'];
  756. if(isset($_GET['leftsidestatus'])) {
  757. dsetcookie('disableleftside', $_GET['leftsidestatus'], 2592000);
  758. $_G['cookie']['disableleftside'] = $_GET['leftsidestatus'];
  759. }
  760. $leftside = empty($_G['cookie']['disableleftside']) && $allowleftside ? forumleftside() : array();
  761. $leftsideswitch = $allowleftside ? "forum.php?mod=forumdisplay&fid=$_G[fid]&page=$page".($multiadd ? '&'.implode('&', $multiadd) : '') : '';
  762. require_once libfile('function/upload');
  763. $swfconfig = getuploadconfig($_G['uid'], $_G['fid']);
  764. $template = 'diy:forum/forumdisplay:'.$_G['fid'];
  765. if(!empty($_G['forum']['threadsorts']['templatelist']) && $_G['forum']['status'] != 3) {
  766. $template = 'diy:forum/forumdisplay_'.$_G['forum']['threadsorts']['templatelist'].':'.$_G['fid'];
  767. } elseif($_G['forum']['status'] == 3) {
  768. $groupviewed_list = get_viewedgroup();
  769. write_groupviewed($_G['fid']);
  770. $template = 'diy:group/group:'.$_G['fid'];
  771. }
  772. if(!defined('IN_ARCHIVER')) {
  773. include template($template);
  774. } else {
  775. include loadarchiver('forum/forumdisplay');
  776. }
  777. ?>