Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1 | <?php |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 2 | /** |
| 3 | * CodeIgniter |
| 4 | * |
| 5 | * An open source application development framework for PHP 5.1.6 or newer |
| 6 | * |
| 7 | * NOTICE OF LICENSE |
Andrey Andreev | 282592c | 2012-01-08 01:01:55 +0200 | [diff] [blame^] | 8 | * |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 9 | * Licensed under the Open Software License version 3.0 |
Andrey Andreev | 282592c | 2012-01-08 01:01:55 +0200 | [diff] [blame^] | 10 | * |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 11 | * This source file is subject to the Open Software License (OSL 3.0) that is |
| 12 | * bundled with this package in the files license.txt / license.rst. It is |
| 13 | * also available through the world wide web at this URL: |
| 14 | * http://opensource.org/licenses/OSL-3.0 |
| 15 | * If you did not receive a copy of the license and are unable to obtain it |
| 16 | * through the world wide web, please send an email to |
| 17 | * licensing@ellislab.com so we can send you a copy immediately. |
| 18 | * |
| 19 | * @package CodeIgniter |
| 20 | * @author EllisLab Dev Team |
Greg Aker | 0defe5d | 2012-01-01 18:46:41 -0600 | [diff] [blame] | 21 | * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 22 | * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) |
| 23 | * @link http://codeigniter.com |
| 24 | * @since Version 1.0 |
| 25 | * @filesource |
| 26 | */ |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 27 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 28 | /* |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 29 | *--------------------------------------------------------------- |
joelcox | cee8075 | 2011-01-15 23:09:47 +0100 | [diff] [blame] | 30 | * APPLICATION ENVIRONMENT |
| 31 | *--------------------------------------------------------------- |
| 32 | * |
| 33 | * You can load different configurations depending on your |
joelcox | bf2b912 | 2011-01-16 15:24:43 +0100 | [diff] [blame] | 34 | * current environment. Setting the environment also influences |
Phil Sturgeon | d88b315 | 2011-02-02 21:19:25 +0000 | [diff] [blame] | 35 | * things like logging and error reporting. |
| 36 | * |
| 37 | * This can be set to anything, but default usage is: |
| 38 | * |
Derek Jones | 4b9c629 | 2011-07-01 17:40:48 -0500 | [diff] [blame] | 39 | * development |
| 40 | * testing |
| 41 | * production |
Phil Sturgeon | d88b315 | 2011-02-02 21:19:25 +0000 | [diff] [blame] | 42 | * |
| 43 | * NOTE: If you change these, also change the error_reporting() code below |
joelcox | cee8075 | 2011-01-15 23:09:47 +0100 | [diff] [blame] | 44 | */ |
| 45 | define('ENVIRONMENT', 'development'); |
Phil Sturgeon | d88b315 | 2011-02-02 21:19:25 +0000 | [diff] [blame] | 46 | /* |
| 47 | *--------------------------------------------------------------- |
| 48 | * ERROR REPORTING |
| 49 | *--------------------------------------------------------------- |
| 50 | * |
| 51 | * Different environments will require different levels of error reporting. |
| 52 | * By default development will show errors but testing and live will hide them. |
| 53 | */ |
| 54 | |
Phil Sturgeon | 05fa611 | 2011-04-06 22:57:43 +0100 | [diff] [blame] | 55 | if (defined('ENVIRONMENT')) |
| 56 | { |
Phil Sturgeon | d88b315 | 2011-02-02 21:19:25 +0000 | [diff] [blame] | 57 | switch (ENVIRONMENT) |
| 58 | { |
| 59 | case 'development': |
Dan Horrigan | 0e95b8b | 2011-08-21 09:34:02 -0400 | [diff] [blame] | 60 | error_reporting(-1); |
Phil Sturgeon | d88b315 | 2011-02-02 21:19:25 +0000 | [diff] [blame] | 61 | break; |
Phil Sturgeon | d88b315 | 2011-02-02 21:19:25 +0000 | [diff] [blame] | 62 | case 'testing': |
| 63 | case 'production': |
| 64 | error_reporting(0); |
| 65 | break; |
Phil Sturgeon | d88b315 | 2011-02-02 21:19:25 +0000 | [diff] [blame] | 66 | default: |
| 67 | exit('The application environment is not set correctly.'); |
| 68 | } |
Phil Sturgeon | 05fa611 | 2011-04-06 22:57:43 +0100 | [diff] [blame] | 69 | } |
joelcox | cee8075 | 2011-01-15 23:09:47 +0100 | [diff] [blame] | 70 | |
| 71 | /* |
| 72 | *--------------------------------------------------------------- |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 73 | * SYSTEM FOLDER NAME |
| 74 | *--------------------------------------------------------------- |
| 75 | * |
| 76 | * This variable must contain the name of your "system" folder. |
Derek Jones | 4b9c629 | 2011-07-01 17:40:48 -0500 | [diff] [blame] | 77 | * Include the path if the folder is not in the same directory |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 78 | * as this file. |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 79 | */ |
Phil Sturgeon | d88b315 | 2011-02-02 21:19:25 +0000 | [diff] [blame] | 80 | $system_path = 'system'; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 81 | |
| 82 | /* |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 83 | *--------------------------------------------------------------- |
| 84 | * APPLICATION FOLDER NAME |
| 85 | *--------------------------------------------------------------- |
| 86 | * |
| 87 | * If you want this front controller to use a different "application" |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 88 | * folder then the default one you can set its name here. The folder |
Andrey Andreev | 282592c | 2012-01-08 01:01:55 +0200 | [diff] [blame^] | 89 | * can also be renamed or relocated anywhere on your server. If |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 90 | * you do, use a full server path. For more info please see the user guide: |
| 91 | * http://codeigniter.com/user_guide/general/managing_apps.html |
| 92 | * |
| 93 | * NO TRAILING SLASH! |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 94 | */ |
Phil Sturgeon | d88b315 | 2011-02-02 21:19:25 +0000 | [diff] [blame] | 95 | $application_folder = 'application'; |
Andrey Andreev | 282592c | 2012-01-08 01:01:55 +0200 | [diff] [blame^] | 96 | |
Joe Cianflone | 8eef9c7 | 2011-08-21 10:39:06 -0400 | [diff] [blame] | 97 | /* |
| 98 | *--------------------------------------------------------------- |
| 99 | * VIEW FOLDER NAME |
| 100 | *--------------------------------------------------------------- |
Andrey Andreev | 282592c | 2012-01-08 01:01:55 +0200 | [diff] [blame^] | 101 | * |
| 102 | * If you want to move the view folder out of the application |
Joe Cianflone | 8eef9c7 | 2011-08-21 10:39:06 -0400 | [diff] [blame] | 103 | * folder set the path to the folder here. The folder can be renamed |
Andrey Andreev | 282592c | 2012-01-08 01:01:55 +0200 | [diff] [blame^] | 104 | * and relocated anywhere on your server. If blank, it will default |
| 105 | * to the standard location inside your application folder. If you |
| 106 | * do move this, use the full server path to this folder. |
Joe Cianflone | 8eef9c7 | 2011-08-21 10:39:06 -0400 | [diff] [blame] | 107 | * |
| 108 | * NO TRAILING SLASH! |
Joe Cianflone | 8eef9c7 | 2011-08-21 10:39:06 -0400 | [diff] [blame] | 109 | */ |
Andrey Andreev | 282592c | 2012-01-08 01:01:55 +0200 | [diff] [blame^] | 110 | $view_folder = ''; |
Joe Cianflone | 8eef9c7 | 2011-08-21 10:39:06 -0400 | [diff] [blame] | 111 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 112 | |
| 113 | /* |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 114 | * -------------------------------------------------------------------- |
| 115 | * DEFAULT CONTROLLER |
| 116 | * -------------------------------------------------------------------- |
| 117 | * |
| 118 | * Normally you will set your default controller in the routes.php file. |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 119 | * You can, however, force a custom routing by hard-coding a |
Andrey Andreev | 282592c | 2012-01-08 01:01:55 +0200 | [diff] [blame^] | 120 | * specific controller class/function here. For most applications, you |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 121 | * WILL NOT set your routing here, but it's an option for those |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 122 | * special instances where you might want to override the standard |
| 123 | * routing in a specific front controller that shares a common CI installation. |
| 124 | * |
Andrey Andreev | 282592c | 2012-01-08 01:01:55 +0200 | [diff] [blame^] | 125 | * IMPORTANT: If you set the routing here, NO OTHER controller will be |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 126 | * callable. In essence, this preference limits your application to ONE |
Andrey Andreev | 282592c | 2012-01-08 01:01:55 +0200 | [diff] [blame^] | 127 | * specific controller. Leave the function name blank if you need |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 128 | * to call functions dynamically via the URI. |
| 129 | * |
| 130 | * Un-comment the $routing array below to use this feature |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 131 | */ |
Derek Jones | 4b9c629 | 2011-07-01 17:40:48 -0500 | [diff] [blame] | 132 | // The directory name, relative to the "controllers" folder. Leave blank |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 133 | // if your controller is not in a sub-folder within the "controllers" folder |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 134 | // $routing['directory'] = ''; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 135 | |
Derek Jones | 4b9c629 | 2011-07-01 17:40:48 -0500 | [diff] [blame] | 136 | // The controller class file name. Example: Mycontroller |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 137 | // $routing['controller'] = ''; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 138 | |
| 139 | // The controller function you wish to be called. |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 140 | // $routing['function'] = ''; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 141 | |
| 142 | |
| 143 | /* |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 144 | * ------------------------------------------------------------------- |
Derek Jones | 4b9c629 | 2011-07-01 17:40:48 -0500 | [diff] [blame] | 145 | * CUSTOM CONFIG VALUES |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 146 | * ------------------------------------------------------------------- |
| 147 | * |
| 148 | * The $assign_to_config array below will be passed dynamically to the |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 149 | * config class when initialized. This allows you to set custom config |
| 150 | * items or override any default config values found in the config.php file. |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 151 | * This can be handy as it permits you to share one application between |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 152 | * multiple front controller files, with each file containing different |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 153 | * config values. |
| 154 | * |
| 155 | * Un-comment the $assign_to_config array below to use this feature |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 156 | */ |
| 157 | // $assign_to_config['name_of_config_item'] = 'value of config item'; |
| 158 | |
| 159 | |
| 160 | |
| 161 | // -------------------------------------------------------------------- |
Derek Jones | 4b9c629 | 2011-07-01 17:40:48 -0500 | [diff] [blame] | 162 | // END OF USER CONFIGURABLE SETTINGS. DO NOT EDIT BELOW THIS LINE |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 163 | // -------------------------------------------------------------------- |
| 164 | |
joelcox | bf2b912 | 2011-01-16 15:24:43 +0100 | [diff] [blame] | 165 | /* |
| 166 | * --------------------------------------------------------------- |
Derek Jones | 4b9c629 | 2011-07-01 17:40:48 -0500 | [diff] [blame] | 167 | * Resolve the system path for increased reliability |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 168 | * --------------------------------------------------------------- |
| 169 | */ |
Phil Sturgeon | 01d1a5b | 2011-02-07 10:54:06 +0000 | [diff] [blame] | 170 | |
| 171 | // Set the current directory correctly for CLI requests |
| 172 | if (defined('STDIN')) |
| 173 | { |
| 174 | chdir(dirname(__FILE__)); |
| 175 | } |
| 176 | |
Greg Aker | 0846d74 | 2010-04-08 11:47:33 -0500 | [diff] [blame] | 177 | if (realpath($system_path) !== FALSE) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 178 | { |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 179 | $system_path = realpath($system_path).'/'; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 180 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 181 | |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 182 | // ensure there's a trailing slash |
| 183 | $system_path = rtrim($system_path, '/').'/'; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 184 | |
Derek Jones | eba3508 | 2010-03-22 10:43:56 -0500 | [diff] [blame] | 185 | // Is the system path correct? |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 186 | if ( ! is_dir($system_path)) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 187 | { |
Andrey Andreev | 282592c | 2012-01-08 01:01:55 +0200 | [diff] [blame^] | 188 | exit('Your system folder path does not appear to be set correctly. Please open the following file and correct this: '.pathinfo(__FILE__, PATHINFO_BASENAME)); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 189 | } |
| 190 | |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 191 | /* |
| 192 | * ------------------------------------------------------------------- |
Derek Jones | 4b9c629 | 2011-07-01 17:40:48 -0500 | [diff] [blame] | 193 | * Now that we know the path, set the main path constants |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 194 | * ------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 195 | */ |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 196 | // The name of THIS file |
| 197 | define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME)); |
| 198 | |
| 199 | // The PHP file extension |
Greg Aker | 3a74665 | 2011-04-19 10:59:47 -0500 | [diff] [blame] | 200 | // this global constant is deprecated. |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 201 | define('EXT', '.php'); |
| 202 | |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 203 | // Path to the system folder |
Andrey Andreev | 282592c | 2012-01-08 01:01:55 +0200 | [diff] [blame^] | 204 | define('BASEPATH', str_replace('\\', '/', $system_path)); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 205 | |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 206 | // Path to the front controller (this file) |
| 207 | define('FCPATH', str_replace(SELF, '', __FILE__)); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 208 | |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 209 | // Name of the "system folder" |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 210 | define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/')); |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 211 | |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 212 | // The path to the "application" folder |
| 213 | if (is_dir($application_folder)) |
| 214 | { |
| 215 | define('APPPATH', $application_folder.'/'); |
| 216 | } |
| 217 | else |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 218 | { |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 219 | if ( ! is_dir(BASEPATH.$application_folder.'/')) |
| 220 | { |
Andrey Andreev | 282592c | 2012-01-08 01:01:55 +0200 | [diff] [blame^] | 221 | exit('Your application folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF); |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 222 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 223 | |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 224 | define('APPPATH', BASEPATH.$application_folder.'/'); |
| 225 | } |
Andrey Andreev | 282592c | 2012-01-08 01:01:55 +0200 | [diff] [blame^] | 226 | |
Joe Cianflone | 8eef9c7 | 2011-08-21 10:39:06 -0400 | [diff] [blame] | 227 | // The path to the "views" folder |
Andrey Andreev | 282592c | 2012-01-08 01:01:55 +0200 | [diff] [blame^] | 228 | if (is_dir($view_folder)) |
Joe Cianflone | 8eef9c7 | 2011-08-21 10:39:06 -0400 | [diff] [blame] | 229 | { |
| 230 | define ('VIEWPATH', $view_folder .'/'); |
| 231 | } |
Andrey Andreev | 282592c | 2012-01-08 01:01:55 +0200 | [diff] [blame^] | 232 | else |
Joe Cianflone | 8eef9c7 | 2011-08-21 10:39:06 -0400 | [diff] [blame] | 233 | { |
| 234 | if ( ! is_dir(APPPATH.'views/')) |
| 235 | { |
Andrey Andreev | 282592c | 2012-01-08 01:01:55 +0200 | [diff] [blame^] | 236 | exit('Your view folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF); |
Joe Cianflone | 8eef9c7 | 2011-08-21 10:39:06 -0400 | [diff] [blame] | 237 | } |
Andrey Andreev | 282592c | 2012-01-08 01:01:55 +0200 | [diff] [blame^] | 238 | |
| 239 | define ('VIEWPATH', APPPATH.'views/' ); |
Joe Cianflone | 8eef9c7 | 2011-08-21 10:39:06 -0400 | [diff] [blame] | 240 | } |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 241 | |
| 242 | /* |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 243 | * -------------------------------------------------------------------- |
| 244 | * LOAD THE BOOTSTRAP FILE |
| 245 | * -------------------------------------------------------------------- |
| 246 | * |
| 247 | * And away we go... |
Derek Jones | 0c1e405 | 2010-03-02 14:31:31 -0600 | [diff] [blame] | 248 | */ |
Greg Aker | 3a74665 | 2011-04-19 10:59:47 -0500 | [diff] [blame] | 249 | require_once BASEPATH.'core/CodeIgniter.php'; |
Derek Jones | 3b890ba | 2010-02-17 18:13:15 -0600 | [diff] [blame] | 250 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 251 | /* End of file index.php */ |
Andrey Andreev | 282592c | 2012-01-08 01:01:55 +0200 | [diff] [blame^] | 252 | /* Location: ./index.php */ |