Heim > Artikel > Backend-Entwicklung > discuz! 为啥能加载到discuz.htm这个文件呢
最近在研究discuz! 但就是搞不懂他怎么在输入127.0.0.1/forum.php后直接加载discuz.htm这个模板呢,百思不得其解.记住本帖一定要说道理,不能干巴巴的,否则是不给分的,这回给分可是不少啊. 一百分
<?php/** * [Discuz!] (C)2001-2099 Comsenz Inc. * This is NOT a freeware, use is subject to license terms * * $Id: forum.php 33828 2013-08-20 02:29:32Z nemohou $ */define('APPTYPEID', 2);define('CURSCRIPT', 'forum');require './source/class/class_core.php';require './source/function/function_forum.php';$modarray = array('ajax','announcement','attachment','forumdisplay', 'group','image','index','medal','misc','modcp','notice','post','redirect', 'relatekw','relatethread','rss','topicadmin','trade','viewthread','tag','collection','guide');$modcachelist = array( 'index' => array('announcements', 'onlinelist', 'forumlinks', 'heats', 'historyposts', 'onlinerecord', 'userstats', 'diytemplatenameforum'), 'forumdisplay' => array('smilies', 'announcements_forum', 'globalstick', 'forums', 'onlinelist', 'forumstick', 'threadtable_info', 'threadtableids', 'stamps', 'diytemplatenameforum'), 'viewthread' => array('smilies', 'smileytypes', 'forums', 'usergroups', 'stamps', 'bbcodes', 'smilies', 'custominfo', 'groupicon', 'stamps', 'threadtableids', 'threadtable_info', 'posttable_info', 'diytemplatenameforum'), 'redirect' => array('threadtableids', 'threadtable_info', 'posttable_info'), 'post' => array('bbcodes_display', 'bbcodes', 'smileycodes', 'smilies', 'smileytypes', 'domainwhitelist', 'albumcategory'), 'space' => array('fields_required', 'fields_optional', 'custominfo'), 'group' => array('grouptype', 'diytemplatenamegroup'),);$mod = !in_array(C::app()->var['mod'], $modarray) ? 'index' : C::app()->var['mod'];define('CURMODULE', $mod);$cachelist = array();if(isset($modcachelist[CURMODULE])) { $cachelist = $modcachelist[CURMODULE]; $cachelist[] = 'plugin'; $cachelist[] = 'pluginlanguage_system';}if(C::app()->var['mod'] == 'group') { $_G['basescript'] = 'group';}C::app()->cachelist = $cachelist;C::app()->init();loadforum();set_rssauth();runhooks();$navtitle = str_replace('{bbname}', $_G['setting']['bbname'], $_G['setting']['seotitle']['forum']);$_G['setting']['threadhidethreshold'] = 1;require DISCUZ_ROOT.'./source/module/forum/forum_'.$mod.'.php';?>
上面这段代码里面在逻辑上就没有discuz这个变量存在,所以俺就是纳闷,他为啥能加载呢
$mod = !in_array(C::app()->var['mod'], $modarray) ? 'index' : C::app()->var['mod'];
没有mod参数就是mod=index;
你到/source/module/forum下就能找到forum_index.php
这就是首页的后台文件
在最后include template('diy:forum/discuz:'.$gid);
就是引入了discuz.html
道理,不能干巴巴的
$mod = !in_array(C::app()->var['mod'], $modarray) ? 'index' : C::app()->var['mod'];
没有mod参数就是mod=index;
你到/source/module/forum下就能找到forum_index.php
这就是首页的后台文件
在最后include template('diy:forum/discuz:'.$gid);
就是引入了discuz.html
C类:source/class/class_core.php,在文件最下面,继承了core类,就在本文件的上面,在core类的上面调用了C::creatapp();此静态方法用到了discuz_application::instance();
discuz_application类:source/class/discuz/discuz_application.php,这个类是核心类,所有入口文件调用的其实就是它,里面定义了$var数组,并有一句$this->var = & $_G;,我想$_G不会不认识吧,所以$_G['mod']也能获取mod的参数值