2005 |
Aurelien |
1 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
2 |
/**
|
|
|
3 |
* CodeIgniter
|
|
|
4 |
*
|
|
|
5 |
* An open source application development framework for PHP 4.3.2 or newer
|
|
|
6 |
*
|
|
|
7 |
* @package CodeIgniter
|
|
|
8 |
* @author ExpressionEngine Dev Team
|
|
|
9 |
* @copyright Copyright (c) 2008, EllisLab, Inc.
|
|
|
10 |
* @license http://codeigniter.com/user_guide/license.html
|
|
|
11 |
* @link http://codeigniter.com
|
|
|
12 |
* @since Version 1.0
|
|
|
13 |
* @filesource
|
|
|
14 |
*/
|
|
|
15 |
|
|
|
16 |
// ------------------------------------------------------------------------
|
|
|
17 |
|
|
|
18 |
/**
|
|
|
19 |
* System Front Controller
|
|
|
20 |
*
|
|
|
21 |
* Loads the base classes and executes the request.
|
|
|
22 |
*
|
|
|
23 |
* @package CodeIgniter
|
|
|
24 |
* @subpackage codeigniter
|
|
|
25 |
* @category Front-controller
|
|
|
26 |
* @author ExpressionEngine Dev Team
|
|
|
27 |
* @link http://codeigniter.com/user_guide/
|
|
|
28 |
*/
|
|
|
29 |
|
|
|
30 |
// CI Version
|
|
|
31 |
define('CI_VERSION', '1.7.0');
|
|
|
32 |
|
|
|
33 |
/*
|
|
|
34 |
* ------------------------------------------------------
|
|
|
35 |
* Load the global functions
|
|
|
36 |
* ------------------------------------------------------
|
|
|
37 |
*/
|
|
|
38 |
require(BASEPATH.'codeigniter/Common'.EXT);
|
|
|
39 |
|
|
|
40 |
/*
|
|
|
41 |
* ------------------------------------------------------
|
|
|
42 |
* Load the compatibility override functions
|
|
|
43 |
* ------------------------------------------------------
|
|
|
44 |
*/
|
|
|
45 |
require(BASEPATH.'codeigniter/Compat'.EXT);
|
|
|
46 |
|
|
|
47 |
/*
|
|
|
48 |
* ------------------------------------------------------
|
|
|
49 |
* Load the framework constants
|
|
|
50 |
* ------------------------------------------------------
|
|
|
51 |
*/
|
|
|
52 |
require(APPPATH.'config/constants'.EXT);
|
|
|
53 |
|
|
|
54 |
/*
|
|
|
55 |
* ------------------------------------------------------
|
|
|
56 |
* Define a custom error handler so we can log PHP errors
|
|
|
57 |
* ------------------------------------------------------
|
|
|
58 |
*/
|
|
|
59 |
set_error_handler('_exception_handler');
|
|
|
60 |
set_magic_quotes_runtime(0); // Kill magic quotes
|
|
|
61 |
|
|
|
62 |
/*
|
|
|
63 |
* ------------------------------------------------------
|
|
|
64 |
* Start the timer... tick tock tick tock...
|
|
|
65 |
* ------------------------------------------------------
|
|
|
66 |
*/
|
|
|
67 |
|
|
|
68 |
$BM =& load_class('Benchmark');
|
|
|
69 |
$BM->mark('total_execution_time_start');
|
|
|
70 |
$BM->mark('loading_time_base_classes_start');
|
|
|
71 |
|
|
|
72 |
/*
|
|
|
73 |
* ------------------------------------------------------
|
|
|
74 |
* Instantiate the hooks class
|
|
|
75 |
* ------------------------------------------------------
|
|
|
76 |
*/
|
|
|
77 |
|
|
|
78 |
$EXT =& load_class('Hooks');
|
|
|
79 |
|
|
|
80 |
/*
|
|
|
81 |
* ------------------------------------------------------
|
|
|
82 |
* Is there a "pre_system" hook?
|
|
|
83 |
* ------------------------------------------------------
|
|
|
84 |
*/
|
|
|
85 |
$EXT->_call_hook('pre_system');
|
|
|
86 |
|
|
|
87 |
/*
|
|
|
88 |
* ------------------------------------------------------
|
|
|
89 |
* Instantiate the base classes
|
|
|
90 |
* ------------------------------------------------------
|
|
|
91 |
*/
|
|
|
92 |
|
|
|
93 |
$CFG =& load_class('Config');
|
|
|
94 |
$URI =& load_class('URI');
|
|
|
95 |
$RTR =& load_class('Router');
|
|
|
96 |
$OUT =& load_class('Output');
|
|
|
97 |
|
|
|
98 |
/*
|
|
|
99 |
* ------------------------------------------------------
|
|
|
100 |
* Is there a valid cache file? If so, we're done...
|
|
|
101 |
* ------------------------------------------------------
|
|
|
102 |
*/
|
|
|
103 |
|
|
|
104 |
if ($EXT->_call_hook('cache_override') === FALSE)
|
|
|
105 |
{
|
|
|
106 |
if ($OUT->_display_cache($CFG, $URI) == TRUE)
|
|
|
107 |
{
|
|
|
108 |
exit;
|
|
|
109 |
}
|
|
|
110 |
}
|
|
|
111 |
|
|
|
112 |
/*
|
|
|
113 |
* ------------------------------------------------------
|
|
|
114 |
* Load the remaining base classes
|
|
|
115 |
* ------------------------------------------------------
|
|
|
116 |
*/
|
|
|
117 |
|
|
|
118 |
$IN =& load_class('Input');
|
|
|
119 |
$LANG =& load_class('Language');
|
|
|
120 |
|
|
|
121 |
/*
|
|
|
122 |
* ------------------------------------------------------
|
|
|
123 |
* Load the app controller and local controller
|
|
|
124 |
* ------------------------------------------------------
|
|
|
125 |
*
|
|
|
126 |
* Note: Due to the poor object handling in PHP 4 we'll
|
|
|
127 |
* conditionally load different versions of the base
|
|
|
128 |
* class. Retaining PHP 4 compatibility requires a bit of a hack.
|
|
|
129 |
*
|
|
|
130 |
* Note: The Loader class needs to be included first
|
|
|
131 |
*
|
|
|
132 |
*/
|
|
|
133 |
if (floor(phpversion()) < 5)
|
|
|
134 |
{
|
|
|
135 |
load_class('Loader', FALSE);
|
|
|
136 |
require(BASEPATH.'codeigniter/Base4'.EXT);
|
|
|
137 |
}
|
|
|
138 |
else
|
|
|
139 |
{
|
|
|
140 |
require(BASEPATH.'codeigniter/Base5'.EXT);
|
|
|
141 |
}
|
|
|
142 |
|
|
|
143 |
// Load the base controller class
|
|
|
144 |
load_class('Controller', FALSE);
|
|
|
145 |
|
|
|
146 |
// Load the local application controller
|
|
|
147 |
// Note: The Router class automatically validates the controller path. If this include fails it
|
|
|
148 |
// means that the default controller in the Routes.php file is not resolving to something valid.
|
|
|
149 |
if ( ! file_exists(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT))
|
|
|
150 |
{
|
|
|
151 |
show_error('Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.');
|
|
|
152 |
}
|
|
|
153 |
|
|
|
154 |
include(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT);
|
|
|
155 |
|
|
|
156 |
// Set a mark point for benchmarking
|
|
|
157 |
$BM->mark('loading_time_base_classes_end');
|
|
|
158 |
|
|
|
159 |
|
|
|
160 |
/*
|
|
|
161 |
* ------------------------------------------------------
|
|
|
162 |
* Security check
|
|
|
163 |
* ------------------------------------------------------
|
|
|
164 |
*
|
|
|
165 |
* None of the functions in the app controller or the
|
|
|
166 |
* loader class can be called via the URI, nor can
|
|
|
167 |
* controller functions that begin with an underscore
|
|
|
168 |
*/
|
|
|
169 |
$class = $RTR->fetch_class();
|
|
|
170 |
$method = $RTR->fetch_method();
|
|
|
171 |
|
|
|
172 |
if ( ! class_exists($class)
|
|
|
173 |
OR $method == 'controller'
|
|
|
174 |
OR strncmp($method, '_', 1) == 0
|
|
|
175 |
OR in_array(strtolower($method), array_map('strtolower', get_class_methods('Controller')))
|
|
|
176 |
)
|
|
|
177 |
{
|
|
|
178 |
show_404("{$class}/{$method}");
|
|
|
179 |
}
|
|
|
180 |
|
|
|
181 |
/*
|
|
|
182 |
* ------------------------------------------------------
|
|
|
183 |
* Is there a "pre_controller" hook?
|
|
|
184 |
* ------------------------------------------------------
|
|
|
185 |
*/
|
|
|
186 |
$EXT->_call_hook('pre_controller');
|
|
|
187 |
|
|
|
188 |
/*
|
|
|
189 |
* ------------------------------------------------------
|
|
|
190 |
* Instantiate the controller and call requested method
|
|
|
191 |
* ------------------------------------------------------
|
|
|
192 |
*/
|
|
|
193 |
|
|
|
194 |
// Mark a start point so we can benchmark the controller
|
|
|
195 |
$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_start');
|
|
|
196 |
|
|
|
197 |
$CI = new $class();
|
|
|
198 |
|
|
|
199 |
// Is this a scaffolding request?
|
|
|
200 |
if ($RTR->scaffolding_request === TRUE)
|
|
|
201 |
{
|
|
|
202 |
if ($EXT->_call_hook('scaffolding_override') === FALSE)
|
|
|
203 |
{
|
|
|
204 |
$CI->_ci_scaffolding();
|
|
|
205 |
}
|
|
|
206 |
}
|
|
|
207 |
else
|
|
|
208 |
{
|
|
|
209 |
/*
|
|
|
210 |
* ------------------------------------------------------
|
|
|
211 |
* Is there a "post_controller_constructor" hook?
|
|
|
212 |
* ------------------------------------------------------
|
|
|
213 |
*/
|
|
|
214 |
$EXT->_call_hook('post_controller_constructor');
|
|
|
215 |
|
|
|
216 |
// Is there a "remap" function?
|
|
|
217 |
if (method_exists($CI, '_remap'))
|
|
|
218 |
{
|
|
|
219 |
$CI->_remap($method);
|
|
|
220 |
}
|
|
|
221 |
else
|
|
|
222 |
{
|
|
|
223 |
// is_callable() returns TRUE on some versions of PHP 5 for private and protected
|
|
|
224 |
// methods, so we'll use this workaround for consistent behavior
|
|
|
225 |
if ( ! in_array(strtolower($method), array_map('strtolower', get_class_methods($CI))))
|
|
|
226 |
{
|
|
|
227 |
show_404("{$class}/{$method}");
|
|
|
228 |
}
|
|
|
229 |
|
|
|
230 |
// Call the requested method.
|
|
|
231 |
// Any URI segments present (besides the class/function) will be passed to the method for convenience
|
|
|
232 |
call_user_func_array(array(&$CI, $method), array_slice($URI->rsegments, 2));
|
|
|
233 |
}
|
|
|
234 |
}
|
|
|
235 |
|
|
|
236 |
// Mark a benchmark end point
|
|
|
237 |
$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_end');
|
|
|
238 |
|
|
|
239 |
/*
|
|
|
240 |
* ------------------------------------------------------
|
|
|
241 |
* Is there a "post_controller" hook?
|
|
|
242 |
* ------------------------------------------------------
|
|
|
243 |
*/
|
|
|
244 |
$EXT->_call_hook('post_controller');
|
|
|
245 |
|
|
|
246 |
/*
|
|
|
247 |
* ------------------------------------------------------
|
|
|
248 |
* Send the final rendered output to the browser
|
|
|
249 |
* ------------------------------------------------------
|
|
|
250 |
*/
|
|
|
251 |
|
|
|
252 |
if ($EXT->_call_hook('display_override') === FALSE)
|
|
|
253 |
{
|
|
|
254 |
$OUT->_display();
|
|
|
255 |
}
|
|
|
256 |
|
|
|
257 |
/*
|
|
|
258 |
* ------------------------------------------------------
|
|
|
259 |
* Is there a "post_system" hook?
|
|
|
260 |
* ------------------------------------------------------
|
|
|
261 |
*/
|
|
|
262 |
$EXT->_call_hook('post_system');
|
|
|
263 |
|
|
|
264 |
/*
|
|
|
265 |
* ------------------------------------------------------
|
|
|
266 |
* Close the DB connection if one exists
|
|
|
267 |
* ------------------------------------------------------
|
|
|
268 |
*/
|
|
|
269 |
if (class_exists('CI_DB') AND isset($CI->db))
|
|
|
270 |
{
|
|
|
271 |
$CI->db->close();
|
|
|
272 |
}
|
|
|
273 |
|
|
|
274 |
|
|
|
275 |
/* End of file CodeIgniter.php */
|
|
|
276 |
/* Location: ./system/codeigniter/CodeIgniter.php */
|