<div onclick="cnblogs_code_show('6df87059-df99-4be9-b9bb-576d5222eade')">
<img ID="code_img_closed6df87059-df99-4be9-b9bb-576d5222eade" src="https://www.jb51.cc/res/2019/02-07/12/1c53668bcee393edac0d7b3b3daff1ae.gif" alt=""><img ID="code_img_opened6df87059-df99-4be9-b9bb-576d5222eade" onclick="cnblogs_code_hIDe('6df87059-df99-4be9-b9bb-576d5222eade',event)" src="https://www.jb51.cc/res/2019/02-07/12/405b18b4b6584ae338e0f6ecaf736533.gif"><span >代码
<div ID="cnblogs_code_open_6df87059-df99-4be9-b9bb-576d5222eade">
概述 代码 1 代码 2 <?php 3 /* 4 [UCenter Home] (C) 2007-2008 Comsenz Inc. 5 $Id: common.php 13217 2009-9-25 ymaozi http://www.codedesign.cn 6 */ 7 8 @define('IN_UCHOME', TRUE); //定义IN_UCHOME 9 define('D_BUG', '0'); //定义错误等级 10 11 D_BUG?error_reporting(7):error_reporting(0); 12 set_magic_quotes_runtime(0); //关闭自动转义功能 13 14 $_SGLOBAL = $_SCONFIG = $_SBLOCK = $_TPL = $_SCOOKIE = $_SN = $space = array(); 15 16 //程序目录 17 define('S_ROOT', dirname(__FILE__).DIRECTORY_SEPARATOR); //定义程序的根目录 18 19 //基本文件 20 include_once(S_ROOT.'./ver.php'); //导入uchome的一些版本信息 21 if(!@include_once(S_ROOT.'./config.php')) { //判断是否存在网站配置文件,不存在的话,安装网站 22 header("Location: install/index.php");//安装 23 exit(); 24 } 25 include_once(S_ROOT.'./source/function_common.php'); //引入公共函数文件 26 27 //时间 28 $mtime = explode(' ', microtime()); //将当前的时间,微秒与年/月/日 时/分/秒 分隔开 29 $_SGLOBAL['timestamp'] = $mtime[1]; //取得当前的年/月/日 时/分/钞 30 $_SGLOBAL['supe_starttime'] = $_SGLOBAL['timestamp'] + $mtime[0]; //年/月/日 时/分/钞 + 微秒 31 32 //GPC过滤 33 $magic_quote = get_magic_quotes_gpc(); //是否开启了自动转义功能 34 if(empty($magic_quote)) { //如果没有开启则手动对提交的$_POST,$_GET进行转义 35 $_GET = saddslashes($_GET); 36 $_POST = saddslashes($_POST); 37 } 38 39 //本站URL 40 if(empty($_SC['siteurl'])) $_SC['siteurl'] = getsiteurl(); 41 42 //链接数据库 43 dbconnect(); 44 45 //缓存文件 46 if(!@include_once(S_ROOT.'./data/data_config.php')) { //是否存在网站初始化信息的缓存 47 include_once(S_ROOT.'./source/function_cache.php'); //如果不存在,则引入处理缓存的文件 48 config_cache(); //创建缓存文件 49 include_once(S_ROOT.'./data/data_config.php'); //将缓存文件引入 50 } 51 foreach (array('app', 'userapp', 'ad', 'magic') as $value) { 52 @include_once(S_ROOT.'./data/data_'.$value.'.php'); //导入app,userapp,ad,magic配置文件 53 } 54 55 //COOKIE 56 $prelength = strlen($_SC['cookiepre']); //获取COOKIE前缀长度 57 foreach($_COOKIE as $key => $val) { 58 if(substr($key, 0, $prelength) == $_SC['cookiepre']) { 59 $_SCOOKIE[(substr($key, $prelength))] = empty($magic_quote) ? saddslashes($val) : $val; 60 } 61 } 62 63 //启用GIP 64 if ($_SC['gzipcompress'] &amp;&amp; function_exists('ob_gzhandler')) { 65 ob_start('ob_gzhandler'); 66 } else { 67 ob_start(); 68 } 69 70 //初始化 71 $_SGLOBAL['supe_uid'] = 0; 72 $_SGLOBAL['supe_username'] = ''; //将用户的uid与username设置为空 73 $_SGLOBAL['inajax'] = empty($_GET['inajax'])?0:intval($_GET['inajax']); //是否采用ajax 74 $_SGLOBAL['mobile'] = empty($_GET['mobile'])?'':trim($_GET['mobile']); //获取$_GET提交的手机号 75 $_SGLOBAL['ajaxmenuid'] = empty($_GET['ajaxmenuid'])?'':$_GET['ajaxmenuid']; 76 $_SGLOBAL['refer'] = empty($_SERVER['HTTP_REFERER'])?'':$_SERVER['HTTP_REFERER']; //获取上一页面的url 77 if(empty($_GET['m_timestamp']) || $_SGLOBAL['mobile'] != md5($_GET['m_timestamp']."t".$_SCONFIG['sitekey'])) $_SGLOBAL['mobile'] = ''; 78 79 //登录注册防灌水机 80 if(empty($_SCONFIG['login_action'])) $_SCONFIG['login_action'] = md5('login'.md5($_SCONFIG['sitekey'])); 81 if(empty($_SCONFIG['register_action'])) $_SCONFIG['register_action'] = md5('register'.md5($_SCONFIG['sitekey'])); 82 83 //整站风格 84 if(empty($_SCONFIG['template'])) { //如果没有设置网站的风格则采用default中的 85 $_SCONFIG['template'] = 'default'; 86 } 87 if($_SCOOKIE['mytemplate']) { 88 $_SCOOKIE['mytemplate'] = str_replace('.','',trim($_SCOOKIE['mytemplate'])); 89 if(file_exists(S_ROOT.'./template/'.$_SCOOKIE['mytemplate'].'/style.css')) { 90 $_SCONFIG['template'] = $_SCOOKIE['mytemplate']; 91 } else { 92 ssetcookie('mytemplate', '', 365000); 93 } 94 } 95 96 //url:http://u.codedesign.cn/space.php?do=home 97 //$_SERVER['REQUEST_URI']得到的:space.php?do=home 98 //$_SERVER['PHP_SELF'] 得到的:space.php 99 //$_SERVER['QUERY_STRING'] : do=home100 //处理REQUEST_URI101 if(!isset($_SERVER['REQUEST_URI'])) {102 $_SERVER['REQUEST_URI'] = $_SERVER['PHP_SELF'];103 if(isset($_SERVER['QUERY_STRING'])) $_SERVER['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];104 }105 if($_SERVER['REQUEST_URI']) {106 $temp = urldecode($_SERVER['REQUEST_URI']);107 if(strexists($temp, '<') || strexists($temp, '"')) {108 $_GET = shtmlspecialchars($_GET);//XSS109 }110 } 111 112 //判断用户登录状态113 checkauth(); //判断是否登录114 $_SGLOBAL['uhash'] = md5($_SGLOBAL['supe_uid']."t".substr($_SGLOBAL['timestamp'], 0, 6)); //将用户的uid与当前时间的前六位进行md5加密115 116 //用户菜单117 getuserapp();118