第一步先打开index.php,可以看到引入了3个文件:config/config.inc.php,header.php,footer.php。
最重要的就是config/config.inc.php了,打开看看。
@
ini_set
(
'display_errors'
,
'off'
)
;
@
ini_set
(
'default_charset'
,
'utf-8'
)
;
//这些部分修改了php.ini里的一些默认设置
header
(
'Content-Type: text/html; charset=utf-8'
)
;
//强调是utf8的编码
function __autoload
(
$className
)
{
if
(
!
class_exists
(
$className
,
false
)
)
require_once
(
dirname
(
__FILE__
)
.
'/../classes/'
.
$className
.
'.php'
)
;
}
//很神奇的自动载入函数,不知道的童鞋看看手册,其实很简单
if
(
!
file_exists
(
dirname
(
__FILE__
)
.
'/settings.inc.php'
)
)
{
$dir
=
(
(
is_dir
(
$_SERVER
[
'REQUEST_URI'
]
) OR
substr
(
$_SERVER
[
'REQUEST_URI'
]
,
-
1
)
==
'/'
) ?
$_SERVER
[
'REQUEST_URI'
]
:
dirname
(
$_SERVER
[
'REQUEST_URI'
]
)
.
'/'
)
;
if
(
!
file_exists
(
dirname
(
__FILE__
)
.
'/../install'
)
)
die
(
'Error: \'install\' directory is missing'
)
;Tools
::
redirect
(
'install'
,
$dir
)
;
}
include
(
dirname
(
__FILE__
)
.
'/settings.inc.php'
)
;
//如果没有settings.inc.php,就开始安装进程
if
(
!
isset
(
$_SERVER
[
'REQUEST_URI'
]
) OR
empty
(
$_SERVER
[
'REQUEST_URI'
]
)
)
{
$_SERVER
[
'REQUEST_URI'
]
=
$_SERVER
[
'SCRIPT_NAME'
]
;
if
(
isset
(
$_SERVER
[
'QUERY_STRING'
]
) AND
!
empty
(
$_SERVER
[
'QUERY_STRING'
]
)
)
$_SERVER
[
'REQUEST_URI'
]
.=
'?'
.
$_SERVER
[
'QUERY_STRING'
]
;
}
//有些web服务器会没有这个REQUEST_URI,所以要处理一下
$currentDir
=
dirname
(
__FILE__
)
;
//这个目录,是config目录,因为__FILE__是当前文件
这下面就是定义常量的了。有些童鞋要问了,为什么不定义成变量呢?一是这些内容不需要改动,二是在smarty中,可以使用$smarty.const.xxx来直接调用常量。
Configuration
::
loadConfiguration
(
)
;
//prestashop把所有的配置都存在一个表里面
Language
::
loadLanguages
(
)
;
//载入语言Tax
::
loadTaxZones
(
)
;
//税,国内就很少有这样的设置
$defaultCountry
=
new Country
(
intval
(Configuration
::
get
(
'PS_COUNTRY_DEFAULT'
)
)
)
;
//读取地区id,设置
$timezone
= Tools
::
getTimezones
(Configuration
::
get
(
'PS_TIMEZONE'
)
)
;
//设定时区
if
(
function_exists
(
'date_default_timezone_set'
)
)
date_default_timezone_set
(
$timezone
)
;
//如果是php5,有date_default_timezone_set函数,则设定时区