index.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <?php
  2. /**
  3. * CodeIgniter
  4. *
  5. * An open source application development framework for PHP
  6. *
  7. * This content is released under the MIT License (MIT)
  8. *
  9. * Copyright (c) 2014 - 2016, British Columbia Institute of Technology
  10. *
  11. * 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:
  17. *
  18. * 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
  31. * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
  32. * @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/)
  33. * @license http://opensource.org/licenses/MIT MIT License
  34. * @link https://codeigniter.com
  35. * @since Version 1.0.0
  36. * @filesource
  37. */
  38. /*
  39. *---------------------------------------------------------------
  40. * APPLICATION ENVIRONMENT
  41. *---------------------------------------------------------------
  42. *
  43. * You can load different configurations depending on your
  44. * current environment. Setting the environment also influences
  45. * things like logging and error reporting.
  46. *
  47. * This can be set to anything, but default usage is:
  48. *
  49. * development
  50. * testing
  51. * production
  52. *
  53. * NOTE: If you change these, also change the error_reporting() code below
  54. */
  55. define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'production');
  56. /*
  57. *---------------------------------------------------------------
  58. * ERROR REPORTING
  59. *---------------------------------------------------------------
  60. *
  61. * Different environments will require different levels of error reporting.
  62. * By default development will show errors but testing and live will hide them.
  63. */
  64. switch (ENVIRONMENT)
  65. {
  66. case 'development':
  67. error_reporting(E_ALL & ~E_NOTICE);
  68. ini_set('display_errors', 1);
  69. break;
  70. case 'testing':
  71. case 'production':
  72. ini_set('display_errors', 0);
  73. if (version_compare(PHP_VERSION, '5.3', '>='))
  74. {
  75. error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
  76. }
  77. else
  78. {
  79. error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
  80. }
  81. break;
  82. default:
  83. header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
  84. echo 'The application environment is not set correctly.';
  85. exit(1); // EXIT_ERROR
  86. }
  87. /*
  88. *---------------------------------------------------------------
  89. * SYSTEM DIRECTORY NAME
  90. *---------------------------------------------------------------
  91. *
  92. * This variable must contain the name of your "system" directory.
  93. * Set the path if it is not in the same directory as this file.
  94. */
  95. $system_path = 'system';
  96. /*
  97. *---------------------------------------------------------------
  98. * APPLICATION DIRECTORY NAME
  99. *---------------------------------------------------------------
  100. *
  101. * If you want this front controller to use a different "application"
  102. * directory than the default one you can set its name here. The directory
  103. * can also be renamed or relocated anywhere on your server. If you do,
  104. * use an absolute (full) server path.
  105. * For more info please see the user guide:
  106. *
  107. * https://codeigniter.com/user_guide/general/managing_apps.html
  108. *
  109. * NO TRAILING SLASH!
  110. */
  111. $application_folder = 'application';
  112. /*
  113. *---------------------------------------------------------------
  114. * VIEW DIRECTORY NAME
  115. *---------------------------------------------------------------
  116. *
  117. * If you want to move the view directory out of the application
  118. * directory, set the path to it here. The directory can be renamed
  119. * and relocated anywhere on your server. If blank, it will default
  120. * to the standard location inside your application directory.
  121. * If you do move this, use an absolute (full) server path.
  122. *
  123. * NO TRAILING SLASH!
  124. */
  125. $view_folder = '';
  126. /*
  127. * --------------------------------------------------------------------
  128. * DEFAULT CONTROLLER
  129. * --------------------------------------------------------------------
  130. *
  131. * Normally you will set your default controller in the routes.php file.
  132. * You can, however, force a custom routing by hard-coding a
  133. * specific controller class/function here. For most applications, you
  134. * WILL NOT set your routing here, but it's an option for those
  135. * special instances where you might want to override the standard
  136. * routing in a specific front controller that shares a common CI installation.
  137. *
  138. * IMPORTANT: If you set the routing here, NO OTHER controller will be
  139. * callable. In essence, this preference limits your application to ONE
  140. * specific controller. Leave the function name blank if you need
  141. * to call functions dynamically via the URI.
  142. *
  143. * Un-comment the $routing array below to use this feature
  144. */
  145. // The directory name, relative to the "controllers" directory. Leave blank
  146. // if your controller is not in a sub-directory within the "controllers" one
  147. // $routing['directory'] = '';
  148. // The controller class file name. Example: mycontroller
  149. // $routing['controller'] = '';
  150. // The controller function you wish to be called.
  151. // $routing['function'] = '';
  152. /*
  153. * -------------------------------------------------------------------
  154. * CUSTOM CONFIG VALUES
  155. * -------------------------------------------------------------------
  156. *
  157. * The $assign_to_config array below will be passed dynamically to the
  158. * config class when initialized. This allows you to set custom config
  159. * items or override any default config values found in the config.php file.
  160. * This can be handy as it permits you to share one application between
  161. * multiple front controller files, with each file containing different
  162. * config values.
  163. *
  164. * Un-comment the $assign_to_config array below to use this feature
  165. */
  166. // $assign_to_config['name_of_config_item'] = 'value of config item';
  167. // --------------------------------------------------------------------
  168. // END OF USER CONFIGURABLE SETTINGS. DO NOT EDIT BELOW THIS LINE
  169. // --------------------------------------------------------------------
  170. /*
  171. * ---------------------------------------------------------------
  172. * Resolve the system path for increased reliability
  173. * ---------------------------------------------------------------
  174. */
  175. // Set the current directory correctly for CLI requests
  176. if (defined('STDIN'))
  177. {
  178. chdir(dirname(__FILE__));
  179. }
  180. if (($_temp = realpath($system_path)) !== FALSE)
  181. {
  182. $system_path = $_temp.DIRECTORY_SEPARATOR;
  183. }
  184. else
  185. {
  186. // Ensure there's a trailing slash
  187. $system_path = strtr(
  188. rtrim($system_path, '/\\'),
  189. '/\\',
  190. DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
  191. ).DIRECTORY_SEPARATOR;
  192. }
  193. // Is the system path correct?
  194. if ( ! is_dir($system_path))
  195. {
  196. header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
  197. echo 'Your system folder path does not appear to be set correctly. Please open the following file and correct this: '.pathinfo(__FILE__, PATHINFO_BASENAME);
  198. exit(3); // EXIT_CONFIG
  199. }
  200. /*
  201. * -------------------------------------------------------------------
  202. * Now that we know the path, set the main path constants
  203. * -------------------------------------------------------------------
  204. */
  205. // The name of THIS file
  206. define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
  207. // Path to the system directory
  208. define('BASEPATH', $system_path);
  209. // Path to the front controller (this file) directory
  210. define('FCPATH', dirname(__FILE__).DIRECTORY_SEPARATOR);
  211. // Name of the "system" directory
  212. define('SYSDIR', basename(BASEPATH));
  213. // The path to the "application" directory
  214. if (is_dir($application_folder))
  215. {
  216. if (($_temp = realpath($application_folder)) !== FALSE)
  217. {
  218. $application_folder = $_temp;
  219. }
  220. else
  221. {
  222. $application_folder = strtr(
  223. rtrim($application_folder, '/\\'),
  224. '/\\',
  225. DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
  226. );
  227. }
  228. }
  229. elseif (is_dir(BASEPATH.$application_folder.DIRECTORY_SEPARATOR))
  230. {
  231. $application_folder = BASEPATH.strtr(
  232. trim($application_folder, '/\\'),
  233. '/\\',
  234. DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
  235. );
  236. }
  237. else
  238. {
  239. header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
  240. echo 'Your application folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF;
  241. exit(3); // EXIT_CONFIG
  242. }
  243. define('APPPATH', $application_folder.DIRECTORY_SEPARATOR);
  244. // The path to the "views" directory
  245. if ( ! isset($view_folder[0]) && is_dir(APPPATH.'views'.DIRECTORY_SEPARATOR))
  246. {
  247. $view_folder = APPPATH.'views';
  248. }
  249. elseif (is_dir($view_folder))
  250. {
  251. if (($_temp = realpath($view_folder)) !== FALSE)
  252. {
  253. $view_folder = $_temp;
  254. }
  255. else
  256. {
  257. $view_folder = strtr(
  258. rtrim($view_folder, '/\\'),
  259. '/\\',
  260. DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
  261. );
  262. }
  263. }
  264. elseif (is_dir(APPPATH.$view_folder.DIRECTORY_SEPARATOR))
  265. {
  266. $view_folder = APPPATH.strtr(
  267. trim($view_folder, '/\\'),
  268. '/\\',
  269. DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
  270. );
  271. }
  272. else
  273. {
  274. header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
  275. echo 'Your view folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF;
  276. exit(3); // EXIT_CONFIG
  277. }
  278. define('VIEWPATH', $view_folder.DIRECTORY_SEPARATOR);
  279. /*
  280. * --------------------------------------------------------------------
  281. * LOAD THE BOOTSTRAP FILE
  282. * --------------------------------------------------------------------
  283. *
  284. * And away we go...
  285. */
  286. require_once BASEPATH.'core/CodeIgniter.php';