【discuzx2】forum_index.php文件的分析

http://blog.csdn.net/yanhui_wei/article/details/9851435
[php]  view plain  copy
 print ?
  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. ?>  
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值