-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathhttpindex.php
More file actions
executable file
·113 lines (107 loc) · 3.25 KB
/
httpindex.php
File metadata and controls
executable file
·113 lines (107 loc) · 3.25 KB
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
<?php
/**
* 请先运行:php server/http_server.php
* @author xmc
*/
class Httpindex
{
static public $httpdefined;
private function __construct()
{
define('ENVIRONMENT', 'development');
if (defined('ENVIRONMENT')) {
switch (ENVIRONMENT) {
case 'development':
error_reporting(E_ALL);
break;
case 'testing':
case 'production':
error_reporting(0);
break;
default:
exit('The application environment is not set correctly.');
}
}
/*
*---------------------------------------------------------------
* SYSTEM FOLDER NAME
*---------------------------------------------------------------
*/
$system_path = 'system';
/*
*---------------------------------------------------------------
* APPLICATION FOLDER NAME
*---------------------------------------------------------------
*/
$application_folder = 'application';
/*
* ---------------------------------------------------------------
* Resolve the system path for increased reliability
* ---------------------------------------------------------------
*/
// Set the current directory correctly for CLI requests
if (defined('STDIN')) {
chdir(dirname(__FILE__));
}
if (realpath($system_path) !== FALSE) {
$system_path = realpath($system_path).'/';
}
// ensure there's a trailing slash
$system_path = rtrim($system_path, '/').'/';
// Is the system path correct?
if ( ! is_dir($system_path)) {
exit("Your system folder path does not appear to be set correctly. Please open the following file and correct this: ".pathinfo(__FILE__, PATHINFO_BASENAME));
}
/*
* -------------------------------------------------------------------
* Now that we know the path, set the main path constants
* -------------------------------------------------------------------
*/
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
define('EXT', '.php');
define('BASEPATH', str_replace("\\", "/", $system_path));
define('FCPATH', str_replace(SELF, '', __FILE__));
define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/'));
if (is_dir($application_folder)) {
define('APPPATH', $application_folder.'/');
} else {
if (!is_dir(BASEPATH.$application_folder.'/')) {
exit("Your application folder path does not appear to be set correctly. Please open the following file and correct this: ".SELF);
}
define('APPPATH', BASEPATH.$application_folder.'/');
}
}
public static function getInstance($request, $response)
{
if (!self::$httpdefined) {
$httpdefined = new self();
self::$httpdefined = $httpdefined;
}
/*
* --------------------------------------------------------------------
* LOAD THE BOOTSTRAP FILE
* --------------------------------------------------------------------
* And away we go...
*/
$_GET = $_POST = array();
$GLOBALS['ISEND'] = FALSE;
$GLOBALS['REQUEST'] = $request;
$GLOBALS['RESPONSE'] = $response;
if (isset($request->header)) {
$_SERVER['server_head'] = $request->header;
}
if (isset($request->get)) {
$_GET = $request->get;
}
if (isset($request->post)) {
$_POST = $request->post;
}
include BASEPATH.'core/CodeIgniter.php';
}
public function __destruct()
{
self::$httpdefined=false;
}
}
/* End of file index.php */
/* Location: ./index.php */