Detailed description of the init. php file in ecshop

Source: Internet
Author: User
: This article mainly introduces the init. PHP file in ecshop. if you are interested in the PHP Tutorial, please refer to it.
Detailed description of the init. php file in ecshop
Under the Directory des/init. php

For work reasons, secondary development of ecshop is required. By the way, some analysis on the source code of ecshop is recorded:

The first is the init. php file. This file is called on every page of ecshop, so we will analyze it first:

 = '5. 1 '&&! Empty ($ timezone) {date_default_timezone_set ($ timezone); // date_default_timezone_set to set the time zone} // $ _ SERVER ['php _ SELF '] returns the current page, to obtain $ _ SERVER ['php _ SELF '], you 'd better use htmlspecialchars to filter out the XSS vulnerability $ php_self = isset ($ _ SERVER ['php _ SELF'])? $ _ SERVER ['php _ SELF ']: $ _ SERVER ['script _ name']; if ('/'= substr ($ php_self,-1 )) // if it is the end of "/", add index. php {$ php_self. = 'index. php ';} define ('php _ SELF', $ php_self); // put the constant require (ROOT_PATH. 'Des/inc_constant.php'); // contains the pre-defined constant file require (ROOT_PATH. 'regiondes/cls_ecshop.php'); // the base class file require (ROOT_PATH. 'includes/cls_error.php '); // The Error class file require (ROOT_PATH. 'regiondes/lib_time.php '); // Time function require (ROO T_PATH. 'mongodes/lib_base.php '); // basic function library require (ROOT_PATH. 'mongodes/lib_common.php '); // basic function library require (ROOT_PATH. 'regiondes/lib_main.php '); // public function library require (ROOT_PATH. 'regiondes/lib_insert.php'); // the dynamic content function library require (ROOT_PATH. 'regiondes/lib_goods.php '); // The product-related function library require (ROOT_PATH. 'delimiterdes/lib_article.php '); // Function Libraries related to articles and Articles/* escape user input variables. */If (! Get_magic_quotes_gpc () {if (! Empty ($ _ GET) {$ _ GET = addslashes_deep ($ _ GET);} if (! Empty ($ _ POST) {$ _ POST = addslashes_deep ($ _ POST);} $ _ COOKIE = addslashes_deep ($ _ COOKIE ); $ _ REQUEST = addslashes_deep ($ _ REQUEST);}/* create an ECSHOP object */$ ecs = new ECS ($ db_name, $ prefix); // parameter description: database name table prefix define ('data _ dir', $ ecs-> data_dir (); // DATA directory define ('image _ dir ', $ ecs-> image_dir (); // image directory/* initialize database class */require (ROOT_PATH. 'Des/cls_mysql.php '); $ db = new cls_mysql ($ db_host, $ db_user, $ db_pass, $ db_name ); /* Set the table that cannot be cached */$ db-> set_disable_cache_tables (array ($ ecs-> table ('Session '), $ ecs-> table ('Sessions _ data'), $ ecs-> table ('cart'); $ db_host = $ db_user = $ db_pass = $ db_name = NULL; /* create an error handling object */$ err = new ecs_error ('message. dwt ');/* load the system parameter */$ _ CFG = load_config (); // load the configuration information function in lib_common.php/* load the language file */require (ROOT_PATH. 'ages /'. $ _ CFG ['Lang ']. '/common. php '); if ($ _ CFG ['shop _ closed'] = 1) {/* The store is closed, and the closed message */header ('content-type: text/html; charset = '. EC_CHARSET); die ('

'. $ _ LANG ['shop _ closed'].'

'. $ _ CFG ['close _ comment'].'

');} // Determine whether the search engine spider function is in lib_main.phpif (is_spider () {/* if it is a spider access, the default Visitor mode is used, and not recorded in the log */if (! Defined ('init _ NO_USERS ') {define ('init _ NO_USERS', true);/* after UC integration, if it is a spider access, the constant */if ($ _ CFG ['integrate _ Code'] = 'ucenter') required to initialize UC {$ user = & init_users ();}} $ _ SESSION = array (); $ _ SESSION ['User _ id'] = 0; $ _ SESSION ['User _ name'] = ''; $ _ SESSION ['email '] = ''; $ _ SESSION ['User _ rank'] = 0; $ _ SESSION ['discount'] = 1.00 ;} // non-search engine spider, record sessionif (! Defined ('init _ NO_USERS ') {/* initialize session */include (ROOT_PATH. 'regiondes/cls_session.php '); $ sess = new cls_session ($ db, $ ecs-> table ('Session '), $ ecs-> table ('Sessions _ data'); define ('sess _ id', $ SESS-> get_session_id ();} // If Smartyif (! Defined ('init _ NO_SMARTY ') {header ('cache-control: private'); header ('content-type: text/html; charset = '. EC_CHARSET);/* Create a Smarty object. */Require (ROOT_PATH. 'shortdes/cls_template.php '); $ smarty = new cls_template; $ smarty-> cache_lifetime =$ _ CFG ['cache _ time']; // cache Time $ smarty-> template_dir = ROOT_PATH. 'themes /'. $ _ CFG ['template']; // template $ smarty-> cache_dir = ROOT_PATH. 'temp/caches'; // The cache $ smarty-> compile_dir = ROOT_PATH. 'temp/compiled '; // if (DEBUG_MODE & 2) = 2) where the template compiled file is located // if the constant DEBUG_MODE value is 2, 3, 6, 7. when {$ smarty-> direct_output = True; // outputs $ smarty-> force_compile = true without using the cache; // forcibly compiles} else {$ smarty-> direct_output = false; $ smarty-> force_compile = false;} $ smarty-> assign ('Lang ', $ _ lang); $ smarty-> assign ('ecs _ charset', EC_CHARSET ); if (! Empty ($ _ CFG ['stylename']) // if you define a style file, use your own {$ smarty-> assign ('ecs _ css_path ', 'themes /'. $ _ CFG ['template']. '/style _'. $ _ CFG ['stylename']. '.css ');} else {$ smarty-> assign ('ecs _ css_path', 'themes /'. $ _ CFG ['template']. '/style.css') ;}// non-search engine crawler, record user information if (! Defined ('init _ NO_USERS ') {/* initialize the member data lib_common.php */$ user = & init_users (); if (! Isset ($ _ SESSION ['User _ id']) {/* GET the name of the serving site */$ site_name = isset ($ _ GET ['from'])? $ _ GET ['from']: addslashes ($ _ LANG ['self _ site']); $ from_ad =! Empty ($ _ GET ['ad _ id'])? Intval ($ _ GET ['ad _ id']): 0; $ _ SESSION ['from _ ad'] = $ from_ad; // ad ID $ _ SESSION ['referer'] = stripslashes ($ site_name); // User source unset ($ site_name); if (! Defined ('ingore _ VISIT_STATS ') {visit_stats () ;}} if (empty ($ _ SESSION ['User _ id']) {if ($ user-> get_cookie ()) {/* if the member has logged on and has not yet obtained the member's account balance, points, and coupons */if ($ _ SESSION ['User _ id']> 0) {update_user_info () ;}} else {$ _ SESSION ['User _ id'] = 0; $ _ SESSION ['User _ name'] = ''; $ _ SESSION ['email '] = ''; $ _ SESSION ['User _ rank'] = 0; $ _ SESSION ['discount'] = 1.00; if (! Isset ($ _ SESSION ['login _ fail ']) {$ _ SESSION ['login _ fail'] = 0 ;}}} /* set recommended members */if (isset ($ _ GET ['u']) {set_affiliate ();} if (isset ($ smarty )) {$ smarty-> assign ('ecs _ session', $ _ session) ;}} if (DEBUG_MODE & 1) = 1) // if the value of the constant DEBUG_MODE is 1, 3, 5, or 7. {error_reporting (E_ALL); // report all errors} else {error_reporting (E_ALL ^ E_NOTICE); // report all errors except E_NOTICE} if (DEBUG_MODE & 4) = 4) // if the constant DEBUG_MODE value is 4, 5, 6, or 7. time, Call Test Program {include (ROOT_PATH. 'Des/lib. debug. php '); //}/* determines whether Gzip mode is supported. if both the web page compression is set using SMARTY, compression is enabled */if (! Defined ('init _ NO_SMARTY ') & gzip_enabled () {ob_start ('OB _ gzhandler'); // compress the data to the buffer} else {ob_start (); // open the buffer, and put the following content first on the server}/* ob_start related functions: 1. Flush: refresh the buffer content and output it. Function format: flush () Description: This function is frequently used and highly efficient. 2. ob_start: format of the function used to open the output buffer: void ob_start (void) description: When the buffer is activated, all non-file header information from the PHP program is not sent, but saved in the internal buffer zone. To output the buffer content, you can use ob_end_flush () or flush () to output the buffer content., Ob_get_contents: returns the content of the internal buffer. Usage: string ob_get_contents (void) Description: This function returns the content in the current buffer. if the output buffer is not activated, FALSE is returned. 4. ob_get_length: return the length of the internal buffer. Usage: int ob_get_length (void) Description: This function returns the length of the current buffer. it is the same as ob_get_contents if the output buffer is not activated. Returns FALSE. 5. ob_end_flush: sends the content of the internal buffer to the browser and closes the output buffer. Usage: void ob_end_flush (void) Description: This function sends the content of the output buffer (if any ). 6. ob_end_clean: delete the content of the internal buffer and disable the use of the internal buffer. void ob_end_clean (void): This function will not delete the content of the internal buffer! 7. ob_implicit_flush: How to enable or disable absolute refresh: void ob_implicit_flush ([int flag]) description: Perl users all know the meaning of $ | = x, this string can enable/disable the buffer, while the ob_implicit_flush function is the same as that. by default, the buffer is disabled. after the absolute output is opened, the output of each script is directly sent to the browser without calling flush () */?>

The above section describes the init. PHP file details in ecshop, including the ecshop and init. PHP files, and hopes to help those who are interested in PHP tutorials.

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.