commit | author | age
|
19351a
|
1 |
<?php |
B |
2 |
|
|
3 |
/** |
|
4 |
API 公用初始化文件 |
|
5 |
* ============================================================================ |
|
6 |
* |
|
7 |
|
|
8 |
* ---------------------------------------------------------------------------- |
|
9 |
|
|
10 |
* ============================================================================ |
|
11 |
|
|
12 |
* $Id: init.php 17217 2011-01-19 06:29:08Z $ |
|
13 |
*/ |
|
14 |
|
|
15 |
if (!defined('IN_ECS')) |
|
16 |
{ |
|
17 |
die('Hacking attempt'); |
|
18 |
} |
|
19 |
|
|
20 |
error_reporting(E_ALL); |
|
21 |
|
|
22 |
if (__FILE__ == '') |
|
23 |
{ |
|
24 |
die('Fatal error code: 0'); |
|
25 |
} |
|
26 |
|
|
27 |
/* 取得当前所在的根目录 */ |
|
28 |
define('ROOT_PATH', str_replace('api', '', str_replace('\\', '/', dirname(__FILE__)))); |
|
29 |
|
|
30 |
/* 初始化设置 */ |
|
31 |
@ini_set('memory_limit', '16M'); |
|
32 |
@ini_set('session.cache_expire', 180); |
|
33 |
@ini_set('session.use_trans_sid', 0); |
|
34 |
@ini_set('session.use_cookies', 1); |
|
35 |
@ini_set('session.auto_start', 0); |
|
36 |
@ini_set('display_errors', 1); |
|
37 |
|
|
38 |
if (DIRECTORY_SEPARATOR == '\\') |
|
39 |
{ |
|
40 |
@ini_set('include_path', '.;' . ROOT_PATH); |
|
41 |
} |
|
42 |
else |
|
43 |
{ |
|
44 |
@ini_set('include_path', '.:' . ROOT_PATH); |
|
45 |
} |
|
46 |
|
|
47 |
if (file_exists(ROOT_PATH . 'data/config.php')) |
|
48 |
{ |
|
49 |
include(ROOT_PATH . 'data/config.php'); |
|
50 |
} |
|
51 |
else |
|
52 |
{ |
|
53 |
include(ROOT_PATH . 'includes/config.php'); |
|
54 |
} |
|
55 |
|
|
56 |
if (defined('DEBUG_MODE') == false) |
|
57 |
{ |
|
58 |
define('DEBUG_MODE', 0); |
|
59 |
} |
|
60 |
|
|
61 |
if (PHP_VERSION >= '5.1' && !empty($timezone)) |
|
62 |
{ |
|
63 |
date_default_timezone_set($timezone); |
|
64 |
} |
|
65 |
|
|
66 |
$php_self = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']; |
|
67 |
if ('/' == substr($php_self, -1)) |
|
68 |
{ |
|
69 |
$php_self .= 'index.php'; |
|
70 |
} |
|
71 |
define('PHP_SELF', $php_self); |
|
72 |
|
|
73 |
require(ROOT_PATH . 'includes/inc_constant.php'); |
|
74 |
require(ROOT_PATH . 'includes/cls_ecshop.php'); |
|
75 |
require(ROOT_PATH . 'includes/lib_base.php'); |
|
76 |
require(ROOT_PATH . 'includes/lib_common.php'); |
|
77 |
require(ROOT_PATH . 'includes/lib_time.php'); |
|
78 |
|
|
79 |
/* 对用户传入的变量进行转义操作。*/ |
|
80 |
if (!get_magic_quotes_gpc()) |
|
81 |
{ |
|
82 |
if (!empty($_GET)) |
|
83 |
{ |
|
84 |
$_GET = addslashes_deep($_GET); |
|
85 |
} |
|
86 |
if (!empty($_POST)) |
|
87 |
{ |
|
88 |
$_POST = addslashes_deep($_POST); |
|
89 |
} |
|
90 |
|
|
91 |
$_COOKIE = addslashes_deep($_COOKIE); |
|
92 |
$_REQUEST = addslashes_deep($_REQUEST); |
|
93 |
} |
|
94 |
|
|
95 |
/* 创建 对象 */ |
|
96 |
$ecs = new ECS($db_name, $prefix); |
|
97 |
$data_dir = $ecs->data_dir(); |
|
98 |
|
|
99 |
/* 初始化数据库类 */ |
|
100 |
require(ROOT_PATH . 'includes/cls_mysql.php'); |
|
101 |
$db = new cls_mysql($db_host, $db_user, $db_pass, $db_name); |
|
102 |
$db_host = $db_user = $db_pass = $db_name = NULL; |
|
103 |
|
|
104 |
/* 初始化session */ |
|
105 |
require(ROOT_PATH . 'includes/cls_session.php'); |
|
106 |
$sess_name = defined("SESS_NAME") ? SESS_NAME : 'ECS_ID'; |
|
107 |
$sess = new cls_session($db, $ecs->table('sessions'), $ecs->table('sessions_data'), $sess_name); |
|
108 |
|
|
109 |
/* 载入系统参数 */ |
|
110 |
$_CFG = load_config(); |
|
111 |
|
|
112 |
/* 初始化用户插件 */ |
|
113 |
$user =& init_users(); |
|
114 |
|
|
115 |
if ((DEBUG_MODE & 1) == 1) |
|
116 |
{ |
|
117 |
error_reporting(E_ALL); |
|
118 |
} |
|
119 |
else |
|
120 |
{ |
|
121 |
error_reporting(E_ALL ^ E_NOTICE); |
|
122 |
} |
|
123 |
if ((DEBUG_MODE & 4) == 4) |
|
124 |
{ |
|
125 |
include(ROOT_PATH . 'includes/lib.debug.php'); |
|
126 |
} |
|
127 |
|
|
128 |
/* 判断是否支持 Gzip 模式 */ |
|
129 |
if (gzip_enabled()) |
|
130 |
{ |
|
131 |
ob_start('ob_gzhandler'); |
|
132 |
} |
|
133 |
|
|
134 |
header('Content-type: text/html; charset=' . EC_CHARSET); |
|
135 |
|
|
136 |
?> |