-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.php
More file actions
146 lines (119 loc) · 3.69 KB
/
bootstrap.php
File metadata and controls
146 lines (119 loc) · 3.69 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
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
<?php
/* bootstrap.php
*
* Curiouser and curiouser!
*
* function email($str){return preg_replace('/^(.*)\/(.*)/', '$2@$1', $str);}
* Authors: Sandeep Shetty email('gmail.com/sandeep.shetty')
*
* Copyright (C) 2005 - date('Y') Collaboration Science,
* http://collaborationscience.com/
*
* This file is part of Inertia.
*
* Inertia is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* Inertia is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* To read the license please visit http://www.gnu.org/copyleft/gpl.html
*
*
*----------------------------------------------------------------------------
*/
define('INERTIA_INSTALL_DIR', dirname(__FILE__).DIRECTORY_SEPARATOR);
define('INERTIA_BOOTSTRAP_HANDLER', 'application');
fix_magic_quotes_gpc_();
require_core_files_();
function fix_magic_quotes_gpc_()
{
$funcname = 'array_stripslashes_';
if (get_magic_quotes_gpc())
{
array_walk($_GET, $funcname);
array_walk($_POST, $funcname);
array_walk($_COOKIE, $funcname);
array_walk($_REQUEST, $funcname);
}
}
function array_stripslashes_(&$value)
{
$value = is_array($value) ? array_walk($value, __FUNCTION__) : stripslashes($value);
}
function require_core_files_()
{
foreach (core_files_() as $file) require $file;
}
function core_files_()
{
return glob(INERTIA_INSTALL_DIR.'core'.DIRECTORY_SEPARATOR.'*.core.php');
}
function request_method_($method)
{
return strtoupper($method);
}
function request_path_($path)
{
return str_sanitize_(rawurldecode('/'.ltrim($path, '/')));
}
function request_body_($body)
{
return empty($body) ? NULL : $body;
}
function bootstrap_inertia_($method, $path, $query, $headers, $body)
{
$query = remove_path_hacks_($query);
if (handler_exists_(INERTIA_BOOTSTRAP_HANDLER))
{
return request_(INERTIA_BOOTSTRAP_HANDLER, $method, $path, $query, $headers, $body);
}
else
{
return inertia_default_response_($path, inertia_relative_uri_($path));
}
}
function remove_path_hacks_($query)
{
if (isset($query['path_']))
{
unset($query['path_']);
}
return $query;
}
function inertia_default_response_($path, $relative_uri)
{
if (is_equal_('/', $path))
{
return response_(STATUS_OK, array('content-type'=>'text/html'), inertia_test_page_());
}
else
{
return response_(STATUS_NOT_FOUND, array('content-type'=>'text/html'), inertia_404_not_found_($relative_uri));
}
}
function inertia_test_page_()
{
$title = 'Inertia Test Page';
$content = "<h1>$title</h1>\n"
."<p><a href=\"http://sandeepshetty.github.com/inertia/\">Inertia</a> has been successfully installed on this system!</p>"
."<p><a href=\"tests/retest.php\">Run all tests</a> and confirm everything passes before you proceed.</p>";
return minimal_html_($title, $content);
}
function inertia_404_not_found_($relative_uri)
{
$title = '404 Not Found';
$content = "<h1>Not Found</h1>\n<p>The requested URL $relative_uri"
." was not found on this server.</p>";
return minimal_html_($title, $content);
}
function minimal_html_($title, $content)
{
return "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n"
."<html>\n<head>\n<title>$title</title>\n</head>\n<body>\n$content\n</body>\n</html>";
}
?>