Ecshop init. php file Analysis

Source: Internet
Author: User

1. ecshop init. php file Analysis
2. <? Php
3.
4 ./**
5. * ECSHOP front-end public files
6 .*
========================================================== ==========================================
=
7. * copyright: 2005-2008 Shanghai shangpi Network Technology Co., Ltd., and all rights reserved.
8. * website address: [url] http://www.ecshop.com [/url];
9 .*----------------------------------------------------------------------------
10. * This is not a free software! You can only modify the program code and
11. * use; re-release of program code in any form and for any purpose is not allowed.
12 .*
========================================================== ==========================================
=
13. * $ Author: likai $
14. * $ Id: init. php 16132 08: 59: 15Z likai $
15 .*/
16.
17. // disable cross-origin File Import.
18. if (! Defined ('in _ ecs ')){
19. die ('hacking attempt'); // hacker attempted
20 .}
21.
22. // useless code, with later function coverage
23. error_reporting (E_ALL );
24.
25. // prevents cainiao from defining this variable from get post or a new constant.
26. if (_ FILE _ = ''){
27. die ('fatal error code: 0 ');
28 .}
29.
30./* obtaining the root directory of the current ecshop is more complex than discuz */
31. define ('root _ path', str_replace ('replace des/init. php ', '', str_replace (' \ ','/', _ FILE __)));
32.
33. // determine whether the install file in the data directory does not exist & include the installation lock file does not exist and is not defined
The NO_CHECK_INSTALL constant jumps to the installation page.
34. if (! File_exists (ROOT_PATH. 'data/install. lock ')&&! File_exists (ROOT_PATH. 'Primary des/install. lock ')
35 .&&! Defined ('no _ CHECK_INSTALL '))
36 .{
37. header ("Location:./install/index. phpn ");
38. exit;
39 .}
40.
41./* initialization settings */
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); // enable error reporting.
48.
49. // set the general import directory. wind is.; the new directory linux is.: What is the separation.
50. if (DIRECTORY_SEPARATOR = '\'){
51. @ ini_set ('include _ path', '.;'. ROOT_PATH );
52 .}
53. else
54 .{
55. @ ini_set ('include _ path', '.:'. ROOT_PATH );
56 .}
57. // introduce the configuration file. simple configuration.
58. require (ROOT_PATH. 'data/config. php ');
59.
60. // form a good habit. All constant definitions determine whether they have been defined.
61. if (defined ('debug _ mode') = false ){
62. define ('debug _ mode', 0); // defined as 0
63 .}
64.
65. // determine the version. if the version is earlier than 5.1, the table $ timezone is not empty. $ timezone comes from the config. php file.
66. if (PHP_VERSION> = '5. 1 '&&! Empty ($ timezone ))
67 .{
68. date_default_timezone_set ($ timezone); // set the common time zone.
69 .}
70.
71. // obtain the current file, excluding GET;
72. $ php_self = isset ($ _ SERVER ['php _ SELF '])? $ _ SERVER ['php _ SELF ']:
$ _ SERVER ['script _ name'];
73.
74. // if the user accesses a directory, the index. php login page will be automatically added.
75. if ('/' = substr ($ php_self,-1 )){
76. $ php_self. = 'index. php ';
77 .}
78. // then define the current page path as a constant, PHP_SELF; no domain name oriented.
79. define ('php _ SELF ', $ php_self );
80.
81. // The file is introduced. Analyze the file one by one later.
82. require (ROOT_PATH. 'des/inc_constant.php ');
83. require (ROOT_PATH. 'des/cls_ecshop.php ');
84. require (ROOT_PATH. 'des/cls_error.php ');
85. require (ROOT_PATH. 'regiondes/lib_time.php ');
86. require (ROOT_PATH. 'regiondes/lib_base.php ');
87. require (ROOT_PATH. 'regiondes/lib_common.php ');
88. require (ROOT_PATH. 'regiondes/lib_main.php ');
89. require (ROOT_PATH. 'regiondes/lib_insert.php ');
90. require (ROOT_PATH. 'regiondes/lib_goods.php ');
91. require (ROOT_PATH. 'regiondes/lib_article.php ');
92.
93./* escape user-passed variables. * /// General escape method. No discuz optimization.
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./* Create an ECSHOP object */
110. $ ecs = new ECS ($ db_name, $ prefix );
111.
112. // define the data directory and image directory.
113. define ('data _ dir', $ ecs-> data_dir ());
114. define ('image _ dir', $ ecs-> image_dir ());
115.
116./* initialize the database class */
117. require (ROOT_PATH. 'des/cls_mysql.php ');
118. $ db = new cls_mysql ($ db_host, $ db_user, $ db_pass, $ db_name );
119. // set a table that does not support caching, such as user actions and columns.
120. $ db-> set_disable_cache_tables (array ($ ecs-> table ('session'), $ ecs-> table ('sessions _ data '),
$ Ecs-> table ('cart ')));
121. $ db_host = $ db_user = $ db_pass = $ db_name = NULL;
122.
123./* Create an error handling object */
124. $ err = new ecs_error ('message. dwt ');
125.
126./* load system parameters */
127. $ _ CFG = load_config ();
128.
129./* load the language file */
130. require (ROOT_PATH. 'AGES/'. $ _ CFG ['lang']. '/common. php ');
131. if ($ _ CFG ['shop _ closed '] = 1)
132 .{
133./* the store is closed and the closed message is output */
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./* if it is a spider's access, the default visitor mode is used and is not recorded in the log */
142. if (! Defined ('init _ NO_USERS '))
143 .{
144. define ('init _ NO_USERS ', true );
145./* after UC integration, if it is a spider access, initialize the constant required by 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./* initialize session */
162. include (ROOT_PATH. 'des/cls_session.php ');
163.
164. $ sess = new cls_session ($ db, $ ecs-> table ('session'), $ 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./* Create a Smarty object. */
175. require (ROOT_PATH. 'regiondes/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. // determine whether to update.
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. // familiar smarty injection.
196. $ smarty-> assign ('lang ', $ _ lang );
197. $ smarty-> assign ('ecs _ charset', EC_CHARSET );
198. // set the CSS file.
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./* member information */
213. $ user = & init_users ();
214.
215. if (! Isset ($ _ SESSION ['user _ id'])
216 .{
217./* get the name of the advertising site */
218. $ site_name = isset ($ _ GET ['from'])? $ _ GET ['from']: addslashes ($ _ LANG ['self _ site']);
219. $ from_ad =! Empty ($ _ GET ['ad _ id'])? Intval ($ _ GET ['ad _ id']): 0;
220.
221. $ _ SESSION ['from _ ad'] = $ from_ad; // The ad ID clicked by the user
222. $ _ SESSION ['Referer'] = stripslashes ($ site_name); // user Source
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./* If the member has logged on and has not yet obtained the member's account balance, points, and coupons */
237. if ($ _ SESSION ['user _ id']> 0)
238 .{
239. update_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./* Set recommendation members */
257. if (isset ($ _ GET ['U'])
258 .{
259. set_affiliate ();
260 .}
261. if (isset ($ smarty ))
262 .{
263. $ smarty-> assign ('ecs _ session ', $ _ SESSION );
264 .}
265 .}
266. // modify the error severity.
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. 'des/lib. debug. php ');
278 .}
279.
280./* determine whether Gzip mode is supported */
281. if (! Defined ('init _ NO_SMARTY ') & gzip_enabled ())
282 .{
283. ob_start ('ob _ gzhandler ');
284 .}
285. else
286 .{
287. ob_start ();
288 .}
289.
290.?>

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.