Code Analysis on discuz (4) Forum Portal file, discuz Forum Portal _ PHP Tutorial

Source: Internet
Author: User
Tags bbcode
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.