Uchome1.2 1.5 code learning common.php_PHP tutorial

WBOY
Release: 2016-07-21 15:47:13
Original
897 people have browsed it

The code of UCHOME is still very good, study it!

Copy code The code is as follows:

/**
* Define some constants
*/
@define('IN_UCHOME', TRUE); //It is said to prevent illegal inclusion of files
define('X_VER' , '1.2'); //Uchome version
define('X_RELEASE', '20080612'); //Release date
define('D_BUG', '0'); //Whether to enable debugging, 0 :off, 1:on
//Set the error reporting level according to whether the debugging function is turned on
D_BUG?error_reporting(7):error_reporting(0);
//Initialize some global variables
$_SGLOBAL = $_SCONFIG = $_SBLOCK = $_TPL = $_SCOOKIE = $space = array();
//Define program directory constants
define('S_ROOT', dirname(__FILE__).DIRECTORY_SEPARATOR);
// Get time, mainly used to output program running time
$mtime = explode(' ', microtime());
$_SGLOBAL['timestamp'] = $mtime[1];
$_SGLOBAL[' supe_starttime'] = $_SGLOBAL['timestamp'] + $mtime[0];
//Basic file, try to include the basic configuration file, if the inclusion is unsuccessful, the installer
if(!@include_once(S_ROOT .'./config.php')) {
header("Location: install/index.php");
exit();
}
//Contains public function library
include_once(S_ROOT.'./source/function_common.php');
//Link database
dbconnect();
//Configuration file, try to include the website configuration information in the cache directory, if unsuccessful , then include it into the cache processing function library and generate the configuration cache
if(!@include_once(S_ROOT.'./data/data_config.php')) {
include_once(S_ROOT.'./source/function_cache.php ');
config_cache();
}
//Force the use of character set
if($_SCONFIG['headercharset']) {
@header('Content-Type: text/ html; charset='.$_SC['charset']);
}
//GPC filtering, automatically escape special characters in $_GET, $_POST, $_COOKIE to prevent SQL injection attacks
$magic_quote = get_magic_quotes_gpc();
if(emptyempty($magic_quote)) {
$_GET = saddslashes($_GET);
$_POST = saddslashes($_POST);
}
//COOKIE
$prelength = strlen($_SC['cookiepre']);
foreach($_COOKIE as $key => $val) {
if(substr($key, 0, $ prelength) == $_SC['cookiepre']) {
$_SCOOKIE[(substr($key, $prelength))] = emptyempty($magic_quote) ? saddslashes($val) : $val;
}
}
//Enable GIP
if ($_SC['gzipcompress'] && function_exists('ob_gzhandler')) {
ob_start('ob_gzhandler');
} else {
ob_start();
}
//Initialization
$_SGLOBAL['supe_uid'] = 0;
$_SGLOBAL['supe_username'] = '';
$_SGLOBAL['inajax '] = emptyempty($_GET['inajax'])?0:intval($_GET['inajax']);
$_SGLOBAL['ajaxmenuid'] = emptyempty($_GET['ajaxmenuid'])?' ':$_GET['ajaxmenuid'];
$_SGLOBAL['refer'] = emptyempty($_SERVER['HTTP_REFERER'])?'':$_SERVER['HTTP_REFERER'];
//Get the user Information
getuser();
//Application list
@include_once(S_ROOT.'./data/data_app.php');
if(emptyempty($_SGLOBAL['app'])) {
include_once(S_ROOT.'./source/function_cache.php');
app_cache();
}
?>
/**
* Define some constants
*/
@define('IN_UCHOME', TRUE); //It is said to prevent illegal inclusion of files
define('X_VER', '1.2'); //Uchome version
define('X_RELEASE ', '20080612');//Release date
define('D_BUG', '0'); //Whether the debugging function is turned on, 0: off, 1: on
//Set according to whether the debugging function is turned on or not Error reporting level
D_BUG?error_reporting(7):error_reporting(0);
//Initialize some global variables
$_SGLOBAL = $_SCONFIG = $_SBLOCK = $_TPL = $_SCOOKIE = $space = array( );
//Define program directory constants
define('S_ROOT', dirname(__FILE__).DIRECTORY_SEPARATOR);
//Get time, mainly used to output program running time
$mtime = explode (' ', microtime());
$_SGLOBAL['timestamp'] = $mtime[1];
$_SGLOBAL['supe_starttime'] = $_SGLOBAL['timestamp'] + $mtime[0] ;
//Basic file, try to include the basic configuration file, if the inclusion is unsuccessful, the installer
if(!@include_once(S_ROOT.'./config.php')) {
header(" Location: install/index.php");
exit();
}
//Include common function library
include_once(S_ROOT.'./source/function_common.php');
//Link database
dbconnect();
//Configuration file, try to include the website configuration information in the cache directory, if unsuccessful, include it in the cache processing function library and generate the configuration cache
if( !@include_once(S_ROOT.'./data/data_config.php')) {
include_once(S_ROOT.'./source/function_cache.php');
config_cache();
}
//Force the use of character set
if($_SCONFIG['headercharset']) {
@header('Content-Type: text/html; charset='.$_SC['charset']);
}
//GPC filtering, automatically escape special characters in $_GET, $_POST, $_COOKIE to prevent SQL injection attacks
$magic_quote = get_magic_quotes_gpc();
if(emptyempty($magic_quote) ) {
$_GET = saddslashes($_GET);
$_POST = saddslashes($_POST);
}
//COOKIE
$prelength = strlen($_SC['cookiepre' ]);
foreach($_COOKIE as $key => $val) {
if(substr($key, 0, $prelength) == $_SC['cookiepre']) {
$ _SCOOKIE[(substr($key, $prelength))] = emptyempty($magic_quote) ? saddslashes($val) : $val;
}
}
//Enable GIP
if ($_SC['gzipcompress'] && function_exists('ob_gzhandler')) {
ob_start('ob_gzhandler');
} else {
ob_start() ;
}
//Initialization
$_SGLOBAL['supe_uid'] = 0;
$_SGLOBAL['supe_username'] = '';
$_SGLOBAL['inajax'] = emptyempty ($_GET['inajax'])?0:intval($_GET['inajax']);
$_SGLOBAL['ajaxmenuid'] = emptyempty($_GET['ajaxmenuid'])?'':$_GET ['ajaxmenuid'];
$_SGLOBAL['refer'] = emptyempty($_SERVER['HTTP_REFERER'])?'':$_SERVER['HTTP_REFERER'];
//Get user information
getuser();
//Application list
@include_once(S_ROOT.'./data/data_app.php');
if(emptyempty($_SGLOBAL['app'])) {
include_once(S_ROOT.'./source/function_cache.php');
app_cache();
}
?>

