home Uchome12 15 code learning commonphp

WBOY
Release: 2016-07-29 08:39:49
Original
1003 people have browsed it

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

Copy the 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 turn on the debugging function, 0: off, 1: on
//Depending on whether the debugging function is turned on Set the 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 , then the installer
if(!@include_once(S_ROOT.'./config.php')) {
header("Location: install/index.php");
exit();
}
//Contains public functions 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 Cache processing function library and generate 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 filter, 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();
}
?>
< ;?php
/**
* 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 the error report according to whether the debugging function is turned on or not Level
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 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, install Program
if(!@include_once(S_ROOT.'./config.php')) {
header("Location: install/index.php");
exit();
}
//Include 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, 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 Filter, 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();
}
//Initialize
$_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 $
*/
//Definition A constant used 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, the 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, the error message will be displayed on the page.
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. The @ symbol is used, so it cannot be found. No error message will be prompted on the page when reaching this file
if(!@include_once(S_ROOT.'./config.php')) {
//If not found, redirect to the installation file
header("Location: install /index.php");
exit();
}
//Common 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 including milliseconds
$mtime = explode(' ', microtime());
$_SGLOBAL['timestamp'] = $mtime[1];
//$mtime[0] is the UNIX timestamp ( shaping), $mtime[0] is milliseconds
$_SGLOBAL['supe_starttime'] = $_SGLOBAL['timestamp'] + $mtime[0];
//get_magic_quotes_gpc detects whether the magic quotes 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 passed parameters
$_GET = saddslashes($_GET);
$_POST = saddslashes ($_POST);
}
//The URL of the cargo owner's site, where 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 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 open and rebuild the cache, function_cache.php is the function file that contains the cache.
include_once(S_ROOT.'. /source/function_cache.php');
$cache_func = $value.'_cache';
//Call the corresponding function to generate the 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 global variable array of data that stores COOKIE
$prelength = strlen($_SC['cookiepre']);
foreach($_COOKIE as $key => $val) {
//Determine which COOKIE belongs to UCHome among 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, this is used to improve PHP transmission speed.
if ($_SC['gzipcompress'] && function_exists('ob_gzhandler')) {
ob_start('ob_gzhandler');
} else {
ob_start();
}
//Initialize
$_SGLOBAL['supe_uid'] = 0; //Initialize the UID of the current user
$_SGLOBAL['supe_username'] = ''; //Initialize the username of the current user
$_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 previous page The URL is used to jump to
//Log in to register the anti-flooding machine
/*
When logging in or registering, you will see a link like: do.php?ac=750e45d29d276b2f86f1445627c08f99
The following 750e45d29d276b2f86f1445627c08f99 to get .
*/
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 path of the site template. Here is the default directory, which is our commonly used yellow style template path
if(emptyempty($_SCONFIG['template'])) {
$_SCONFIG['template'] = 'default';
}
//On the homepage by The way you can choose your own style in the lower corner 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' , '');
}
}
//Process REQUEST_URI, query string (content after the first question mark? in the URL). 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();
//Process UC applications, this It 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;
}
}
}
}
?>

The above introduces home Uchome12 15 code learning commonphp, including home content. I hope it will be helpful to friends who are interested in PHP tutorials.

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