Php5 common compatible public files.-PHP source code

Source: Internet
Author: User
Tags server array
Php 5 is a common compatible public file. every new project requires many php modifications for environment configuration. For this reason, I have compiled this generic php header file.
Save the code as a php file and introduce it to the project.

The code functions as follows:
1: The normalization encoding problem, UTF-8, time zone, and number length are all changed.
2: For canonicalized character escaping, all use the standards after php5.3 and do not convert them.
3: the session and gzip are used to determine the startup. This helps prevent implicit conflicts.
4: sort SERVER arrays to hide some unsafe segments and add data starting with HTTP _, such as memory usage, start time, current url address, ip address, get, post and so on. as long as you print out the $ _ SERVER array, basically a lot of data will be available, and it is super Global.

 $ V) $ _ GET [$ k] = stripslashes ($ v); foreach ($ _ POST as $ k => $ v) $ _ POST [$ k] = stripslashes ($ v); foreach ($ _ COOKIE as $ k => $ v) $ _ COOKIE [$ k] = stripslashes ($ v) ;}# clear the $ _ ENV array and release several key values in the $ _ SERVER array. unset ($ _ ENV, $ _ SERVER ['mibdir'], $ _ SERVER ['MySQL _ home'], $ _ SERVER ['openssl _ Conf'], $ _ SERVER ['php _ PEAR_SYSCONF_DIR '], $ _ SERVER ['phprc'], $ _ SERVER ['systemroot'], $ _ SERVER ['comspec'], $ _ SERVER ['pathext '], $ _ SERVER ['win DIR '], $ _ SERVER ['path']); # Some functions. function ini_end () {} function ini_sets ($ key, $ val) {return @ ini_set ($ key, $ val);} function ini_http_server () {if (! $ _ SERVER ['request _ URI ']) {// IIS 5 compatibility $ _ SERVER ['request _ URI'] = $ _ SERVER ['orig _ PATH_INFO '];} if (! Strpos ($ _ SERVER ['request _ URI '],'? ') & $ _ SERVER ['query _ string']! = '') {// IIS 7 compatibility $ _ SERVER ['request _ URI ']. = '? '. $ _ SERVER ['query _ string'];} $ _ SERVER ['request _ URI '] = strtr ($ _ SERVER ['request _ URI'], array ('&' => '&'); $ HTTPS =$ _ SERVER ['https'] & strcasecmp ($ _ SERVER ['https'], 'off'); $ php_selfs = rawurlencode (dirname ($ _ SERVER ['script _ name']); $ php_selfs = strtr ($ php_selfs, array ('% 2F' => '/', '% 5C' => '/'); $ php_selfs = trim ($ php_selfs ,'/'); if ($ php_selfs) $ _ SERVER ['request _ URI '] = strtr ($ _ SERVER ['request _ URI'], Array ($ php_selfs. '/' => ''); $ httppre = (! $ HTTPS )? 'Http': 'https'; if ($ _ SERVER ['server _ port']! = '80' & $ _ SERVER ['server _ port']! = '000000') {$ host = trim ($ httppre. '://'. $ _ SERVER ['http _ host']. ':'. $ _ SERVER ['server _ port']. '/'. $ php_selfs ,'/'). '/';} else {$ php_selfs & $ php_selfs = '/'. $ php_selfs; $ host = trim ($ httppre. '://'. $ _ SERVER ['http _ host']. $ php_selfs ,'/'). '/';} $ files = trim ($ _ SERVER ['request _ URI '],'. /'); $ _ SERVER ['http _ url'] = $ host. $ files; $ _ SERVER ['http _ path'] = $ _ SERVER ['document _ root']. '/'; $ _ SERVER ['http _ IP'] = max (getenv ('server _ ADDR '), getenv ('remote _ ADDR '), getenv ('http _ X_FORWARDED_FOR '), getenv ('http _ CLIENT_IP'); $ _ SERVER ['http _ TIME_FLOAT '] = microtime (true ); $ _ SERVER ['http _ MEMORY_PEAK_USAGE '] = memory_get_peak_usage (); $ _ SERVER ['http _ MEMORY_USAGE'] = memory_get_usage (); $ _ SERVER ['http _ get'] =_ _ GET; $ _ SERVER ['http _ post'] =$ _ POST; $ _ SERVER ['http _ cookies'] =$ _ COOKIE ;}

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.