ecshop init.php文件解析
添加时间:2013-7-22 点击量:
1.  ecshop init.php文件解析 
2.  <?php  
3.   
4.  /  
5.   ECSHOP 前台公用文件  
6.   
===========================================================================
=  
7.   版权所有  2005-2008 上海商派收集科技有限公司,并保存所有权力。  
8.   网站地址: [url]http://www.ecshop.com[/url];  
9.   ----------------------------------------------------------------------------  
10.   这不是一个软件!您只能在不消于贸易目标的前提下对法度代码进行批改和  
11.   应用;不容许对法度代码以任何情势任何目标的再公布。  
12.   
===========================================================================
=  
13.   ¥Author: likai ¥  
14.   ¥Id: init.php 16132 2009-05-31 08:59:15Z likai ¥  
15.  /  
16.   
17.  // 禁止跨域引入文件.  
18.  if (!defined(IN_ECS)){  
19.  die(Hacking attempt); //  黑客妄图  
20.  }  
21.   
22.  // 无用代码,后期功能复盖  
23.  error_reporting(E_ALL);  
24.   
25.  // 防止菜鸟将此变量从GET POST 或者新常量定义.  
26.  if (__FILE__ == ){  
27.  die(Fatal error code: 0);  
28.  }  
29.   
30.  / 取合适前ecshop地点的根目次  比discuz的错杂  /  
31.  define(ROOT_PATH, str_replace(includes/init.php, , str_replace(\, /, __FILE__)));  
32.   
33.  // 断定data目次中的install文件不存在  && include中的安装锁文件不存在 并且没有定义 
NO_CHECK_INSTALL常量,  就跳转到安装页.  
34.  if (!file_exists(ROOT_PATH . data/install.lock) && !file_exists(ROOT_PATH . includes/install.lock)  
35.  && !defined(NO_CHECK_INSTALL))  
36.  {  
37.  header(Location: ./install/index.phpn);  
38.  exit;  
39.  }  
40.   
41.  / 初始化设置  /  
42.  @ini_set(memory_limit, 64M);  
43.  @ini_set(session.cache_expire, 180);  
44.  @ini_set(session.use_trans_sid, 0);  
45.  @ini_set(session.use_cookies, 1);  
46.  @ini_set(session.auto_start, 0);  
47.  @ini_set(display_errors, 1); //  开启报错.  
48.   
49.  //设置通用的引入目次. wind 是  .;  新的目次  linux是  .:  就是以什么为分隔.  
50.  if (DIRECTORY_SEPARATOR == \){  
51.  @ini_set(include_path, .; . ROOT_PATH);  
52.  }  
53.  else  
54.  {  
55.  @ini_set(include_path, .: . ROOT_PATH);  
56.  }  
57.  // 引入设备文件.简单的设备.  
58.  require(ROOT_PATH . data/config.php);  
59.   
60.  // 养成杰出的习惯,  凡是常量定义,都断定一下是否已经定义过.  
61.  if (defined(DEBUG_MODE) == false){  
62.  define(DEBUG_MODE, 0); //  定义为0  
63.  }  
64.   
65.  //版本断定,  若是版本低于5.1 并表¥timezone不为空. ¥timezone来自  config.php文件  
66.  if (PHP_VERSION >= 5.1 && !empty(¥timezone))  
67.  {  
68.  date_default_timezone_set(¥timezone); //  设置通用时区.  
69.  }  
70.   
71.  //获合适前文件,不包含GET;  
72.  ¥php_self = isset(¥_SERVER[PHP_SELF]) ? ¥_SERVER[PHP_SELF] : 
¥_SERVER[SCRIPT_NAME];  
73.   
74.  // 假如用户接见的是目次,  就主动添加index.php默认页.  
75.  if (/ == substr(¥php_self, -1)){  
76.  ¥php_self .= index.php;  
77.  }  
78.  // 然后将当前页路径定义为常量,PHP_SELF;  没有域名导向的.  
79.  define(PHP_SELF, ¥php_self);  
80.   
81.  // 开端引入文件了.日后再一个一个解析.  
82.  require(ROOT_PATH . includes/inc_constant.php);  
83.  require(ROOT_PATH . includes/cls_ecshop.php);  
84.  require(ROOT_PATH . includes/cls_error.php);  
85.  require(ROOT_PATH . includes/lib_time.php);  
86.  require(ROOT_PATH . includes/lib_base.php);  
87.  require(ROOT_PATH . includes/lib_common.php);  
88.  require(ROOT_PATH . includes/lib_main.php);  
89.  require(ROOT_PATH . includes/lib_.php);  
90.  require(ROOT_PATH . includes/lib_goods.php);  
91.  require(ROOT_PATH . includes/lib_article.php);  
92.   
93.  / 对用户传入的变量进行转义操纵。/ //通用转义办法.  没discuz优化.  
94.  if (!get_magic_quotes_gpc())  
95.  {  
96.  if (!empty(¥_GET))  
97.  {  
98.  ¥_GET = addslashes_deep(¥_GET);  
99.  }  
100.  if (!empty(¥_POST))  
101.  {  
102.  ¥_POST = addslashes_deep(¥_POST);  
103.  }  
104.   
105.  ¥_COOKIE = addslashes_deep(¥_COOKIE);  
106.  ¥_REQUEST = addslashes_deep(¥_REQUEST);  
107.  }  
108.   
109.  / 创建  ECSHOP 对象  /  
110.  ¥ecs = new ECS(¥db_name, ¥prefix);  
111.   
112.  //定义数据目次及目次.  
113.  define(DATA_DIR, ¥ecs->data_dir());  
114.  define(IMAGE_DIR, ¥ecs->image_dir());  
115.   
116.  / 初始化数据库类  /  
117.  require(ROOT_PATH . includes/cls_mysql.php);  
118.  ¥db = new cls_mysql(¥db_host, ¥db_user, ¥db_pass, ¥db_name);  
119.  // 设置不充许缓存的表,  比如用户动作,栏目.  
120.  ¥db->set_disable_cache_tables(array(¥ecs->table(sessions), ¥ecs->table(sessions_data), 
¥ecs->table(cart)));  
121.  ¥db_host = ¥db_user = ¥db_pass = ¥db_name = NULL;  
122.   
123.  / 创建错误处理惩罚对象  /  
124.  ¥err = new ecs_error(message.dwt);  
125.   
126.  / 载入体系参数  /  
127.  ¥_CFG = load_config();  
128.   
129.  / 载入说话文件  /  
130.  require(ROOT_PATH . languages/ . ¥_CFG[lang] . /common.php);  
131.  if (¥_CFG[shop_closed] == 1)  
132.  {  
133.  / 市廛封闭了,输出封闭的消息  /  
134.  header(Content-type: text/html; charset=.EC_CHARSET);  
135.   
136.  die(<div style=margin: 150px; text-align: center; font-size: 14px><p> . ¥_LANG[shop_closed] . 
</p><p> . ¥_CFG[close_comment] . </p></div>);  
137.  }  
138.   
139.  if (is_spider())  
140.  {  
141.  / 若是是蜘蛛的接见,那么默认为访客体式格式,并且不记录到日记中  /  
142.  if (!defined(INIT_NO_USERS))  
143.  {  
144.  define(INIT_NO_USERS, true);  
145.  / 整合UC后,若是是蜘蛛接见,初始化UC须要的常量  /  
146.  if(¥_CFG[integrate_code] == ucenter)  
147.  {  
148.  ¥user = & init_users();  
149.  }  
150.  }  
151.  ¥_SESSION = array();  
152.  ¥_SESSION[user_id] = 0;  
153.  ¥_SESSION[user_name] = ;  
154.  ¥_SESSION[email] = ;  
155.  ¥_SESSION[user_rank] = 0;  
156.  ¥_SESSION[discount] = 1.00;  
157.  }  
158.   
159.  if (!defined(INIT_NO_USERS))  
160.  {  
161.  / 初始化session /  
162.  include(ROOT_PATH . includes/cls_session.php);  
163.   
164.  ¥sess = new cls_session(¥db, ¥ecs->table(sessions), ¥ecs->table(sessions_data));  
165.   
166.  define(SESS_ID, ¥sess->get_session_id());  
167.  }  
168.   
169.  if (!defined(INIT_NO_SMARTY))  
170.  {  
171.  header(Cache-control: private);  
172.  header(Content-type: text/html; charset=.EC_CHARSET);  
173.   
174.  / 创建  Smarty 对象。/  
175.  require(ROOT_PATH . includes/cls_template.php);  
176.  ¥smarty = new cls_template;  
177.   
178.  ¥smarty->cache_lifetime = ¥_CFG[cache_time];  
179.  ¥smarty->template_dir = ROOT_PATH . themes/ . ¥_CFG[template];  
180.  ¥smarty->cache_dir = ROOT_PATH . temp/caches;  
181.  ¥smarty->compile_dir = ROOT_PATH . temp/compiled;  
182.   
183.  // 断定一下是否进行更新.  
184.  if ((DEBUG_MODE & 2) == 2)  
185.  {  
186.  ¥smarty->direct_output = true;  
187.  ¥smarty->force_compile = true;  
188.  }  
189.  else  
190.  {  
191.  ¥smarty->direct_output = false;  
192.  ¥smarty->force_compile = false;  
193.  }  
194.   
195.  // 熟悉的smarty的注入.  
196.  ¥smarty->assign(lang, ¥_LANG);  
197.  ¥smarty->assign(ecs_charset, EC_CHARSET);  
198.  // 设置CSS文件.  
199.  if (!empty(¥_CFG[stylename]))  
200.  {  
201.  ¥smarty->assign(ecs_css_path, themes/ . ¥_CFG[template] . /style_ . ¥_CFG[stylename] . .css);  
202.  }  
203.  else  
204.  {  
205.  ¥smarty->assign(ecs_css_path, themes/ . ¥_CFG[template] . /style.css);  
206.  }  
207.   
208.  }  
209.   
210.  if (!defined(INIT_NO_USERS))  
211.  {  
212.  / 会员信息  /  
213.  ¥user =& init_users();  
214.   
215.  if (!isset(¥_SESSION[user_id]))  
216.  {  
217.  / 获取投放站点的名称  /  
218.  ¥site_name = isset(¥_GET[]) ? ¥_GET[] : addslashes(¥_LANG[self_site]);  
219.  ¥_ad = !empty(¥_GET[ad_id]) ? intval(¥_GET[ad_id]) : 0;  
220.   
221.  ¥_SESSION[_ad] = ¥_ad; //  用户点击的告白ID  
222.  ¥_SESSION[referer] = stripslashes(¥site_name); //  用户起原  
223.   
224.  unset(¥site_name);  
225.   
226.  if (!defined(INGORE_VISIT_STATS))  
227.  {  
228.  visit_stats();  
229.  }  
230.  }  
231.   
232.  if (empty(¥_SESSION[user_id]))  
233.  {  
234.  if (¥user->get_cookie())  
235.  {  
236.  / 若是会员已经登录并且还没有获得会员的帐户余额、积分以及优惠券  /  
237.  if (¥_SESSION[user_id] > 0)  
238.  {  
239.  _user_info();  
240.  }  
241.  }  
242.  else  
243.  {  
244.  ¥_SESSION[user_id] = 0;  
245.  ¥_SESSION[user_name] = ;  
246.  ¥_SESSION[email] = ;  
247.  ¥_SESSION[user_rank] = 0;  
248.  ¥_SESSION[discount] = 1.00;  
249.  if (!isset(¥_SESSION[login_fail]))  
250.  {  
251.  ¥_SESSION[login_fail] = 0;  
252.  }  
253.  }  
254.  }  
255.   
256.  / 设置推荐会员  /  
257.  if (isset(¥_GET[u]))  
258.  {  
259.  set_affiliate();  
260.  }  
261.  if (isset(¥smarty))  
262.  {  
263.  ¥smarty->assign(ecs_session, ¥_SESSION);  
264.  }  
265.  }  
266.  // 批改报错级别.  
267.  if ((DEBUG_MODE & 1) == 1)  
268.  {  
269.  error_reporting(E_ALL);  
270.  }  
271.  else  
272.  {  
273.  error_reporting(E_ALL ^ E_NOTICE);  
274.  }  
275.  if ((DEBUG_MODE & 4) == 4)  
276.  {  
277.  include(ROOT_PATH . includes/lib.debug.php);  
278.  }  
279.   
280.  / 断定是否支撑  Gzip 模式  /  
281.  if (!defined(INIT_NO_SMARTY) && gzip_enabled())  
282.  {  
283.  ob_start(ob_gzhandler);  
284.  }  
285.  else  
286.  {  
287.  ob_start();  
288.  }  
289.   
290.  ?> 
 管家婆官方网店
管家婆官方网店 管家婆官方微博
管家婆官方微博 管家婆官方微信
管家婆官方微信


