Uchome code is still very good, learn!
Copy Code code as follows:
<?php
/**
* Define some constants
*/
@define (' In_uchome ', TRUE); It is said to prevent files from illegally including
Define (' X_ver ', ' 1.2 '); Uchome version
Define (' X_release ', ' 20080612 ')/release date
Define (' D_bug ', ' 0 '); Whether to turn on debugging, 0: Off, 1: Open
Set the error reporting level based on whether debugging is turned on
D_bug?error_reporting (7): error_reporting (0);
Initialization of some global variables
$_sglobal = $_sconfig = $_sblock = $_tpl = $_scookie = $space = Array ();
Defining Program Directory Constants
Define (' S_root ', DirName (__file__). Directory_separator);
Get time, mainly for output program run time
$mtime = Explode (', microtime ());
$_sglobal[' timestamp '] = $mtime [1];
$_sglobal[' supe_starttime '] = $_sglobal[' timestamp '] + $mtime [0];
Base file, try to include the base configuration file, if it is not successful, install the program
if (! @include_once (s_root. ') /config.php ')) {
Header ("location:install/index.php");
Exit ();
}
Include Common function libraries
Include_once (s_root. ") /source/function_common.php ');
Link Database
Dbconnect ();
Configuration file that attempts to include the site configuration information in the cached directory and, if unsuccessful, includes the cache processing function library and generating the configuration cache
if (! @include_once (s_root. ') /data/data_config.php ')) {
Include_once (s_root. ") /source/function_cache.php ');
Config_cache ();
}
Force Character Set
if ($_sconfig[' Headercharset ']) {
@header (' content-type:text/html charset= '. $_sc[' CharSet '));
}
GPC filter to 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);
}
Cookies
$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 ();
}
Class
$_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 ();
}
?>
<?php
/**
* Define some constants
*/
@define (' In_uchome ', TRUE); It is said to prevent files from illegally including
Define (' X_ver ', ' 1.2 '); Uchome version
Define (' X_release ', ' 20080612 ')/release date
Define (' D_bug ', ' 0 '); Whether to turn on debugging, 0: Off, 1: Open
Set the error reporting level based on whether debugging is turned on
D_bug?error_reporting (7): error_reporting (0);
Initialization of some global variables
$_sglobal = $_sconfig = $_sblock = $_tpl = $_scookie = $space = Array ();
Defining Program Directory Constants
Define (' S_root ', DirName (__file__). Directory_separator);
Get time, mainly for output program run time
$mtime = Explode (', microtime ());
$_sglobal[' timestamp '] = $mtime [1];
$_sglobal[' supe_starttime '] = $_sglobal[' timestamp '] + $mtime [0];
Base file, try to include the base configuration file, if it is not successful, install the program
if (! @include_once (s_root. ') /config.php ')) {
Header ("location:install/index.php");
Exit ();
}
Include Common function libraries
Include_once (s_root. ") /source/function_common.php ');
Link Database
Dbconnect ();
Configuration file that attempts to include the site configuration information in the cached directory and, if unsuccessful, includes the cache processing function library and generating the configuration cache
if (! @include_once (s_root. ') /data/data_config.php ')) {
Include_once (s_root. ") /source/function_cache.php ');
Config_cache ();
}
Force Character Set
if ($_sconfig[' Headercharset ']) {
@header (' content-type:text/html charset= '. $_sc[' CharSet '));
}
GPC filter to 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);
}
Cookies
$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 ();
}
Class
$_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 ();
}
?>
Here's the 1.5 version of common.php.
Copy Code code as follows:
<?php
/*
[Ucenter Home] (C) 2007-2008 Comsenz Inc.
$Id: common.php 10981 2009-01-14 03:05:20z Liguode $
*/
Defines a constant that is used in other pages to prevent direct calls to other PHP files by malicious users.
@define (' In_uchome ', TRUE);
Defines a constant that represents the version number
Define (' X_ver ', ' 1.5 ');
This is also a constant, minor version number
Define (' X_release ', ' 20090114 ');
/* Define the Debug mode of the program, set the constant value to 1 when we debug the program, and the error message is displayed on the page when the program goes wrong.
After debugging, the normal operation is set to 0, so that the program error will not be displayed to the user.
*/
Define (' D_bug ', ' 0 ');
Specifies the error report type by D_bug a constant value. The parameter of error_reporting () is the error report type, the related parameter can query PHP manual
D_bug?error_reporting (7): error_reporting (0);
Here are the global variables that are defined. Specific will be used in the back when the introduction of each
$_sglobal = $_sconfig = $_sblock = $_tpl = $_scookie = $_SN = $space = Array ();
Defines a program directory constant. Where Directory_separator is the path separator, Linux is on '/' windows is ' \ '
Define (' S_root ', DirName (__file__). Directory_separator);
Load basic configuration file with @ symbol, no error message on page when no file found
if (! @include_once (s_root. ') /config.php ')) {
Redirect to setup file if not found
Header ("location:install/index.php");
Exit ();
}
Common function file, the specific function in the introduction time will explain
Include_once (s_root. ") /source/function_common.php ');
Time Microtime () Gets the time that contains milliseconds
$mtime = Explode (', microtime ());
$_sglobal[' timestamp '] = $mtime [1];
$mtime [0] is a UNIX timestamp (reshaping), $mtime [0] is a millisecond
$_sglobal[' supe_starttime '] = $_sglobal[' timestamp '] + $mtime [0];
GET_MAGIC_QUOTES_GPC detect if the Magic quotes feature in the php.ini configuration is turned on
$magic _quote = GET_MAGIC_QUOTES_GPC ();
if (Emptyempty ($magic _quote)) {
If automatic filtering is performed on each open, the parameters passed in are escaped
$_get = Saddslashes ($_get);
$_post = Saddslashes ($_post);
}
The URL of the owner's site where Getsiteurl () is used to get 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 cache files open failed rebuild cache, function_cache.php is a function file that contains the cache
Include_once (s_root. ") /source/function_cache.php ');
$cache _func = $value. ' _cache ';
Call the appropriate function to generate the cache.
$cache _func ();
}
}
Gets the length of the cookie prefix, $_sc[' cookiepre ' is the prefix name of the cookie function defined in config.php, $_cookie is a data global variable array that holds the cookie
$prelength = strlen ($_sc[' cookiepre '));
foreach ($_cookie as $key => $val) {
To determine the cookie belonging to Uchome in the cookie under the current domain name
if (substr ($key, 0, $prelength) = = $_sc[' Cookiepre ']) {
Escaping the cookie value
$_scookie[(substr ($key, $prelength))] = Emptyempty ($magic _quote)? Saddslashes ($val): $val;
}
}
Whether to enable GIP compression transmission, this is used to improve the speed of PHP transfer.
if ($_sc[' gzipcompress '] && function_exists (' Ob_gzhandler ')) {
Ob_start (' Ob_gzhandler ');
} else {
Ob_start ();
}
Class
$_sglobal[' supe_uid '] = 0; Initializes the current user's UID
$_sglobal[' supe_username '] = '; Initializes the user name of the current user
$_sglobal[' inajax '] = Emptyempty ($_get[' Inajax ']) 0:intval ($_get[' Inajax ')); This is used in the page to control some pop-up boxes, in the template article will introduce
$_sglobal[' ajaxmenuid '] = Emptyempty ($_get[' ajaxmenuid '])? ': $_get[' ajaxmenuid ';
$_sglobal[' refer '] = Emptyempty ($_server[' http_referer '])? ': $_server[' http_referer '; Gets the URL to the previous page to jump
Sign up for a drip-irrigation machine
/*
When you sign in or sign up, see a link like: do.php?ac=750e45d29d276b2f86f1445627c08f99
The 750e45d29d276b2f86f1445627c08f99 in the back is obtained with the following.
*/
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 station style, check the path of the site template. Here is the default directory, which is our common yellow style template path
if (Emptyempty ($_sconfig[' template ')) {
$_sconfig[' template ' = ' default ';
}
On the homepage by the bottom corner can choose the style of the implementation is 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 ', ');
}
}
Handle the Request_uri, query (query) string (the first question mark in the URL). After the content). If blank, 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 '];
}
Determining User Logon Status
Checkauth ();
User Menu
Getuserapp ();
Handle UC applications, this is a roaming related menu, no need to explain
$_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;
}
}
}
}
?>