index.php 8.4 KB

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