Ecshopinit. php file analysis. 1. ecshopinit. php file analysis 2 .? Php3.4. ** 5. * ECSHOP front-end public file 6.*7. * All rights reserved. 1. ecshop init. php file analysis
2. 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 ('
'. $ _ LANG ['shop _ closed'].
'
'. $ _ CFG ['close _ comment'].'
');
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.?>
Analysis of http://www.bkjia.com/PHPjc/440381.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/440381.htmlTechArticle1. ecshop init. php file 2 .? Php 3. 4. /** 5. * ECSHOP foreground public files 6. * ===================================================== =======================================================7. * All rights reserved...