日期:2014-05-17 浏览次数:20747 次
<?php /* [Discuz!] (C)2001-2009 Comsenz Inc. This is NOT a freeware, use is subject to license terms $Id: common.inc.php 17460 2008-12-24 01:46:38Z monkey $ */ //关闭magic_quotes_gpc 引用 ,设置关闭PHP错误报告 error_reporting(0); set_magic_quotes_runtime(0); //获取脚本开始的时间,最后有脚本结束时间减去这个就会得到整个脚本运行的时间 $mtime = explode(' ', microtime()); $discuz_starttime = $mtime[1] + $mtime[0]; //设置一些常量 //SYSY_DEBUG是当前是否是调试状态 //IN_DISCUZ是在一些不允许直接浏览的页面用的,如果直接浏览这些页面,就会退出并出现Access Denied //DISCUZ_ROOT是获取当前的论坛的主目录的绝对路径 //MAGIC_QUOTES_GPC 是 当前的magic_quotes_gpc的状态 //CURSCRIPT是当前运行的脚本的名称吧...现在设置为空...在其他脚本中会有值.... define('SYS_DEBUG', FALSE); define('IN_DISCUZ', TRUE); define('DISCUZ_ROOT', substr(dirname(__FILE__), 0, -7)); define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc()); !defined('CURSCRIPT') && define('CURSCRIPT', ''); //为了兼容性 if(PHP_VERSION < '4.1.0') { $_GET = &$HTTP_GET_VARS; $_POST = &$HTTP_POST_VARS; $_COOKIE = &$HTTP_COOKIE_VARS; $_SERVER = &$HTTP_SERVER_VARS; $_ENV = &$HTTP_ENV_VARS; $_FILES = &$HTTP_POST_FILES; } //为了安全性...因为脚本运行到这里之前这两个global数组是不会被定义的... if (isset($_REQUEST['GLOBALS']) OR isset($_FILES['GLOBALS'])) { exit('Request tainting attempted.'); } //包含论坛的函数库...这个函数库里面有几乎整个论坛需要用到的函数 require_once DISCUZ_ROOT.'./include/global.func.php'; //测试下浏览者是什么玩意...是不是ROBOT是的话就退出显示403.... getrobot(); if(defined('NOROBOT') && IS_ROBOT) { exit(header("HTTP/1.1 403 Forbidden")); } //获取$_COOKIE 等等的值然后 设置里面的key为一个变量,值为其对应的值并添加引用.... //比如说有$_COOKIE['discuz_auth'] = '123456' 就设置$discuz_auth = '123456' //以此类推 foreach(array('_COOKIE', '_POST', '_GET') as $_request) { foreach($$_request as $_key => $_value) { $_key{0} != '_' && $$_key = daddslashes($_value); } } //过滤$_FILES,也就是添加引用 if (!MAGIC_QUOTES_GPC && $_FILES) { $_FILES = daddslashes($_FILES); } //初始化一些变量 $charset = $dbs = $dbcharset = $forumfounders = $metakeywords = $extrahead = $seodescription = $mnid = ''; $plugins = $hooks = $admincp = $jsmenu = $forum = $thread = $language = $actioncode = $modactioncode = $lang = array(); $_DCOOKIE = $_DSESSION = $_DCACHE = $_DPLUGIN = $advlist = array(); //包含论坛的配置文件 require_once DISCUZ_ROOT.'./config.inc.php'; //$urlxssdefend是论坛访问页面防御开关,可避免用户通过非法的url地址对本站用户造成危害 if($urlxssdefend && !empty($_SERVER['REQUEST_URI'])) { $temp = urldecode($_SERVER['REQUEST_URI']); if(strpos($temp, '<') !== false || strpos($temp, '"') !== false) exit('Request Bad url'); } //$prelength为设置的cookie的前缀的长度 //循环检查$_COOKIE里面带设置的前缀的变量,如果带前缀就填入到$_DCOOKIE里面并且不带前缀 //最后 过滤值 $prelength = strlen($cookiepre); foreach($_COOKIE as $key => $val) { if(substr($key, 0, $prelength) == $cookiepre) { $_DCOOKIE[(substr($key, $prelength))] = MAGIC_QUOTES_GPC ? $val : daddslashes($val); } } //销毁这些变量,都是对$_类数组操作用到的一些变量 unset($prelength, $_request, $_key, $_value); // $inajax = !empty($inajax); $handlekey = !empty($handlekey) ? htmlspecialchars($handlekey) : ''; $timestamp = time(); //$attackevasive 论坛防御级别,可防止大量的非正常请求造成的拒绝服务攻击 if($attackevasive && CURSCRIPT != 'seccode') { require_once DISCUZ_ROOT.'./include/security.inc.php'; } //包含数据库类 的文件 require_once DISCUZ_ROOT.'./include/db_'.$database.'.class.php'; //$PHP_SELF为当前活动的脚本相对于网站主目录的路径 //$BASESCRIPT为当前活动的脚本文件名字带扩展名 //$BASEFILENAME为当前活动的脚本文件的名字不带扩展名 //$boardurl为当前活动脚本的全网站路径去掉后面文件名,如果有api|archiver|wap文件夹就去掉... $PHP_SELF = dhtmlspecialchars($_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']); $BASESCRIPT = basename($PHP_SELF); list($BASEFILENAME) = explode('.', $BASESCRIPT); $boardurl = htmlspecialchars('http://'.$_SERVER['HTTP_HOST'].preg_replace("/\/+(api|archiver|wap)?\/*$/i", '', substr($PHP_SELF, 0, strrpos($PHP_SELF, '/'))).'/'); //获得当前浏览者IP if(getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown')) { $onlineip = getenv('HTTP_