blob: 818d1cbcdb7cca482e3b94712dd198d228cf4239 [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 *
Instructor, BCIT0e59db62019-01-01 08:34:36 -08009 * Copyright (c) 2014 - 2019, 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/)
Instructor, BCIT0e59db62019-01-01 08:34:36 -080032 * @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33 * @license https://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 *---------------------------------------------------------------
Andrey Andreeva990a8d2016-03-13 15:44:01 +020094 * SYSTEM DIRECTORY NAME
Derek Jones0c1e4052010-03-02 14:31:31 -060095 *---------------------------------------------------------------
96 *
Andrey Andreev29618832016-03-12 20:01:57 +020097 * This variable must contain the name of your "system" directory.
98 * Set the path if it is not in the same directory as this file.
Derek Jones0c1e4052010-03-02 14:31:31 -060099 */
Luigi Santivetti7bab4942019-06-16 07:40:53 +0000100 $system_path = '/var/www/system';
Derek Allard2067d1a2008-11-13 22:59:24 +0000101
102/*
Derek Jones0c1e4052010-03-02 14:31:31 -0600103 *---------------------------------------------------------------
Andrey Andreev29618832016-03-12 20:01:57 +0200104 * APPLICATION DIRECTORY NAME
Derek Jones0c1e4052010-03-02 14:31:31 -0600105 *---------------------------------------------------------------
106 *
107 * If you want this front controller to use a different "application"
Andrey Andreev29618832016-03-12 20:01:57 +0200108 * directory than the default one you can set its name here. The directory
109 * can also be renamed or relocated anywhere on your server. If you do,
110 * use an absolute (full) server path.
111 * For more info please see the user guide:
112 *
Andrey Andreevbd202c92016-01-11 12:50:18 +0200113 * https://codeigniter.com/user_guide/general/managing_apps.html
Derek Jones0c1e4052010-03-02 14:31:31 -0600114 *
115 * NO TRAILING SLASH!
Derek Jones0c1e4052010-03-02 14:31:31 -0600116 */
Luigi Santivetti7bab4942019-06-16 07:40:53 +0000117 $application_folder = '/var/www/application';
Andrey Andreev282592c2012-01-08 01:01:55 +0200118
Joe Cianflone8eef9c72011-08-21 10:39:06 -0400119/*
120 *---------------------------------------------------------------
Andrey Andreev29618832016-03-12 20:01:57 +0200121 * VIEW DIRECTORY NAME
Joe Cianflone8eef9c72011-08-21 10:39:06 -0400122 *---------------------------------------------------------------
Andrey Andreev282592c2012-01-08 01:01:55 +0200123 *
Andrey Andreev29618832016-03-12 20:01:57 +0200124 * If you want to move the view directory out of the application
125 * directory, set the path to it here. The directory can be renamed
Andrey Andreev282592c2012-01-08 01:01:55 +0200126 * and relocated anywhere on your server. If blank, it will default
Andrey Andreev29618832016-03-12 20:01:57 +0200127 * to the standard location inside your application directory.
128 * If you do move this, use an absolute (full) server path.
Joe Cianflone8eef9c72011-08-21 10:39:06 -0400129 *
130 * NO TRAILING SLASH!
Joe Cianflone8eef9c72011-08-21 10:39:06 -0400131 */
Andrey Andreev282592c2012-01-08 01:01:55 +0200132 $view_folder = '';
Joe Cianflone8eef9c72011-08-21 10:39:06 -0400133
Derek Allard2067d1a2008-11-13 22:59:24 +0000134
135/*
Derek Jones0c1e4052010-03-02 14:31:31 -0600136 * --------------------------------------------------------------------
137 * DEFAULT CONTROLLER
138 * --------------------------------------------------------------------
139 *
140 * Normally you will set your default controller in the routes.php file.
Barry Mienydd671972010-10-04 16:33:58 +0200141 * You can, however, force a custom routing by hard-coding a
Andrey Andreev282592c2012-01-08 01:01:55 +0200142 * specific controller class/function here. For most applications, you
Barry Mienydd671972010-10-04 16:33:58 +0200143 * WILL NOT set your routing here, but it's an option for those
Derek Jones0c1e4052010-03-02 14:31:31 -0600144 * special instances where you might want to override the standard
145 * routing in a specific front controller that shares a common CI installation.
146 *
Andrey Andreev282592c2012-01-08 01:01:55 +0200147 * IMPORTANT: If you set the routing here, NO OTHER controller will be
Derek Jones0c1e4052010-03-02 14:31:31 -0600148 * callable. In essence, this preference limits your application to ONE
Andrey Andreev282592c2012-01-08 01:01:55 +0200149 * specific controller. Leave the function name blank if you need
Derek Jones0c1e4052010-03-02 14:31:31 -0600150 * to call functions dynamically via the URI.
151 *
152 * Un-comment the $routing array below to use this feature
Derek Jones0c1e4052010-03-02 14:31:31 -0600153 */
Andrey Andreev29618832016-03-12 20:01:57 +0200154 // The directory name, relative to the "controllers" directory. Leave blank
155 // if your controller is not in a sub-directory within the "controllers" one
Derek Jones0c1e4052010-03-02 14:31:31 -0600156 // $routing['directory'] = '';
Barry Mienydd671972010-10-04 16:33:58 +0200157
vlakoffe40e56f2012-07-15 12:57:38 +0200158 // The controller class file name. Example: mycontroller
Derek Jones0c1e4052010-03-02 14:31:31 -0600159 // $routing['controller'] = '';
Barry Mienydd671972010-10-04 16:33:58 +0200160
161 // The controller function you wish to be called.
Derek Jones0c1e4052010-03-02 14:31:31 -0600162 // $routing['function'] = '';
Derek Allard2067d1a2008-11-13 22:59:24 +0000163
164
165/*
Derek Jones0c1e4052010-03-02 14:31:31 -0600166 * -------------------------------------------------------------------
Derek Jones4b9c6292011-07-01 17:40:48 -0500167 * CUSTOM CONFIG VALUES
Derek Jones0c1e4052010-03-02 14:31:31 -0600168 * -------------------------------------------------------------------
169 *
170 * The $assign_to_config array below will be passed dynamically to the
Barry Mienydd671972010-10-04 16:33:58 +0200171 * config class when initialized. This allows you to set custom config
172 * items or override any default config values found in the config.php file.
Derek Jones0c1e4052010-03-02 14:31:31 -0600173 * This can be handy as it permits you to share one application between
Barry Mienydd671972010-10-04 16:33:58 +0200174 * multiple front controller files, with each file containing different
Derek Jones0c1e4052010-03-02 14:31:31 -0600175 * config values.
176 *
177 * Un-comment the $assign_to_config array below to use this feature
Derek Jones0c1e4052010-03-02 14:31:31 -0600178 */
179 // $assign_to_config['name_of_config_item'] = 'value of config item';
180
181
182
183// --------------------------------------------------------------------
Derek Jones4b9c6292011-07-01 17:40:48 -0500184// END OF USER CONFIGURABLE SETTINGS. DO NOT EDIT BELOW THIS LINE
Derek Jones0c1e4052010-03-02 14:31:31 -0600185// --------------------------------------------------------------------
186
joelcoxbf2b9122011-01-16 15:24:43 +0100187/*
188 * ---------------------------------------------------------------
Derek Jones4b9c6292011-07-01 17:40:48 -0500189 * Resolve the system path for increased reliability
Derek Jones0c1e4052010-03-02 14:31:31 -0600190 * ---------------------------------------------------------------
191 */
Phil Sturgeon01d1a5b2011-02-07 10:54:06 +0000192
193 // Set the current directory correctly for CLI requests
194 if (defined('STDIN'))
195 {
196 chdir(dirname(__FILE__));
197 }
198
Andrey Andreev806ca602012-06-12 12:51:27 +0300199 if (($_temp = realpath($system_path)) !== FALSE)
Derek Allard2067d1a2008-11-13 22:59:24 +0000200 {
Andrey Andreev29618832016-03-12 20:01:57 +0200201 $system_path = $_temp.DIRECTORY_SEPARATOR;
Derek Allard2067d1a2008-11-13 22:59:24 +0000202 }
Andrey Andreev079fbfc2012-06-12 02:26:58 +0300203 else
204 {
205 // Ensure there's a trailing slash
Andrey Andreev29618832016-03-12 20:01:57 +0200206 $system_path = strtr(
207 rtrim($system_path, '/\\'),
208 '/\\',
209 DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
210 ).DIRECTORY_SEPARATOR;
Andrey Andreev079fbfc2012-06-12 02:26:58 +0300211 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000212
Derek Joneseba35082010-03-22 10:43:56 -0500213 // Is the system path correct?
Derek Jones0c1e4052010-03-02 14:31:31 -0600214 if ( ! is_dir($system_path))
Derek Allard2067d1a2008-11-13 22:59:24 +0000215 {
Andrey Andreev806ca602012-06-12 12:51:27 +0300216 header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
Daniel Hunsaker3b5b7f42013-02-22 19:17:56 -0700217 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 +0200218 exit(3); // EXIT_CONFIG
Derek Allard2067d1a2008-11-13 22:59:24 +0000219 }
220
Derek Jones0c1e4052010-03-02 14:31:31 -0600221/*
222 * -------------------------------------------------------------------
Derek Jones4b9c6292011-07-01 17:40:48 -0500223 * Now that we know the path, set the main path constants
Derek Jones0c1e4052010-03-02 14:31:31 -0600224 * -------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200225 */
Derek Jones0c1e4052010-03-02 14:31:31 -0600226 // The name of THIS file
227 define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
228
Andrey Andreev29618832016-03-12 20:01:57 +0200229 // Path to the system directory
230 define('BASEPATH', $system_path);
Barry Mienydd671972010-10-04 16:33:58 +0200231
Andrey Andreev29618832016-03-12 20:01:57 +0200232 // Path to the front controller (this file) directory
233 define('FCPATH', dirname(__FILE__).DIRECTORY_SEPARATOR);
Barry Mienydd671972010-10-04 16:33:58 +0200234
Andrey Andreev29618832016-03-12 20:01:57 +0200235 // Name of the "system" directory
236 define('SYSDIR', basename(BASEPATH));
Derek Jones0c1e4052010-03-02 14:31:31 -0600237
Andrey Andreev29618832016-03-12 20:01:57 +0200238 // The path to the "application" directory
Derek Jones0c1e4052010-03-02 14:31:31 -0600239 if (is_dir($application_folder))
240 {
Andrey Andreevcce91802012-06-12 13:25:31 +0300241 if (($_temp = realpath($application_folder)) !== FALSE)
Andrey Andreev079fbfc2012-06-12 02:26:58 +0300242 {
Andrey Andreevca956162016-03-12 20:04:08 +0200243 $application_folder = $_temp;
Joe Cianflone8eef9c72011-08-21 10:39:06 -0400244 }
Andrey Andreev079fbfc2012-06-12 02:26:58 +0300245 else
246 {
Andrey Andreev29618832016-03-12 20:01:57 +0200247 $application_folder = strtr(
248 rtrim($application_folder, '/\\'),
249 '/\\',
250 DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
251 );
Andrey Andreev079fbfc2012-06-12 02:26:58 +0300252 }
Joe Cianflone8eef9c72011-08-21 10:39:06 -0400253 }
Andrey Andreev29618832016-03-12 20:01:57 +0200254 elseif (is_dir(BASEPATH.$application_folder.DIRECTORY_SEPARATOR))
Andrey Andreev079fbfc2012-06-12 02:26:58 +0300255 {
Andrey Andreev29618832016-03-12 20:01:57 +0200256 $application_folder = BASEPATH.strtr(
257 trim($application_folder, '/\\'),
258 '/\\',
259 DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
260 );
Andrey Andreev079fbfc2012-06-12 02:26:58 +0300261 }
262 else
263 {
Andrey Andreev29618832016-03-12 20:01:57 +0200264 header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
265 echo 'Your application folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF;
266 exit(3); // EXIT_CONFIG
Andrey Andreev079fbfc2012-06-12 02:26:58 +0300267 }
268
Andrey Andreev29618832016-03-12 20:01:57 +0200269 define('APPPATH', $application_folder.DIRECTORY_SEPARATOR);
270
271 // The path to the "views" directory
272 if ( ! isset($view_folder[0]) && is_dir(APPPATH.'views'.DIRECTORY_SEPARATOR))
273 {
274 $view_folder = APPPATH.'views';
275 }
276 elseif (is_dir($view_folder))
277 {
278 if (($_temp = realpath($view_folder)) !== FALSE)
279 {
280 $view_folder = $_temp;
281 }
282 else
283 {
284 $view_folder = strtr(
285 rtrim($view_folder, '/\\'),
286 '/\\',
287 DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
288 );
289 }
290 }
291 elseif (is_dir(APPPATH.$view_folder.DIRECTORY_SEPARATOR))
292 {
293 $view_folder = APPPATH.strtr(
294 trim($view_folder, '/\\'),
295 '/\\',
296 DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
297 );
298 }
299 else
300 {
301 header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
302 echo 'Your view folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF;
303 exit(3); // EXIT_CONFIG
304 }
305
306 define('VIEWPATH', $view_folder.DIRECTORY_SEPARATOR);
Andrey Andreev079fbfc2012-06-12 02:26:58 +0300307
Derek Allard2067d1a2008-11-13 22:59:24 +0000308/*
Derek Jones0c1e4052010-03-02 14:31:31 -0600309 * --------------------------------------------------------------------
310 * LOAD THE BOOTSTRAP FILE
311 * --------------------------------------------------------------------
312 *
313 * And away we go...
Derek Jones0c1e4052010-03-02 14:31:31 -0600314 */
Greg Aker3a746652011-04-19 10:59:47 -0500315require_once BASEPATH.'core/CodeIgniter.php';