summaryrefslogtreecommitdiffstats
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rwxr-xr-x[-rw-r--r--]index.php87
1 files changed, 53 insertions, 34 deletions
diff --git a/index.php b/index.php
index 5a1190112..107a2095b 100644..100755
--- a/index.php
+++ b/index.php
@@ -42,7 +42,8 @@
*
* NOTE: If you change these, also change the error_reporting() code below
*/
- define('ENVIRONMENT', 'development');
+ define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');
+
/*
*---------------------------------------------------------------
* ERROR REPORTING
@@ -51,21 +52,22 @@
* Different environments will require different levels of error reporting.
* By default development will show errors but testing and live will hide them.
*/
-
-if (defined('ENVIRONMENT'))
+switch (ENVIRONMENT)
{
- switch (ENVIRONMENT)
- {
- case 'development':
- error_reporting(-1);
- break;
- case 'testing':
- case 'production':
- error_reporting(0);
- break;
- default:
- exit('The application environment is not set correctly.');
- }
+ case 'development':
+ error_reporting(-1);
+ ini_set('display_errors', 1);
+ break;
+
+ case 'testing':
+ case 'production':
+ error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_STRICT);
+ ini_set('display_errors', 0);
+ break;
+
+ default:
+ header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
+ exit('The application environment is not set correctly.');
}
/*
@@ -133,7 +135,7 @@ if (defined('ENVIRONMENT'))
// if your controller is not in a sub-folder within the "controllers" folder
// $routing['directory'] = '';
- // The controller class file name. Example: Mycontroller
+ // The controller class file name. Example: mycontroller
// $routing['controller'] = '';
// The controller function you wish to be called.
@@ -174,17 +176,20 @@ if (defined('ENVIRONMENT'))
chdir(dirname(__FILE__));
}
- if (realpath($system_path) !== FALSE)
+ if (($_temp = realpath($system_path)) !== FALSE)
{
- $system_path = realpath($system_path).'/';
+ $system_path = $_temp.'/';
+ }
+ else
+ {
+ // Ensure there's a trailing slash
+ $system_path = rtrim($system_path, '/').'/';
}
-
- // ensure there's a trailing slash
- $system_path = rtrim($system_path, '/').'/';
// Is the system path correct?
if ( ! is_dir($system_path))
{
+ header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
exit('Your system folder path does not appear to be set correctly. Please open the following file and correct this: '.pathinfo(__FILE__, PATHINFO_BASENAME));
}
@@ -196,10 +201,6 @@ if (defined('ENVIRONMENT'))
// The name of THIS file
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
- // The PHP file extension
- // this global constant is deprecated.
- define('EXT', '.php');
-
// Path to the system folder
define('BASEPATH', str_replace('\\', '/', $system_path));
@@ -212,13 +213,18 @@ if (defined('ENVIRONMENT'))
// The path to the "application" folder
if (is_dir($application_folder))
{
+ if (($_temp = realpath($application_folder)) !== FALSE)
+ {
+ $application_folder = $_temp;
+ }
+
define('APPPATH', $application_folder.'/');
}
else
{
if ( ! is_dir(BASEPATH.$application_folder.'/'))
{
- header('HTTP/1.1 503 Service Unavailable.', TRUE, '503');
+ header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
exit('Your application folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF);
}
@@ -226,21 +232,34 @@ if (defined('ENVIRONMENT'))
}
// The path to the "views" folder
- if (is_dir($view_folder))
+ if ( ! is_dir($view_folder))
{
- define ('VIEWPATH', $view_folder .'/');
- }
- else
- {
- if ( ! is_dir(APPPATH.'views/'))
+ if ( ! empty($view_folder) && is_dir(APPPATH.$view_folder.'/'))
{
- header('HTTP/1.1 503 Service Unavailable.', TRUE, '503');
+ $view_folder = APPPATH.$view_folder;
+ }
+ elseif ( ! is_dir(APPPATH.'views/'))
+ {
+ header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
exit('Your view folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF);
}
+ else
+ {
+ $view_folder = APPPATH.'views';
+ }
+ }
- define ('VIEWPATH', APPPATH.'views/' );
+ if (($_temp = realpath($view_folder)) !== FALSE)
+ {
+ $view_folder = realpath($view_folder).'/';
+ }
+ else
+ {
+ $view_folder = rtrim($view_folder, '/').'/';
}
+ define('VIEWPATH', $view_folder);
+
/*
* --------------------------------------------------------------------
* LOAD THE BOOTSTRAP FILE