这两天需要改动discuz的一点东西,于是看看要改的这里的代码,记录下,方便以后使用
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: forum.php 33828 2013-08-20 02:29:32Z nemohou $
*/
/*这个函数是从thinkphp赋值的打印数组的*/
function dump($var, $echo=true, $label=null, $strict=true) {
$label = ($label === null) ? '' : rtrim($label) . ' ';
if (!$strict) {
if (ini_get('html_errors')) {
$output = print_r($var, true);
$output = '<pre>' . $label . htmlspecialchars($output, ENT_QUOTES) . '</pre>';
} else {
$output = $label . print_r($var, true);
}
} else {
ob_start();
var_dump($var);
$output = ob_get_clean();
if (!extension_loaded('xdebug')) {
$output = preg_replace('/\]\=\>\n(\s+)/m', '] => ', $output);
$output = '<pre>' . $label . htmlspecialchars($output, ENT_QUOTES) . '</pre>';
}
}
if ($echo) {
echo($output);
return null;
}else
return $output;
}
define('APPTYPEID', 2);
define('CURSCRIPT', 'forum');
require './source/class/class_core.php';//定义错误处理机制,自动加载机制等等的机制,实例化一个discuz_application对象赋值给C对象的$_app属性,实例化discuz_application的时候对象的构造函数,调用了几个方法,取出了一系列的参数,get,cookie之类的,并放到了$_G 中,同时把变量地址赋值给了discuz_application->var属性
require './source/function/function_forum.php';//载入了各种函数
$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'),
);
$mod = !in_array(C::app()->var['mod'], $modarray) ? 'index' : C::app()->var['mod'];//取出模式变量,在前面已经取出了get参数
define('CURMODULE', $mod);//定义了常量,存放模式的值
$cachelist = array();
if(isset($modcachelist[CURMODULE])) {//查看数组是否存在,这里是存在的
$cachelist = $modcachelist[CURMODULE];
$cachelist[] = 'plugin';
$cachelist[] = 'pluginlanguage_system';//把模式的变量赋值给$cachelist数组并加上了两项
}
if(C::app()->var['mod'] == 'group') {//这里不等于,不做下面的动作
$_G['basescript'] = 'group';
}
//var_dump($cachelist);
C::app()->cachelist = $cachelist;//把模式的变量,赋值给discuz_application的属性
C::app()->init();//实例化数据库对象,设置参数,取出用户信息,session信息等大量的系统需要的数据,(网站菜单栏,全局变量,等等)
loadforum();//获取参数,这里是$_GET['fid'](板块id),先获取了板块的内容(板块描述,主题分类等等)的内容
set_rssauth();//获取用户的某些信息,这里没有登录,不做研究
runhooks();//定义了常量,运行hookscript函数,
//hookscript函数,引入了各个插件类,引入各个插件的内容
$navtitle = str_replace('{bbname}', $_G['setting']['bbname'], $_G['setting']['seotitle']['forum']);
$_G['setting']['threadhidethreshold'] = 1;
require DISCUZ_ROOT.'./source/module/forum/forum_'.$mod.'.php';
?>