Code analysis and learning of discuz (4) Forum entrance file
Just a rough analysis of the execution process, mainly to obtain the value of the mod parameter, and load the controller according to the value. The controller position is specified in 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>
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>
3) If the mod parameter is empty or illegal, the expression will be true, causing the value to be index
<span>$mod</span> = !<span>in_array</span>(C::app()-><span>var</span>['mod'], <span>$modarray</span>) ? 'index' : C::app()-><span>var</span>['mod'];
4) Do 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>
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';
The above introduces the forum entrance file for code analysis and learning of discuz (4), including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



OpenIV is a popular game modification tool, mainly used in the Grand Theft Auto (GTA) series of games. Although using mods can add new features and improve the experience to the game, sometimes we may need to delete installed mods for various reasons. This article will explain how to remove mods using OpenIV. First, make sure you have the OpenIV tools installed. For users who have not installed it, you can download it from the OpenIV official website (https://www.ope

One of the standout features ofCyberpunk 2077is path tracing, but it can put a heavy toll on performance. Even systems with reasonably capable graphics cards, such as the RTX 4080 (Gigabyte AERO OC curr. $949.99 on Amazon), struggle to offer a stable

Earlier this month, a YouTuber named HowToMen showcased the Rabbit R1 running Android. With this mod, the device that was originally meant to be less distracting than a phone got to function like one. That isn't a bad thing, though, as Rabbit didn't

The Asus ROG Ally features a 40 Wh battery, which typically results in about two hours of runtime. On the Ally X, however, Asus upgraded the battery to 80 Wh, pushing the battery life to around four hours, depending on the TDP. iFixit came up with a

When playing games such as Grand Theft Auto V, many players like to use Mods to increase the fun and playability of the game. As a well-known Mod management tool, OpenIV can simplify the Mod installation and management process. So, let’s take a look at how to add Mod to OpenIV. First, you need to make sure you have downloaded and installed OpenIV. It can be found on the official website of OpenIV (https://openiv.com/)

Title: Example of using the Array.Sort function to sort an array in C# Text: In C#, array is a commonly used data structure, and it is often necessary to sort the array. C# provides the Array class, which has the Sort method to conveniently sort arrays. This article will demonstrate how to use the Array.Sort function in C# to sort an array and provide specific code examples. First, we need to understand the basic usage of the Array.Sort function. Array.So

The biggest dark horse at the beginning of 2024, "Phantom Parlu" recently landed on Steam Early Access and has continuously set new records. Not only has sales exceeded 5 million copies. The peak number of people online for this game reached a new high, exceeding 1.58 million (1,582,482 people)! This achievement also makes "Eidolon Parlu" become the top 3 games with the highest number of online users in the history of Steam! Second only to “PlayerUnknown’s Battlegrounds” (3.25 million) and “CS2” (1.81 million)! In addition, "Eidolon Pallu" also has the first player-made "Pokémon" Mod, which can turn players into Ash Ketchum and turn all Pallu into Pokémon. A masterpiece to start the new year! Sales exceeded 5 million copies in 3 days. Don’t miss it! Click https://www.17

Use MySQL's MOD function to find the remainder of the modular operation. In the MySQL database, the MOD function can be used to perform modular operations, that is, to find the remainder of two numbers. This article will introduce how to use the MOD function to perform modular operations and give corresponding code examples. The syntax of the MOD function is as follows: MOD(N,M) where N and M are the two numbers to be performed modulo operation, N is the dividend, and M is the divisor. The MOD function returns the remainder of N divided by M. Below is a simple example showing how to use the MOD function to find the remainder of two numbers
