Workflow of the zhphpframework three framework

Source: Internet
Author: User
: This article mainly introduces the workflow of the zhphpframework three framework. if you are interested in the PHP Tutorial, refer to it.
 Version_compare(PHP_VERSION, '5. 2', '> = ')? True: die ('
 
  
Severe warning: php versions earlier than php5.2!
 '); # Obtain the php version and determine the minimum ph version of the Zhphp framework as php5.2 ######################## ############### gzip compres start ##################### #######################################$ HTTP_ACCEPT_ENCODING = $ GLOBALS ['_ server'] ['http _ ACCEPT_ENCODING']; function CheckCanGzip () {# check whether global $ HTTP_ACCEPT_ENCODING is supported; if (! Ini_get ('zlib. output_compression ') {# determine if you have configured php server compression if (extension_loaded ("zlib") {if (strpos ($ HTTP_ACCEPT_ENCODING, 'X-gzip ')! = False) {return "x-gzip";} else if (strpos ($ HTTP_ACCEPT_ENCODING, 'gzip ')! = False) {return "gzip" ;}} return 0 ;} /*** output after Page compression * @ param $ content * @ return string */function ob_gzlib ($ content) {$ ENCODING = CheckCanGzip (); if ($ ENCODING) {$ content = gzencode ($ content, 6); header ("Content-Encoding :". $ ENCODING); header ("Vary: Accept-Encoding"); header ("Content-Length :". strlen ($ content); return $ content;} return false ;} ################################### stystem set defi Ne start ###################################### ################### defined ('app _ debug ')? APP_DEBUG: define ('app _ debug', false); # Is it set to DEBUG defined ('DS ')? DS: define ('Ds', DIRECTORY_SEPARATOR); # delimiter defined ('doc _ root ')? DOC_ROOT: define ('doc _ root', $ GLOBALS ['_ server'] ['document _ root']); # get the server root directory address defined ('app _ name ')? APP_NAME: define ('app _ name', 'application'); # default project NAME $ http_type = (isset ($ GLOBALS ['_ server'] ['']) & $ GLOBALS ['_ server'] ['https'] = 'on ') | (isset ($ GLOBALS ['_ server'] ['http _ X_FORWARDED_PROTO']) & $ GLOBALS ['_ server'] ['http _ x_forwarded_proto'] = 'https '))? 'Https: // ': 'http: //'; $ httpHost = isset ($ GLOBALS ['_ server'] ['http _ host'])? $ GLOBALS ['_ server'] ['http _ host']: $ _ SERVER ['http _ host']; defined ('class _ http ')? CLASS_HTTP: define ('class _ http', $ http_type. $ _ SERVER ['http _ host']. substr ($ _ SERVER ['php _ SELF '], 0, strrpos ($ _ SERVER ['php _ SELF'], '/'); $ requestUri = isset ($ GLOBALS ['_ server'] ['request _ URI'])? $ GLOBALS ['_ server'] ['request _ URI']: $ _ SERVER ['request _ URI ']; defined ('http ')? HTTP: define ('http ', $ httpHost); defined ('app _ URI ')? APP_URI: define ('app _ url', $ http_type. $ httpHost. $ requestUri); # The script file address of the current file is defined ('server _ host ')? SERVER_HOST: define ('server _ host', $ http_type. $ httpHost. '/'); # domain NAME address defined ('server _ name ')? SERVER_NAME: define ('server _ name', $ http_type. $ httpHost); # Do not include/domain NAME defined ('app _ path ')? APP_PATH: define ('app _ path', str_replace ('\', '/', dirname (_ FILE __))). '/'. APP_NAME. '/'); defined ('Project _ path ')? PROJECT_PATH: define ('Project _ path', dirname (APP_PATH); # obtain the project path if (PROJECT_PATH! = DOC_ROOT) {$ arr = explode ('/', PROJECT_PATH); # decomposition PROJECT defined ('Project _ name ')? PROJECT_NAME: define ('Project _ name', end ($ arr); # get the project name and set the global constant} else {defined ('Project _ name ')? PROJECT_NAME: define ('Project _ name', APP_NAME); # obtain the project name and set the global constant} defined ('web _ STATIC ')? WEB_STATIC: define ('web _ STATIC ', PROJECT_PATH.'/'. APP_NAME.'/WEB/'); # STATIC rendering layer address defined ('root _ path ')? ROOT_PATH: define ('root _ path', str_ireplace ('\', '/', dirname (_ FILE __))). '/'); # get the current system and directory address defined ('app _ host ')? APP_HOST: define ('app _ host', $ httpHost. '/'); unset ($ http_type, $ is_version, $ httpHost, $ requestUri, $ project_work, $ project_name, $ arr, $ environment ); # manually destroy the corresponding variable include_once ROOT_PATH. 'Common/define. php '; # load your application constant ################################# ####### php. ini config ###################################### ######### program-to-server security configuration ini_set ('safe _ mode ', 'on'); # enable the php Security mode ini_set ('expose _ php', 'off'); # hide the php version information ini_set ('log _ errors ', 'on'); # enable the error log function ini_set ('error _ log', APP_PATH. 'data/error_log/general_errors.log '); # record the error log file ini_set ('register _ globals', 'off'); # CloseGlobal variablesRegister ini_set ('memory _ limit ', '12m'); # set the running memory ini_set ('session. cache_expire ', 180); ini_set ('session. use_trans_sid ', 0); ini_set ('session. use_cookies ', 1); ini_set ('session. auto_start ', 0); ini_set ('session. gc_maxlifetime ', 'Time _ in_seconds'); ini_set ('session. name ', 'zhphpsession'); ini_set ('session. gc_probability ', 0); ini_set ('session. cookie_path ', SESSION_PATH); ini_set ('session. cookie_domain ', SESSION_DOMAIN); I Ni_set ('session. cookie_lifetime ', '20140901'); ini_set ('session. save_path ', SESSION_PATH); include_once ROOT_PATH. 'engine/loader. class. php '; # load loader class loader: init (); engine: loadCommon ('common'); # load the system tool function file config: loadConfig (); # set_error_handler ('error '); # Custom error functions ################################### development environment debugging ###################################### ###########################$ envirswitch ($ environment) {case 1: defined ('http _ url ')? HTTP_URL: define ('http _ url', SERVER_HOST.PROJECT_NAME. '/'); break; # set the global constant case 2: defined ('http _ url ')? HTTP_URL: define ('http _ url', SERVER_HOST); break; case 3: echo 'waiting for test'; break ;}# set the error display level if (APP_DEBUG) {ini_set ('display _ errors ', true); error_reporting (E_ALL); browserDebug (); # load the browser debugging tool to facilitate browser debugging during development, currently, Firefox, Chrome} else {ini_set ('display _ errors ', false); error_reporting (0) ;}$ GLOBALS ['router'] = engine :: load ('router '); # routing engine instantiation result ################################ preventionSQL injectionAnd program security prevention start ################################ checkSafeInput (); if (! Get_magic_quotes_gpc () {$ _ GET = addslashes_deep ($ _ GET); $ _ POST = addslashes_deep ($ _ POST); $ _ COOKIE = addslashes_deep ($ _ COOKIE ); $ _ REQUEST = addslashes_deep ($ _ REQUEST );}

The preceding section describes the workflow of the zhphp framework, including version_compare, global variables, and SQL injection. if you are interested in the PHP Tutorial.

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.