Skip to content

Commit fd1ce2c

Browse files
committed
Updated CodeIgniter files to 2.0.3 (Aug 20, 2011 release)
Signed-off-by: Fabio Borraccetti <[email protected]>
1 parent ac4ba81 commit fd1ce2c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1533
-1645
lines changed

index.php

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,49 @@
22

33
/*
44
*---------------------------------------------------------------
5-
* PHP ERROR REPORTING LEVEL
5+
* APPLICATION ENVIRONMENT
66
*---------------------------------------------------------------
77
*
8-
* By default CI runs with error reporting set to ALL. For security
9-
* reasons you are encouraged to change this to 0 when your site goes live.
10-
* For more info visit: http://www.php.net/error_reporting
8+
* You can load different configurations depending on your
9+
* current environment. Setting the environment also influences
10+
* things like logging and error reporting.
11+
*
12+
* This can be set to anything, but default usage is:
13+
*
14+
* development
15+
* testing
16+
* production
17+
*
18+
* NOTE: If you change these, also change the error_reporting() code below
1119
*
1220
*/
13-
error_reporting(E_ALL);
21+
define('ENVIRONMENT', 'development');
22+
/*
23+
*---------------------------------------------------------------
24+
* ERROR REPORTING
25+
*---------------------------------------------------------------
26+
*
27+
* Different environments will require different levels of error reporting.
28+
* By default development will show errors but testing and live will hide them.
29+
*/
30+
31+
if (defined('ENVIRONMENT'))
32+
{
33+
switch (ENVIRONMENT)
34+
{
35+
case 'development':
36+
error_reporting(E_ALL);
37+
break;
38+
39+
case 'testing':
40+
case 'production':
41+
error_reporting(0);
42+
break;
43+
44+
default:
45+
exit('The application environment is not set correctly.');
46+
}
47+
}
1448

1549
/*
1650
*---------------------------------------------------------------
@@ -22,7 +56,7 @@
2256
* as this file.
2357
*
2458
*/
25-
$system_path = "system";
59+
$system_path = 'system';
2660

2761
/*
2862
*---------------------------------------------------------------
@@ -38,7 +72,7 @@
3872
* NO TRAILING SLASH!
3973
*
4074
*/
41-
$application_folder = "application";
75+
$application_folder = 'application';
4276

