-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
370 lines (339 loc) · 13.5 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
<?php
/**
* CodeIgniter
*
* An open source application development framework for PHP
*
* This content is released under the MIT License (MIT)
*
* Copyright (c) 2014 - 2015, British Columbia Institute of Technology
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @package CodeIgniter
* @author EllisLab Dev Team
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
* @copyright Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/)
* @license http://opensource.org/licenses/MIT MIT License
* @link http://codeigniter.com
* @since Version 1.0.0
* @filesource
*/
/*
*---------------------------------------------------------------
* APPLICATION ENVIRONMENT
* 应用程序运行环境
*---------------------------------------------------------------
*
* You can load different configurations depending on your
* current environment. Setting the environment also influences
* things like logging and error reporting.
* 根据当前运行环境,可以加载不同的配置文件。更改运行环境同样会影响
* 日志和错误报告
*
* This can be set to anything, but default usage is:
* 环境可以设置为任意值,默认用法是:
* 开发环境
* 测试环境
* 生产环境
*
* development
* testing
* production
*
* NOTE: If you change these, also change the error_reporting() code below
* 注意,假如你更改这里,同样会改变下面的错误报告代码
*/
/**
* 如果设置了CI_ENV全局变量 则以CI_ENV的值为当前环境,
* 否则指定为开发环境
*/
define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');
/*
*---------------------------------------------------------------
* ERROR REPORTING
* 错误报告级别
*---------------------------------------------------------------
*
* Different environments will require different levels of error reporting.
* By default development will show errors but testing and live will hide them.
* 不同的环境需要不同的错误报告级别。开发环境会显示错误,但测试环境和生产环境会
* 隐藏错误
*/
switch (ENVIRONMENT)
{
case 'development':
error_reporting(-1);
ini_set('display_errors', 1);
break;
case 'testing':
case 'production':
ini_set('display_errors', 0);
if (version_compare(PHP_VERSION, '5.3', '>='))
{
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
}
else
{
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
}
break;
default:
header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
echo 'The application environment is not set correctly.';
exit(1); // EXIT_ERROR
}
/*
*---------------------------------------------------------------
* SYSTEM FOLDER NAME
* 系统文件夹名称
*---------------------------------------------------------------
*
* This variable must contain the name of your "system" folder.
* Include the path if the folder is not in the same directory
* as this file.
* 本变量必须包含你项目的系统文件夹名称。假如系统文件夹与本脚本
* 文件不在同一文件夹内,则要设为系统文件夹的路径。
*/
$system_path = 'system';
/*
*---------------------------------------------------------------
* APPLICATION FOLDER NAME
* 应用文件夹名称
*---------------------------------------------------------------
*
* If you want this front controller to use a different "application"
* folder than the default one you can set its name here. The folder
* can also be renamed or relocated anywhere on your server. If
* you do, use a full server path. For more info please see the user guide:
* http://codeigniter.com/user_guide/general/managing_apps.html
* 你可以将你的应用程序目录移动到除 Web 根目录之外的其他位置, 移到之后你
* 需要打开 index.php 文件将 $application_folder 变量改成新的位置
* (使用**绝对路径**):
*
* NO TRAILING SLASH!
* 注意:不能有右侧尾部文件夹分隔符
*/
$application_folder = 'application';
/*
*---------------------------------------------------------------
* VIEW FOLDER NAME
* 视图文件夹名称
*---------------------------------------------------------------
*
* If you want to move the view folder out of the application
* folder set the path to the folder here. The folder can be renamed
* and relocated anywhere on your server. If blank, it will default
* to the standard location inside your application folder. If you
* do move this, use the full server path to this folder.
* 假如你想将视图文件移动到其他地方,则需要重命名此变量。假如此变量为空
* 则使用默认位置,即应用文件夹下的views文件夹。假如你移动了,则应将此变量
* 指定为绝对路径。
*
* NO TRAILING SLASH!
* 注意:不能有右侧尾部文件夹分隔符
*/
$view_folder = '';
/*
* --------------------------------------------------------------------
* DEFAULT CONTROLLER
* 默认控制器
* --------------------------------------------------------------------
*
* Normally you will set your default controller in the routes.php file.
* You can, however, force a custom routing by hard-coding a
* specific controller class/function here. For most applications, you
* WILL NOT set your routing here, but it's an option for those
* special instances where you might want to override the standard
* routing in a specific front controller that shares a common CI installation.
* 通常情况下,应该在配置文件routes.php中设置默认控制器。你可以在此以class/function
* 的形式强制指定一个用户路由。
*
* IMPORTANT: If you set the routing here, NO OTHER controller will be
* callable. In essence, this preference limits your application to ONE
* specific controller. Leave the function name blank if you need
* to call functions dynamically via the URI.
* 注意:假如你在此指定了默认路由,则其他控制器将不会被调用。本质来说,
* 这个变量限制了你的应用只能使用一个指定的控制器,假如你想动态指定控制器
* 的方法你可以将方法段留空。
*
* Un-comment the $routing array below to use this feature
* 取消下面代码的注释可以获得此功能。
*/
// The directory name, relative to the "controllers" folder. Leave blank
// if your controller is not in a sub-folder within the "controllers" folder
// 相对于控制器文件夹的文件夹名称,假如不像指定子文件夹,则可以将本变量留空。
// $routing['directory'] = '';
// The controller class file name. Example: mycontroller
// 默认使用的控制器类文件名
// $routing['controller'] = '';
// The controller function you wish to be called.
// 默认要调用的控制器方法名。
// $routing['function'] = '';
/*
* -------------------------------------------------------------------
* CUSTOM CONFIG VALUES
* 用户设置项
* -------------------------------------------------------------------
*
* The $assign_to_config array below will be passed dynamically to the
* config class when initialized. This allows you to set custom config
* items or override any default config values found in the config.php file.
* This can be handy as it permits you to share one application between
* multiple front controller files, with each file containing different
* config values.
* 在初始化时,下面的$assign_to_config数组会动态地向配置类传递设置。因此
* 你可以在这里指定覆盖config.php文件的配置项。
*
* Un-comment the $assign_to_config array below to use this feature
* 取消注释即可使用本功能。
*/
// $assign_to_config['name_of_config_item'] = 'value of config item';
// --------------------------------------------------------------------
// END OF USER CONFIGURABLE SETTINGS. DO NOT EDIT BELOW THIS LINE
// 不要更改下面这一行
// --------------------------------------------------------------------
/*
* ---------------------------------------------------------------
* Resolve the system path for increased reliability
* 增加获取系统文件夹的可靠性
* ---------------------------------------------------------------
*/
// Set the current directory correctly for CLI requests
// 将命令行模式设置为当前文件夹
if (defined('STDIN'))
{
chdir(dirname(__FILE__));
}
// 为系统文件夹加上右侧文件夹分隔符
if (($_temp = realpath($system_path)) !== FALSE)
{
$system_path = $_temp.'/';
}
else
{
// Ensure there's a trailing slash
// 确保系统文件夹有一个右侧文件夹分隔符
$system_path = rtrim($system_path, '/').'/';
}
// Is the system path correct?
// 看看文件夹是否是合法的
if ( ! is_dir($system_path))
{
header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
echo 'Your system folder path does not appear to be set correctly. Please open the following file and correct this: '.pathinfo(__FILE__, PATHINFO_BASENAME);
exit(3); // EXIT_CONFIG
}
/*
* -------------------------------------------------------------------
* Now that we know the path, set the main path constants
* 既然我们知道了一些主要的文件夹了,现在开始设置主要文件夹的常量
* -------------------------------------------------------------------
*/
// The name of THIS file
// 获取当前文件名
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
// Path to the system folder
// 设置系统文件夹常量
define('BASEPATH', str_replace('\\', '/', $system_path));
// Path to the front controller (this file)
// 设置前台控制器路径(就是本文件所在路径。)
define('FCPATH', dirname(__FILE__).'/');
// Name of the "system folder"
// 返回BASEPATH的文件夹名称(确实不能用dirname啊)
define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/'));
// The path to the "application" folder
// 算出应用文件夹的绝对路径
if (is_dir($application_folder))
{
if (($_temp = realpath($application_folder)) !== FALSE)
{
$application_folder = $_temp;
}
define('APPPATH', $application_folder.DIRECTORY_SEPARATOR);
}
else
{
if ( ! is_dir(BASEPATH.$application_folder.DIRECTORY_SEPARATOR))
{
header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
echo 'Your application folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF;
exit(3); // EXIT_CONFIG
}
define('APPPATH', BASEPATH.$application_folder.DIRECTORY_SEPARATOR);
}
// The path to the "views" folder
// is_dir('');结果为false
if ( ! is_dir($view_folder))
{
if ( ! empty($view_folder) && is_dir(APPPATH.$view_folder.DIRECTORY_SEPARATOR))
{
$view_folder = APPPATH.$view_folder;
}
elseif ( ! is_dir(APPPATH.'views'.DIRECTORY_SEPARATOR))
{
header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
echo 'Your view folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF;
exit(3); // EXIT_CONFIG
}
else
{
$view_folder = APPPATH.'views';
}
}
//
if (($_temp = realpath($view_folder)) !== FALSE)
{
$view_folder = $_temp.DIRECTORY_SEPARATOR;
}
else
{
$view_folder = rtrim($view_folder, '/\\').DIRECTORY_SEPARATOR;
}
define('VIEWPATH', $view_folder);
/*
* var_dump(get_defined_constants(true));die;部分结果
* ["user"]=>
* array(7) {
* ["ENVIRONMENT"]=>
* string(11) "development"
* ["SELF"]=>
* string(9) "index.php"
* ["BASEPATH"]=>
* string(40) "D:/amp/www/localhost/codeigniter/system/"
* ["FCPATH"]=>
* string(33) "D:\amp\www\localhost\codeigniter/"
* ["SYSDIR"]=>
* string(6) "system"
* ["APPPATH"]=>
* string(45) "D:\amp\www\localhost\codeigniter\application\"
* ["VIEWPATH"]=>
* string(51) "D:\amp\www\localhost\codeigniter\application\views\"
* }
* P.S:realpath('')为当前文件夹
*/
/*
* --------------------------------------------------------------------
* LOAD THE BOOTSTRAP FILE
* 加载启动文件
* --------------------------------------------------------------------
*
* And away we go...
*/
require_once BASEPATH.'core/CodeIgniter.php';