common.inc.php
Last Update:2016-06-23
Source: Internet
Author: User
Define (' Phpcms_root ', str_replace ("\ \", '/', substr (DirName (__file__), 0,-7))); Defining the root directory
Define (' Microtime_start ', Microtime ()); Set start time
Define (' In_phpcms ', TRUE); Site Entry Judgment variable
Define (' MAGIC_QUOTES_GPC ', GET_MAGIC_QUOTES_GPC ()); Setting the magic Word will convert the switch
Define (' Time ', Time ()); Build time
Set_include_path (phpcms_root. ' include/'); Load file directory
Set_magic_quotes_runtime (0); Set the magic word run time switch, 0 is off
Unset ($LANG, $HTTP _env_vars, $HTTP _post_vars, $HTTP _get_vars, $HTTP _post_files, $HTTP _cookie_vars);//Empty variable
Require ' config.inc.php '; Core configuration Files
Require ' global.func.php '; Global function functions
Require ' dir.func.php '; Directory function operation function function
Require ' url.func.php '; URL-related action functions
Require ' output.class.php '; Data Output correlation function
Require ' priv_group.class.php '; Group Permission class
Require ' times.class.php '; Time Processing class
Require phpcms_root. ' languages/'. LANG '/phpcms.lang.php '; Load Language Function Pack
Errorlog? Set_error_handler (' Phpcms_error '): error_reporting (E_error | e_warning | E_parse); Set Error handling Wit
Define (' IP ', IP ());
Define (' Http_referer ', isset ($_server[' http_referer '])? $_server[' Http_referer ']: ');
Define (' Script_name ', isset ($_server[' script_name '])? $_server[' Script_name ': Preg_replace ("/(. *) \.php (. *)/I", " http://www.cnblogs.com/igaofen/admin/file://1.php/", $_server[' php_self '));
Define (' Query_string ', $_server[' query_string ');
Define (' Path_info ', isset ($_server[' path_info '])? $_server[' Path_info ']: ');
Define (' DOMAIN ', isset ($_server[' server_name ')? $_server[' server_name ']: Preg_replace ("/([^:]*) [: 0-9]*/i", "http ://WWW.CNBLOGS.COM/IGAOFEN/ADMIN/FILE://0.0.0.1/", $_server[' http_host '));
Define (' SCHEME ', $_server[' server_port ') = = ' 443 '? ' https://': '/http ');
Define (' Site_url ', scheme.$_server[' http_host '). Phpcms_path);
Define (' Relate_url ', isset ($_server[' Request_uri ')? $_server[' Request_uri ']: Script_name. ( Query_string? '?'. Query_string:path_info));
Define (' URL ', scheme.$_server[' http_host '). Relate_url);
Define (' Relate_referer ', UrlEncode (Relate_url));
Defines a series of server-related variables to prepare for subsequent cache-related parameters
if (function_exists (' Date_default_timezone_set ')) Date_default_timezone_set (timezone);//Set the default time zone for functions such as
Header (' content-type:text/html; charset= '. CHARSET); Set character sets
if (cache_page &&!defined (' in_admin ')) Cache_page_start (); See if the page cache is called
if (GZIP && extension_loaded (' zlib ')) ini_set (' zlib.output_compression ', ' on '); is gzip optimized
Ob_start (); Cache start, start Ob_start output partial turn cache, flush, all output
$dbclass = ' db_ '. Db_database; Generate Db.class's name
Require $dbclass. " Class.php '; Database class file that loads db
$db = new $dbclass; Instance Send database
$db->connect (Db_host, Db_user, DB_PW, Db_name, Db_pconnect, Db_charset); Connecting to a database
Require ' session_ '. Session_storage. '. Class.php '; Load Session Class
$session = new session (); Initialize session
Session_set_cookie_params (0, Cookie_path, cookie_domain); Set cookies
if ($_request)//Escape the REQUEST variable
{
if (MAGIC_QUOTES_GPC)
{
$_request = New_stripslashes ($_request);
if ($_cookie) $_cookie = New_stripslashes ($_cookie);
}
if (!defined (' in_admin ')) $_request = FILTER_XSS ($_request, allowed_htmltags);
Extract ($db->escape ($_request), extr_skip);
if ($_cookie) $db->escape ($_cookie);
}
if (query_string && strpos (query_string, ' = ') = = = False && Preg_match ("/^ (. *) \. ( htm|html|shtm|shtml) $/", Query_string, $urlvar))
{
Parse_str (Str_replace (Array ('/', '-', '), Array (' & ', ' = ', '), $urlvar [1]);
}
$CACHE = Cache_read (' common.php '); Read cache,comman.php generated some of the initial variables of the site, such as column name, etc., can be viewed under the data/cahce/
if (! $CACHE)
{
Require_once ' cache.func.php ';
Cache_all ();
$CACHE = Cache_read (' common.php ');
}
Extract ($CACHE); Turn an array into a variable
Unset ($CACHE); Destroying variables
if ($PHPCMS [' enable_ipbanned '] && ip_banned (IP)) showmessage ($LANG [' administrator_banned_this_ip ']);// IP Address Restrictions
if (!defined (' in_admin '))////illegal information shielding scope (0 disabled, 1 front desk, 2 full station)
{
if (filter_enable && Filter_word ()) showmessage (' The content including illegal information: '. Illegal_word. '. ');
if ($PHPCMS [' minrefreshtime '])
{
$CC = new Times ();
$CC->set (' cc ', $PHPCMS [' Minrefreshtime '], 1);
if ($cc->check ()) showmessage (' Do not refresh the page '. $PHPCMS [' Minrefreshtime ']. ' seconds! ');
$CC->add ();
Unset ($CC);
}
if (!isset ($forward)) $forward = Http_referer;
}
$M = $TEMP = Array ();
if (!isset ($mod)) $mod = ' phpcms '; Set the module, if nothing is set, use Phpcms
if ($mod! = ' phpcms ')//If there are settings, call the relevant module information and read the CAHCE that they generated
{
Isset ($MODULE [$mod]) or exit ($LANG [' module_not_exists ']);
$langfile = defined (' In_admin ')? $mod. ' _admin ': $mod;
@include phpcms_root. ' languages/'. LANG '/'. $langfile. ' Lang.php ';
$M = Cache_read (' Module_ '. $mod. php ');
}
$_userid = 0;
$_username = ";
$_groupid = 3;
$phpcms _auth = Get_cookie (' auth '); Determine whether you have logged in before, and to adjust the authentication information, authority to judge
if ($phpcms _auth)
{
$auth _key = MD5 (auth_key.$_server[' http_user_agent ');
List ($_userid, $_password) = explode ("\ t", Phpcms_auth ($phpcms _auth, ' DECODE ', $auth _key));
$_userid = Intval ($_userid);
$sql _member = "SELECT * from". Db_pre. " Member_cache ' WHERE ' userid ' =$_userid ';
$r = $db->get_one ($sql _member);
if (! $r && Cache_member ())
{
$r = $db->get_one ($sql _member);
}
if ($r && $r [' password '] = = = $_password)
{
if ($r [' groupid '] = = 2)
{
Set_cookie (' auth ', ');
ShowMessage ($LANG [' userid_banned_by_administrator ']);
}
@extract ($r, Extr_prefix_all, ");
}
Else
{
$_userid = 0;
$_username = ";
$_groupid = 3;
Set_cookie (' auth ', ');
}
Unset ($r, $phpcms _auth, $phpcms _auth_key, $_password, $sql _member);
}
$G = Cache_read (' Member_group_ '. $_groupid. php '); Read Member's group information
$priv _group = new Priv_group (); Initialize Group user Information
Define (' Skin_path ', ' templates/'). Tpl_name. ' /skins/'. Tpl_css. ' /'); To load a template's CSS file
Define (' Passport_enable ', ($PHPCMS [' UC '] | | $PHPCMS [' enablepassport '] | | $PHPCMS [' enableserverpassport '])? 1:0); Set up UC, other password passes, switches
?>
This article from Csdn Blog, reproduced please indicate the source: http://blog.csdn.net/guwenzhong/archive/2009/03/05/3959500.aspx