summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Sturgeon <email@philsturgeon.co.uk>2012-01-08 03:55:45 +0100
committerPhil Sturgeon <email@philsturgeon.co.uk>2012-01-08 03:55:45 +0100
commit239e9cd2298c3430d448db25e7d7f61ee3f4c744 (patch)
tree80000ec6c0b835fd5a7dab483e2edcbc6fefe7f3
parent972e1d627e2f35aa8e4084bad3a4c396856f6074 (diff)
parent29ce5d90b4276fc8a4e9354c1435963111f09a24 (diff)
Merge pull request #881 from narfbg/develop-core-codeigniter
Improve index.php & system/core/CodeIgniter.php
-rw-r--r--index.php57
-rwxr-xr-xsystem/core/CodeIgniter.php44
2 files changed, 41 insertions, 60 deletions
diff --git a/index.php b/index.php
index 4ae1ceebd..1712a7d66 100644
--- a/index.php
+++ b/index.php
@@ -5,9 +5,9 @@
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -41,7 +41,6 @@
* production
*
* NOTE: If you change these, also change the error_reporting() code below
- *
*/
define('ENVIRONMENT', 'development');
/*
@@ -60,12 +59,10 @@ if (defined('ENVIRONMENT'))
case 'development':
error_reporting(-1);
break;
-
case 'testing':
case 'production':
error_reporting(0);
break;
-
default:
exit('The application environment is not set correctly.');
}
@@ -79,7 +76,6 @@ if (defined('ENVIRONMENT'))
* 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';
@@ -90,30 +86,28 @@ if (defined('ENVIRONMENT'))
*
* If you want this front controller to use a different "application"
* folder then the default one you can set its name here. The folder
- * can also be renamed or relocated anywhere on your server. If
+ * 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
*
* NO TRAILING SLASH!
- *
*/
$application_folder = 'application';
-
+
/*
*---------------------------------------------------------------
* VIEW FOLDER NAME
*---------------------------------------------------------------
- *
- * If you want to move the view folder out of the application
+ *
+ * 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
+ * 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.
*
* NO TRAILING SLASH!
- *
*/
- $view_folder = '';
+ $view_folder = '';
/*
@@ -123,18 +117,17 @@ if (defined('ENVIRONMENT'))
*
* 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
+ * 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.
*
- * IMPORTANT: If you set the routing here, NO OTHER controller will be
+ * 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
+ * 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
@@ -160,7 +153,6 @@ if (defined('ENVIRONMENT'))
* config values.
*
* Un-comment the $assign_to_config array below to use this feature
- *
*/
// $assign_to_config['name_of_config_item'] = 'value of config item';
@@ -193,7 +185,7 @@ if (defined('ENVIRONMENT'))
// 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));
+ exit('Your system folder path does not appear to be set correctly. Please open the following file and correct this: '.pathinfo(__FILE__, PATHINFO_BASENAME));
}
/*
@@ -209,7 +201,7 @@ if (defined('ENVIRONMENT'))
define('EXT', '.php');
// Path to the system folder
- define('BASEPATH', str_replace("\\", "/", $system_path));
+ define('BASEPATH', str_replace('\\', '/', $system_path));
// Path to the front controller (this file)
define('FCPATH', str_replace(SELF, '', __FILE__));
@@ -217,7 +209,6 @@ if (defined('ENVIRONMENT'))
// Name of the "system folder"
define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/'));
-
// The path to the "application" folder
if (is_dir($application_folder))
{
@@ -227,27 +218,26 @@ if (defined('ENVIRONMENT'))
{
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);
+ 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.'/');
}
-
+
// The path to the "views" folder
- if (is_dir($view_folder))
+ if (is_dir($view_folder))
{
define ('VIEWPATH', $view_folder .'/');
}
- else
+ else
{
if ( ! is_dir(APPPATH.'views/'))
{
- exit("Your view folder path does not appear to be set correctly. Please open the following file and correct this: ".SELF);
+ exit('Your view folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF);
}
-
- define ('VIEWPATH', APPPATH.'views/' );
+
+ define ('VIEWPATH', APPPATH.'views/' );
}
-
/*
* --------------------------------------------------------------------
@@ -255,9 +245,8 @@ if (defined('ENVIRONMENT'))
* --------------------------------------------------------------------
*
* And away we go...
- *
*/
require_once BASEPATH.'core/CodeIgniter.php';
/* End of file index.php */
-/* Location: ./index.php */ \ No newline at end of file
+/* Location: ./index.php */
diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php
index 5152073d5..cb5d439bd 100755
--- a/system/core/CodeIgniter.php
+++ b/system/core/CodeIgniter.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -59,7 +59,7 @@
* Load the framework constants
* ------------------------------------------------------
*/
- if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/constants.php'))
+ if (defined('ENVIRONMENT') && file_exists(APPPATH.'config/'.ENVIRONMENT.'/constants.php'))
{
require(APPPATH.'config/'.ENVIRONMENT.'/constants.php');
}
@@ -91,12 +91,12 @@
* "libraries" folder. Since CI allows config items to be
* overriden via data set in the main index. php file,
* before proceeding we need to know if a subclass_prefix
- * override exists. If so, we will set this value now,
+ * override exists. If so, we will set this value now,
* before any classes are loaded
* Note: Since the config file data is cached it doesn't
* hurt to load it here.
*/
- if (isset($assign_to_config['subclass_prefix']) AND $assign_to_config['subclass_prefix'] != '')
+ if (isset($assign_to_config['subclass_prefix']) && $assign_to_config['subclass_prefix'] != '')
{
get_config(array('subclass_prefix' => $assign_to_config['subclass_prefix']));
}
@@ -106,13 +106,10 @@
* Set a liberal script execution time limit
* ------------------------------------------------------
*/
- if (function_exists("set_time_limit") AND @ini_get("safe_mode") == 0)
+ if (function_exists('set_time_limit') && @ini_get('safe_mode') == 0
+ && php_sapi_name() !== 'cli') // Do not override the Time Limit value if running from Command Line
{
- // Do not override the Time Limit value if running from Command Line
- if(php_sapi_name() != 'cli')
- {
- @set_time_limit(300);
- }
+ @set_time_limit(300);
}
/*
@@ -162,7 +159,6 @@
* after the Config class is instantiated.
*
*/
-
$UNI =& load_class('Utf8', 'core');
/*
@@ -195,15 +191,13 @@
/*
* ------------------------------------------------------
- * Is there a valid cache file? If so, we're done...
+ * Is there a valid cache file? If so, we're done...
* ------------------------------------------------------
*/
- if ($EXT->_call_hook('cache_override') === FALSE)
+ if ($EXT->_call_hook('cache_override') === FALSE
+ && $OUT->_display_cache($CFG, $URI) == TRUE)
{
- if ($OUT->_display_cache($CFG, $URI) == TRUE)
- {
- exit;
- }
+ exit;
}
/*
@@ -273,13 +267,13 @@
$method = $RTR->fetch_method();
if ( ! class_exists($class)
- OR strncmp($method, '_', 1) == 0
+ OR strpos($method, '_', 1) === 0
OR in_array(strtolower($method), array_map('strtolower', get_class_methods('CI_Controller')))
)
{
if ( ! empty($RTR->routes['404_override']))
{
- $x = explode('/', $RTR->routes['404_override']);
+ $x = explode('/', $RTR->routes['404_override'], 2);
$class = $x[0];
$method = (isset($x[1]) ? $x[1] : 'index');
if ( ! class_exists($class))
@@ -341,7 +335,7 @@
// Check and see if we are using a 404 override and use it.
if ( ! empty($RTR->routes['404_override']))
{
- $x = explode('/', $RTR->routes['404_override']);
+ $x = explode('/', $RTR->routes['404_override'], 2);
$class = $x[0];
$method = (isset($x[1]) ? $x[1] : 'index');
if ( ! class_exists($class))
@@ -367,7 +361,6 @@
call_user_func_array(array(&$CI, $method), array_slice($URI->rsegments, 2));
}
-
// Mark a benchmark end point
$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_end');
@@ -400,11 +393,10 @@
* Close the DB connection if one exists
* ------------------------------------------------------
*/
- if (class_exists('CI_DB') AND isset($CI->db))
+ if (class_exists('CI_DB') && isset($CI->db))
{
$CI->db->close();
}
-
/* End of file CodeIgniter.php */
-/* Location: ./system/core/CodeIgniter.php */ \ No newline at end of file
+/* Location: ./system/core/CodeIgniter.php */