Uchome code is still very good, learn!
Copy CodeThe code is as follows:
/**
* Define some constants
*/
@define (' In_uchome ', TRUE); It is said to prevent the file from being illegally included
Define (' X_ver ', ' 1.2 '); Uchome version
Define (' X_release ', ' 20080612 ');//Release date
Define (' D_bug ', ' 0 '); Whether to turn on the debug function, 0: OFF, 1: Open
Set error reporting levels based on whether debugging is turned on
D_bug?error_reporting (7): error_reporting (0);
Initialize some of the global variables
$_sglobal = $_sconfig = $_sblock = $_tpl = $_scookie = $space = Array ();
Defining Program Directory Constants
Define (' S_root ', DirName (__file__). Directory_separator);
Get time, primarily for output program run time
$mtime = Explode (' ', Microtime ());
$_sglobal[' timestamp ' = $mtime [1];
$_sglobal[' supe_starttime ' = $_sglobal[' timestamp '] + $mtime [0];
Basic file, try to include the base profile, if it contains unsuccessful, 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, attempt to include site configuration information from the cache directory, and if unsuccessful, include the cache handler 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 sets
if ($_sconfig[' Headercharset ']) {
@header (' content-type:text/html; charset= '. $_sc[' CharSet ');
}
GPC filtering, automatic escape of 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 ();
}
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 ();
App 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 the file from being illegally included
Define (' X_ver ', ' 1.2 '); Uchome version
Define (' X_release ', ' 20080612 ');//Release date
Define (' D_bug ', ' 0 '); Whether to turn on the debug function, 0: OFF, 1: Open
Set error reporting levels based on whether debugging is turned on
D_bug?error_reporting (7): error_reporting (0);
Initialize some of the global variables
$_sglobal = $_sconfig = $_sblock = $_tpl = $_scookie = $space = Array ();
Defining Program Directory Constants
Define (' S_root ', DirName (__file__). Directory_separator);
Get time, primarily for output program run time
$mtime = Explode (' ', Microtime ());
$_sglobal[' timestamp ' = $mtime [1];
$_sglobal[' supe_starttime ' = $_sglobal[' timestamp '] + $mtime [0];
Basic file, try to include the base profile, if it contains unsuccessful, 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, attempt to include site configuration information from the cache directory, and if unsuccessful, include the cache handler 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 sets
if ($_sconfig[' Headercharset ']) {
@header (' content-type:text/html; charset= '. $_sc[' CharSet ');
}
GPC filtering, automatic escape of 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 ();
}
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 ();
App List
@include_once (S_root. /data/data_app.php ');
if (Emptyempty ($_sglobal[' app ')) {
Include_once (S_root. /source/function_cache.php ');
App_cache ();
}
?>
Here is the 1.5 version of common.php
Copy CodeThe code is as follows:
/*
[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 malicious users from invoking other PHP files directly.
@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, so the error message will be displayed on the page when the program goes wrong.
Set to 0 after commissioning is complete, so the program error is not displayed to the user.
*/
Define (' D_bug ', ' 0 ');
Specifies the error report type by D_bug constant value. where the error_reporting () parameter is the error report type, the relevant parameters can be queried 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 of the time to introduce
$_sglobal = $_sconfig = $_sblock = $_tpl = $_scookie = $_SN = $space = Array ();
Defines the program directory constants. Where Directory_separator is the path delimiter, Linux is '/' on Windows ' \ '
Define (' S_root ', DirName (__file__). Directory_separator);
The basic configuration file is loaded with the @ symbol, and the error message is not prompted on the page when the file cannot be found
if (! @include_once (s_root. /config.php ')) {
Redirect to the installation file if it is not found
Header ("location:install/index.php");
Exit ();
}
General function file, the specific function in the introduction time will be explained
Include_once (S_root. /source/function_common.php ');
Time Microtime () Gets the time with milliseconds
$mtime = Explode (' ', Microtime ());
$_sglobal[' timestamp ' = $mtime [1];
$mtime [0] is a UNIX timestamp (shaping), $mtime [0] is milliseconds
$_sglobal[' supe_starttime ' = $_sglobal[' timestamp '] + $mtime [0];
GET_MAGIC_QUOTES_GPC detect if the Magic quotes feature is turned on in the php.ini configuration
$magic _quote = GET_MAGIC_QUOTES_GPC ();
if (Emptyempty ($magic _quote)) {
If automatic filtering is turned on, the passed-in parameters are escaped
$_get = Saddslashes ($_get);
$_post = Saddslashes ($_post);
}
The URL of the shipper 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 the cache file open fails to rebuild the cache, function_cache.php is the function file that contains the build 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, and $_cookie is the data global variable array that holds the cookie
$prelength = strlen ($_sc[' cookiepre ');
foreach ($_cookie as $key = = $val) {
Determine the cookie belonging to Uchome in the cookie under the current domain name
if (substr ($key, 0, $prelength) = = $_sc[' Cookiepre ']) {
Escaping a cookie value
$_scookie[(substr ($key, $prelength))] = Emptyempty ($magic _quote)? Saddslashes ($val): $val;
}
}
Whether to enable GIP compression transfer, this is used to improve the speed of PHP transfer.
if ($_sc[' gzipcompress ') && function_exists (' Ob_gzhandler ')) {
Ob_start (' Ob_gzhandler ');
} else {
Ob_start ();
}
Initialization
$_sglobal[' supe_uid '] = 0; Initialize the UID of the current user
$_sglobal[' supe_username '] = '; Initializes the user name of the current user
$_sglobal[' Inajax ' = Emptyempty ($_get[' Inajax '])? 0:intval ($_get[' Inajax ']); This is used to control some pop-up boxes in the page, which will be introduced in the template
$_sglobal[' ajaxmenuid ' = Emptyempty ($_get[' ajaxmenuid '])? ": $_get[' Ajaxmenuid '];
$_sglobal[' refer ' = Emptyempty ($_server[' http_referer '])? ": $_server[' http_referer ']; Get the URL of the previous page to jump to
Login registration Anti-drip machine
/*
When you sign in or register, see the form: do.php?ac=750e45d29d276b2f86f1445627c08f99 link
The 750e45d29d276b2f86f1445627c08f99 in the back is obtained using 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 ']));
Entire station style, check the path of the site template. Here is the default directory, which is our usual yellow style template path
if (Emptyempty ($_sconfig[' template ')) {
$_sconfig[' template ' = ' default ';
}
In the homepage from the bottom corner can choose their own style of 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 ', ');
}
}
A string that handles Request_uri, query (the first question mark in the URL?). After the content). If empty, 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 logon status
Checkauth ();
User Menu
Getuserapp ();
To handle UC applications, this is a roaming-related menu, not explained 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;
}
}
}
}
?>
http://www.bkjia.com/PHPjc/319981.html www.bkjia.com true http://www.bkjia.com/PHPjc/319981.html techarticle Uchome code is still very good, learn! Copy the code as follows:? PHP/** * Defines some constants */@define (' In_uchome ', TRUE); It is said to prevent the illegal inclusion of the de ...