时间:2021-07-01 10:21:17 帮助过:19人阅读
1 )定义应用名称,加载两个必要文件
define('APPTYPEID', 2); define('CURSCRIPT', 'forum'); require './source/class/class_core.php';//核心类 require './source/function/function_forum.php';//论坛函数库
2 )modarray数组限定了mod取值范围
$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'), );
3 )如果mod参数为空或者不合法都会让表达式为真,导致值为index
$mod = !in_array(C::app()->var['mod'], $modarray) ? 'index' : C::app()->var['mod'];
4 )做初始化
define('CURMODULE', $mod); //var_dump(CURMODULE); $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();
5 )加载控制器
$navtitle = str_replace('{bbname}', $_G['setting']['bbname'], $_G['setting']['seotitle']['forum']); $_G['setting']['threadhidethreshold'] = 1; //var_dump($mod); require DISCUZ_ROOT.'./source/module/forum/forum_'.$mod.'.php';
以上就介绍了对discuz的代码分析学习(四)论坛入口文件,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。