Rumah > php教程 > php手册 > 对discuz的代码分析学习(四)论坛入口文件,discuz论坛入口

对discuz的代码分析学习(四)论坛入口文件,discuz论坛入口

WBOY
Lepaskan: 2016-06-13 09:12:34
asal
1106 orang telah melayarinya

对discuz的代码分析学习(四)论坛入口文件,discuz论坛入口

只是大致分析下执行流程,主要就是取得mod参数的值,根据取值加载控制器,控制器位置在最后一行指定了。

 

1 )定义应用名称,加载两个必要文件

<span>define</span>('APPTYPEID', 2<span>);
</span><span>define</span>('CURSCRIPT', 'forum'<span>);

</span><span>require</span> './source/class/class_core.php';<span>//</span><span>核心类</span>
<span>require</span> './source/function/function_forum.php';<span>//</span><span>论坛函数库</span>
Salin selepas log masuk

2 )modarray数组限定了mod取值范围

<span>$modarray</span> = <span>array</span>('ajax','announcement','attachment','forumdisplay',
    'group','image','index','medal','misc','modcp','notice','post','redirect',
    'relatekw','relatethread','rss','topicadmin','trade','viewthread','tag','collection','guide'<span>
);
</span><span>//</span><span>模块缓存列表,各个子数组分别表示各个模块要缓存的缓存项</span>
<span>$modcachelist</span> = <span>array</span><span>(
    </span>'index'        => <span>array</span>('announcements', 'onlinelist', 'forumlinks',
            'heats', 'historyposts', 'onlinerecord', 'userstats', 'diytemplatenameforum'),
    'forumdisplay'    => <span>array</span>('smilies', 'announcements_forum', 'globalstick', 'forums',
            'onlinelist', 'forumstick', 'threadtable_info', 'threadtableids', 'stamps', 'diytemplatenameforum'),
    'viewthread'    => <span>array</span>('smilies', 'smileytypes', 'forums', 'usergroups',
            'stamps', 'bbcodes', 'smilies',    'custominfo', 'groupicon', 'stamps',
            'threadtableids', 'threadtable_info', 'posttable_info', 'diytemplatenameforum'),
    'redirect'    => <span>array</span>('threadtableids', 'threadtable_info', 'posttable_info'),
    'post'        => <span>array</span>('bbcodes_display', 'bbcodes', 'smileycodes', 'smilies', 'smileytypes',
            'domainwhitelist', 'albumcategory'),
    'space'        => <span>array</span>('fields_required', 'fields_optional', 'custominfo'),
    'group'        => <span>array</span>('grouptype', 'diytemplatenamegroup'),<span>
);</span>
Salin selepas log masuk

3 )如果mod参数为空或者不合法都会让表达式为真,导致值为index

<span>$mod</span> = !<span>in_array</span>(C::app()-><span>var</span>['mod'], <span>$modarray</span>) ? 'index' : C::app()-><span>var</span>['mod'];
Salin selepas log masuk

4 )做初始化

<span>define</span>('CURMODULE', <span>$mod</span><span>);
</span><span>//</span><span>var_dump(CURMODULE);</span>
<span>$cachelist</span> = <span>array</span><span>();
</span><span>if</span>(<span>isset</span>(<span>$modcachelist</span>[CURMODULE])) {<span>//</span><span>如果当前缓存项存在的话,</span>
    <span>$cachelist</span> = <span>$modcachelist</span>[CURMODULE];<span>//</span><span>获取当前缓存组的缓存列表项</span>

    <span>$cachelist</span>[] = 'plugin'<span>;
    </span><span>$cachelist</span>[] = 'pluginlanguage_system'<span>;
}
</span><span>if</span>(C::app()-><span>var</span>['mod'] == 'group'<span>) {
    </span><span>$_G</span>['basescript'] = 'group'<span>;
}

C</span>::app()->cachelist = <span>$cachelist</span><span>;
C</span>::app()->init();<span>//</span><span>初始化</span>
<span>

loadforum();


set_rssauth();


runhooks();</span>
Salin selepas log masuk

5 )加载控制器

<span>$navtitle</span> = <span>str_replace</span>('{bbname}', <span>$_G</span>['setting']['bbname'], <span>$_G</span>['setting']['seotitle']['forum'<span>]);
</span><span>$_G</span>['setting']['threadhidethreshold'] = 1<span>;
</span><span>//</span><span>var_dump($mod);</span>
<span>require</span> DISCUZ_ROOT.'./source/module/forum/forum_'.<span>$mod</span>.'.php';
Salin selepas log masuk
Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Cadangan popular
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan