Code analysis and learning of discuz (4) Forum entrance file, discuz forum entrance_PHP tutorial

WBOY
Release: 2016-07-13 10:04:05
Original
1078 people have browsed it

Code analysis and study of discuz (4) Forum entrance file, discuz forum entrance

is just a rough analysis of the execution process, mainly to obtain the value of the mod parameter and load it according to the value Controller, the controller position is specified on the last line.

1) Define the application name and load two necessary files

<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>
Copy after login

2) The modarray array limits the mod value range

<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>
Copy after login

3) If the mod parameter is empty or illegal, the expression will be true, resulting in a value of index

<span>$mod</span> = !<span>in_array</span>(C::app()-><span>var</span>['mod'], <span>$modarray</span>) ? 'index' : C::app()-><span>var</span>['mod'];
Copy after login

4) Initialization

<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>
Copy after login

5) Load controller

<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';
Copy after login

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/966826.htmlTechArticle Code analysis and study of discuz (4) Forum entrance file, discuz forum entrance only briefly analyzes the execution process, mainly It is to get the value of the mod parameter, load the controller according to the value, and control...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!