コード例 #1
0
 protected function get_guide_list($view, $start = 0, $num = 20, $again = 0)
 {
     global $_G;
     $setting_guide = unserialize($_G['setting']['guide']);
     if (!in_array($view, array('hot', 'digest', 'new', 'newthread'))) {
         return array();
     }
     loadcache('forums');
     loadcache('forum_guide');
     $cachetimelimit = 900;
     //cache 15分钟
     $cache = $_G['cache']['forum_guide'][$view];
     $tids = array();
     $white_list = isset($_GET['displayid']) ? $_GET['displayid'] : "";
     $black_list = isset($_GET['forbiddenid']) ? $_GET['forbiddenid'] : "";
     $white_arr = explode(',', $white_list);
     $black_arr = explode(',', $black_list);
     foreach ($_G['cache']['forums'] as $fid => $forum) {
         if ($forum['type'] != 'group' && $forum['status'] > 0 && !$forum['havepassword']) {
             if ((in_array($fid, $white_arr) || empty($white_arr[0])) && !in_array($fid, $black_arr)) {
                 $fids[] = $fid;
             }
         }
     }
     if (empty($fids)) {
         return array();
     }
     $maxnum = 50000;
     $maxtid = C::t('forum_thread')->fetch_max_tid();
     $limittid = max(0, $maxtid - $maxnum);
     if ($again) {
         $limittid = max(0, $limittid - $maxnum);
     }
     if (false) {
         $updatecache = false;
         $query = $cache['data'];
     } else {
         $dateline = 0;
         $updatecache = true;
         //need update
         $query = C::t('forum_thread')->fetch_all_for_guide($view, $limittid, $tids, $_G['setting']['heatthread']['guidelimit'], $dateline);
     }
     $n = 0;
     foreach ($query as $thread) {
         if (empty($tids) && ($thread['isgroup'] || !in_array($thread['fid'], $fids))) {
             continue;
         }
         if ($thread['displayorder'] < 0) {
             continue;
         }
         $thread = BigAppAPI::guide_procthread($thread);
         $threadids[] = $thread['tid'];
         if ($tids || $n >= $start && $n < $start + $num) {
             $list[$thread[tid]] = $thread;
             $fids[$thread[fid]] = $thread['fid'];
         }
         $n++;
     }
     if ($limittid > $maxnum && !$again && count($list) < 50) {
         return BigAppAPI::get_guide_list($view, $start, $num, 1);
     }
     $forumnames = array();
     if ($fids) {
         $forumnames = C::t('forum_forum')->fetch_all_name_by_fid($fids);
     }
     $threadlist = array();
     if ($tids) {
         $threadids = array();
         foreach ($tids as $key => $tid) {
             if ($list[$tid]) {
                 $threadlist[$key] = $list[$tid];
                 $threadids[] = $tid;
             }
         }
     } else {
         $threadlist = $list;
     }
     unset($list);
     $threadcount = count($threadids);
     /*if($updatecache) {
     			//cache 处理之前帖子数据
     			$data = array('cachetime' => TIMESTAMP, 'data' => $query);
     			$_G['cache']['forum_guide'][$view] = $data;
     			savecache('forum_guide', $_G['cache']['forum_guide']);
     		}*/
     return array('forumnames' => $forumnames, 'threadcount' => $threadcount, 'threadlist' => $threadlist);
 }