PageRenderTime 61ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/source/module/forum/forum_forumdisplay.php

https://github.com/jinbo51/DiscuzX
PHP | 967 lines | 947 code | 14 blank | 6 comment | 18 complexity | 368c1619e65983d03f7afa3fd5a53440 MD5 | raw file
Possible License(s): BSD-3-Clause
  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 33431 2013-06-13 07:05:28Z andyzheng $
  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. if($_G['forum']['level'] == -1) {
  88. showmessage('group_verify', '', array(), array('alert' => 'info'));
  89. }
  90. $_G['seokeywords'] = $_G['setting']['seokeywords']['group'];
  91. $_G['seodescription'] = $_G['setting']['seodescription']['group'];
  92. $action = getgpc('action') ? $_GET['action'] : 'list';
  93. require_once libfile('function/group');
  94. $status = groupperm($_G['forum'], $_G['uid']);
  95. if($status == -1) {
  96. showmessage('forum_not_group', 'group.php');
  97. } elseif($status == 1) {
  98. showmessage('forum_group_status_off');
  99. } elseif($status == 2) {
  100. showmessage('forum_group_noallowed', 'forum.php?mod=group&fid='.$_G['fid']);
  101. } elseif($status == 3) {
  102. showmessage('forum_group_moderated', 'forum.php?mod=group&fid='.$_G['fid']);
  103. }
  104. $_G['forum']['icon'] = get_groupimg($_G['forum']['icon'], 'icon');
  105. $_G['grouptypeid'] = $_G['forum']['fup'];
  106. $_G['forum']['dateline'] = dgmdate($_G['forum']['dateline'], 'd');
  107. $nav = get_groupnav($_G['forum']);
  108. $groupnav = $nav['nav'];
  109. $onlinemember = grouponline($_G['fid']);
  110. $groupmanagers = $_G['forum']['moderators'];
  111. $groupcache = getgroupcache($_G['fid'], array('replies', 'views', 'digest', 'lastpost', 'ranking', 'activityuser', 'newuserlist'));
  112. $seotype = 'grouppage';
  113. $seodata['first'] = $nav['first']['name'];
  114. $seodata['second'] = $nav['second']['name'];
  115. $seodata['gdes'] = $_G['forum']['description'];
  116. $forumseoset = array();
  117. }
  118. $_G['forum']['banner'] = get_forumimg($_G['forum']['banner']);
  119. list($navtitle, $metadescription, $metakeywords) = get_seosetting($seotype, $seodata, $forumseoset);
  120. if(!$navtitle) {
  121. $navtitle = helper_seo::get_title_page($_G['forum']['name'], $_G['page']);
  122. $nobbname = false;
  123. } else {
  124. $nobbname = true;
  125. }
  126. $_GET['typeid'] = intval($_GET['typeid']);
  127. if(!empty($_GET['typeid']) && !empty($_G['forum']['threadtypes']['types'][$_GET['typeid']])) {
  128. $navtitle = strip_tags($_G['forum']['threadtypes']['types'][$_GET['typeid']]).' - '.$navtitle;
  129. }
  130. if(!$metakeywords) {
  131. $metakeywords = $_G['forum']['name'];
  132. }
  133. if(!$metadescription) {
  134. $metadescription = $_G['forum']['name'];
  135. }
  136. if($_G['forum']['viewperm'] && !forumperm($_G['forum']['viewperm']) && !$_G['forum']['allowview']) {
  137. showmessagenoperm('viewperm', $_G['fid'], $_G['forum']['formulaperm']);
  138. } elseif($_G['forum']['formulaperm']) {
  139. formulaperm($_G['forum']['formulaperm']);
  140. }
  141. if($_G['forum']['password']) {
  142. if($_GET['action'] == 'pwverify') {
  143. if($_GET['pw'] != $_G['forum']['password']) {
  144. showmessage('forum_passwd_incorrect', NULL);
  145. } else {
  146. dsetcookie('fidpw'.$_G['fid'], $_GET['pw']);
  147. showmessage('forum_passwd_correct', "forum.php?mod=forumdisplay&fid=$_G[fid]");
  148. }
  149. } elseif($_G['forum']['password'] != $_G['cookie']['fidpw'.$_G['fid']]) {
  150. include template('forum/forumdisplay_passwd');
  151. exit();
  152. }
  153. }
  154. if($_G['forum']['price'] && !$_G['forum']['ismoderator']) {
  155. $membercredits = C::t('common_member_forum_buylog')->get_credits($_G['uid'], $_G['fid']);
  156. $paycredits = $_G['forum']['price'] - $membercredits;
  157. if($paycredits > 0) {
  158. if($_GET['action'] == 'paysubmit') {
  159. updatemembercount($_G['uid'], array($_G['setting']['creditstransextra'][1] => -$paycredits), 1, 'FCP', $_G['fid']);
  160. C::t('common_member_forum_buylog')->update_credits($_G['uid'], $_G['fid'], $_G['forum']['price']);
  161. showmessage('forum_pay_correct', "forum.php?mod=forumdisplay&fid=$_G[fid]");
  162. } else {
  163. if(getuserprofile('extcredits'.$_G['setting']['creditstransextra'][1]) < $paycredits) {
  164. showmessage('forum_pay_incorrect', NULL, array('paycredits' => $paycredits, 'credits' => $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][1]]['unit'].$_G['setting']['extcredits'][$_G['setting']['creditstransextra'][1]]['title'], 'title' => $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][1]]['title']));
  165. } else {
  166. include template('forum/forumdisplay_pay');
  167. exit();
  168. }
  169. }
  170. }
  171. }
  172. if(!isset($_G['cookie']['collapse']) || strpos($_G['cookie']['collapse'], 'forum_rules_'.$_G['fid']) === FALSE) {
  173. $collapse['forum_rules'] = '';
  174. $collapse['forum_rulesimg'] = 'no';
  175. } else {
  176. $collapse['forum_rules'] = 'display: none';
  177. $collapse['forum_rulesimg'] = 'yes';
  178. }
  179. $forumlastvisit = 0;
  180. if(empty($_G['forum']['picstyle']) && isset($_G['cookie']['forum_lastvisit']) && strexists($_G['cookie']['forum_lastvisit'], 'D_'.$_G['fid'])) {
  181. preg_match('/D\_'.$_G['fid'].'\_(\d+)/', $_G['cookie']['forum_lastvisit'], $a);
  182. $forumlastvisit = $a[1];
  183. unset($a);
  184. }
  185. dsetcookie('forum_lastvisit', preg_replace("/D\_".$_G['fid']."\_\d+/", '', $_G['cookie']['forum_lastvisit']).'D_'.$_G['fid'].'_'.TIMESTAMP, 604800);
  186. $threadtableids = !empty($_G['cache']['threadtableids']) ? $_G['cache']['threadtableids'] : array();
  187. $tableid = $_GET['archiveid'] && in_array($_GET['archiveid'], $threadtableids) ? intval($_GET['archiveid']) : 0;
  188. if($_G['setting']['allowmoderatingthread'] && $_G['uid']) {
  189. $threadmodcount = C::t('forum_thread')->count_by_fid_displayorder_authorid($_G['fid'], -2, $_G['uid'], $tableid);
  190. }
  191. $optionadd = $filterurladd = $searchsorton = '';
  192. $quicksearchlist = array();
  193. if(!empty($_G['forum']['threadsorts']['types'])) {
  194. require_once libfile('function/threadsort');
  195. $showpic = intval($_GET['showpic']);
  196. $templatearray = $sortoptionarray = array();
  197. foreach($_G['forum']['threadsorts']['types'] as $stid => $sortname) {
  198. loadcache(array('threadsort_option_'.$stid, 'threadsort_template_'.$stid));
  199. sortthreadsortselectoption($stid);
  200. $templatearray[$stid] = $_G['cache']['threadsort_template_'.$stid]['subject'];
  201. $sortoptionarray[$stid] = $_G['cache']['threadsort_option_'.$stid];
  202. }
  203. if(!empty($_G['forum']['threadsorts']['defaultshow']) && empty($_GET['sortid']) && empty($_GET['sortall'])) {
  204. $_GET['sortid'] = $_G['forum']['threadsorts']['defaultshow'];
  205. $_GET['filter'] = 'sortid';
  206. $_SERVER['QUERY_STRING'] = $_SERVER['QUERY_STRING'] ? $_SERVER['QUERY_STRING'].'&sortid='.$_GET['sortid'] : 'sortid='.$_GET['sortid'];
  207. $filterurladd = '&amp;filter=sort';
  208. }
  209. $_GET['sortid'] = $_GET['sortid'] ? $_GET['sortid'] : $_GET['searchsortid'];
  210. if(isset($_GET['sortid']) && $_G['forum']['threadsorts']['types'][$_GET['sortid']]) {
  211. $searchsortoption = $sortoptionarray[$_GET['sortid']];
  212. $quicksearchlist = quicksearch($searchsortoption);
  213. $_G['forum_optionlist'] = $_G['cache']['threadsort_option_'.$_GET['sortid']];
  214. $forum_optionlist = getsortedoptionlist();
  215. }
  216. }
  217. $_GET['sortid'] = intval($_GET['sortid']);
  218. $moderatedby = $_G['forum']['status'] != 3 ? moddisplay($_G['forum']['moderators'], 'forumdisplay') : '';
  219. $_GET['highlight'] = empty($_GET['highlight']) ? '' : dhtmlspecialchars($_GET['highlight']);
  220. if($_G['forum']['autoclose']) {
  221. $closedby = $_G['forum']['autoclose'] > 0 ? 'dateline' : 'lastpost';
  222. $_G['forum']['autoclose'] = abs($_G['forum']['autoclose']) * 86400;
  223. }
  224. $subexists = 0;
  225. foreach($_G['cache']['forums'] as $sub) {
  226. if($sub['type'] == 'sub' && $sub['fup'] == $_G['fid'] && (!$_G['setting']['hideprivate'] || !$sub['viewperm'] || forumperm($sub['viewperm']) || strstr($sub['users'], "\t$_G[uid]\t"))) {
  227. if(!$sub['status']) {
  228. continue;
  229. }
  230. $subexists = 1;
  231. $sublist = array();
  232. $query = C::t('forum_forum')->fetch_all_info_by_fids(0, 'available', 0, $_G['fid'], 1, 0, 0, 'sub');
  233. if(!empty($_G['member']['accessmasks'])) {
  234. $fids = array_keys($query);
  235. $accesslist = C::t('forum_access')->fetch_all_by_fid_uid($fids, $_G['uid']);
  236. foreach($query as $key => $val) {
  237. $query[$key]['allowview'] = $accesslist[$key];
  238. }
  239. }
  240. foreach($query as $sub) {
  241. $sub['extra'] = dunserialize($sub['extra']);
  242. if(!is_array($sub['extra'])) {
  243. $sub['extra'] = array();
  244. }
  245. if(forum($sub)) {
  246. $sub['orderid'] = count($sublist);
  247. $sublist[] = $sub;
  248. }
  249. }
  250. break;
  251. }
  252. }
  253. if(!empty($_GET['archiveid']) && in_array($_GET['archiveid'], $threadtableids)) {
  254. $subexists = 0;
  255. }
  256. if($subexists) {
  257. if($_G['forum']['forumcolumns']) {
  258. $_G['forum']['forumcolwidth'] = (floor(100 / $_G['forum']['forumcolumns']) - 0.1).'%';
  259. $_G['forum']['subscount'] = count($sublist);
  260. $_G['forum']['endrows'] = '';
  261. if($colspan = $_G['forum']['subscount'] % $_G['forum']['forumcolumns']) {
  262. while(($_G['forum']['forumcolumns'] - $colspan) > 0) {
  263. $_G['forum']['endrows'] .= '<td>&nbsp;</td>';
  264. $colspan ++;
  265. }
  266. $_G['forum']['endrows'] .= '</tr>';
  267. }
  268. }
  269. if(empty($_G['cookie']['collapse']) || strpos($_G['cookie']['collapse'], 'subforum_'.$_G['fid']) === FALSE) {
  270. $collapse['subforum'] = '';
  271. $collapseimg['subforum'] = 'collapsed_no.gif';
  272. } else {
  273. $collapse['subforum'] = 'display: none';
  274. $collapseimg['subforum'] = 'collapsed_yes.gif';
  275. }
  276. }
  277. $page = $_G['page'];
  278. $subforumonly = $_G['forum']['simple'] & 1;
  279. $simplestyle = !$_G['forum']['allowside'] || $page > 1 ? true : false;
  280. if($subforumonly) {
  281. $_G['setting']['fastpost'] = false;
  282. $_GET['orderby'] = '';
  283. if(!defined('IN_ARCHIVER')) {
  284. include template('diy:forum/forumdisplay:'.$_G['fid']);
  285. } else {
  286. include loadarchiver('forum/forumdisplay');
  287. }
  288. exit();
  289. }
  290. if($_GET['filter'] != 'hot') {
  291. $page = $_G['setting']['threadmaxpages'] && $page > $_G['setting']['threadmaxpages'] ? 1 : $page;
  292. }
  293. if($_G['forum']['modrecommend'] && $_G['forum']['modrecommend']['open']) {
  294. $_G['forum']['recommendlist'] = recommendupdate($_G['fid'], $_G['forum']['modrecommend'], '', 1);
  295. }
  296. $recommendgroups = array();
  297. if($_G['forum']['status'] != 3 && helper_access::check_module('group')) {
  298. loadcache('forumrecommend');
  299. $recommendgroups = $_G['cache']['forumrecommend'][$_G['fid']];
  300. }
  301. if($recommendgroups) {
  302. if(empty($_G['cookie']['collapse']) || strpos($_G['cookie']['collapse'], 'recommendgroups_'.$_G['fid']) === FALSE) {
  303. $collapse['recommendgroups'] = '';
  304. $collapseimg['recommendgroups'] = 'collapsed_no.gif';
  305. } else {
  306. $collapse['recommendgroups'] = 'display: none';
  307. $collapseimg['recommendgroups'] = 'collapsed_yes.gif';
  308. }
  309. }
  310. if(!$simplestyle || !$_G['forum']['allowside'] && $page == 1) {
  311. if($_G['cache']['announcements_forum'] && (!$_G['cache']['announcements_forum']['endtime'] || $_G['cache']['announcements_forum']['endtime'] > TIMESTAMP)) {
  312. $announcement = $_G['cache']['announcements_forum'];
  313. $announcement['starttime'] = dgmdate($announcement['starttime'], 'd');
  314. } else {
  315. $announcement = NULL;
  316. }
  317. }
  318. $filteradd = $sortoptionurl = $sp = '';
  319. $sorturladdarray = $selectadd = array();
  320. $forumdisplayadd = array('orderby' => '');
  321. $specialtype = array('poll' => 1, 'trade' => 2, 'reward' => 3, 'activity' => 4, 'debate' => 5);
  322. $filterfield = array('digest', 'recommend', 'sortall', 'typeid', 'sortid', 'dateline', 'page', 'orderby', 'specialtype', 'author', 'view', 'reply', 'lastpost', 'hot');
  323. foreach($filterfield as $v) {
  324. $forumdisplayadd[$v] = '';
  325. }
  326. $filter = isset($_GET['filter']) && in_array($_GET['filter'], $filterfield) ? $_GET['filter'] : '';
  327. $filterbool = !empty($filter);
  328. $filterarr = $multiadd = array();
  329. $threadclasscount = array();
  330. if($filter && $filter != 'hot') {
  331. if($query_string = $_SERVER['QUERY_STRING']) {
  332. $query_string = substr($query_string, (strpos($query_string, "&") + 1));
  333. parse_str($query_string, $geturl);
  334. $geturl = daddslashes($geturl, 1);
  335. if($geturl && is_array($geturl)) {
  336. $issort = isset($_GET['sortid']) && isset($_G['forum']['threadsorts']['types'][$_GET['sortid']]) && $quicksearchlist ? TRUE : FALSE;
  337. $selectadd = $issort ? $geturl : array();
  338. foreach($filterfield as $option) {
  339. foreach($geturl as $field => $value) {
  340. if(in_array($field, $filterfield) && $option != $field && $field != 'page' && ($field != 'orderby' || !in_array($option, array('author', 'reply', 'view', 'lastpost', 'heat')))) {
  341. if(!(in_array($option, array('digest', 'recommend')) && in_array($field, array('digest', 'recommend')))) {
  342. $forumdisplayadd[$option] .= '&'.$field.'='.rawurlencode($value);
  343. }
  344. }
  345. }
  346. if($issort) {
  347. $sfilterfield = array_merge(array('filter', 'sortid', 'orderby', 'fid'), $filterfield);
  348. foreach($geturl as $soption => $value) {
  349. $forumdisplayadd[$soption] .= !in_array($soption, $sfilterfield) ? "&$soption=".rawurlencode($value) : '';
  350. }
  351. unset($sfilterfield);
  352. }
  353. }
  354. if($issort && is_array($quicksearchlist)) {
  355. foreach($quicksearchlist as $option) {
  356. $identifier = $option['identifier'];
  357. foreach($geturl as $option => $value) {
  358. $sorturladdarray[$identifier] .= !in_array($option, array('filter', 'sortid', 'orderby', 'fid', 'searchsort', $identifier)) ? "&amp;$option=$value" : '';
  359. }
  360. }
  361. }
  362. foreach($geturl as $field => $value) {
  363. if($field != 'page' && $field != 'fid' && $field != 'searchoption') {
  364. $multiadd[] = $field.'='.rawurlencode($value);
  365. if(in_array($field, $filterfield)) {
  366. if($field == 'digest') {
  367. $filterarr['digest'] = 1;
  368. } elseif($field == 'recommend') {
  369. $filterarr['recommends'] = intval($_G['setting']['recommendthread']['iconlevels'][0]);
  370. } elseif($field == 'specialtype') {
  371. $filterarr['special'] = $specialtype[$value];
  372. $filterarr['specialthread'] = 1;
  373. if($value == 'reward') {
  374. if($_GET['rewardtype'] == 1) {
  375. $filterarr['pricemore'] = 0;
  376. } elseif($_GET['rewardtype'] == 2) {
  377. $filterarr['pricesless'] = 0;
  378. }
  379. }
  380. } elseif($field == 'dateline') {
  381. if($value) {
  382. $filterarr['lastpostmore'] = TIMESTAMP - $value;
  383. }
  384. } elseif($field == 'typeid' || $field == 'sortid') {
  385. $fieldstr = $field == 'typeid' ? 'intype' : 'insort';
  386. $filterarr[$fieldstr] = $value;
  387. }
  388. $sp = ' ';
  389. }
  390. }
  391. }
  392. if(count($filterarr) == 1) {
  393. foreach($filterarr as $key => $value) {
  394. if($key == 'intype') {
  395. $threadclasscount = array('id' => $value, 'idtype' => 'typeid');
  396. } elseif($key == 'insort') {
  397. $threadclasscount = array('id' => $value, 'idtype' => 'sortid');
  398. }
  399. }
  400. }
  401. }
  402. }
  403. $simplestyle = true;
  404. }
  405. if(!empty($_GET['orderby']) && !$_G['setting']['closeforumorderby'] && in_array($_GET['orderby'], array('lastpost', 'dateline', 'replies', 'views', 'recommends', 'heats'))) {
  406. $forumdisplayadd['orderby'] .= '&orderby='.$_GET['orderby'];
  407. } else {
  408. $_GET['orderby'] = isset($_G['cache']['forums'][$_G['fid']]['orderby']) ? $_G['cache']['forums'][$_G['fid']]['orderby'] : 'lastpost';
  409. }
  410. $_GET['ascdesc'] = isset($_G['cache']['forums'][$_G['fid']]['ascdesc']) ? $_G['cache']['forums'][$_G['fid']]['ascdesc'] : 'DESC';
  411. $check = array();
  412. $check[$filter] = $check[$_GET['orderby']] = $check[$_GET['ascdesc']] = 'selected="selected"';
  413. if(($_G['forum']['status'] != 3 && $_G['forum']['allowside']) || !empty($_G['forum']['threadsorts']['templatelist'])) {
  414. updatesession();
  415. $onlinenum = C::app()->session->count_by_fid($_G['fid']);
  416. if(!IS_ROBOT && ($_G['setting']['whosonlinestatus'] == 2 || $_G['setting']['whosonlinestatus'] == 3)) {
  417. $_G['setting']['whosonlinestatus'] = 1;
  418. $detailstatus = $showoldetails == 'yes' || (((!isset($_G['cookie']['onlineforum']) && !$_G['setting']['whosonline_contract']) || $_G['cookie']['onlineforum']) && !$showoldetails);
  419. if($detailstatus) {
  420. $actioncode = lang('forum/action');
  421. $whosonline = array();
  422. $forumname = strip_tags($_G['forum']['name']);
  423. $whosonline = C::app()->session->fetch_all_by_fid($_G['fid'], 12);
  424. $_G['setting']['whosonlinestatus'] = 1;
  425. }
  426. } else {
  427. $_G['setting']['whosonlinestatus'] = 0;
  428. }
  429. }
  430. if($_G['forum']['threadsorts']['types'] && $sortoptionarray && ($_GET['searchoption'] || $_GET['searchsort'])) {
  431. $sortid = intval($_GET['sortid']);
  432. if($_GET['searchoption']){
  433. $forumdisplayadd['page'] = '&sortid='.$sortid;
  434. foreach($_GET['searchoption'] as $optionid => $option) {
  435. $optionid = intval($optionid);
  436. $searchoption = '';
  437. if(is_array($option['value'])) {
  438. foreach($option['value'] as $v) {
  439. $v = rawurlencode((string)$v);
  440. $searchoption .= "&searchoption[$optionid][value][$v]=$v";
  441. }
  442. } else {
  443. $option['value'] = rawurlencode((string)$option['value']);
  444. $option['value'] && $searchoption = "&searchoption[$optionid][value]=$option[value]";
  445. }
  446. $option['type'] = rawurlencode((string)$option['type']);
  447. $identifier = $sortoptionarray[$sortid][$optionid]['identifier'];
  448. $forumdisplayadd['page'] .= $searchoption ? "$searchoption&searchoption[$optionid][type]=$option[type]" : '';
  449. }
  450. }
  451. $searchsorttids = sortsearch($_GET['sortid'], $sortoptionarray, $_GET['searchoption'], $selectadd, $_G['fid']);
  452. $filterarr['intids'] = $searchsorttids ? $searchsorttids : array(0);
  453. }
  454. if(isset($_GET['searchoption'])) {
  455. $_GET['searchoption'] = dhtmlspecialchars($_GET['searchoption']);
  456. }
  457. if($_G['forum']['relatedgroup']) {
  458. $relatedgroup = explode(',', $_G['forum']['relatedgroup']);
  459. $relatedgroup[] = $_G['fid'];
  460. $filterarr['inforum'] = $relatedgroup;
  461. } else {
  462. $filterarr['inforum'] = $_G['fid'];
  463. }
  464. if(empty($filter) && empty($_GET['sortid']) && empty($_G['forum']['relatedgroup'])) {
  465. if($forumarchive) {
  466. if($_GET['archiveid']) {
  467. $_G['forum_threadcount'] = $forumarchive[$_GET['archiveid']]['threads'];
  468. } else {
  469. $primarytabthreads = $_G['forum']['threads'];
  470. foreach($forumarchive as $arcid => $avalue) {
  471. if($arcid) {
  472. $primarytabthreads = $primarytabthreads - $avalue['threads'];
  473. }
  474. }
  475. $_G['forum_threadcount'] = $primarytabthreads;
  476. }
  477. } else {
  478. $_G['forum_threadcount'] = $_G['forum']['threads'];
  479. }
  480. } else {
  481. $filterarr['sticky'] = 0;
  482. $_G['forum_threadcount'] = C::t('forum_thread')->count_search($filterarr, $tableid);
  483. if($threadclasscount) {
  484. threadclasscount($_G['fid'], $threadclasscount['id'], $threadclasscount['idtype'], $_G['forum_threadcount']);
  485. }
  486. }
  487. $thisgid = $_G['forum']['type'] == 'forum' ? $_G['forum']['fup'] : (!empty($_G['cache']['forums'][$_G['forum']['fup']]['fup']) ? $_G['cache']['forums'][$_G['forum']['fup']]['fup'] : 0);
  488. $forumstickycount = $stickycount = 0;
  489. $stickytids = '';
  490. $showsticky = !defined('MOBILE_HIDE_STICKY') || !MOBILE_HIDE_STICKY;
  491. if($showsticky) {
  492. $forumstickytids = array();
  493. if($_G['page'] !== 1 || $filterbool === false) {
  494. if($_G['setting']['globalstick'] && $_G['forum']['allowglobalstick']) {
  495. $stickytids = explode(',', str_replace("'", '', $_G['cache']['globalstick']['global']['tids']));
  496. if(!empty($_G['cache']['globalstick']['categories'][$thisgid]['count'])) {
  497. $stickytids = array_merge($stickytids, explode(',', str_replace("'", '', $_G['cache']['globalstick']['categories'][$thisgid]['tids'])));
  498. }
  499. if($_G['forum']['status'] != 3) {
  500. $stickycount = $_G['cache']['globalstick']['global']['count'];
  501. if(!empty($_G['cache']['globalstick']['categories'][$thisgid])) {
  502. $stickycount += $_G['cache']['globalstick']['categories'][$thisgid]['count'];
  503. }
  504. }
  505. }
  506. if($_G['forum']['allowglobalstick']) {
  507. $forumstickycount = 0;
  508. $forumstickfid = $_G['forum']['status'] != 3 ? $_G['fid'] : $_G['forum']['fup'];
  509. if(isset($_G['cache']['forumstick'][$forumstickfid])) {
  510. $forumstickycount = count($_G['cache']['forumstick'][$forumstickfid]);
  511. $forumstickytids = $_G['cache']['forumstick'][$forumstickfid];
  512. }
  513. if(!empty($forumstickytids)) {
  514. $stickytids = array_merge($stickytids, $forumstickytids);
  515. }
  516. $stickycount += $forumstickycount;
  517. }
  518. }
  519. }
  520. if($_G['forum']['picstyle']) {
  521. $forumdefstyle = isset($_GET['forumdefstyle']) ? $_GET['forumdefstyle'] : '';
  522. if($forumdefstyle) {
  523. switch($forumdefstyle) {
  524. case 'no': dsetcookie('forumdefstyle', ''); break;
  525. case 'yes': dsetcookie('forumdefstyle', 1, 31536000); break;
  526. }
  527. }
  528. if(empty($_G['cookie']['forumdefstyle'])) {
  529. if(!empty($_G['setting']['forumpicstyle']['thumbnum'])) {
  530. $_G['tpp'] = $_G['setting']['forumpicstyle']['thumbnum'];
  531. }
  532. $stickycount = $showsticky = 0;
  533. }
  534. }
  535. if($filter != 'hot' && @ceil($_G['forum_threadcount']/$_G['tpp']) < $page) {
  536. $page = 1;
  537. }
  538. $start_limit = ($page - 1) * $_G['tpp'];
  539. $forumdisplayadd['page'] = !empty($forumdisplayadd['page']) ? $forumdisplayadd['page'] : '';
  540. $multipage_archive = $_GET['archiveid'] && in_array($_GET['archiveid'], $threadtableids) ? "&archiveid={$_GET['archiveid']}" : '';
  541. $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']);
  542. $realpages = @ceil($_G['forum_threadcount']/$_G['tpp']);
  543. $maxpage = ($_G['setting']['threadmaxpages'] && $_G['setting']['threadmaxpages'] < $realpages) ? $_G['setting']['threadmaxpages'] : $realpages;
  544. $nextpage = ($page + 1) > $maxpage ? 1 : ($page + 1);
  545. $multipage_more = "forum.php?mod=forumdisplay&fid=$_G[fid]".$forumdisplayadd['page'].($multiadd ? '&'.implode('&', $multiadd) : '')."$multipage_archive".'&page='.$nextpage;
  546. $extra = rawurlencode(!IS_ROBOT ? 'page='.$page.($forumdisplayadd['page'] ? '&filter='.$filter.$forumdisplayadd['page'] : '').($forumdisplayadd['orderby'] ? $forumdisplayadd['orderby'] : '') : 'page=1');
  547. $separatepos = 0;
  548. $_G['forum_threadlist'] = $threadids = array();
  549. $_G['forum_colorarray'] = array('', '#EE1B2E', '#EE5023', '#996600', '#3C9D40', '#2897C5', '#2B65B7', '#8F2A90', '#EC1282');
  550. $filterarr['sticky'] = 4;
  551. $filterarr['displayorder'] = !$filterbool && $stickycount ? array(0, 1) : array(0, 1, 2, 3, 4);
  552. if($filter !== 'hot') {
  553. $threadlist = array();
  554. $indexadd = '';
  555. $_order = "displayorder DESC, $_GET[orderby] $_GET[ascdesc]";
  556. if($filterbool) {
  557. if($filterarr['digest']) {
  558. $indexadd = " FORCE INDEX (digest) ";
  559. }
  560. } elseif($showsticky && $stickytids && is_array($stickytids)) {
  561. $filterarr1 = $filterarr;
  562. $filterarr1['inforum'] = '';
  563. $filterarr1['intids'] = $stickytids;
  564. $filterarr1['displayorder'] = array(2, 3, 4);
  565. $threadlist = C::t('forum_thread')->fetch_all_search($filterarr1, $tableid, $start_limit, $_G['tpp'], $_order, '');
  566. unset($filterarr1);
  567. }
  568. $threadlist = array_merge($threadlist, C::t('forum_thread')->fetch_all_search($filterarr, $tableid, $start_limit, $_G['tpp'], $_order, '', $indexadd));
  569. unset($_order);
  570. if(empty($threadlist) && $page <= ceil($_G['forum_threadcount'] / $_G['tpp'])) {
  571. require_once libfile('function/post');
  572. updateforumcount($_G['fid']);
  573. }
  574. } else {
  575. $hottime = dintval(str_replace('-', '', $_GET['time']));
  576. $multipage = '';
  577. if($hottime && checkdate(substr($hottime, 4, 2), substr($hottime, 6, 2), substr($hottime, 0, 4))) {
  578. $calendartime = abs($hottime);
  579. $ctime = sprintf('%04d', substr($hottime, 0, 4)).'-'.sprintf('%02d', substr($hottime, 4, 2)).'-'.sprintf('%02d', substr($hottime, 6, 2));
  580. } else {
  581. $calendartime = dgmdate(strtotime(dgmdate(TIMESTAMP, 'Y-m-d')) - 86400, 'Ymd');
  582. $ctime = dgmdate(strtotime(dgmdate(TIMESTAMP, 'Y-m-d')) - 86400, 'Y-m-d');
  583. }
  584. $caldata = C::t('forum_threadcalendar')->fetch_by_fid_dateline($_G['fid'], $calendartime);
  585. $_G['forum_threadcount'] = 0;
  586. if($caldata) {
  587. $hottids = C::t('forum_threadhot')->fetch_all_tid_by_cid($caldata['cid']);
  588. $threadlist = C::t('forum_thread')->fetch_all_by_tid($hottids);
  589. $_G['forum_threadcount'] = count($threadlist);
  590. }
  591. }
  592. $_G['ppp'] = $_G['forum']['threadcaches'] && !$_G['uid'] ? $_G['setting']['postperpage'] : $_G['ppp'];
  593. $page = $_G['page'];
  594. $todaytime = strtotime(dgmdate(TIMESTAMP, 'Ymd'));
  595. $verify = $verifyuids = $authorids = $grouptids = $rushtids = array();
  596. $threadindex = 0;
  597. foreach($threadlist as $thread) {
  598. $thread['allreplies'] = $thread['replies'] + $thread['comments'];
  599. $thread['ordertype'] = getstatus($thread['status'], 4);
  600. if($_G['forum']['picstyle'] && empty($_G['cookie']['forumdefstyle'])) {
  601. if($thread['fid'] != $_G['fid'] && empty($thread['cover'])) {
  602. continue;
  603. }
  604. $thread['coverpath'] = getthreadcover($thread['tid'], $thread['cover']);
  605. $thread['cover'] = abs($thread['cover']);
  606. }
  607. $thread['forumstick'] = in_array($thread['tid'], $forumstickytids);
  608. $thread['related_group'] = 0;
  609. if($_G['forum']['relatedgroup'] && $thread['fid'] != $_G['fid']) {
  610. if($thread['closed'] > 1) continue;
  611. $thread['related_group'] = 1;
  612. $grouptids[] = $thread['tid'];
  613. }
  614. $thread['lastposterenc'] = rawurlencode($thread['lastposter']);
  615. if($thread['typeid'] && !empty($_G['forum']['threadtypes']['prefix']) && isset($_G['forum']['threadtypes']['types'][$thread['typeid']])) {
  616. if($_G['forum']['threadtypes']['prefix'] == 1) {
  617. $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>';
  618. } elseif($_G['forum']['threadtypes']['icons'][$thread['typeid']] && $_G['forum']['threadtypes']['prefix'] == 2) {
  619. $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>';
  620. }
  621. $thread['typename'] = $_G['forum']['threadtypes']['types'][$thread['typeid']];
  622. } else {
  623. $thread['typename'] = $thread['typehtml'] = '';
  624. }
  625. $thread['sorthtml'] = $thread['sortid'] && !empty($_G['forum']['threadsorts']['prefix']) && isset($_G['forum']['threadsorts']['types'][$thread['sortid']]) ?
  626. '<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>' : '';
  627. $thread['multipage'] = '';
  628. $topicposts = $thread['special'] ? $thread['replies'] : $thread['replies'] + 1;
  629. $multipate_archive = $_GET['archiveid'] && in_array($_GET['archiveid'], $threadtableids) ? "archiveid={$_GET['archiveid']}" : '';
  630. if($topicposts > $_G['ppp']) {
  631. $pagelinks = '';
  632. $thread['pages'] = ceil($topicposts / $_G['ppp']);
  633. $realtid = $_G['forum']['status'] != 3 && $thread['isgroup'] == 1 ? $thread['closed'] : $thread['tid'];
  634. for($i = 2; $i <= 6 && $i <= $thread['pages']; $i++) {
  635. $pagelinks .= "<a href=\"forum.php?mod=viewthread&tid=$realtid&amp;".(!empty($multipate_archive) ? "$multipate_archive&amp;" : '')."extra=$extra&amp;page=$i\">$i</a>";
  636. }
  637. if($thread['pages'] > 6) {
  638. $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>";
  639. }
  640. $thread['multipage'] = '&nbsp;...'.$pagelinks;
  641. }
  642. if($thread['highlight']) {
  643. $string = sprintf('%02d', $thread['highlight']);
  644. $stylestr = sprintf('%03b', $string[0]);
  645. $thread['highlight'] = ' style="';
  646. $thread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';
  647. $thread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';
  648. $thread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';
  649. $thread['highlight'] .= $string[1] ? 'color: '.$_G['forum_colorarray'][$string[1]].';' : '';
  650. if($thread['bgcolor']) {
  651. $thread['highlight'] .= "background-color: $thread[bgcolor];";
  652. }
  653. $thread['highlight'] .= '"';
  654. } else {
  655. $thread['highlight'] = '';
  656. }
  657. $thread['recommendicon'] = '';
  658. if(!empty($_G['setting']['recommendthread']['status']) && $thread['recommends']) {
  659. foreach($_G['setting']['recommendthread']['iconlevels'] as $k => $i) {
  660. if($thread['recommends'] > $i) {
  661. $thread['recommendicon'] = $k+1;
  662. break;
  663. }
  664. }
  665. }
  666. $thread['moved'] = $thread['heatlevel'] = $thread['new'] = 0;
  667. if($_G['forum']['status'] != 3 && ($thread['closed'] || ($_G['forum']['autoclose'] && $thread['fid'] == $_G['fid'] && TIMESTAMP - $thread[$closedby] > $_G['forum']['autoclose']))) {
  668. if($thread['isgroup'] == 1) {
  669. $thread['folder'] = 'common';
  670. $grouptids[] = $thread['closed'];
  671. } else {
  672. if($thread['closed'] > 1) {
  673. $thread['moved'] = $thread['tid'];
  674. $thread['allreplies'] = $thread['replies'] = '-';
  675. $thread['views'] = '-';
  676. }
  677. $thread['folder'] = 'lock';
  678. }
  679. } elseif($_G['forum']['status'] == 3 && $thread['closed'] == 1) {
  680. $thread['folder'] = 'lock';
  681. } else {
  682. $thread['folder'] = 'common';
  683. $thread['weeknew'] = TIMESTAMP - 604800 <= $thread['dbdateline'];
  684. if($thread['allreplies'] > $thread['views']) {
  685. $thread['views'] = $thread['allreplies'];
  686. }
  687. if($_G['setting']['heatthread']['iconlevels']) {
  688. foreach($_G['setting']['heatthread']['iconlevels'] as $k => $i) {
  689. if($thread['heats'] > $i) {
  690. $thread['heatlevel'] = $k + 1;
  691. break;
  692. }
  693. }
  694. }
  695. }
  696. $thread['icontid'] = $thread['forumstick'] || !$thread['moved'] && $thread['isgroup'] != 1 ? $thread['tid'] : $thread['closed'];
  697. if(!$thread['forumstick'] && ($thread['isgroup'] == 1 || $thread['fid'] != $_G['fid'])) {
  698. $thread['icontid'] = $thread['closed'] > 1 ? $thread['closed'] : $thread['tid'];
  699. }
  700. $thread['istoday'] = $thread['dateline'] > $todaytime ? 1 : 0;
  701. $thread['dbdateline'] = $thread['dateline'];
  702. $thread['dateline'] = dgmdate($thread['dateline'], 'u', '9999', getglobal('setting/dateformat'));
  703. $thread['dblastpost'] = $thread['lastpost'];
  704. $thread['lastpost'] = dgmdate($thread['lastpost'], 'u');
  705. if(in_array($thread['displayorder'], array(1, 2, 3, 4))) {
  706. $thread['id'] = 'stickthread_'.$thread['tid'];
  707. $separatepos++;
  708. } else {
  709. $thread['id'] = 'normalthread_'.$thread['tid'];
  710. if($thread['folder'] == 'common' && $thread['dblastpost'] >= $forumlastvisit || !$forumlastvisit) {
  711. $thread['new'] = 1;
  712. $thread['folder'] = 'new';
  713. $thread['weeknew'] = TIMESTAMP - 604800 <= $thread['dbdateline'];
  714. }
  715. }
  716. if(isset($_G['setting']['verify']['enabled']) && $_G['setting']['verify']['enabled']) {
  717. $verifyuids[$thread['authorid']] = $thread['authorid'];
  718. }
  719. $authorids[$thread['authorid']] = $thread['authorid'];
  720. $thread['mobile'] = base_convert(getstatus($thread['status'], 13).getstatus($thread['status'], 12).getstatus($thread['status'], 11), 2, 10);
  721. $thread['rushreply'] = getstatus($thread['status'], 3);
  722. if($thread['rushreply']) {
  723. $rushtids[$thread['tid']] = $thread['tid'];
  724. }
  725. $threadids[$threadindex] = $thread['tid'];
  726. $_G['forum_threadlist'][$threadindex] = $thread;
  727. $threadindex++;
  728. }
  729. $livethread = array();
  730. if($_G['forum']['livetid'] && $page == 1 && (!$filter || ($filter == 'sortid' && $_G['forum']['threadsorts']['defaultshow'] == $_GET['sortid']))) {
  731. include_once libfile('function/post');
  732. $livethread = C::t('forum_thread')->fetch($_G['forum']['livetid']);
  733. $livepost = C::t('forum_post')->fetch_threadpost_by_tid_invisible($_G['forum']['livetid']);
  734. $livemessage = messagecutstr($livepost['message'], 200);
  735. $liveallowpostreply = ($_G['forum']['allowreply'] != -1) && (($livethread['isgroup'] || (!$livethread['closed'] && !checkautoclose($livethread))) || $_G['forum']['ismoderator']) && ((!$_G['forum']['replyperm'] && $_G['group']['allowreply']) || ($_G['forum']['replyperm'] && forumperm($_G['forum']['replyperm'])) || $_G['forum']['allowreply']);
  736. }
  737. if($rushtids) {
  738. $rushinfo = C::t('forum_threadrush')->fetch_all($rushtids);
  739. foreach($rushinfo as $tid => $info) {
  740. if($info['starttimefrom'] > TIMESTAMP) {
  741. $info['timer'] = $info['starttimefrom'] - TIMESTAMP;
  742. $info['timertype'] = 'start';
  743. } elseif($info['starttimeto'] > TIMESTAMP) {
  744. $info['timer'] = $info['starttimeto'] - TIMESTAMP;
  745. $info['timertype'] = 'end';
  746. } else {
  747. $info = '';
  748. }
  749. $rushinfo[$tid] = $info;
  750. }
  751. }
  752. if(!empty($threadids)) {
  753. $indexlist = array_flip($threadids);
  754. foreach(C::t('forum_threadaddviews')->fetch_all($threadids) as $tidkey => $value) {
  755. $index = $indexlist[$tidkey];
  756. $threadlist[$index]['views'] += $value['addviews'];
  757. $_G['forum_threadlist'][$index]['views'] += $value['addviews'];
  758. }
  759. }
  760. if($_G['setting']['verify']['enabled'] && $verifyuids) {
  761. foreach(C::t('common_member_verify')->fetch_all($verifyuids) as $value) {
  762. foreach($_G['setting']['verify'] as $vid => $vsetting) {
  763. if($vsetting['available'] && $vsetting['showicon'] && $value['verify'.$vid] == 1) {
  764. $srcurl = '';
  765. if(!empty($vsetting['icon'])) {
  766. $srcurl = $vsetting['icon'];
  767. }
  768. $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>';
  769. }
  770. }
  771. }
  772. }
  773. if($authorids) {
  774. loadcache('usergroups');
  775. $groupcolor = array();
  776. foreach(C::t('common_member')->fetch_all($authorids) as $value) {
  777. $groupcolor[$value['uid']] = $_G['cache']['usergroups'][$value['groupid']]['color'];
  778. }
  779. }
  780. $_G['forum_threadnum'] = count($_G['forum_threadlist']) - $separatepos;
  781. if(!empty($grouptids)) {
  782. $groupfids = array();
  783. foreach(C::t('forum_thread')->fetch_all_by_tid($grouptids) as $row) {
  784. $groupnames[$row['tid']]['fid'] = $row['fid'];
  785. $groupnames[$row['tid']]['views'] = $row['views'];
  786. $groupfids[] = $row['fid'];
  787. }
  788. $forumsinfo = C::t('forum_forum')->fetch_all($groupfids);
  789. foreach($groupnames as $gtid => $value) {
  790. $gfid = $groupnames[$gtid]['fid'];
  791. $groupnames[$gtid]['name'] = $forumsinfo[$gfid]['name'];
  792. }
  793. }
  794. $stemplate = null;
  795. if($_G['forum']['threadsorts']['types'] && $sortoptionarray && $templatearray && $threadids) {
  796. $sortid = intval($_GET['sortid']);
  797. if(!strexists($templatearray[$sortid], '{subject_url}') && !strexists($templatearray[$sortid], '{tid}')) {
  798. $sortlistarray = showsorttemplate($sortid, $_G['fid'], $sortoptionarray, $templatearray, $_G['forum_threadlist'], $threadids);
  799. $stemplate = $sortlistarray['template'];
  800. } else {
  801. $sorttemplate = showsortmodetemplate($sortid, $_G['fid'], $sortoptionarray, $templatearray, $_G['forum_threadlist'], $threadids, $verify);
  802. $_G['forum']['sortmode'] = 1;
  803. }
  804. if(($_GET['searchoption'] || $_GET['searchsort']) && empty($searchsorttids)) {
  805. $_G['forum_threadlist'] = $multipage = '';
  806. }
  807. }
  808. $separatepos = $separatepos ? $separatepos + 1 : 0;
  809. $_G['setting']['visitedforums'] = $_G['setting']['visitedforums'] && $_G['forum']['status'] != 3 ? visitedforums() : '';
  810. $_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']);
  811. $fastpost = $_G['setting']['fastpost'] && !$_G['forum']['allowspecialonly'] && !$_G['forum']['threadsorts']['required'] && !$_G['forum']['picstyle'];
  812. $allowfastpost = $fastpost && $_G['group']['allowpost'];
  813. $_G['group']['allowpost'] = isset($_G['forum']['allowpost']) && $_G['forum']['allowpost'] == -1 ? false : $_G['group']['allowpost'];
  814. $_G['forum']['allowpostattach'] = isset($_G['forum']['allowpostattach']) ? $_G['forum']['allowpostattach'] : '';
  815. $allowpostattach = $fastpost && ($_G['forum']['allowpostattach'] != -1 && ($_G['forum']['allowpostattach'] == 1 || (!$_G['forum']['postattachperm'] && $_G['group']['allowpostattach']) || ($_G['forum']['postattachperm'] && forumperm($_G['forum']['postattachperm']))));
  816. if($fastpost || $livethread) {
  817. 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)) {
  818. $allowfastpost = false;
  819. }
  820. $usesigcheck = $_G['uid'] && $_G['group']['maxsigsize'];
  821. $seccodecheck = ($_G['setting']['seccodestatus'] & 4) && (!$_G['setting']['seccodedata']['minposts'] || getuserprofile('posts') < $_G['setting']['seccodedata']['minposts']);
  822. $secqaacheck = $_G['setting']['secqaa']['status'] & 2 && (!$_G['setting']['secqaa']['minposts'] || getuserprofile('posts') < $_G['setting']['secqaa']['minposts']);
  823. } elseif(!$_G['uid']) {
  824. $fastpostdisabled = true;
  825. }
  826. $showpoll = $showtrade = $showreward = $showactivity = $showdebate = 0;
  827. if($_G['forum']['allowpostspecial']) {
  828. $showpoll = $_G['forum']['allowpostspecial'] & 1;
  829. $showtrade = $_G['forum']['allowpostspecial'] & 2;
  830. $showreward = isset($_G['setting']['extcredits'][$_G['setting']['creditstransextra'][2]]) && ($_G['forum']['allowpostspecial'] & 4);
  831. $showactivity = $_G['forum']['allowpostspecial'] & 8;
  832. $showdebate = $_G['forum']['allowpostspecial'] & 16;
  833. }
  834. if($_G['group']['allowpost']) {
  835. $_G['group']['allowpostpoll'] = $_G['group']['allowpostpoll'] && $showpoll;
  836. $_G['group']['allowposttrade'] = $_G['group']['allowposttrade'] && $showtrade;
  837. $_G['group']['allowpostreward'] = $_G['group']['allowpostreward'] && $showreward;
  838. $_G['group']['allowpostactivity'] = $_G['group']['allowpostactivity'] && $showactivity;
  839. $_G['group']['allowpostdebate'] = $_G['group']['allowpostdebate'] && $showdebate;
  840. }
  841. $showthreadclasscount = array();
  842. if(($_G['forum']['threadtypes'] && $_G['forum']['threadtypes']['listable']) || count($_G['forum']['threadsorts']['types']) > 0) {
  843. $showthreadclasscount = threadclasscount($_G['fid']);
  844. }
  845. $_G['forum']['threadplugin'] = $_G['group']['allowpost'] && $_G['setting']['threadplugins'] ? dunserialize($_G['forum']['threadplugin']) : array();
  846. $allowleftside = !$subforumonly && $_G['setting']['leftsidewidth'] && !$_G['forum']['allowside'];
  847. if(isset($_GET['leftsidestatus'])) {
  848. dsetcookie('disableleftside', $_GET['leftsidestatus'], 2592000);
  849. $_G['cookie']['disableleftside'] = $_GET['leftsidestatus'];
  850. }
  851. $leftside = empty($_G['cookie']['disableleftside']) && $allowleftside ? forumleftside() : array();
  852. $leftsideswitch = $allowleftside ? "forum.php?mod=forumdisplay&fid=$_G[fid]&page=$page".($multiadd ? '&'.implode('&', $multiadd) : '') : '';
  853. require_once libfile('function/upload');
  854. $swfconfig = getuploadconfig($_G['uid'], $_G['fid']);
  855. $template = 'diy:forum/forumdisplay:'.$_G['fid'];
  856. if(!empty($_G['forum']['threadsorts']['templatelist']) && $_G['forum']['status'] != 3) {
  857. $template = 'diy:forum/forumdisplay_'.$_G['forum']['threadsorts']['templatelist'].':'.$_G['fid'];
  858. } elseif($_G['forum']['status'] == 3) {
  859. $groupviewed_list = get_viewedgroup();
  860. write_groupviewed($_G['fid']);
  861. $template = 'diy:group/group:'.$_G['fid'];
  862. }
  863. if(!defined('IN_ARCHIVER')) {
  864. include template($template);
  865. } else {
  866. include loadarchiver('forum/forumdisplay');
  867. }
  868. ?>