This is the php code used by uchome. when you are learning programming, you can see some mature cms systems at that time, provided that you are familiar with the program, otherwise, the study will be dispelled. UCHOME code is still very good. learn it!
The code is as follows:
/**
* Define constants
*/
@ Define ('in _ UCHOME ', TRUE); // It is said that it can prevent illegal file inclusion
Define ('x _ VER ', '1. 2'); // Uchome version
Define ('x _ release', '000000'); // RELEASE date
Define ('d _ BUG, '0'); // whether to enable the debugging function, 0: Disabled, 1: enabled
// Set the error report level based on whether debugging is enabled
D_BUG? Error_reporting (7): error_reporting (0 );
// Initialize some global variables
$ _ SGLOBAL =$ _ SCONFIG =$ _ SBLOCK =$ _ TPL =$ _ SCOOKIE = $ space = array ();
// Define the program directory constant
Define ('s _ ROOT ', dirname (_ FILE _). DIRECTORY_SEPARATOR );
// Get the time, mainly used to output the 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 file cannot be included, install the program.
If (! @ Include_once (S_ROOT. './config. php ')){
Header ("Location: install/index. php ");
Exit ();
}
// Contains the public function library
Include_once (S_ROOT. './source/function_common.php ');
// Link to the database
Dbconnect ();
// Configure the file and try to contain the website configuration information in the cache Directory. if the file fails, it is included in the cache processing function library and the configuration cache is generated.
If (! @ Include_once (S_ROOT. './data/data_config.php ')){
Include_once (S_ROOT. './source/function_cache.php ');
Config_cache ();
}
// Use the character set forcibly
If ($ _ SCONFIG ['headercharset']) {
@ Header ('content-Type: text/html; charset = '. $ _ SC ['charset']);
}
// GPC filter, automatically escape special characters in $ _ GET, $ _ POST, and $ _ Cookies 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 ['Ajax '] = emptyempty ($ _ GET ['Ajax'])? 0: intval ($ _ GET ['Ajax ']);
$ _ SGLOBAL ['ajaxmenuid'] = emptyempty ($ _ GET ['ajaxmenuid'])? '': $ _ GET ['ajaxmenuid'];
$ _ SGLOBAL ['referer'] = emptyempty ($ _ SERVER ['http _ referer'])? '': $ _ SERVER ['http _ referer'];
// Obtain 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 constants
*/
@ Define ('in _ UCHOME ', TRUE); // It is said that it can prevent illegal file inclusion
Define ('x _ VER ', '1. 2'); // Uchome version
Define ('x _ release', '000000'); // RELEASE date
Define ('d _ BUG, '0'); // whether to enable the debugging function, 0: Disabled, 1: enabled
// Set the error report level based on whether debugging is enabled
D_BUG? Error_reporting (7): error_reporting (0 );
// Initialize some global variables
$ _ SGLOBAL =$ _ SCONFIG =$ _ SBLOCK =$ _ TPL =$ _ SCOOKIE = $ space = array ();
// Define the program directory constant
Define ('s _ ROOT ', dirname (_ FILE _). DIRECTORY_SEPARATOR );
// Get the time, mainly used to output the 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 file cannot be included, install the program.
If (! @ Include_once (S_ROOT. './config. php ')){
Header ("Location: install/index. php ");
Exit ();
}
// Contains the public function library
Include_once (S_ROOT. './source/function_common.php ');
// Link to the database
Dbconnect ();
// Configure the file and try to contain the website configuration information in the cache Directory. if the file fails, it is included in the cache processing function library and the configuration cache is generated.
If (! @ Include_once (S_ROOT. './data/data_config.php ')){
Include_once (S_ROOT. './source/function_cache.php ');
Config_cache ();
}
// Use the character set forcibly
If ($ _ SCONFIG ['headercharset']) {
@ Header ('content-Type: text/html; charset = '. $ _ SC ['charset']);
}
// GPC filter, automatically escape special characters in $ _ GET, $ _ POST, and $ _ Cookies 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 ['Ajax '] = emptyempty ($ _ GET ['Ajax'])? 0: intval ($ _ GET ['Ajax ']);
$ _ SGLOBAL ['ajaxmenuid'] = emptyempty ($ _ GET ['ajaxmenuid'])? '': $ _ GET ['ajaxmenuid'];
$ _ SGLOBAL ['referer'] = emptyempty ($ _ SERVER ['http _ referer'])? '': $ _ SERVER ['http _ referer'];
// Obtain 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 ();
}
?>
Below is the 1.5 version of common. php
The code is as follows:
/*
[UCenter Home] (C) 2007-2008 Comsenz Inc.
$ Id: common. php 10981 03: 05: 20Z liguode $
*/
// Define a constant to prevent malicious users from directly calling other PHP files on other pages.
@ Define ('in _ UCHOME ', TRUE );
// Define a constant, which indicates the version number
Define ('x _ VER ', '1. 5 ');
// This is also a constant, the minor version number
Define ('x _ release', '123 ');
/* Define the debugging mode of the program. when debugging the program, set the constant value to 1, so that the error message is displayed on the page when the program fails.
Set it to 0 After debugging is completed and put into use normally, so that program errors are not displayed to users.
*/
Define ('d _ BUG ', '0 ');
// Use the D_BUG constant value to specify the error report type. The error_reporting () parameter is the error report type. you can query the relevant parameters in the PHP Manual.
D_BUG? Error_reporting (7): error_reporting (0 );
// The global variables are defined below. The details will be described one by one later.
$ _ SGLOBAL =$ _ SCONFIG =$ _ SBLOCK =$ _ TPL =$ _ SCOOKIE =$ _ SN = $ space = array ();
// Define the program directory constant. DIRECTORY_SEPARATOR is the path separator, and '/' is '\' on windows '\'
Define ('s _ ROOT ', dirname (_ FILE _). DIRECTORY_SEPARATOR );
// Load the basic configuration file and use the @ symbol. if the file cannot be found, no error message is displayed on the page.
If (! @ Include_once (S_ROOT. './config. php ')){
// If not found, redirect to the installation file
Header ("Location: install/index. php ");
Exit ();
}
// General function file. the specific functions will be explained one by one during the introduction time.
Include_once (S_ROOT. './source/function_common.php ');
// Obtain the time in milliseconds in microtime ()
$ Mtime = explode ('', microtime ());
$ _ SGLOBAL ['timestamp'] = $ mtime [1];
// $ Mtime [0] is a UNIX timestamp (integer), and $ mtime [0] is a millisecond
$ _ SGLOBAL ['supe _ starttime'] = $ _ SGLOBAL ['timestamp'] + $ mtime [0];
// Get_magic_quotes_gpc checks whether the magic quotation mark function in the PHP. INI configuration is enabled
$ Magic_quote = get_magic_quotes_gpc ();
If (emptyempty ($ magic_quote )){
// If it is automatically filtered out, the input parameters are escaped.
$ _ GET = saddslashes ($ _ GET );
$ _ POST = saddslashes ($ _ POST );
}
// The URL of the cargo master site. getsiteurl () is used to obtain the domain name of the current site.
If (emptyempty ($ _ SC ['siteurl']) $ _ SC ['siteurl'] = getsiteurl ();
// Link to the database
Dbconnect ();
// Open the cached file
Foreach (array ('config', 'app', 'userapp', 'AD') as $ value ){
If (! @ Include_once (S_ROOT. './data _'. $ value. '. php ')){
// If the cache file fails to be opened and the cache is rebuilt, function_cache.php is a function file that contains the function file for creating the cache.
Include_once (S_ROOT. './source/function_cache.php ');
$ Cache_func = $ value. '_ cache ';
// Call the corresponding function to generate the cache.
$ Cache_func ();
}
}
// Obtain the COOKIE prefix length. $ _ SC ['cookiepre'] is in config. the prefix name of the COOKIE function defined in php. $ _ COOKIE is an array of global variables for storing COOKIE data.
$ Prelength = strlen ($ _ SC ['cookiepre']);
Foreach ($ _ COOKIE as $ key => $ val ){
// Determine the UCHome COOKIE in the COOKIE under the current domain name
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, which is used to speed up PHP transmission.
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'] = ''; // initialize the user name of the current user
$ _ SGLOBAL ['Ajax '] = emptyempty ($ _ GET ['Ajax'])? 0: intval ($ _ GET ['inajax ']); // This is used to control some pop-up boxes on the page. this will be introduced in the template section.
$ _ SGLOBAL ['ajaxmenuid'] = emptyempty ($ _ GET ['ajaxmenuid'])? '': $ _ GET ['ajaxmenuid'];
$ _ SGLOBAL ['referer'] = emptyempty ($ _ SERVER ['http _ referer'])? '': $ _ SERVER ['http _ referer']; // gets the URL of the previous page to jump
// Log on and register the Water anti-irrigation agent
/*
Do. php? Ac = 750e45d29d276b2f86f1445627c08f99
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']);
// The whole site style. check the path of the site template. Here is the default directory, which is a commonly used template path in the yellow style.
If (emptyempty ($ _ SCONFIG ['template']) {
$ _ SCONFIG ['template'] = 'default ';
}
// On the homepage, you can select a style by yourself.
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, the query string (the first question mark in the URL? ). If it is null, the current page is displayed.
If (! Isset ($ _ SERVER ['request _ URI ']) {
$ _ SERVER ['request _ URI '] = $ _ SERVER ['php _ SELF'];
If (isset ($ _ SERVER ['query _ string']) $ _ SERVER ['request _ URI ']. = '? '. $ _ SERVER ['query _ string'];
}
// Determine the user logon status
Checkauth ();
// User menu
Getuserapp ();
// Process the UC application. this is the roaming menu. you do not need to explain it here.
$ _ SGLOBAL ['append'] = $ _ SGLOBAL ['append'] = array ();
If ($ _ SGLOBAL ['app']) {
Foreach ($ _ SGLOBAL ['app'] as $ value ){
If ($ value ['open']) {
If (emptyempty ($ _ SGLOBAL ['append']) {
$ _ SGLOBAL ['append'] = $ value;
} Else {
$ _ SGLOBAL ['append'] [] = $ value;
}
}
}
}
?>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.