fetch_all_by_uid_idtype($_G['uid'], 'fid'); if(!$forum_favlist) { dsetcookie('nofavfid', 1, 31536000); } foreach($forum_favlist as $key => $favorite) { if(defined('IN_MOBILE')) { $forum_favlist[$key]['title'] = strip_tags($favorite['title']); } $favfids[] = $favorite['id']; } if($favfids) { $favforumlist = C::t('forum_forum')->fetch_all($favfids); $favforumlist_fields = C::t('forum_forumfield')->fetch_all($favfids); foreach($favforumlist as $id => $forum) { if($favforumlist_fields[$forum['fid']]['fid']) { $favforumlist[$id] = array_merge($forum, $favforumlist_fields[$forum['fid']]); } forum($favforumlist[$id]); } } } if(!$gid && $_G['setting']['collectionstatus'] && ($_G['setting']['collectionrecommendnum'] || !$_G['setting']['hidefollowcollection'])) { require_once libfile('function/cache'); loadcache('collection_index'); $collectionrecommend = dunserialize($_G['setting']['collectionrecommend']); if(TIMESTAMP - $_G['cache']['collection_index']['dateline'] > 3600 * 4) { $collectiondata = $followdata = array(); if($_G['setting']['collectionrecommendnum']) { if($collectionrecommend['ctids']) { $collectionrecommend['ctidsKey'] = array_keys($collectionrecommend['ctids']); $tmpcollection = C::t('forum_collection')->fetch_all($collectionrecommend['ctidsKey']); foreach($collectionrecommend['ctids'] as $ctid=>$setcollection) { if($tmpcollection[$ctid]) { $collectiondata[$ctid] = $tmpcollection[$ctid]; } } unset($tmpcollection, $ctid, $setcollection); } if($collectionrecommend['autorecommend']) { require_once libfile('function/collection'); $autorecommenddata = getHotCollection(500); } } savecache('collection_index', array('dateline' => TIMESTAMP, 'data' => $collectiondata, 'auto' => $autorecommenddata)); $collectiondata = array('data' => $collectiondata, 'auto' => $autorecommenddata); } else { $collectiondata = &$_G['cache']['collection_index']; } if($_G['setting']['showfollowcollection']) { $followcollections = $_G['uid'] ? C::t('forum_collectionfollow')->fetch_all_by_uid($_G['uid']) : array();; if($followcollections) { $collectiondata['follows'] = C::t('forum_collection')->fetch_all(array_keys($followcollections), 'dateline', 'DESC', 0, $_G['setting']['showfollowcollection']); } } if($collectionrecommend['autorecommend'] && $collectiondata['auto']) { $randrecommend = array_rand($collectiondata['auto'], min($collectionrecommend['autorecommend'], count($collectiondata['auto']))); if($randrecommend && !is_array($randrecommend)) { $collectiondata['data'][$randrecommend] = $collectiondata['auto'][$randrecommend]; } else { foreach($randrecommend as $ctid) { $collectiondata['data'][$ctid] = $collectiondata['auto'][$ctid]; } } } if($collectiondata['data']) { $collectiondata['data'] = array_slice($collectiondata['data'], 0, $collectionrecommend['autorecommend'], true); } } if(empty($gid) && empty($_G['member']['accessmasks']) && empty($showoldetails)) { extract(get_index_memory_by_groupid($_G['member']['groupid'])); if(defined('FORUM_INDEX_PAGE_MEMORY') && FORUM_INDEX_PAGE_MEMORY) { categorycollapse(); if(!defined('IN_ARCHIVER')) { include template('diy:forum/discuz'); } else { include loadarchiver('forum/discuz'); } dexit(); } } $grids = array(); if($_G['setting']['grid']['showgrid']) { loadcache('grids'); $cachelife = $_G['setting']['grid']['cachelife'] ? $_G['setting']['grid']['cachelife'] : 600; $now = dgmdate(TIMESTAMP, lang('form/misc', 'y_m_d')).' '.lang('forum/misc', 'week_'.dgmdate(TIMESTAMP, 'w')); if(TIMESTAMP - $_G['cache']['grids']['cachetime'] < $cachelife) { $grids = $_G['cache']['grids']; } else { $images = array(); $_G['setting']['grid']['fids'] = in_array(0, $_G['setting']['grid']['fids']) ? 0 : $_G['setting']['grid']['fids']; if($_G['setting']['grid']['gridtype']) { $grids['digest'] = C::t('forum_thread')->fetch_all_for_guide('digest', 0, array(), 3, 0, 0, 10, $_G['setting']['grid']['fids']); } else { $images = C::t('forum_threadimage')->fetch_all_order_by_tid(10); foreach($images as $key => $value) { $tids[$value['tid']] = $value['tid']; } $grids['image'] = C::t('forum_thread')->fetch_all_by_tid($tids); } $grids['newthread'] = C::t('forum_thread')->fetch_all_for_guide('newthread', 0, array(), 0, 0, 0, 10, $_G['setting']['grid']['fids']); $grids['newreply'] = C::t('forum_thread')->fetch_all_for_guide('reply', 0, array(), 0, 0, 0, 10, $_G['setting']['grid']['fids']); $grids['hot'] = C::t('forum_thread')->fetch_all_for_guide('hot', 0, array(), 3, 0, 0, 10, $_G['setting']['grid']['fids']); $_G['forum_colorarray'] = array('', '#EE1B2E', '#EE5023', '#996600', '#3C9D40', '#2897C5', '#2B65B7', '#8F2A90', '#EC1282'); foreach($grids as $type => $gridthreads) { foreach($gridthreads as $key => $gridthread) { $gridthread['dateline'] = str_replace('"', '\'', dgmdate($gridthread['dateline'], 'u', '9999', getglobal('setting/dateformat'))); $gridthread['lastpost'] = str_replace('"', '\'', dgmdate($gridthread['lastpost'], 'u', '9999', getglobal('setting/dateformat'))); if($gridthread['highlight'] && $_G['setting']['grid']['highlight']) { $string = sprintf('%02d', $gridthread['highlight']); $stylestr = sprintf('%03b', $string[0]); $gridthread['highlight'] = ' style="'; $gridthread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : ''; $gridthread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : ''; $gridthread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : ''; $gridthread['highlight'] .= $string[1] ? 'color: '.$_G['forum_colorarray'][$string[1]] : ''; $gridthread['highlight'] .= '"'; } else { $gridthread['highlight'] = ''; } if($_G['setting']['grid']['textleng']) { $gridthread['oldsubject'] = dhtmlspecialchars($gridthread['subject']); $gridthread['subject'] = cutstr($gridthread['subject'], $_G['setting']['grid']['textleng']); } $grids[$type][$key] = $gridthread; } } if(!$_G['setting']['grid']['gridtype']) { $focuspic = $focusurl = $focustext = array(); $grids['focus'] = 'config=5|0xffffff|0x0099ff|50|0xffffff|0x0099ff|0x000000'; foreach($grids['image'] as $ithread) { if($ithread['displayorder'] < 0) { continue; } if($images[$ithread['tid']]['remote']) { $imageurl = $_G['setting']['ftp']['attachurl'].'forum/'.$images[$ithread['tid']]['attachment']; } else { $imageurl = $_G['setting']['attachurl'].'forum/'.$images[$ithread['tid']]['attachment']; } $grids['slide'][$ithread['tid']] = array( 'image' => $imageurl, 'url' => 'forum.php?mod=viewthread&tid='.$ithread['tid'], 'subject' => addslashes($ithread['subject']) ); } } $grids['cachetime'] = TIMESTAMP; savecache('grids', $grids); } } if(!$gid && (!defined('FORUM_INDEX_PAGE_MEMORY') || !FORUM_INDEX_PAGE_MEMORY)) { $announcements = get_index_announcements(); $forums = C::t('forum_forum')->fetch_all_by_status(1); $fids = array(); foreach($forums as $forum) { $fids[$forum['fid']] = $forum['fid']; } $forum_access = array(); if(!empty($_G['member']['accessmasks'])) { $forum_access = C::t('forum_access')->fetch_all_by_fid_uid($fids, $_G['uid']); } $forum_fields = C::t('forum_forumfield')->fetch_all($fids); foreach($forums as $forum) { if($forum_fields[$forum['fid']]['fid']) { $forum = array_merge($forum, $forum_fields[$forum['fid']]); } if($forum_access['fid']) { $forum = array_merge($forum, $forum_access[$forum['fid']]); } $forumname[$forum['fid']] = strip_tags($forum['name']); $forum['extra'] = empty($forum['extra']) ? array() : dunserialize($forum['extra']); if(!is_array($forum['extra'])) { $forum['extra'] = array(); } if($forum['type'] != 'group') { $threads += $forum['threads']; $posts += $forum['posts']; $todayposts += $forum['todayposts']; if($forum['type'] == 'forum' && isset($catlist[$forum['fup']])) { if(forum($forum)) { $catlist[$forum['fup']]['forums'][] = $forum['fid']; $forum['orderid'] = $catlist[$forum['fup']]['forumscount']++; $forum['subforums'] = ''; $forumlist[$forum['fid']] = $forum; } } elseif(isset($forumlist[$forum['fup']])) { $forumlist[$forum['fup']]['threads'] += $forum['threads']; $forumlist[$forum['fup']]['posts'] += $forum['posts']; $forumlist[$forum['fup']]['todayposts'] += $forum['todayposts']; if($_G['setting']['subforumsindex'] && $forumlist[$forum['fup']]['permission'] == 2 && !($forumlist[$forum['fup']]['simple'] & 16) || ($forumlist[$forum['fup']]['simple'] & 8)) { $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']; $forumlist[$forum['fup']]['subforums'] .= (empty($forumlist[$forum['fup']]['subforums']) ? '' : ', ').''.$forum['name'].''; } } } else { if($forum['moderators']) { $forum['moderators'] = moddisplay($forum['moderators'], 'flat'); } $forum['forumscount'] = 0; $catlist[$forum['fid']] = $forum; } } unset($forum_access, $forum_fields); foreach($catlist as $catid => $category) { $catlist[$catid]['collapseimg'] = 'collapsed_no.gif'; if($catlist[$catid]['forumscount'] && $category['forumcolumns']) { $catlist[$catid]['forumcolwidth'] = (floor(100 / $category['forumcolumns']) - 0.1).'%'; $catlist[$catid]['endrows'] = ''; if($colspan = $category['forumscount'] % $category['forumcolumns']) { while(($category['forumcolumns'] - $colspan) > 0) { $catlist[$catid]['endrows'] .= '