The following is the 1.5 version of common.php
Copy code The code is as follows:

/*
[UCenter Home] (C) 2007-2008 Comsenz Inc.
$Id: common.php 10981 2009-01-14 03:05: 20Z liguode $
*/
//Define a constant to prevent malicious users from directly calling other PHP files in other pages.
@define('IN_UCHOME', TRUE);
//Define a constant, which represents the version number
define('X_VER', '1.5');
//This is also a constant , minor version number
define('X_RELEASE', '20090114');
/*Define the debugging mode of the program. When we debug the program, set the constant value to 1, so that when the program errors, it will be displayed on the page An error message is displayed.
Set to 0 after debugging and normal use, so that program errors will not be displayed to the user.
*/
define('D_BUG', '0');
//Specify the error report type through the D_BUG constant value. The parameter of error_reporting() is the error reporting type. The relevant parameters can be found in the PHP manual
D_BUG?error_reporting(7):error_reporting(0);
//These are all global variables defined below. The details will be introduced one by one when used later
$_SGLOBAL = $_SCONFIG = $_SBLOCK = $_TPL = $_SCOOKIE = $_SN = $space = array();
//Define program directory constants. Among them, DIRECTORY_SEPARATOR is the path separator, which is '/' on Linux and '' on Windows.
define('S_ROOT', dirname(__FILE__).DIRECTORY_SEPARATOR);
//Load the basic configuration file, using the @ symbol , no error message will be prompted on the page when the file cannot be found
if(!@include_once(S_ROOT.'./config.php')) {
//If not found, redirect to installation File
header("Location: install/index.php");
exit();
}
//General function file, specific functions will be explained one by one in the introduction time
include_once (S_ROOT.'./source/function_common.php');
//Time microtime() gets the time in milliseconds
$mtime = explode(' ', microtime());
$_SGLOBAL[ 'timestamp'] = $mtime[1];
//$mtime[0] is the UNIX timestamp (shaped), $mtime[0] is milliseconds
$_SGLOBAL['supe_starttime'] = $_SGLOBAL[ 'timestamp'] + $mtime[0];
//get_magic_quotes_gpc checks whether the magic quotation mark function in the PHP.INI configuration is turned on
$magic_quote = get_magic_quotes_gpc();
if(emptyempty($magic_quote)) {
//If automatic filtering is turned on, escape the incoming parameters
$_GET = saddslashes($_GET);
$_POST = saddslashes($_POST);
}
//The URL of the owner’s site, where getsiteurl() is used to obtain the domain name of the current site
if(emptyempty($_SC['siteurl'])) $_SC['siteurl'] = getsiteurl();
//Link database
dbconnect();
//Open cache file
foreach (array('config', 'app', 'userapp', 'ad') as $value) {
if(!@include_once(S_ROOT.'./data/data_'.$value.'.php')) {
//If the cache file fails to be opened and the cache is rebuilt, function_cache.php contains the function to create the cache File
include_once(S_ROOT.'./source/function_cache.php');
$cache_func = $value.'_cache';
//Call the corresponding function to generate cache.
$cache_func();
}
}
//Get the length of the COOKIE prefix, $_SC['cookiepre'] is the prefix name of the COOKIE function defined in config.php, $_COOKIE Is the data global variable array that stores COOKIE
$prelength = strlen($_SC['cookiepre']);
foreach($_COOKIE as $key => $val) {
//Judge the current domain name COOKIE belonging to UCHome among the COOKIES under
if(substr($key, 0, $prelength) == $_SC['cookiepre']) {
//Escape the COOKIE value
$_SCOOKIE [(substr($key, $prelength))] = emptyempty($magic_quote) ? saddslashes($val) : $val;
}
}
//Whether to enable GIP compression transmission, this is used To improve PHP transmission speed.
if ($_SC['gzipcompress'] && function_exists('ob_gzhandler')) {
ob_start('ob_gzhandler');
} else {
ob_start();
}
//Initialization
$_SGLOBAL['supe_uid'] = 0; //Initialize the current user's UID
$_SGLOBAL['supe_username'] = ''; //Initialize the current user's username
$ _SGLOBAL['inajax'] = emptyempty($_GET['inajax'])?0:intval($_GET['inajax']); //This is used to control some pop-up boxes on the page, which will be introduced in the template chapter
$_SGLOBAL['ajaxmenuid'] = emptyempty($_GET['ajaxmenuid'])?'':$_GET['ajaxmenuid'];
$_SGLOBAL['refer'] = emptyempty($_SERVER[' HTTP_REFERER'])?'':$_SERVER['HTTP_REFERER']; //Get the URL of the previous page and use it to jump
//Log in to register the anti-flooding machine
/*
Log in or When registering, you will see a link like: do.php?ac=750e45d29d276b2f86f1445627c08f99
The following 750e45d29d276b2f86f1445627c08f99 is obtained using the following method.
*/
if(emptyempty($_SCONFIG['login_action'])) $_SCONFIG['login_action'] = md5('login'.md5($_SCONFIG['sitekey']));
if(emptyempty($_SCONFIG['register_action'])) $_SCONFIG['register_action'] = md5('register'.md5($_SCONFIG['sitekey']));
//Whole site style, check the site The path to the template. This is the default directory, which is our commonly used yellow style template path
if(emptyempty($_SCONFIG['template'])) {
$_SCONFIG['template'] = 'default';
}
//You can choose your own style from the lower corner of the homepage through this paragraph.
if($_SCOOKIE['mytemplate']) {
$_SCOOKIE['mytemplate'] = str_replace('.','',trim($_SCOOKIE['mytemplate']));
if (file_exists(S_ROOT.'./template/'.$_SCOOKIE['mytemplate'].'/style.css')) {
$_SCONFIG['template'] = $_SCOOKIE['mytemplate'];
} else {
ssetcookie('mytemplate', '');
}
}
//Process REQUEST_URI, query string (after the first question mark? in the URL content). If empty, it is the current page.
if(!isset($_SERVER['REQUEST_URI'])) {
$_SERVER['REQUEST_URI'] = $_SERVER['PHP_SELF'];
if(isset($_SERVER['QUERY_STRING' ])) $_SERVER['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
}
//Determine user login status
checkauth();
//User Menu
getuserapp();
//Processing UC applications, this is a roaming-related menu, no need to explain here
$_SGLOBAL['appmenus'] = $_SGLOBAL['appmenu'] = array();
if($_SGLOBAL['app']) {
foreach ($_SGLOBAL['app'] as $value) {
if($value['open']) {
if( emptyempty($_SGLOBAL['appmenu'])) {
$_SGLOBAL['appmenu'] = $value;
} else {
$_SGLOBAL['appmenus'][] = $value;
}
}
}
}
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/319981.htmlTechArticleUCHOME’s code is still very good, study it! Copy the code The code is as follows: ?php /*** Define some constants*/ @define('IN_UCHOME', TRUE); //It is said to prevent illegal inclusion of files de...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!