4377
/*
4478
* --------------------------------------------------------------------
@@ -64,7 +98,7 @@
6498
// if your controller is not in a sub-folder within the "controllers" folder
6599
// $routing['directory'] = '';
66100

67-
// The controller class file name. Example: Mycontroller.php
101+
// The controller class file name. Example: Mycontroller
68102
// $routing['controller'] = '';
69103

70104
// The controller function you wish to be called.
@@ -94,14 +128,18 @@
94128
// END OF USER CONFIGURABLE SETTINGS. DO NOT EDIT BELOW THIS LINE
95129
// --------------------------------------------------------------------
96130

97-
98-
99-
100131
/*
101132
* ---------------------------------------------------------------
102133
* Resolve the system path for increased reliability
103134
* ---------------------------------------------------------------
104135
*/
136+
137+
// Set the current directory correctly for CLI requests
138+
if (defined('STDIN'))
139+
{
140+
chdir(dirname(__FILE__));
141+
}
142+
105143
if (realpath($system_path) !== FALSE)
106144
{
107145
$system_path = realpath($system_path).'/';
@@ -125,6 +163,7 @@
125163
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
126164

127165
// The PHP file extension
166+
// this global constant is deprecated.
128167
define('EXT', '.php');
129168

130169
// Path to the system folder
@@ -160,7 +199,7 @@
160199
* And away we go...
161200
*
162201
*/
163-
require_once BASEPATH.'core/CodeIgniter'.EXT;
202+
require_once BASEPATH.'core/CodeIgniter.php';
164203

165204
/* End of file index.php */
166205
/* Location: ./index.php */

system/core/CodeIgniter.php

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,35 @@
3232
* Define the CodeIgniter Version
3333
* ------------------------------------------------------
3434
*/
35-
define('CI_VERSION', '2.0');
35+
define('CI_VERSION', '2.0.3');
36+
37+
/*
38+
* ------------------------------------------------------
39+
* Define the CodeIgniter Branch (Core = TRUE, Reactor = FALSE)
40+
* ------------------------------------------------------
41+
*/
42+
define('CI_CORE', FALSE);
3643

3744
/*
3845
* ------------------------------------------------------
3946
* Load the global functions
4047
* ------------------------------------------------------
4148
*/
42-
require(BASEPATH.'core/Common'.EXT);
49+
require(BASEPATH.'core/Common.php');
4350

4451
/*
4552
* ------------------------------------------------------
4653
* Load the framework constants
4754
* ------------------------------------------------------
4855
*/
49-
require(APPPATH.'config/constants'.EXT);
56+
if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/constants.php'))
57+
{
58+
require(APPPATH.'config/'.ENVIRONMENT.'/constants.php');
59+
}
60+
else
61+
{
62+
require(APPPATH.'config/constants.php');
63+
}
5064

5165
/*
5266
* ------------------------------------------------------
@@ -80,7 +94,7 @@
8094
{
8195
get_config(array('subclass_prefix' => $assign_to_config['subclass_prefix']));
8296
}
83-
97+
8498
/*
8599
* ------------------------------------------------------
86100
* Set a liberal script execution time limit
@@ -182,6 +196,13 @@
182196
}
183197
}
184198

199+
/*
200+
* -----------------------------------------------------
201+
* Load the security class for xss and csrf support
202+
* -----------------------------------------------------
203+
*/
204+
$SEC =& load_class('Security', 'core');
205+
185206
/*
186207
* ------------------------------------------------------
187208
* Load the Input class and sanitize globals
@@ -203,28 +224,28 @@
203224
*
204225
*/
205226
// Load the base controller class
206-
require BASEPATH.'core/Controller'.EXT;
227+
require BASEPATH.'core/Controller.php';
207228

208229
function &get_instance()
209230
{
210231
return CI_Controller::get_instance();
211232
}
212233

213234

214-
if (file_exists(APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller'.EXT))
235+
if (file_exists(APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php'))
215236
{
216-
require APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller'.EXT;
237+
require APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php';
217238
}
218239

219240
// Load the local application controller
220241
// Note: The Router class automatically validates the controller path using the router->_validate_request().
221242
// If this include fails it means that the default controller in the Routes.php file is not resolving to something valid.
222-
if ( ! file_exists(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT))
243+
if ( ! file_exists(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().'.php'))
223244
{
224245
show_error('Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.');
225246
}
226247

227-
include(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT);
248+
include(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().'.php');
228249

229250
// Set a mark point for benchmarking
230251
$BM->mark('loading_time:_base_classes_end');
@@ -289,7 +310,28 @@ function &get_instance()
289310
// methods, so we'll use this workaround for consistent behavior
290311
if ( ! in_array(strtolower($method), array_map('strtolower', get_class_methods($CI))))
291312
{
292-
show_404("{$class}/{$method}");
313+
// Check and see if we are using a 404 override and use it.
314+
if ( ! empty($RTR->routes['404_override']))
315+
{
316+
$x = explode('/', $RTR->routes['404_override']);
317+
$class = $x[0];
318+
$method = (isset($x[1]) ? $x[1] : 'index');
319+
if ( ! class_exists($class))
320+
{
321+
if ( ! file_exists(APPPATH.'controllers/'.$class.'.php'))
322+
{
323+
show_404("{$class}/{$method}");
324+
}
325+
326+
include_once(APPPATH.'controllers/'.$class.'.php');
327+
unset($CI);
328+
$CI = new $class();
329+
}
330+
}
331+
else
332+
{
333+
show_404("{$class}/{$method}");
334+
}
293335
}
294336

295337
// Call the requested method.

0 commit comments

Comments
 (0)