【discuzx2】forum_index.php文件的分析

http://blog.csdn.net/yanhui_wei/article/details/9851435
  1. <?php  
  2.   
  3. /** 
  4.  *      [Discuz!] (C)2001-2099 Comsenz Inc. 
  5.  *      This is NOT a freeware, use is subject to license terms 
  6.  * 
  7.  *      $Id: forum_index.php 29580 2012-04-20 02:53:59Z svn_project_zhangjie $ 
  8.  */  
  9.   
  10. //mod文件只能被入口文件引用,不能直接訪問  
  11. if(!defined('IN_DISCUZ')) {  
  12.     exit('Access Denied');  
  13. }  
  14.   
  15. /** 
  16. * 返回庫文件的全路徑 
  17. * 
  18. * @param string $libname 庫文件分類及名稱 
  19. * @param string $folder 模塊目錄'module','include','class' 
  20. * @return string 
  21. * 
  22. * @example require DISCUZ_ROOT.'./source/function/function_cache.php' 
  23. * @example 我們可以利用此函數簡寫爲:require libfile('function/cache'); 
  24. * 再如:require_once libfile('space/'.$do, 'include');//包含 "/source/include/space/space_profile.php" 文件 
  25. * 1、libfile函數返回庫文件的全路徑 
  26. * 2、包含文件路徑格式:"/source/include/space/space_$do.php" 
  27. * 3、require_once "返回的庫文件的全路徑",這樣就可以將庫文件包含進來 
  28. */  
  29. require_once libfile('function/forumlist');//引入"/source/function/function_forumlist.php"函數庫文件  
  30.   
  31. $gid = intval(getgpc('gid'));//默認值爲0:分區id;何爲分區?簡單說,就是凌駕與版塊之上的一個分類  
  32. $showoldetails = get_index_online_details();//默認情況下爲空值,不知道怎麼回事  
  33.   
  34. //論壇首頁緩存更細時間,0-不開啓  
  35. //uid-管理員id   gid-分區id   cacheindexlife-首頁緩存時間  
  36. //gid爲空的情況  
  37. if(!$_G['uid'] && !$gid && $_G['setting']['cacheindexlife'] && !defined('IN_ARCHIVER') && !defined('IN_MOBILE')) {  
  38.     get_index_page_guest_cache();//此代碼只針對遊客  
  39. }  
  40.   
  41. $newthreads = round((TIMESTAMP - $_G['member']['lastvisit'] + 600) / 1000) * 1000;  
  42. //初始化數組變量  
  43. $catlist = $forumlist = $sublist = $forumname = $collapse = $favforumlist = array();  
  44. //初始化普通變量:主題、帖子、今日帖子、短消息  
  45. $threads = $posts = $todayposts = $announcepm = 0;  
  46. //定義發帖數量  
  47. $postdata = $_G['cache']['historyposts'] ? explode("\t"$_G['cache']['historyposts']) : array(0,0);  
  48. $postdata[0] = intval($postdata[0]);//昨日發帖  
  49. $postdata[1] = intval($postdata[1]);//歷史最高發帖  
  50.   
  51. //創建站點欄目名稱、描述、關鍵字  
  52. list($navtitle$metadescription$metakeywords) = get_seosetting('forum');  
  53. if(!$navtitle) {//$navtitle-默認值爲“論壇”  
  54.     $navtitle = $_G['setting']['navs'][2]['navname'];  
  55.     $nobbname = false;  
  56. else {  
  57.         //默認執行  
  58.     $nobbname = true;  
  59. }  
  60. //描述  
  61. if(!$metadescription) {  
  62.     $metadescription = $navtitle;  
  63. }  
  64. //關鍵字  
  65. if(!$metakeywords) {  
  66.     $metakeywords = $navtitle;  
  67. }  
  68.   
  69. //heatthread:熱帖  
  70. if($_G['setting']['indexhot']['status'] && $_G['cache']['heats']['expiration'] < TIMESTAMP) {  
  71.     require_once libfile('function/cache');//引入"/source/function/function_cache.php"函數庫文件  
  72.     updatecache('heats');  
  73. }  
  74.   
  75. if($_G['uid'] && empty($_G['cookie']['nofavfid'])) {  
  76.     $favfids = array();  
  77.     $forum_favlist = C::t('home_favorite')->fetch_all_by_uid_idtype($_G['uid'], 'fid');  
  78.     if(!$forum_favlist) {  
  79.         dsetcookie('nofavfid', 1, 31536000);  
  80.     }  
  81.     foreach($forum_favlist as $key => $favorite) {  
  82.         if(defined('IN_MOBILE')) {  
  83.             $forum_favlist[$key]['title'] = strip_tags($favorite['title']);  
  84.         }  
  85.         $favfids[] = $favorite['id'];  
  86.     }  
  87.     if($favfids) {  
  88.         $favforumlist = C::t('forum_forum')->fetch_all($favfids);  
  89.         foreach($favforumlist as $id => $forum) {  
  90.             forum($favforumlist[$id]);  
  91.         }  
  92.     }  
  93. }  
  94.   
  95.   
  96. //默認情況下不執行,即:直接跳過這段if代碼段  
  97. if(empty($gid) && empty($_G['member']['accessmasks']) && empty($showoldetails)) {  
  98.     extract(get_index_memory_by_groupid($_G['member']['groupid']));  
  99.     if(defined('FORUM_INDEX_PAGE_MEMORY') && FORUM_INDEX_PAGE_MEMORY) {  
  100.         categorycollapse();  
  101.         if(!defined('IN_ARCHIVER')) {  
  102.             include template('diy:forum/discuz');//引入模板文件的方式  
  103.         } else {  
  104.             include loadarchiver('forum/discuz');  
  105.         }  
  106.         dexit();  
  107.     }  
  108. }  
  109.   
  110. //默認情況下執行此if代碼段;FORUM_INDEX_PAGE_MEMORY是首頁所有緩存數據的一個常量  
  111. //gid爲空的情況             FORUM_INDEX_PAGE_MEMORY常量  
  112. if(!$gid && (!defined('FORUM_INDEX_PAGE_MEMORY') || !FORUM_INDEX_PAGE_MEMORY)) {  
  113.     /*格式: 
  114.          * <li><span><a href="">公告1</a></span></li> 
  115.          * <li><span><a href="">公告2</a></span></li> 
  116.          */  
  117.         $announcements = get_index_announcements();//首頁公告,此函數的定義在當前文件底部  
  118.   
  119.         //通過狀態值查詢所有開啓的版塊或分區相關信息,可查看桌面$forums = Ct('forum_forum')-fetch_all_by_status(1).txt文件  
  120.     //對應pre_forum_forum數據表中的記錄  
  121.         $forums = C::t('forum_forum')->fetch_all_by_status(1);  
  122.     //初始化一個數組變量  
  123.         $fids = array();  
  124.     foreach($forums as $forum) {//$forum-代表每一個開啓的分區或版塊相關的信息數組,一般爲一維數組  
  125.             //分區或版塊id數組,格式:$fid[分區或版塊id]=分區或版塊id;$fids[1]=1  
  126.             $fids[$forum['fid']] = $forum['fid'];//啓用的分區id或版塊id  
  127.     }  
  128.   
  129.         //初始化一個版塊訪問權限數組變量  
  130.     $forum_access = array();  
  131.     if(!empty($_G['member']['accessmasks'])) {//用戶訪問權限標誌,默認值爲1  
  132.         $forum_access = C::t('forum_access')->fetch_all_by_fid_uid($fids$_G['uid']);  
  133.     }  
  134.         //獲取版塊擴展字段信息,對應數據表:pre_forum_forumfield,查看桌面 $forum_fields.txt文件  
  135.     $forum_fields = C::t('forum_forumfield')->fetch_all($fids);  
  136.     foreach($forums as $forum) {  
  137.         if($forum_fields[$forum['fid']]['fid']) {//分區或版塊id  
  138.                         //將分區或版塊的通用信息字段或擴展字段信息合併在一起  
  139.                         //即將pre_forum_forum表的字段與pre_forum_fields表的字段合併在一起  
  140.             $forum = array_merge($forum$forum_fields[$forum['fid']]);//一維數組  
  141.         }  
  142.         if($forum_access['fid']) {  
  143.             $forum = array_merge($forum$forum_access[$forum['fid']]);  
  144.         }  
  145.                 //版塊或分區的名稱  
  146.         $forumname[$forum['fid']] = strip_tags($forum['name']);  
  147.                 //反序列化的pre_forum_forumfields表中extra字段的值  
  148.         $forum['extra'] = empty($forum['extra']) ? array() : dunserialize($forum['extra']);  
  149.         if(!is_array($forum['extra'])) {  
  150.             $forum['extra'] = array();//數組  
  151.         }  
  152.                   
  153.                 //版塊的情況,不包括分區的情況  
  154.         if($forum['type'] != 'group') {//版塊數組信息的情況   group-分區  forum-版塊  
  155.                       
  156.             $threads += $forum['threads'];//主題數量  
  157.             $posts += $forum['posts'];//帖子數量  
  158.             $todayposts += $forum['todayposts'];//今日發帖數量  
  159.   
  160.                         //版塊的情況  
  161.             if($forum['type'] == 'forum' && isset($catlist[$forum['fup']])) {//版塊存在上級分區的情況  
  162.                                 //forum函數的定義位置:"/source/function/function_forumlist.php"函數庫文件  
  163.                 if(forum($forum)) {  
  164.                     $catlist[$forum['fup']]['forums'][] = $forum['fid'];//分區下的所有的版塊id  
  165.                                         /*如下形式: 
  166.                                          * [forums] => Array         //當前分區下版塊id數組,即是fid數組 
  167.                                             ( 
  168.                                                 [0] => 2         //娛樂 
  169.                                                 [1] => 36        //文化 
  170.                                                 [2] => 37        //體育 
  171.                                                 [3] => 38        //藝術 
  172.                                                 [4] => 39        //商界 
  173.                                             ) 
  174.                                          */  
  175.                                         //排序id  
  176.                     $forum['orderid'] = $catlist[$forum['fup']]['forumscount']++;  
  177.                     //子版塊  
  178.                                         $forum['subforums'] = '';  
  179.                     $forumlist[$forum['fid']] = $forum;//僅版塊數組 $forumlist,可查看桌面$forumlist.txt文件  
  180.                 }  
  181.   
  182.             } elseif(isset($forumlist[$forum['fup']])) {//$forum['fup']=64 的情況,即:女裝版塊  
  183.                                 //女裝版塊下的子版塊數組信息  
  184.                 $forumlist[$forum['fup']]['threads'] += $forum['threads'];//主題數量  
  185.                 $forumlist[$forum['fup']]['posts'] += $forum['posts'];//帖子數量  
  186.                 $forumlist[$forum['fup']]['todayposts'] += $forum['todayposts'];//今日發帖數  
  187.                 if($_G['setting']['subforumsindex'] && $forumlist[$forum['fup']]['permission'] == 2 && !($forumlist[$forum['fup']]['simple'] & 16) || ($forumlist[$forum['fup']]['simple'] & 8)) {  
  188.                     //綁定的域名  
  189.                                         $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'];  
  190.                     $forumlist[$forum['fup']]['subforums'] .= (empty($forumlist[$forum['fup']]['subforums']) ? '' : ', ').'<a href="'.$forumurl.'" '.(!empty($forum['extra']['namecolor']) ? ' style="color: ' . $forum['extra']['namecolor'].';"' : '') . '>'.$forum['name'].'</a>';  
  191.                 }  
  192.             }  
  193.   
  194.         } else {//分區的情況,不包含版塊的情況  
  195.   
  196.             if($forum['moderators']) {//版主  
  197.                 $forum['moderators'] = moddisplay($forum['moderators'], 'flat');  
  198.             }  
  199.             $forum['forumscount']   = 0;  
  200.             $catlist[$forum['fid']] = $forum;//分區數組信息  
  201.   
  202.         }  
  203.     }  
  204.         //銷燬不用的數組變量  
  205.     unset($forum_access$forum_fields);  
  206.   
  207.         //循環分區二維數組信息   分區id  一維數組分區信息  
  208.     foreach($catlist as $catid => $category) {  
  209.         $catlist[$catid]['collapseimg'] = 'collapsed_no.gif';//伸張或收縮圖片  
  210.         if($catlist[$catid]['forumscount'] && $category['forumcolumns']) {  
  211.             $catlist[$catid]['forumcolwidth'] = (floor(100 / $category['forumcolumns']) - 0.1).'%';  
  212.             $catlist[$catid]['endrows'] = '';  
  213.             if($colspan = $category['forumscount'] % $category['forumcolumns']) {  
  214.                 while(($category['forumcolumns'] - $colspan) > 0) {  
  215.                     $catlist[$catid]['endrows'] .= '<td width="'.$catlist[$catid]['forumcolwidth'].'"> </td>';  
  216.                     $colspan ++;  
  217.                 }  
  218.                 $catlist[$catid]['endrows'] .= '</tr>';  
  219.             }  
  220.         } elseif(empty($category['forumscount'])) {  
  221.             unset($catlist[$catid]);  
  222.         }  
  223.     }  
  224.     unset($catid$category);  
  225.   
  226.     if(isset($catlist[0]) && $catlist[0]['forumscount']) {  
  227.         $catlist[0]['fid'] = 0;  
  228.         $catlist[0]['type'] = 'group';  
  229.         $catlist[0]['name'] = $_G['setting']['bbname'];  
  230.         $catlist[0]['collapseimg'] = 'collapsed_no.gif';  
  231.     } else {  
  232.         unset($catlist[0]);  
  233.     }  
  234.   
  235.     if(!IS_ROBOT && ($_G['setting']['whosonlinestatus'] == 1 || $_G['setting']['whosonlinestatus'] == 3)) {  
  236.         $_G['setting']['whosonlinestatus'] = 1;  
  237.   
  238.         $onlineinfo = explode("\t"$_G['cache']['onlinerecord']);//在線訪問記錄.Array ( [0] => 2 [1] => 1378968576 )  
  239.               
  240.         if(empty($_G['cookie']['onlineusernum'])) {//在線用戶數  
  241.             $onlinenum = C::app()->session->count();  
  242.             if($onlinenum > $onlineinfo[0]) {  
  243.                 $onlinerecord = "$onlinenum\t".TIMESTAMP;  
  244.                 C::t('common_setting')->update('onlinerecord'$onlinerecord);  
  245.                 savecache('onlinerecord'$onlinerecord);  
  246.                 $onlineinfo = array($onlinenum, TIMESTAMP);  
  247.             }  
  248.             dsetcookie('onlineusernum'intval($onlinenum), 300);  
  249.         } else {  
  250.             $onlinenum = intval($_G['cookie']['onlineusernum']);  
  251.         }  
  252.         $onlineinfo[1] = dgmdate($onlineinfo[1], 'd');  
  253.   
  254.         $detailstatus = $showoldetails == 'yes' || (((!isset($_G['cookie']['onlineindex']) && !$_G['setting']['whosonline_contract']) || $_G['cookie']['onlineindex']) && $onlinenum < 500 && !$showoldetails);  
  255.   
  256.         $guestcount = $membercount = 0;  
  257.         if(!empty($_G['setting']['sessionclose'])) {  
  258.             $detailstatus = false;  
  259.             $membercount = C::app()->session->count(1);  
  260.             $guestcount = $onlinenum - $membercount;  
  261.         }  
  262.   
  263.         if($detailstatus) {  
  264.             $actioncode = lang('action');  
  265.   
  266.             $_G['uid'] && updatesession();  
  267.             $whosonline = array();  
  268.   
  269.             $_G['setting']['maxonlinelist'] = $_G['setting']['maxonlinelist'] ? $_G['setting']['maxonlinelist'] : 500;  
  270.             foreach(C::app()->session->fetch_member(1, 0, $_G['setting']['maxonlinelist']) as $online){  
  271.                 $membercount ++;  
  272.                 if($online['invisible']) {  
  273.                     $invisiblecount++;  
  274.                     continue;  
  275.                 } else {  
  276.                     $online['icon'] = !empty($_G['cache']['onlinelist'][$online['groupid']]) ? $_G['cache']['onlinelist'][$online['groupid']] : $_G['cache']['onlinelist'][0];  
  277.                 }  
  278.                 $online['lastactivity'] = dgmdate($online['lastactivity'], 't');  
  279.                 $whosonline[] = $online;  
  280.             }  
  281.             if(isset($_G['cache']['onlinelist'][7]) && $_G['setting']['maxonlinelist'] > $membercount) {  
  282.                 foreach(C::app()->session->fetch_member(2, 0, $_G['setting']['maxonlinelist'] - $membercountas $online){  
  283.                     $online['icon'] = $_G['cache']['onlinelist'][7];  
  284.                     $online['username'] = $_G['cache']['onlinelist']['guest'];  
  285.                     $online['lastactivity'] = dgmdate($online['lastactivity'], 't');  
  286.                     $whosonline[] = $online;  
  287.                 }  
  288.             }  
  289.             unset($actioncode$online);  
  290.   
  291.             if($onlinenum > $_G['setting']['maxonlinelist']) {  
  292.                 $membercount = C::app()->session->count(1);  
  293.                 $invisiblecount = C::app()->session->count_invisible();  
  294.             }  
  295.   
  296.             if($onlinenum < $membercount) {  
  297.                 $onlinenum = C::app()->session->count();  
  298.                 dsetcookie('onlineusernum'intval($onlinenum), 300);  
  299.             }  
  300.   
  301.             $invisiblecount = intval($invisiblecount);  
  302.             $guestcount = $onlinenum - $membercount;  
  303.   
  304.             unset($online);  
  305.         }  
  306.   
  307.     } else {  
  308.         $_G['setting']['whosonlinestatus'] = 0;  
  309.     }  
  310.   
  311.     if(defined('FORUM_INDEX_PAGE_MEMORY') && !FORUM_INDEX_PAGE_MEMORY) {  
  312.         $key = !IS_ROBOT ? $_G['member']['groupid'] : 'for_robot';  
  313.         memory('set''forum_index_page_'.$keyarray(  
  314.             'catlist' => $catlist,//分區數組列表,不包含版塊,此數組對應版塊擴展表及版塊表-pre_forum_forumfield、pre_forum_forum的字段  
  315.             'forumlist' => $forumlist,//無下級版塊的版塊信息數組  
  316.             'sublist' => $sublist,//子版塊列表  
  317.             'whosonline' => $whosonline,//誰在線  
  318.             'onlinenum' => $onlinenum,//在線人數  
  319.             'membercount' => $membercount,//會員數  
  320.             'guestcount' => $guestcount,//遊客數  
  321.             'announcements' => $announcements,//公告  
  322.             'threads' => $threads,//主題數  
  323.             'posts' => $posts,//帖子數  
  324.             'todayposts' => $todayposts,//今天發表帖子數  
  325.             'onlineinfo' => $onlineinfo,//在線信息  
  326.             'announcepm' => $announcepm), getglobal('setting/memory/forumindex'));  
  327.     }  
  328.   
  329. else {  
  330.     require_once DISCUZ_ROOT.'./source/include/misc/misc_category.php';  
  331. }  
  332.   
  333.   
  334. if(defined('IN_ARCHIVER')) {  
  335.     include loadarchiver('forum/discuz');  
  336.     exit();  
  337. }  
  338.   
  339. //版塊伸張或收縮  
  340. categorycollapse();  
  341.   
  342. /* 
  343.  * 1、gid-分區id不爲空的情況,如果gid爲空時,不會執行下面if...else...中的代碼段 
  344.  * 2、$catlist:查看桌面 
  345.         echo "<pre>"; 
  346.         print_r($catlist); 
  347.         exit; 
  348.  * 3、$_G['category']全局變量的生成 
  349.  * 4、$_G['fid']全局變量的生成 
  350.  */  
  351. //gid不爲空的情況  
  352. if($gid && !empty($catlist)) {//當前分區版塊  
  353.     $_G['category'] = $catlist[$gid];//gid-分區id        當前分區數組數據,包括所有的子版塊fid  
  354.     $forumseoset = array(//當前分區的SEO設置  
  355.         'seotitle' => $catlist[$gid]['seotitle'],//分區SEO標題  
  356.         'seokeywords' => $catlist[$gid]['keywords'],//分區SEO關鍵字  
  357.         'seodescription' => $catlist[$gid]['seodescription']//分區SEO描述  
  358.     );  
  359.     $seodata = array('fgroup' => $catlist[$gid]['name']);//當前分區名稱  
  360.         //生成當前分區的SEO信息  
  361.     list($navtitle$metadescription$metakeywords) = get_seosetting('threadlist'$seodata$forumseoset);  
  362.     if(empty($navtitle)) {  
  363.         $navtitle = $navtitle_g;  
  364.         $nobbname = false;  
  365.     } else {//默認執行  
  366.         $nobbname = true;  
  367.     }  
  368.     $_G['fid'] = $gid;//當前分區id  
  369. }  
  370.   
  371. /* 
  372.  * 1、對應模板文件:/data/diy/forum/discuz.htm  或者 /template/default/forum/discuz.htm,兩者選其一 
  373.  * 2、使用template()函數顯示已經存在的模板 
  374.  * 3、格式 include template("模板文件夾/模板名稱無後綴");的方式進行解析 
  375.  * 4、在 source/function/function_core.php文件中定義 
  376.  * 5、如:include template('forum/mytest'); //使用自定義模板套系中的forum目錄的mytest.htm 
  377.  */  
  378. include template('diy:forum/discuz:'.$gid);//結果:template("diy:forum/discuz:0")  
  379.   
  380. /* 
  381.  * 1、獲取首頁公告 
  382.  */  
  383. function get_index_announcements() {  
  384.     global $_G;//超級全局變量  
  385.     $announcements = '';//公告變量  
  386.     if($_G['cache']['announcements']) {//公告數組  
  387.         $readapmids = !empty($_G['cookie']['readapmid']) ? explode('D'$_G['cookie']['readapmid']) : array();  
  388.         foreach($_G['cache']['announcements'as $announcement) {  
  389.                         //公告結束時間不爲空,公告結束時間大於當前時間  
  390.             if(!$announcement['endtime'] || $announcement['endtime'] > TIMESTAMP && (empty($announcement['groups']) || in_array($_G['member']['groupid'], $announcement['groups']))) {  
  391.                 if(empty($announcement['type'])) {//公告類型爲空的情況  
  392.                     $announcements .= '<li><span><a href="forum.php?mod=announcement&id='.$announcement['id'].'" target="_blank" class="xi2">'.$announcement['subject'].  
  393.                         '</a></span><em>('.dgmdate($announcement['starttime'], 'd').')</em></li>';  
  394.                 } elseif($announcement['type'] == 1) {//公告類型爲1的情況  
  395.                     $announcements .= '<li><span><a href="'.$announcement['message'].'" target="_blank" class="xi2">'.$announcement['subject'].  
  396.                         '</a></span><em>('.dgmdate($announcement['starttime'], 'd').')</em></li>';  
  397.                 }  
  398.             }  
  399.         }  
  400.     }  
  401.     return $announcements;  
  402. }  
  403.   
  404. /* 
  405.  * 1、獲取遊客數據緩存 
  406.  */  
  407. function get_index_page_guest_cache() {  
  408.     global $_G;  
  409.     $indexcache = getcacheinfo(0);  
  410.     if(TIMESTAMP - $indexcache['filemtime'] > $_G['setting']['cacheindexlife']) {  
  411.         @unlink($indexcache['filename']);  
  412.         define('CACHE_FILE'$indexcache['filename']);  
  413.     } elseif($indexcache['filename']) {  
  414.         @readfile($indexcache['filename']);  
  415.         $updatetime = dgmdate($indexcache['filemtime'], 'H:i:s');  
  416.         $gzip = $_G['gzipcompress'] ? ', Gzip enabled' : '';  
  417.         echo "<script type=\"text/javascript\">  
  418.             if($('debuginfo')) {  
  419.                 $('debuginfo').innerHTML = '. This page is cached  at $updatetime $gzip .';  
  420.             }  
  421.             </script>";  
  422.         exit();  
  423.     }  
  424. }  
  425.   
  426. /* 
  427.  * 1、獲取論壇首頁緩存 
  428.  */  
  429. function get_index_memory_by_groupid($key) {  
  430.     $enable = getglobal('setting/memory/forumindex');  
  431.     if($enable !== null && memory('check')) {  
  432.         if(IS_ROBOT) {  
  433.             $key = 'for_robot';  
  434.         }  
  435.         $ret = memory('get''forum_index_page_'.$key);  
  436.         define('FORUM_INDEX_PAGE_MEMORY'$ret ? 1 : 0);  
  437.         if($ret) {  
  438.             return $ret;  
  439.         }  
  440.     }  
  441.     return array('none' => null);  
  442. }  
  443.   
  444. /* 
  445.  * 1、獲取首頁在線信息詳情 
  446.  */  
  447. function get_index_online_details() {  
  448.     $showoldetails = getgpc('showoldetails');  
  449.     switch($showoldetails) {  
  450.         case 'no': dsetcookie('onlineindex'''); break;  
  451.         case 'yes': dsetcookie('onlineindex', 1, 86400 * 365); break;  
  452.     }  
  453.     return $showoldetails;  
  454. }  
  455.   
  456. /* 
  457.  * 1、版塊綁定的域名 
  458.  */  
  459. function do_forum_bind_domains() {  
  460.     global $_G;  
  461.     if($_G['setting']['binddomains'] && $_G['setting']['forumdomains']) {  
  462.         $loadforum = isset($_G['setting']['binddomains'][$_SERVER['HTTP_HOST']]) ? max(0, intval($_G['setting']['binddomains'][$_SERVER['HTTP_HOST']])) : 0;  
  463.         if($loadforum) {  
  464.             dheader('Location: '.$_G['setting']['siteurl'].'/forum.php?mod=forumdisplay&fid='.$loadforum);  
  465.         }  
  466.     }  
  467. }  
  468.   
  469. //版塊伸張或收縮功能函數  
  470. function categorycollapse() {  
  471.     global $_G$collapse$catlist;  
  472.     if(!$_G['uid']) {  
  473.         return;  
  474.     }  
  475.         //此時 fid-分區id   forum-可以查看桌面  
  476.         //如果是首頁,那麼就會有多個分區  
  477.     foreach($catlist as $fid => $forum) {  
  478.         if(!isset($_G['cookie']['collapse']) || strpos($_G['cookie']['collapse'], '_category_'.$fid.'_') === FALSE) {  
  479.             $catlist[$fid]['collapseimg'] = 'collapsed_no.gif';  
  480.             $collapse['category_'.$fid] = '';  
  481.         } else {  
  482.             $catlist[$fid]['collapseimg'] = 'collapsed_yes.gif';//伸展或收縮圖片  
  483.             $collapse['category_'.$fid] = 'display: none';//跟html標籤的id屬性值有關  
  484.         }  
  485.     }  
  486.     if(!isset($_G['cookie']['collapse']) || strpos($_G['cookie']['collapse'], '_category_0_') === FALSE) {  
  487.         $collapse['collapseimg_0'] = 'collapsed_no.gif';//伸展或收縮圖片  
  488.         $collapse['category_0'] = '';  
  489.     } else {  
  490.         $collapse['collapseimg_0'] = 'collapsed_yes.gif';//伸展或收縮圖片  
  491.         $collapse['category_0'] = 'display: none';  
  492.     }  
  493. }  
  494. ?>  
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章