免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2920 | 回复: 0
打印 上一主题 下一主题

哪位高手能说明一下discuz X2.5 upload/index.php文件思路! [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-01-31 16:46 |只看该作者 |倒序浏览
discuz X2.5 upload/index.php代码如下,主说针对运行步骤(架构思路)说明一下,越详细越好,非常感谢!!!
  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: index.php 27617 2012-02-07 08:24:14Z monkey $
  7. */

  8. if(!empty($_SERVER['QUERY_STRING']) && is_numeric($_SERVER['QUERY_STRING'])) {
  9.         $_ENV['curapp'] = 'home';
  10.         $_GET = array('mod'=>'space', 'uid'=>$_SERVER['QUERY_STRING']);
  11. } else {

  12.         $url = '';
  13.         $domain = $_ENV = array();
  14.         $jump = false;
  15.         @include_once './data/sysdata/cache_domain.php';
  16.         $_ENV['domain'] = $domain;
  17.         if(empty($_ENV['domain'])) {
  18.                 $_ENV['curapp'] = 'forum';
  19.         } else {
  20.                 $_ENV['defaultapp'] = array('portal.php' => 'portal', 'forum.php' => 'forum', 'group.php' => 'group', 'home.php' => 'home');
  21.                 $_ENV['hostarr'] = explode('.', $_SERVER['HTTP_HOST']);
  22.                 $_ENV['domainroot'] = substr($_SERVER['HTTP_HOST'], strpos($_SERVER['HTTP_HOST'], '.')+1);
  23.                 if(!empty($_ENV['domain']['app']) && is_array($_ENV['domain']['app']) && in_array($_SERVER['HTTP_HOST'], $_ENV['domain']['app'])) {
  24.                         $_ENV['curapp'] = array_search($_SERVER['HTTP_HOST'], $_ENV['domain']['app']);
  25.                         if($_ENV['curapp'] == 'mobile') {
  26.                                 $_ENV['curapp'] = 'forum';
  27.                                 if(@$_GET['mobile'] != 'no') {
  28.                                         @$_GET['mobile'] = 'yes';
  29.                                 }
  30.                         }
  31.                         if($_ENV['curapp'] == 'default' || !isset($_ENV['defaultapp'][$_ENV['curapp'].'.php'])) {
  32.                                 $_ENV['curapp'] = '';
  33.                         }
  34.                 } elseif(!empty($_ENV['domain']['root']) && is_array($_ENV['domain']['root']) && in_array($_ENV['domainroot'], $_ENV['domain']['root'])) {

  35.                         $_G['setting']['holddomain'] = $_ENV['domain']['holddomain'] ? $_ENV['domain']['holddomain'] : array('www');
  36.                         $list = $_ENV['domain']['list'];
  37.                         if(isset($list[$_SERVER['HTTP_HOST']])) {
  38.                                 $domain = $list[$_SERVER['HTTP_HOST']];
  39.                                 $id = intval($domain['id']);
  40.                                 switch($domain['idtype']) {
  41.                                         case 'subarea':
  42.                                                 $_ENV['curapp'] = 'forum';
  43.                                                 $_GET['gid'] = $id;
  44.                                                 break;
  45.                                         case 'forum':
  46.                                                 $_ENV['curapp'] = 'forum';
  47.                                                 $_GET['mod'] = 'forumdisplay';
  48.                                                 $_GET['fid'] = $id;
  49.                                                 break;
  50.                                         case 'topic':
  51.                                                 $_ENV['curapp'] = 'portal';
  52.                                                 $_GET['mod'] = 'topic';
  53.                                                 $_GET['topicid'] = $id;
  54.                                                 break;
  55.                                         case 'channel':
  56.                                                 $_ENV['curapp'] = 'portal';
  57.                                                 $_GET['mod'] = 'list';
  58.                                                 $_GET['catid'] = $id;
  59.                                                 break;
  60.                                 }
  61.                         } elseif(count($_ENV['hostarr']) > 2 && $_ENV['hostarr'][0] != 'www' && !checkholddomain($_ENV['hostarr'][0])) {
  62.                                 $_ENV['prefixdomain'] = addslashes($_ENV['hostarr'][0]);
  63.                                 $_ENV['domainroot'] = addslashes($_ENV['domainroot']);
  64.                                 require_once './source/class/class_core.php';
  65.                                 C::app()->init_setting = true;
  66.                                 C::app()->init_user = false;
  67.                                 C::app()->init_session = false;
  68.                                 C::app()->init_cron = false;
  69.                                 C::app()->init_misc = false;
  70.                                 C::app()->init();
  71.                                 $jump = true;
  72.                                 $domain = C::t('common_domain')->fetch_by_domain_domainroot($_ENV['prefixdomain'], $_ENV['domainroot']);
  73.                                 $apphost = $_ENV['domain']['app'][$domain['idtype']] ? $_ENV['domain']['app'][$domain['idtype']] : $_ENV['domain']['app']['default'];
  74.                                 $apphost = $apphost ? 'http://'.$apphost.'/' : '';
  75.                                 switch($domain['idtype']) {
  76.                                         case 'home':
  77.                                                 if($_G['setting']['rewritestatus'] && in_array('home_space', $_G['setting']['rewritestatus'])) {
  78.                                                         $url = rewriteoutput('home_space', 1, $apphost, $domain['id']);
  79.                                                 } else {
  80.                                                         $url = $apphost.'home.php?mod=space&uid='.$domain['id'];
  81.                                                 }
  82.                                                 break;
  83.                                         case 'group':
  84.                                                 if($_G['setting']['rewritestatus'] && in_array('group_group', $_G['setting']['rewritestatus'])) {
  85.                                                         $url = rewriteoutput('group_group', 1, $apphost, $domain['id']);
  86.                                                 } else {
  87.                                                         $url = $apphost.'forum.php?mod=group&fid='.$domain['id'].'&page=1';
  88.                                                 }
  89.                                                 break;
  90.                                 }
  91.                         }
  92.                 } else {
  93.                         $jump = true;
  94.                 }
  95.                 if(empty($url) && empty($_ENV['curapp'])) {
  96.                         if(!empty($_ENV['domain']['defaultindex']) && !$jump) {
  97.                                 if($_ENV['defaultapp'][$_ENV['domain']['defaultindex']]) {
  98.                                         $_ENV['curapp'] = $_ENV['defaultapp'][$_ENV['domain']['defaultindex']];
  99.                                 } else {
  100.                                         $url = $_ENV['domain']['defaultindex'];
  101.                                 }
  102.                         } else {
  103.                                 if($jump) {
  104.                                         $url = empty($_ENV['domain']['app']['default']) ? (!empty($_ENV['domain']['defaultindex']) ? $_ENV['domain']['defaultindex'] : 'forum.php') : 'http://'.$_ENV['domain']['app']['default'];
  105.                                 } else {
  106.                                         $_ENV['curapp'] = 'forum';
  107.                                 }
  108.                         }
  109.                 }
  110.         }
  111. }
  112. if(!empty($url)) {
  113.         $delimiter = strrpos($url, '?') ? '&' : '?';
  114.         if(isset($_GET['fromuid']) && $_GET['fromuid']) {
  115.                 $url .= $delimiter.'fromuid='.$_GET['fromuid'];
  116.         } elseif(isset($_GET['fromuser']) && $_GET['fromuser']) {
  117.                 $url .= $delimiter.'fromuser='.$_GET['fromuser'];
  118.         }
  119.         header("HTTP/1.1 301 Moved Permanently");
  120.         header("location: $url");
  121. } else {
  122.         require './'.$_ENV['curapp'].'.php';
  123. }

  124. function checkholddomain($domain) {
  125.         global $_G;

  126.         $domain = strtolower($domain);
  127.         if(preg_match("/^[^a-z]/i", $domain)) return true;
  128.         $holdmainarr = empty($_G['setting']['holddomain']) ? array('www') : explode('|', $_G['setting']['holddomain']);
  129.         $ishold = false;
  130.         foreach ($holdmainarr as $value) {
  131.                 if(strpos($value, '*') === false) {
  132.                         if(strtolower($value) == $domain) {
  133.                                 $ishold = true;
  134.                                 break;
  135.                         }
  136.                 } else {
  137.                         $value = str_replace('*', '.*?', $value);
  138.                         if(@preg_match("/$value/i", $domain)) {
  139.                                 $ishold = true;
  140.                                 break;
  141.                         }
  142.                 }
  143.         }
  144.         return $ishold;
  145. }
  146. ?>
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP