blob: 13fcd5996888f6c604f77c6565593e84df7a4ae3 [file] [log] [blame]
Derek Allard2067d1a2008-11-13 22:59:24 +00001<?php
Derek Jonesf4a4bd82011-10-20 12:18:42 -05002/**
3 * CodeIgniter
4 *
Andrey Andreevfe9309d2015-01-09 17:48:58 +02005 * An open source application development framework for PHP
Derek Jonesf4a4bd82011-10-20 12:18:42 -05006 *
Andrey Andreevbdb96ca2014-10-28 00:13:31 +02007 * This content is released under the MIT License (MIT)
Andrey Andreev282592c2012-01-08 01:01:55 +02008 *
Andrey Andreevfe9309d2015-01-09 17:48:58 +02009 * Copyright (c) 2014 - 2015, British Columbia Institute of Technology
Andrey Andreev282592c2012-01-08 01:01:55 +020010 *
Andrey Andreevbdb96ca2014-10-28 00:13:31 +020011 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this software and associated documentation files (the "Software"), to deal
13 * in the Software without restriction, including without limitation the rights
14 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 * copies of the Software, and to permit persons to whom the Software is
16 * furnished to do so, subject to the following conditions:
Derek Jonesf4a4bd82011-10-20 12:18:42 -050017 *
Andrey Andreevbdb96ca2014-10-28 00:13:31 +020018 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 * THE SOFTWARE.
28 *
29 * @package CodeIgniter
30 * @author EllisLab Dev Team
Andrey Andreev1924e872016-01-11 12:55:34 +020031 * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
Andrey Andreevfe9309d2015-01-09 17:48:58 +020032 * @copyright Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/)
Andrey Andreevbdb96ca2014-10-28 00:13:31 +020033 * @license http://opensource.org/licenses/MIT MIT License
Andrey Andreevbd202c92016-01-11 12:50:18 +020034 * @link https://codeigniter.com
Andrey Andreevbdb96ca2014-10-28 00:13:31 +020035 * @since Version 1.0.0
Derek Jonesf4a4bd82011-10-20 12:18:42 -050036 * @filesource
37 */
Derek Jones0c1e4052010-03-02 14:31:31 -060038
Derek Allard2067d1a2008-11-13 22:59:24 +000039/*
Derek Jones0c1e4052010-03-02 14:31:31 -060040 *---------------------------------------------------------------
joelcoxcee80752011-01-15 23:09:47 +010041 * APPLICATION ENVIRONMENT
42 *---------------------------------------------------------------
43 *
44 * You can load different configurations depending on your
joelcoxbf2b9122011-01-16 15:24:43 +010045 * current environment. Setting the environment also influences
Phil Sturgeond88b3152011-02-02 21:19:25 +000046 * things like logging and error reporting.
47 *
48 * This can be set to anything, but default usage is:
49 *
Derek Jones4b9c6292011-07-01 17:40:48 -050050 * development
51 * testing
52 * production
Phil Sturgeond88b3152011-02-02 21:19:25 +000053 *
54 * NOTE: If you change these, also change the error_reporting() code below
joelcoxcee80752011-01-15 23:09:47 +010055 */
Phil Sturgeondda21f62012-06-03 10:36:36 -050056 define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');
vlakofffe832492012-07-13 20:40:06 +020057
Phil Sturgeond88b3152011-02-02 21:19:25 +000058/*
59 *---------------------------------------------------------------
60 * ERROR REPORTING
61 *---------------------------------------------------------------
62 *
63 * Different environments will require different levels of error reporting.
64 * By default development will show errors but testing and live will hide them.
65 */
Root35ac46d2012-05-25 18:51:48 -040066switch (ENVIRONMENT)
Phil Sturgeon05fa6112011-04-06 22:57:43 +010067{
Root35ac46d2012-05-25 18:51:48 -040068 case 'development':
Gints Murans8d021e62012-05-30 21:15:08 +030069 error_reporting(-1);
Root35ac46d2012-05-25 18:51:48 -040070 ini_set('display_errors', 1);
71 break;
72
73 case 'testing':
74 case 'production':
75 ini_set('display_errors', 0);
Andrey Andreevd40d94c2014-10-06 03:19:17 +030076 if (version_compare(PHP_VERSION, '5.3', '>='))
77 {
78 error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
79 }
80 else
81 {
82 error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
83 }
Root35ac46d2012-05-25 18:51:48 -040084 break;
85
86 default:
Andrey Andreevcbb654d2012-07-10 11:36:32 +030087 header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
Daniel Hunsaker3b5b7f42013-02-22 19:17:56 -070088 echo 'The application environment is not set correctly.';
Andrey Andreev7cf682a2014-03-13 14:55:45 +020089 exit(1); // EXIT_ERROR
Phil Sturgeon05fa6112011-04-06 22:57:43 +010090}
joelcoxcee80752011-01-15 23:09:47 +010091
92/*
93 *---------------------------------------------------------------
Derek Jones0c1e4052010-03-02 14:31:31 -060094 * SYSTEM FOLDER NAME
95 *---------------------------------------------------------------
96 *
97 * This variable must contain the name of your "system" folder.
vlakoffc941d852013-08-06 14:44:40 +020098 * Include the path if the folder is not in the same directory
Derek Jones0c1e4052010-03-02 14:31:31 -060099 * as this file.
Derek Jones0c1e4052010-03-02 14:31:31 -0600100 */
Phil Sturgeond88b3152011-02-02 21:19:25 +0000101 $system_path = 'system';
Derek Allard2067d1a2008-11-13 22:59:24 +0000102
103/*
Derek Jones0c1e4052010-03-02 14:31:31 -0600104 *---------------------------------------------------------------
105 * APPLICATION FOLDER NAME
106 *---------------------------------------------------------------
107 *
108 * If you want this front controller to use a different "application"
Adam Carmichaele90b8302013-01-04 01:04:29 +1100109 * folder than the default one you can set its name here. The folder
Andrey Andreev282592c2012-01-08 01:01:55 +0200110 * can also be renamed or relocated anywhere on your server. If
Derek Jones0c1e4052010-03-02 14:31:31 -0600111 * you do, use a full server path. For more info please see the user guide:
Andrey Andreevbd202c92016-01-11 12:50:18 +0200112 * https://codeigniter.com/user_guide/general/managing_apps.html
Derek Jones0c1e4052010-03-02 14:31:31 -0600113 *
114 * NO TRAILING SLASH!
Derek Jones0c1e4052010-03-02 14:31:31 -0600115 */
Phil Sturgeond88b3152011-02-02 21:19:25 +0000116 $application_folder = 'application';
Andrey Andreev282592c2012-01-08 01:01:55 +0200117
Joe Cianflone8eef9c72011-08-21 10:39:06 -0400118/*
119 *---------------------------------------------------------------
120 * VIEW FOLDER NAME
121 *---------------------------------------------------------------
Andrey Andreev282592c2012-01-08 01:01:55 +0200122 *
123 * If you want to move the view folder out of the application
Joe Cianflone8eef9c72011-08-21 10:39:06 -0400124 * folder set the path to the folder here. The folder can be renamed
Andrey Andreev282592c2012-01-08 01:01:55 +0200125 * and relocated anywhere on your server. If blank, it will default
126 * to the standard location inside your application folder. If you
127 * do move this, use the full server path to this folder.
Joe Cianflone8eef9c72011-08-21 10:39:06 -0400128 *
129 * NO TRAILING SLASH!
Joe Cianflone8eef9c72011-08-21 10:39:06 -0400130 */
Andrey Andreev282592c2012-01-08 01:01:55 +0200131 $view_folder = '';
Joe Cianflone8eef9c72011-08-21 10:39:06 -0400132
Derek Allard2067d1a2008-11-13 22:59:24 +0000133
134/*
Derek Jones0c1e4052010-03-02 14:31:31 -0600135 * --------------------------------------------------------------------
136 * DEFAULT CONTROLLER
137 * --------------------------------------------------------------------
138 *
139 * Normally you will set your default controller in the routes.php file.
Barry Mienydd671972010-10-04 16:33:58 +0200140 * You can, however, force a custom routing by hard-coding a
Andrey Andreev282592c2012-01-08 01:01:55 +0200141 * specific controller class/function here. For most applications, you
Barry Mienydd671972010-10-04 16:33:58 +0200142 * WILL NOT set your routing here, but it's an option for those
Derek Jones0c1e4052010-03-02 14:31:31 -0600143 * special instances where you might want to override the standard
144 * routing in a specific front controller that shares a common CI installation.
145 *
Andrey Andreev282592c2012-01-08 01:01:55 +0200146 * IMPORTANT: If you set the routing here, NO OTHER controller will be
Derek Jones0c1e4052010-03-02 14:31:31 -0600147 * callable. In essence, this preference limits your application to ONE
Andrey Andreev282592c2012-01-08 01:01:55 +0200148 * specific controller. Leave the function name blank if you need
Derek Jones0c1e4052010-03-02 14:31:31 -0600149 * to call functions dynamically via the URI.
150 *
151 * Un-comment the $routing array below to use this feature
Derek Jones0c1e4052010-03-02 14:31:31 -0600152 */
Derek Jones4b9c6292011-07-01 17:40:48 -0500153 // The directory name, relative to the "controllers" folder. Leave blank
Barry Mienydd671972010-10-04 16:33:58 +0200154 // if your controller is not in a sub-folder within the "controllers" folder
Derek Jones0c1e4052010-03-02 14:31:31 -0600155 // $routing['directory'] = '';
Barry Mienydd671972010-10-04 16:33:58 +0200156
vlakoffe40e56f2012-07-15 12:57:38 +0200157 // The controller class file name. Example: mycontroller
Derek Jones0c1e4052010-03-02 14:31:31 -0600158 // $routing['controller'] = '';
Barry Mienydd671972010-10-04 16:33:58 +0200159
160 // The controller function you wish to be called.
Derek Jones0c1e4052010-03-02 14:31:31 -0600161 // $routing['function'] = '';
Derek Allard2067d1a2008-11-13 22:59:24 +0000162
163
164/*
Derek Jones0c1e4052010-03-02 14:31:31 -0600165 * -------------------------------------------------------------------
Derek Jones4b9c6292011-07-01 17:40:48 -0500166 * CUSTOM CONFIG VALUES
Derek Jones0c1e4052010-03-02 14:31:31 -0600167 * -------------------------------------------------------------------
168 *
169 * The $assign_to_config array below will be passed dynamically to the
Barry Mienydd671972010-10-04 16:33:58 +0200170 * config class when initialized. This allows you to set custom config
171 * items or override any default config values found in the config.php file.
Derek Jones0c1e4052010-03-02 14:31:31 -0600172 * This can be handy as it permits you to share one application between
Barry Mienydd671972010-10-04 16:33:58 +0200173 * multiple front controller files, with each file containing different
Derek Jones0c1e4052010-03-02 14:31:31 -0600174 * config values.
175 *
176 * Un-comment the $assign_to_config array below to use this feature
Derek Jones0c1e4052010-03-02 14:31:31 -0600177 */
178 // $assign_to_config['name_of_config_item'] = 'value of config item';
179
180
181
182// --------------------------------------------------------------------
Derek Jones4b9c6292011-07-01 17:40:48 -0500183// END OF USER CONFIGURABLE SETTINGS. DO NOT EDIT BELOW THIS LINE
Derek Jones0c1e4052010-03-02 14:31:31 -0600184// --------------------------------------------------------------------
185
joelcoxbf2b9122011-01-16 15:24:43 +0100186/*
187 * ---------------------------------------------------------------
Derek Jones4b9c6292011-07-01 17:40:48 -0500188 * Resolve the system path for increased reliability
Derek Jones0c1e4052010-03-02 14:31:31 -0600189 * ---------------------------------------------------------------
190 */
Phil Sturgeon01d1a5b2011-02-07 10:54:06 +0000191
192 // Set the current directory correctly for CLI requests
193 if (defined('STDIN'))
194 {
195 chdir(dirname(__FILE__));
196 }
197
Andrey Andreev806ca602012-06-12 12:51:27 +0300198 if (($_temp = realpath($system_path)) !== FALSE)
Derek Allard2067d1a2008-11-13 22:59:24 +0000199 {
Andrey Andreev806ca602012-06-12 12:51:27 +0300200 $system_path = $_temp.'/';
Derek Allard2067d1a2008-11-13 22:59:24 +0000201 }
Andrey Andreev079fbfc2012-06-12 02:26:58 +0300202 else
203 {
204 // Ensure there's a trailing slash
205 $system_path = rtrim($system_path, '/').'/';
206 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000207
Derek Joneseba35082010-03-22 10:43:56 -0500208 // Is the system path correct?
Derek Jones0c1e4052010-03-02 14:31:31 -0600209 if ( ! is_dir($system_path))
Derek Allard2067d1a2008-11-13 22:59:24 +0000210 {
Andrey Andreev806ca602012-06-12 12:51:27 +0300211 header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
Daniel Hunsaker3b5b7f42013-02-22 19:17:56 -0700212 echo 'Your system folder path does not appear to be set correctly. Please open the following file and correct this: '.pathinfo(__FILE__, PATHINFO_BASENAME);
Andrey Andreev7cf682a2014-03-13 14:55:45 +0200213 exit(3); // EXIT_CONFIG
Derek Allard2067d1a2008-11-13 22:59:24 +0000214 }
215
Derek Jones0c1e4052010-03-02 14:31:31 -0600216/*
217 * -------------------------------------------------------------------
Derek Jones4b9c6292011-07-01 17:40:48 -0500218 * Now that we know the path, set the main path constants
Derek Jones0c1e4052010-03-02 14:31:31 -0600219 * -------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200220 */
Derek Jones0c1e4052010-03-02 14:31:31 -0600221 // The name of THIS file
222 define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
223
Barry Mienydd671972010-10-04 16:33:58 +0200224 // Path to the system folder
Andrey Andreev282592c2012-01-08 01:01:55 +0200225 define('BASEPATH', str_replace('\\', '/', $system_path));
Barry Mienydd671972010-10-04 16:33:58 +0200226
Derek Jones0c1e4052010-03-02 14:31:31 -0600227 // Path to the front controller (this file)
Andrey Andreev514896e2015-02-05 16:03:25 +0200228 define('FCPATH', dirname(__FILE__).'/');
Barry Mienydd671972010-10-04 16:33:58 +0200229
Derek Jones0c1e4052010-03-02 14:31:31 -0600230 // Name of the "system folder"
Barry Mienydd671972010-10-04 16:33:58 +0200231 define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/'));
Derek Jones0c1e4052010-03-02 14:31:31 -0600232
Derek Jones0c1e4052010-03-02 14:31:31 -0600233 // The path to the "application" folder
234 if (is_dir($application_folder))
235 {
Andrey Andreevcce91802012-06-12 13:25:31 +0300236 if (($_temp = realpath($application_folder)) !== FALSE)
Andrey Andreev079fbfc2012-06-12 02:26:58 +0300237 {
Andrey Andreev806ca602012-06-12 12:51:27 +0300238 $application_folder = $_temp;
Andrey Andreev079fbfc2012-06-12 02:26:58 +0300239 }
240
Andrey Andreev9f417d02013-10-14 12:24:36 +0300241 define('APPPATH', $application_folder.DIRECTORY_SEPARATOR);
Derek Jones0c1e4052010-03-02 14:31:31 -0600242 }
243 else
Barry Mienydd671972010-10-04 16:33:58 +0200244 {
Andrey Andreev9f417d02013-10-14 12:24:36 +0300245 if ( ! is_dir(BASEPATH.$application_folder.DIRECTORY_SEPARATOR))
Derek Jones0c1e4052010-03-02 14:31:31 -0600246 {
Andrey Andreev806ca602012-06-12 12:51:27 +0300247 header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
Daniel Hunsaker3b5b7f42013-02-22 19:17:56 -0700248 echo 'Your application folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF;
Andrey Andreev7cf682a2014-03-13 14:55:45 +0200249 exit(3); // EXIT_CONFIG
Derek Jones0c1e4052010-03-02 14:31:31 -0600250 }
Barry Mienydd671972010-10-04 16:33:58 +0200251
Andrey Andreev9f417d02013-10-14 12:24:36 +0300252 define('APPPATH', BASEPATH.$application_folder.DIRECTORY_SEPARATOR);
Derek Jones0c1e4052010-03-02 14:31:31 -0600253 }
Andrey Andreev282592c2012-01-08 01:01:55 +0200254
Joe Cianflone8eef9c72011-08-21 10:39:06 -0400255 // The path to the "views" folder
Andrey Andreev079fbfc2012-06-12 02:26:58 +0300256 if ( ! is_dir($view_folder))
Joe Cianflone8eef9c72011-08-21 10:39:06 -0400257 {
Andrey Andreev9f417d02013-10-14 12:24:36 +0300258 if ( ! empty($view_folder) && is_dir(APPPATH.$view_folder.DIRECTORY_SEPARATOR))
Andrey Andreev079fbfc2012-06-12 02:26:58 +0300259 {
260 $view_folder = APPPATH.$view_folder;
261 }
Andrey Andreev9f417d02013-10-14 12:24:36 +0300262 elseif ( ! is_dir(APPPATH.'views'.DIRECTORY_SEPARATOR))
Joe Cianflone8eef9c72011-08-21 10:39:06 -0400263 {
Andrey Andreev806ca602012-06-12 12:51:27 +0300264 header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
Daniel Hunsaker3b5b7f42013-02-22 19:17:56 -0700265 echo 'Your view folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF;
Andrey Andreev7cf682a2014-03-13 14:55:45 +0200266 exit(3); // EXIT_CONFIG
Joe Cianflone8eef9c72011-08-21 10:39:06 -0400267 }
Andrey Andreev079fbfc2012-06-12 02:26:58 +0300268 else
269 {
270 $view_folder = APPPATH.'views';
271 }
Joe Cianflone8eef9c72011-08-21 10:39:06 -0400272 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000273
Andrey Andreev806ca602012-06-12 12:51:27 +0300274 if (($_temp = realpath($view_folder)) !== FALSE)
Andrey Andreev079fbfc2012-06-12 02:26:58 +0300275 {
Andrey Andreev9f417d02013-10-14 12:24:36 +0300276 $view_folder = $_temp.DIRECTORY_SEPARATOR;
Andrey Andreev079fbfc2012-06-12 02:26:58 +0300277 }
278 else
279 {
Andrey Andreev9f417d02013-10-14 12:24:36 +0300280 $view_folder = rtrim($view_folder, '/\\').DIRECTORY_SEPARATOR;
Andrey Andreev079fbfc2012-06-12 02:26:58 +0300281 }
282
Andrey Andreevcce91802012-06-12 13:25:31 +0300283 define('VIEWPATH', $view_folder);
Andrey Andreev079fbfc2012-06-12 02:26:58 +0300284
Derek Allard2067d1a2008-11-13 22:59:24 +0000285/*
Derek Jones0c1e4052010-03-02 14:31:31 -0600286 * --------------------------------------------------------------------
287 * LOAD THE BOOTSTRAP FILE
288 * --------------------------------------------------------------------
289 *
290 * And away we go...
Derek Jones0c1e4052010-03-02 14:31:31 -0600291 */
Greg Aker3a746652011-04-19 10:59:47 -0500292require_once BASEPATH.'core/CodeIgniter.php';