zencart全解析(一)

Index.php

1. Load application_top.php - see {@tutorial initsystem}

2. Set main language directory based on $_SESSION['language']

3. Load all *header_php.php files from includes/modules/pages/PAGE_NAME/

4. Load html_header.php (this is a common template file)

5. Load main_template_vars.php (this is a common template file)

6. Load on_load scripts (page based and site wide)

7. Load tpl_main_page.php (this is a common template file)

8. Load application_bottom.php

 

require('includes/application_top.php');   //Load common library stuff

 

application_top.php

1. application_top.php Common actions carried out at the start of each page invocation.

2. Initializes common classes & methods. Controlled by an array which describes

3. the elements to be initialised and the order in which that happens.

 

First

inoculate against hack attempts which waste CPU cycles,预防黑客试图浪费cpu周期.

 

Note:

if (isset($_REQUEST['GLOBALS']) OR isset($_FILES['GLOBALS'])) {
     exit('Request tainting attempted.');
}

因为如果register_globals打开的话, 客户端提交的数据中含有GLOBALS变量名, 就会覆盖服务器上的$GLOBALS变量. 所以这段代码, 就是判断, 如果提交的数据中有GLOBALS变量名, 就终止程序.

 

unset()是用来销毁变量的

 

ini_set

Sets the value of the given configuration option. The configuration option will keep this new value during the script's execution, and will be restored at the script's ending.

1.ini_set函数是设置选项中的值,在执行函数后生效,脚本结束的时候,这个设置也失效。ini_set 用于更改配置文件的配制,次更改仅用于此脚本的执行。不是所有的选项都能被改函数设置的。

2.ini_getini_set的姐妹函数,

ini_set是改变php.ini里的设置,ini_get是获取php.ini里的环境变量的值.

 

@ini_set("arg_separator.output","&");

PHP 所产生的 URL 中来分隔参数的分隔符。

 

include('includes/local/configure.php');   // Set the local configuration parameters - mainly for developers  (文件不存在)

define('DEBUG_AUTOLOAD', false);// boolean if true the autoloader scripts will be parsed and their output shown. For debugging purposes only.

 

error_reporting(0)

就是系统或应用程序出错时弹出的 错误报告,编程人员根据这个报告的内容可以判断是哪一段程序代码出问题了。

 

turn off magic-quotes support, for both runtime and sybase, as both will cause problems if enabled

function_exists('set_magic_quotes_runtime')  

set_magic_quotes_runtime(0);

 

if (@ini_get('magic_quotes_sybase') != 0) @ini_set('magic_quotes_sybase', 0);

 

if    file_exists('includes/configure.php')

include('includes/configure.php');

 

NOTE: This file is similar, but DIFFERENT from the "admin" version of configure.php.

The 2 files should be kept separate and not used to overwrite each other.  

Define the webserver and path parameters

DIR_WS_* = Webserver directories (virtual/URL)

 

// * DIR_FS_* = Filesystem directories (local/physical)

the following path is a COMPLETE path to your Zen Cart files. eg: /var/www/vhost/accountname/public_html/store/

 

define our database connection

 

for STORE_SESSIONS, use 'db' for best support, or '' for file-based storage

// The next 2 "defines" are for SQL cache support.

  // For SQL_CACHE_METHOD, you can select from:  none, database, or file

  // If you choose "file", then you need to set the DIR_FS_SQL_CACHE to a directory where your apache

  // or webserver user has write privileges (chmod 666 or 777). We recommend using the "cache" folder inside the Zen Cart folder

 

Else  configure.php  not found

 

includes/templates/template_default/templates/tpl_zc_install_suggested_default.php

This page is auto-displayed if the configure.php file cannot be read properly. It is intended simply to recommend clicking on the zc_install link to begin installation.

 

Click here  zc_install/index.php  进入安装程序

 

Ensure that the include_path can handle relative paths, before we try to load any files

strstr() 函数搜索一个字符串在另一个字符串中的第一次出现。

该函数返回字符串的其余部分(从匹配点)。如果未找到所搜索的字符串,则返回 false

 

PHP中的预定义常量


再补充几个内置的常量,

(1) DIRECTORY_SEPARATOR :路径分隔符,linux上就是’/ ’    windows上是’/ ’

(2) PATH_SEPARATOR include 多个路径使用,在win下,当你要include多个路径的话,你要用”; ” 隔开,但在linux下就使用”: ”隔开的。

2个常量的使用能够避免不同平台的兼容性问题。  

PHP配置函数ini_get()相信很多人都使过,就是获取配置文件中某一个选项的值,如果是true值就返回1,如果是false值就返回0,字符串就返回字符串。

比如手册中的例子:

<?php

/* Our php.ini contains the following settings: display_errors = On register_globals = Off post_max_size = 8M */

 

echo 'display_errors = ' . ini_get('display_errors') . " "; //显示错误是否打开

echo 'register_globals = ' . ini_get('register_globals') . " "; //全局变量是否打开

echo 'post_max_size = ' . ini_get('post_max_size') . " "; //最多能提交的文件大小

echo 'post_max_size+1 = ' . (ini_get('post_max_size')+1) . " ";

 

?>

 

require('includes/application_top.php');    zc_install/includes/application_top.php

 

Set the installer configuration parameters

include('includes/installer_params.php');

 

is_writable() 函数判断指定的文件是否可写。

$session_save_path   d:/wamp/tmp

 

set the level of error reporting 

error_reporting

Timezone detection

ini_get('date.timezone')

check settings for, and then turn off magic-quotes support, for both runtime and sybase, as both will cause problems if enabled

boolean used to see if we are in the admin script, obviously set to false here.

if (!defined('IS_ADMIN_FLAG')) define('IS_ADMIN_FLAG', false);

define the project version

require('version.php');

set php_self in the local scope

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值