./upload/forum.php

时间:2023-11-22 16:27:02

这是forum.php的全部代码,然后试着读一读,自己做做笔记。

define('APPTYPEID', 2);
define('CURSCRIPT', 'forum');

define(); 定义常量的函数,结果为  apptypeid = 2, curscript = 'forum'。

为何这么设定,还不知道。

require './source/class/class_core.php';
require './source/function/function_forum.php';

导入2个文件

class_core.php  - 论坛的主要类文件,core类和c类,都是在这个文件中定义的

function_forum.php - 论坛forum模块使用的函数,都放在这个文件中。

$modarray = array('ajax','announcement','attachment','forumdisplay',
'group','image','index','medal','misc','modcp','notice','post','redirect',
'relatekw','relatethread','rss','topicadmin','trade','viewthread','tag','collection','guide'
); $modcachelist = array(
'index' => array('announcements', 'onlinelist', 'forumlinks',
'heats', 'historyposts', 'onlinerecord', 'userstats', 'diytemplatenameforum'),
'forumdisplay' => array('smilies', 'announcements_forum', 'globalstick', 'forums',
'onlinelist', 'forumstick', 'threadtable_info', 'threadtableids', 'stamps', 'diytemplatenameforum'),
'viewthread' => array('smilies', 'smileytypes', 'forums', 'usergroups',
'stamps', 'bbcodes', 'smilies', 'custominfo', 'groupicon', 'stamps',
'threadtableids', 'threadtable_info', 'posttable_info', 'diytemplatenameforum'),
'redirect' => array('threadtableids', 'threadtable_info', 'posttable_info'),
'post' => array('bbcodes_display', 'bbcodes', 'smileycodes', 'smilies', 'smileytypes',
'domainwhitelist', 'albumcategory'),
'space' => array('fields_required', 'fields_optional', 'custominfo'),
'group' => array('grouptype', 'diytemplatenamegroup'),
);

定义了2个变量

$modarray 模型的种类, 'ajax','announcement','attachment'...
$modcachelist 模型的缓存列表 index 包含'announcements', 'onlinelist', 'forumlinks'   //还不太理解为何这样。
$mod = !in_array(C::app()->var['mod'], $modarray) ? 'index' : C::app()->var['mod'];

语法没问题, in_arrary(), $mod为 首页,index, 否则 模块为 。

$mod = !in_array(C::app()->var['mod'], $modarray) ? 'index' : C::app()->var['mod'];

define('CURMODULE', $mod);
$cachelist = array();
if(isset($modcachelist[CURMODULE])) {
$cachelist = $modcachelist[CURMODULE]; $cachelist[] = 'plugin';
$cachelist[] = 'pluginlanguage_system';
}
if(C::app()->var['mod'] == 'group') {
$_G['basescript'] = 'group';
} C::app()->cachelist = $cachelist;
C::app()->init(); loadforum(); set_rssauth(); runhooks(); $navtitle = str_replace('{bbname}', $_G['setting']['bbname'], $_G['setting']['seotitle']['forum']);
$_G['setting']['threadhidethreshold'] = 1;
require DISCUZ_ROOT.'./source/module/forum/forum_'.$mod.'.php';