forum_index.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  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_index.php 36265 2016-11-04 07:10:47Z nemohou $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. require_once libfile('function/forumlist');
  12. $gid = intval(getgpc('gid'));
  13. $showoldetails = get_index_online_details();
  14. if(!$_G['uid'] && !$gid && $_G['setting']['cacheindexlife'] && !defined('IN_ARCHIVER') && !defined('IN_MOBILE')) {
  15. get_index_page_guest_cache();
  16. }
  17. $newthreads = round((TIMESTAMP - $_G['member']['lastvisit'] + 600) / 1000) * 1000;
  18. $catlist = $forumlist = $sublist = $forumname = $collapse = $favforumlist = array();
  19. $threads = $posts = $todayposts = $announcepm = 0;
  20. $postdata = $_G['cache']['historyposts'] ? explode("\t", $_G['cache']['historyposts']) : array(0,0);
  21. $postdata[0] = intval($postdata[0]);
  22. $postdata[1] = intval($postdata[1]);
  23. list($navtitle, $metadescription, $metakeywords) = get_seosetting('forum');
  24. if(!$navtitle) {
  25. $navtitle = $_G['setting']['navs'][2]['navname'];
  26. $nobbname = false;
  27. } else {
  28. $nobbname = true;
  29. }
  30. if(!$metadescription) {
  31. $metadescription = $navtitle;
  32. }
  33. if(!$metakeywords) {
  34. $metakeywords = $navtitle;
  35. }
  36. if($_G['setting']['indexhot']['status'] && $_G['cache']['heats']['expiration'] < TIMESTAMP) {
  37. require_once libfile('function/cache');
  38. updatecache('heats');
  39. }
  40. if($_G['uid'] && empty($_G['cookie']['nofavfid'])) {
  41. $favfids = array();
  42. $forum_favlist = C::t('home_favorite')->fetch_all_by_uid_idtype($_G['uid'], 'fid');
  43. if(!$forum_favlist) {
  44. dsetcookie('nofavfid', 1, 31536000);
  45. }
  46. foreach($forum_favlist as $key => $favorite) {
  47. if(defined('IN_MOBILE')) {
  48. $forum_favlist[$key]['title'] = strip_tags($favorite['title']);
  49. }
  50. $favfids[] = $favorite['id'];
  51. }
  52. if($favfids) {
  53. $favforumlist = C::t('forum_forum')->fetch_all($favfids);
  54. $favforumlist_fields = C::t('forum_forumfield')->fetch_all($favfids);
  55. foreach($favforumlist as $id => $forum) {
  56. if($favforumlist_fields[$forum['fid']]['fid']) {
  57. $favforumlist[$id] = array_merge($forum, $favforumlist_fields[$forum['fid']]);
  58. }
  59. forum($favforumlist[$id]);
  60. }
  61. }
  62. }
  63. if(!$gid && $_G['setting']['collectionstatus'] && ($_G['setting']['collectionrecommendnum'] || !$_G['setting']['hidefollowcollection'])) {
  64. require_once libfile('function/cache');
  65. loadcache('collection_index');
  66. $collectionrecommend = dunserialize($_G['setting']['collectionrecommend']);
  67. if(TIMESTAMP - $_G['cache']['collection_index']['dateline'] > 3600 * 4) {
  68. $collectiondata = $followdata = array();
  69. if($_G['setting']['collectionrecommendnum']) {
  70. if($collectionrecommend['ctids']) {
  71. $collectionrecommend['ctidsKey'] = array_keys($collectionrecommend['ctids']);
  72. $tmpcollection = C::t('forum_collection')->fetch_all($collectionrecommend['ctidsKey']);
  73. foreach($collectionrecommend['ctids'] as $ctid=>$setcollection) {
  74. if($tmpcollection[$ctid]) {
  75. $collectiondata[$ctid] = $tmpcollection[$ctid];
  76. }
  77. }
  78. unset($tmpcollection, $ctid, $setcollection);
  79. }
  80. if($collectionrecommend['autorecommend']) {
  81. require_once libfile('function/collection');
  82. $autorecommenddata = getHotCollection(500);
  83. }
  84. }
  85. savecache('collection_index', array('dateline' => TIMESTAMP, 'data' => $collectiondata, 'auto' => $autorecommenddata));
  86. $collectiondata = array('data' => $collectiondata, 'auto' => $autorecommenddata);
  87. } else {
  88. $collectiondata = &$_G['cache']['collection_index'];
  89. }
  90. if($_G['setting']['showfollowcollection']) {
  91. $followcollections = $_G['uid'] ? C::t('forum_collectionfollow')->fetch_all_by_uid($_G['uid']) : array();;
  92. if($followcollections) {
  93. $collectiondata['follows'] = C::t('forum_collection')->fetch_all(array_keys($followcollections), 'dateline', 'DESC', 0, $_G['setting']['showfollowcollection']);
  94. }
  95. }
  96. if($collectionrecommend['autorecommend'] && $collectiondata['auto']) {
  97. $randrecommend = array_rand($collectiondata['auto'], min($collectionrecommend['autorecommend'], count($collectiondata['auto'])));
  98. if($randrecommend && !is_array($randrecommend)) {
  99. $collectiondata['data'][$randrecommend] = $collectiondata['auto'][$randrecommend];
  100. } else {
  101. foreach($randrecommend as $ctid) {
  102. $collectiondata['data'][$ctid] = $collectiondata['auto'][$ctid];
  103. }
  104. }
  105. }
  106. if($collectiondata['data']) {
  107. $collectiondata['data'] = array_slice($collectiondata['data'], 0, $collectionrecommend['autorecommend'], true);
  108. }
  109. }
  110. if(empty($gid) && empty($_G['member']['accessmasks']) && empty($showoldetails)) {
  111. extract(get_index_memory_by_groupid($_G['member']['groupid']));
  112. if(defined('FORUM_INDEX_PAGE_MEMORY') && FORUM_INDEX_PAGE_MEMORY) {
  113. categorycollapse();
  114. if(!defined('IN_ARCHIVER')) {
  115. include template('diy:forum/discuz');
  116. } else {
  117. include loadarchiver('forum/discuz');
  118. }
  119. dexit();
  120. }
  121. }
  122. $grids = array();
  123. if($_G['setting']['grid']['showgrid']) {
  124. loadcache('grids');
  125. $cachelife = $_G['setting']['grid']['cachelife'] ? $_G['setting']['grid']['cachelife'] : 600;
  126. $now = dgmdate(TIMESTAMP, lang('form/misc', 'y_m_d')).' '.lang('forum/misc', 'week_'.dgmdate(TIMESTAMP, 'w'));
  127. if(TIMESTAMP - $_G['cache']['grids']['cachetime'] < $cachelife) {
  128. $grids = $_G['cache']['grids'];
  129. } else {
  130. $images = array();
  131. $_G['setting']['grid']['fids'] = in_array(0, $_G['setting']['grid']['fids']) ? 0 : $_G['setting']['grid']['fids'];
  132. if($_G['setting']['grid']['gridtype']) {
  133. $grids['digest'] = C::t('forum_thread')->fetch_all_for_guide('digest', 0, array(), 3, 0, 0, 10, $_G['setting']['grid']['fids']);
  134. } else {
  135. $images = C::t('forum_threadimage')->fetch_all_order_by_tid(10);
  136. foreach($images as $key => $value) {
  137. $tids[$value['tid']] = $value['tid'];
  138. }
  139. $grids['image'] = C::t('forum_thread')->fetch_all_by_tid($tids);
  140. }
  141. $grids['newthread'] = C::t('forum_thread')->fetch_all_for_guide('newthread', 0, array(), 0, 0, 0, 10, $_G['setting']['grid']['fids']);
  142. $grids['newreply'] = C::t('forum_thread')->fetch_all_for_guide('reply', 0, array(), 0, 0, 0, 10, $_G['setting']['grid']['fids']);
  143. $grids['hot'] = C::t('forum_thread')->fetch_all_for_guide('hot', 0, array(), 3, 0, 0, 10, $_G['setting']['grid']['fids']);
  144. $_G['forum_colorarray'] = array('', '#EE1B2E', '#EE5023', '#996600', '#3C9D40', '#2897C5', '#2B65B7', '#8F2A90', '#EC1282');
  145. foreach($grids as $type => $gridthreads) {
  146. foreach($gridthreads as $key => $gridthread) {
  147. $gridthread['dateline'] = str_replace('"', '\'', dgmdate($gridthread['dateline'], 'u', '9999', getglobal('setting/dateformat')));
  148. $gridthread['lastpost'] = str_replace('"', '\'', dgmdate($gridthread['lastpost'], 'u', '9999', getglobal('setting/dateformat')));
  149. if($gridthread['highlight'] && $_G['setting']['grid']['highlight']) {
  150. $string = sprintf('%02d', $gridthread['highlight']);
  151. $stylestr = sprintf('%03b', $string[0]);
  152. $gridthread['highlight'] = ' style="';
  153. $gridthread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';
  154. $gridthread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';
  155. $gridthread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';
  156. $gridthread['highlight'] .= $string[1] ? 'color: '.$_G['forum_colorarray'][$string[1]] : '';
  157. $gridthread['highlight'] .= '"';
  158. } else {
  159. $gridthread['highlight'] = '';
  160. }
  161. if($_G['setting']['grid']['textleng']) {
  162. $gridthread['oldsubject'] = dhtmlspecialchars($gridthread['subject']);
  163. $gridthread['subject'] = cutstr($gridthread['subject'], $_G['setting']['grid']['textleng']);
  164. }
  165. $grids[$type][$key] = $gridthread;
  166. }
  167. }
  168. if(!$_G['setting']['grid']['gridtype']) {
  169. $focuspic = $focusurl = $focustext = array();
  170. $grids['focus'] = 'config=5|0xffffff|0x0099ff|50|0xffffff|0x0099ff|0x000000';
  171. foreach($grids['image'] as $ithread) {
  172. if($ithread['displayorder'] < 0) {
  173. continue;
  174. }
  175. if($images[$ithread['tid']]['remote']) {
  176. $imageurl = $_G['setting']['ftp']['attachurl'].'forum/'.$images[$ithread['tid']]['attachment'];
  177. } else {
  178. $imageurl = $_G['setting']['attachurl'].'forum/'.$images[$ithread['tid']]['attachment'];
  179. }
  180. $grids['slide'][$ithread['tid']] = array(
  181. 'image' => $imageurl,
  182. 'url' => 'forum.php?mod=viewthread&tid='.$ithread['tid'],
  183. 'subject' => addslashes($ithread['subject'])
  184. );
  185. }
  186. }
  187. $grids['cachetime'] = TIMESTAMP;
  188. savecache('grids', $grids);
  189. }
  190. }
  191. if(!$gid && (!defined('FORUM_INDEX_PAGE_MEMORY') || !FORUM_INDEX_PAGE_MEMORY)) {
  192. $announcements = get_index_announcements();
  193. $forums = C::t('forum_forum')->fetch_all_by_status(1);
  194. $fids = array();
  195. foreach($forums as $forum) {
  196. $fids[$forum['fid']] = $forum['fid'];
  197. }
  198. $forum_access = array();
  199. if(!empty($_G['member']['accessmasks'])) {
  200. $forum_access = C::t('forum_access')->fetch_all_by_fid_uid($fids, $_G['uid']);
  201. }
  202. $forum_fields = C::t('forum_forumfield')->fetch_all($fids);
  203. foreach($forums as $forum) {
  204. if($forum_fields[$forum['fid']]['fid']) {
  205. $forum = array_merge($forum, $forum_fields[$forum['fid']]);
  206. }
  207. if($forum_access['fid']) {
  208. $forum = array_merge($forum, $forum_access[$forum['fid']]);
  209. }
  210. $forumname[$forum['fid']] = strip_tags($forum['name']);
  211. $forum['extra'] = empty($forum['extra']) ? array() : dunserialize($forum['extra']);
  212. if(!is_array($forum['extra'])) {
  213. $forum['extra'] = array();
  214. }
  215. if($forum['type'] != 'group') {
  216. $threads += $forum['threads'];
  217. $posts += $forum['posts'];
  218. $todayposts += $forum['todayposts'];
  219. if($forum['type'] == 'forum' && isset($catlist[$forum['fup']])) {
  220. if(forum($forum)) {
  221. $catlist[$forum['fup']]['forums'][] = $forum['fid'];
  222. $forum['orderid'] = $catlist[$forum['fup']]['forumscount']++;
  223. $forum['subforums'] = '';
  224. $forumlist[$forum['fid']] = $forum;
  225. }
  226. } elseif(isset($forumlist[$forum['fup']])) {
  227. $forumlist[$forum['fup']]['threads'] += $forum['threads'];
  228. $forumlist[$forum['fup']]['posts'] += $forum['posts'];
  229. $forumlist[$forum['fup']]['todayposts'] += $forum['todayposts'];
  230. if($_G['setting']['subforumsindex'] && $forumlist[$forum['fup']]['permission'] == 2 && !($forumlist[$forum['fup']]['simple'] & 16) || ($forumlist[$forum['fup']]['simple'] & 8)) {
  231. $forumurl = !empty($forum['domain']) && !empty($_G['setting']['domain']['root']['forum']) ? 'http://'.$forum['domain'].'.'.$_G['setting']['domain']['root']['forum'] : 'forum.php?mod=forumdisplay&fid='.$forum['fid'];
  232. $forumlist[$forum['fup']]['subforums'] .= (empty($forumlist[$forum['fup']]['subforums']) ? '' : ', ').'<a href="'.$forumurl.'" '.(!empty($forum['extra']['namecolor']) ? ' style="color: ' . $forum['extra']['namecolor'].';"' : '') . '>'.$forum['name'].'</a>';
  233. }
  234. }
  235. } else {
  236. if($forum['moderators']) {
  237. $forum['moderators'] = moddisplay($forum['moderators'], 'flat');
  238. }
  239. $forum['forumscount'] = 0;
  240. $catlist[$forum['fid']] = $forum;
  241. }
  242. }
  243. unset($forum_access, $forum_fields);
  244. foreach($catlist as $catid => $category) {
  245. $catlist[$catid]['collapseimg'] = 'collapsed_no.gif';
  246. if($catlist[$catid]['forumscount'] && $category['forumcolumns']) {
  247. $catlist[$catid]['forumcolwidth'] = (floor(100 / $category['forumcolumns']) - 0.1).'%';
  248. $catlist[$catid]['endrows'] = '';
  249. if($colspan = $category['forumscount'] % $category['forumcolumns']) {
  250. while(($category['forumcolumns'] - $colspan) > 0) {
  251. $catlist[$catid]['endrows'] .= '<td width="'.$catlist[$catid]['forumcolwidth'].'">&nbsp;</td>';
  252. $colspan ++;
  253. }
  254. }
  255. } elseif(empty($category['forumscount'])) {
  256. unset($catlist[$catid]);
  257. }
  258. }
  259. unset($catid, $category);
  260. if(isset($catlist[0]) && $catlist[0]['forumscount']) {
  261. $catlist[0]['fid'] = 0;
  262. $catlist[0]['type'] = 'group';
  263. $catlist[0]['name'] = $_G['setting']['bbname'];
  264. $catlist[0]['collapseimg'] = 'collapsed_no.gif';
  265. } else {
  266. unset($catlist[0]);
  267. }
  268. if(!IS_ROBOT && ($_G['setting']['whosonlinestatus'] == 1 || $_G['setting']['whosonlinestatus'] == 3)) {
  269. $_G['setting']['whosonlinestatus'] = 1;
  270. $onlineinfo = explode("\t", $_G['cache']['onlinerecord']);
  271. if(empty($_G['cookie']['onlineusernum'])) {
  272. $onlinenum = C::app()->session->count();
  273. if($onlinenum > $onlineinfo[0]) {
  274. $onlinerecord = "$onlinenum\t".TIMESTAMP;
  275. C::t('common_setting')->update('onlinerecord', $onlinerecord);
  276. savecache('onlinerecord', $onlinerecord);
  277. $onlineinfo = array($onlinenum, TIMESTAMP);
  278. }
  279. dsetcookie('onlineusernum', intval($onlinenum), 300);
  280. } else {
  281. $onlinenum = intval($_G['cookie']['onlineusernum']);
  282. }
  283. $onlineinfo[1] = dgmdate($onlineinfo[1], 'd');
  284. $detailstatus = $showoldetails == 'yes' || (((!isset($_G['cookie']['onlineindex']) && !$_G['setting']['whosonline_contract']) || $_G['cookie']['onlineindex']) && $onlinenum < 500 && !$showoldetails);
  285. $guestcount = $membercount = 0;
  286. if(!empty($_G['setting']['sessionclose'])) {
  287. $detailstatus = false;
  288. $membercount = C::app()->session->count(1);
  289. $guestcount = $onlinenum - $membercount;
  290. }
  291. if($detailstatus) {
  292. $actioncode = lang('action');
  293. $_G['uid'] && updatesession();
  294. $whosonline = array();
  295. $_G['setting']['maxonlinelist'] = $_G['setting']['maxonlinelist'] ? $_G['setting']['maxonlinelist'] : 500;
  296. foreach(C::app()->session->fetch_member(1, 0, $_G['setting']['maxonlinelist']) as $online){
  297. $membercount ++;
  298. if($online['invisible']) {
  299. $invisiblecount++;
  300. continue;
  301. } else {
  302. $online['icon'] = !empty($_G['cache']['onlinelist'][$online['groupid']]) ? $_G['cache']['onlinelist'][$online['groupid']] : $_G['cache']['onlinelist'][0];
  303. }
  304. $online['lastactivity'] = dgmdate($online['lastactivity'], 't');
  305. $whosonline[] = $online;
  306. }
  307. if(isset($_G['cache']['onlinelist'][7]) && $_G['setting']['maxonlinelist'] > $membercount) {
  308. foreach(C::app()->session->fetch_member(2, 0, $_G['setting']['maxonlinelist'] - $membercount) as $online){
  309. $online['icon'] = $_G['cache']['onlinelist'][7];
  310. $online['username'] = $_G['cache']['onlinelist']['guest'];
  311. $online['lastactivity'] = dgmdate($online['lastactivity'], 't');
  312. $whosonline[] = $online;
  313. }
  314. }
  315. unset($actioncode, $online);
  316. if($onlinenum > $_G['setting']['maxonlinelist']) {
  317. $membercount = C::app()->session->count(1);
  318. $invisiblecount = C::app()->session->count_invisible();
  319. }
  320. if($onlinenum < $membercount) {
  321. $onlinenum = C::app()->session->count();
  322. dsetcookie('onlineusernum', intval($onlinenum), 300);
  323. }
  324. $invisiblecount = intval($invisiblecount);
  325. $guestcount = $onlinenum - $membercount;
  326. unset($online);
  327. }
  328. } else {
  329. $_G['setting']['whosonlinestatus'] = 0;
  330. }
  331. if(defined('FORUM_INDEX_PAGE_MEMORY') && !FORUM_INDEX_PAGE_MEMORY) {
  332. $key = !IS_ROBOT ? $_G['member']['groupid'] : 'for_robot';
  333. memory('set', 'forum_index_page_'.$key, array(
  334. 'catlist' => $catlist,
  335. 'forumlist' => $forumlist,
  336. 'sublist' => $sublist,
  337. 'whosonline' => $whosonline,
  338. 'onlinenum' => $onlinenum,
  339. 'membercount' => $membercount,
  340. 'guestcount' => $guestcount,
  341. 'grids' => $grids,
  342. 'announcements' => $announcements,
  343. 'threads' => $threads,
  344. 'posts' => $posts,
  345. 'todayposts' => $todayposts,
  346. 'onlineinfo' => $onlineinfo,
  347. 'announcepm' => $announcepm), getglobal('setting/memory/forumindex'));
  348. }
  349. } else {
  350. require_once DISCUZ_ROOT.'./source/include/misc/misc_category.php';
  351. }
  352. if(defined('IN_ARCHIVER')) {
  353. include loadarchiver('forum/discuz');
  354. exit();
  355. }
  356. categorycollapse();
  357. if($gid && !empty($catlist)) {
  358. $_G['category'] = $catlist[$gid];
  359. $forumseoset = array(
  360. 'seotitle' => $catlist[$gid]['seotitle'],
  361. 'seokeywords' => $catlist[$gid]['keywords'],
  362. 'seodescription' => $catlist[$gid]['seodescription']
  363. );
  364. $seodata = array('fgroup' => $catlist[$gid]['name']);
  365. list($navtitle, $metadescription, $metakeywords) = get_seosetting('threadlist', $seodata, $forumseoset);
  366. if(empty($navtitle)) {
  367. $navtitle = $navtitle_g;
  368. $nobbname = false;
  369. } else {
  370. $nobbname = true;
  371. }
  372. $_G['fid'] = $gid;
  373. }
  374. include template('diy:forum/discuz:'.$gid);
  375. function get_index_announcements() {
  376. global $_G;
  377. $announcements = '';
  378. if($_G['cache']['announcements']) {
  379. $readapmids = !empty($_G['cookie']['readapmid']) ? explode('D', $_G['cookie']['readapmid']) : array();
  380. foreach($_G['cache']['announcements'] as $announcement) {
  381. if(!$announcement['endtime'] || $announcement['endtime'] > TIMESTAMP && (empty($announcement['groups']) || in_array($_G['member']['groupid'], $announcement['groups']))) {
  382. if(empty($announcement['type'])) {
  383. $announcements .= '<li><span><a href="forum.php?mod=announcement&id='.$announcement['id'].'" target="_blank" class="xi2">'.$announcement['subject'].
  384. '</a></span><em>('.dgmdate($announcement['starttime'], 'd').')</em></li>';
  385. } elseif($announcement['type'] == 1) {
  386. $announcements .= '<li><span><a href="'.$announcement['message'].'" target="_blank" class="xi2">'.$announcement['subject'].
  387. '</a></span><em>('.dgmdate($announcement['starttime'], 'd').')</em></li>';
  388. }
  389. }
  390. }
  391. }
  392. return $announcements;
  393. }
  394. function get_index_page_guest_cache() {
  395. global $_G;
  396. $indexcache = getcacheinfo(0);
  397. if(TIMESTAMP - $indexcache['filemtime'] > $_G['setting']['cacheindexlife']) {
  398. @unlink($indexcache['filename']);
  399. define('CACHE_FILE', $indexcache['filename']);
  400. } elseif($indexcache['filename']) {
  401. @readfile($indexcache['filename']);
  402. $updatetime = dgmdate($indexcache['filemtime'], 'H:i:s');
  403. $gzip = $_G['gzipcompress'] ? ', Gzip enabled' : '';
  404. echo "<script type=\"text/javascript\">
  405. if($('debuginfo')) {
  406. $('debuginfo').innerHTML = '. This page is cached at $updatetime $gzip .';
  407. }
  408. </script>";
  409. echo '</body></html>';
  410. exit();
  411. }
  412. }
  413. function get_index_memory_by_groupid($key) {
  414. $enable = getglobal('setting/memory/forumindex');
  415. if($enable !== null && memory('check')) {
  416. if(IS_ROBOT) {
  417. $key = 'for_robot';
  418. }
  419. $ret = memory('get', 'forum_index_page_'.$key);
  420. define('FORUM_INDEX_PAGE_MEMORY', $ret ? 1 : 0);
  421. if($ret) {
  422. return $ret;
  423. }
  424. }
  425. return array('none' => null);
  426. }
  427. function get_index_online_details() {
  428. $showoldetails = getgpc('showoldetails');
  429. switch($showoldetails) {
  430. case 'no': dsetcookie('onlineindex', ''); break;
  431. case 'yes': dsetcookie('onlineindex', 1, 86400 * 365); break;
  432. }
  433. return $showoldetails;
  434. }
  435. function do_forum_bind_domains() {
  436. global $_G;
  437. if($_G['setting']['binddomains'] && $_G['setting']['forumdomains']) {
  438. $loadforum = isset($_G['setting']['binddomains'][$_SERVER['HTTP_HOST']]) ? max(0, intval($_G['setting']['binddomains'][$_SERVER['HTTP_HOST']])) : 0;
  439. if($loadforum) {
  440. dheader('Location: '.$_G['setting']['siteurl'].'/forum.php?mod=forumdisplay&fid='.$loadforum);
  441. }
  442. }
  443. }
  444. function categorycollapse() {
  445. global $_G, $collapse, $catlist;
  446. if(!$_G['uid']) {
  447. return;
  448. }
  449. foreach($catlist as $fid => $forum) {
  450. if(!isset($_G['cookie']['collapse']) || strpos($_G['cookie']['collapse'], '_category_'.$fid.'_') === FALSE) {
  451. $catlist[$fid]['collapseimg'] = 'collapsed_no.gif';
  452. $collapse['category_'.$fid] = '';
  453. } else {
  454. $catlist[$fid]['collapseimg'] = 'collapsed_yes.gif';
  455. $collapse['category_'.$fid] = 'display: none';
  456. }
  457. }
  458. for($i = -2; $i <= 0; $i++) {
  459. if(!isset($_G['cookie']['collapse']) || strpos($_G['cookie']['collapse'], '_category_'.$i.'_') === FALSE) {
  460. $collapse['collapseimg_'.$i] = 'collapsed_no.gif';
  461. $collapse['category_'.$i] = '';
  462. } else {
  463. $collapse['collapseimg_'.$i] = 'collapsed_yes.gif';
  464. $collapse['category_'.$i] = 'display: none';
  465. }
  466. }
  467. }
  468. ?>