forum_forumdisplay.php 42 KB

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