Code Analysis and Learning for discuz (4) Forum Portal file and discuz Forum Portal. Code Analysis and Learning for discuz (4) Forum Portal file. the discuz Forum portal only roughly analyzes the execution process, mainly obtaining the mod parameter value and loading the controller according to the value, analyze and learn discuz code (4) Forum Portal file and discuz Forum Portal
The execution process is roughly analyzed. The value of the mod parameter is obtained. the controller is loaded based on the value, and the controller position is specified in the last line.
1) define the application name and load two necessary files
Define ('apptypeid', 2); define ('curscript', 'forum'); require '. /source/class/class_core.php '; // core class require '. /source/function/function_forum.php '; // forum function library
2) the modarray array limits the mod value range.
$ Modarray = array ('Ajax ', 'announcement', 'attachment ', 'forumdisplay', 'group', 'Image', 'index', 'Medal ', 'Misc', 'modcp', 'notic', 'post', 'redirect', 'relatekw', 'relatethread', 'RSS ', 'topicadmin', 'trade ', 'viewthread', 'tag', 'Collect', 'guide'); // module cache list, each sub-array represents the cache items to be cached by each module. $ modcachelist = array ('index' => array ('announcements', 'onlinelist', 'forumlink', 'hats ', 'historyposts', 'onlinerecord ', 'userstats', 'didtemplatenameforum'), 'forumdisplay' => array ('smilies ', 'announcements _ forum', 'globalstart ', 'forums', 'onlinelist', 'forumstick', 'threadtable _ info', 'threadtableids ', 'stamps', 'didtemplatenameforum '), 'viewthread' => array ('smilies ', 'smileytypes', 'forums', 'usergroups', 'stamps', 'bbcode', 'smils', 'custominfo ', 'groupicon ', 'stamps', 'threadtableids', 'threadtable _ info', 'posttable _ info', 'didtemplatenameforum'), 'redirect' => array ('threadtableids ', 'threadtable _ info', 'posttable _ info'), 'post' => array ('bbcodes _ display', 'bbcode', 'smileycode', 'smilies ', 'smileytypes ', 'domainwhitelist', 'albumcategory'), 'space' => array ('Fields _ required', 'fields _ optional', 'minminfo '), 'Group' => array ('grouptype ', 'didtemplatenamegroup '),);
3) If the mod parameter is null or invalid, the expression is true, resulting in the value of index.
$mod = !in_array(C::app()->var['mod'], $modarray) ? 'index' : C::app()->var['mod'];
4) perform initialization.
Define ('curmodule', $ mod); // var_dump (CURMODULE); $ cachelist = array (); if (isset ($ modcachelist [CURMODULE]) {// if the current cache item exists, $ cachelist = $ modcachelist [CURMODULE]; // Obtain the cache list item of the current cache Group $ cachelist [] = 'plugin '; $ cachelist [] = 'ininlanguage _ system';} if (C: app ()-> var ['mod'] = 'group ') {$ _ G ['basescript'] = 'group';} C: app ()-> cachelist = $ cachelist; C: app ()-> init (); // initialize loadforum (); set_rssauth (); runhooks ();
5) load the controller
$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';
Forum (4) Forum Portal file. the discuz Forum Portal is just a rough analysis of the execution process, mainly to get the mod parameter value, load the controller according to the value, control...