/public/index.php

https://github.com/creative-area/CodeIgniter · PHP · 210 lines · 53 code · 31 blank · 126 comment · 8 complexity · 6d15b6f4f3503e149c54d113b6db9cd8 MD5 · raw file

  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. */
  20. $env_path = dirname(__FILE__).'/../application/config/env.php';
  21. if ( file_exists($env_path)) {
  22. require_once($env_path);
  23. if (!defined('ENVIRONMENT')) {
  24. define('ENVIRONMENT', 'production');
  25. }
  26. }
  27. /*
  28. *---------------------------------------------------------------
  29. * ERROR REPORTING
  30. *---------------------------------------------------------------
  31. *
  32. * Different environments will require different levels of error reporting.
  33. * By default development will show errors but testing and live will hide them.
  34. */
  35. switch (ENVIRONMENT)
  36. {
  37. case 'development':
  38. case 'testing':
  39. error_reporting(E_ALL);
  40. break;
  41. case 'production':
  42. error_reporting(0);
  43. break;
  44. default:
  45. exit('The application environment is not set correctly.');
  46. }
  47. /*
  48. *---------------------------------------------------------------
  49. * SYSTEM FOLDER NAME
  50. *---------------------------------------------------------------
  51. *
  52. * This variable must contain the name of your "system" folder.
  53. * Include the path if the folder is not in the same directory
  54. * as this file.
  55. *
  56. */
  57. $system_path = dirname(__FILE__).'/../system';
  58. /*
  59. *---------------------------------------------------------------
  60. * APPLICATION FOLDER NAME
  61. *---------------------------------------------------------------
  62. *
  63. * If you want this front controller to use a different "application"
  64. * folder then the default one you can set its name here. The folder
  65. * can also be renamed or relocated anywhere on your server. If
  66. * you do, use a full server path. For more info please see the user guide:
  67. * http://codeigniter.com/user_guide/general/managing_apps.html
  68. *
  69. * NO TRAILING SLASH!
  70. *
  71. */
  72. $application_folder = dirname(__FILE__).'/../application';
  73. /*
  74. * --------------------------------------------------------------------
  75. * DEFAULT CONTROLLER
  76. * --------------------------------------------------------------------
  77. *
  78. * Normally you will set your default controller in the routes.php file.
  79. * You can, however, force a custom routing by hard-coding a
  80. * specific controller class/function here. For most applications, you
  81. * WILL NOT set your routing here, but it's an option for those
  82. * special instances where you might want to override the standard
  83. * routing in a specific front controller that shares a common CI installation.
  84. *
  85. * IMPORTANT: If you set the routing here, NO OTHER controller will be
  86. * callable. In essence, this preference limits your application to ONE
  87. * specific controller. Leave the function name blank if you need
  88. * to call functions dynamically via the URI.
  89. *
  90. * Un-comment the $routing array below to use this feature
  91. *
  92. */
  93. // The directory name, relative to the "controllers" folder. Leave blank
  94. // if your controller is not in a sub-folder within the "controllers" folder
  95. // $routing['directory'] = '';
  96. // The controller class file name. Example: Mycontroller
  97. // $routing['controller'] = '';
  98. // The controller function you wish to be called.
  99. // $routing['function'] = '';
  100. /*
  101. * -------------------------------------------------------------------
  102. * CUSTOM CONFIG VALUES
  103. * -------------------------------------------------------------------
  104. *
  105. * The $assign_to_config array below will be passed dynamically to the
  106. * config class when initialized. This allows you to set custom config
  107. * items or override any default config values found in the config.php file.
  108. * This can be handy as it permits you to share one application between
  109. * multiple front controller files, with each file containing different
  110. * config values.
  111. *
  112. * Un-comment the $assign_to_config array below to use this feature
  113. *
  114. */
  115. // $assign_to_config['name_of_config_item'] = 'value of config item';
  116. // --------------------------------------------------------------------
  117. // END OF USER CONFIGURABLE SETTINGS. DO NOT EDIT BELOW THIS LINE
  118. // --------------------------------------------------------------------
  119. /*
  120. * ---------------------------------------------------------------
  121. * Resolve the system path for increased reliability
  122. * ---------------------------------------------------------------
  123. */
  124. // Set the current directory correctly for CLI requests
  125. if (defined('STDIN'))
  126. {
  127. chdir(dirname(__FILE__));
  128. }
  129. if (realpath($system_path) !== FALSE)
  130. {
  131. $system_path = realpath($system_path).'/';
  132. }
  133. // ensure there's a trailing slash
  134. $system_path = rtrim($system_path, '/').'/';
  135. // Is the system path correct?
  136. if ( ! is_dir($system_path))
  137. {
  138. exit("Your system folder path does not appear to be set correctly. Please open the following file and correct this: ".pathinfo(__FILE__, PATHINFO_BASENAME));
  139. }
  140. /*
  141. * -------------------------------------------------------------------
  142. * Now that we know the path, set the main path constants
  143. * -------------------------------------------------------------------
  144. */
  145. // The name of THIS file
  146. define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
  147. // The PHP file extension
  148. // this global constant is deprecated.
  149. define('EXT', '.php');
  150. // Path to the system folder
  151. define('BASEPATH', str_replace("\\", "/", $system_path));
  152. // Path to the front controller (this file)
  153. define('FCPATH', str_replace(SELF, '', __FILE__));
  154. // Name of the "system folder"
  155. define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/'));
  156. // The path to the "application" folder
  157. if (is_dir($application_folder))
  158. {
  159. define('APPPATH', $application_folder.'/');
  160. }
  161. else
  162. {
  163. if ( ! is_dir(BASEPATH.$application_folder.'/'))
  164. {
  165. exit("Your application folder path does not appear to be set correctly. Please open the following file and correct this: ".SELF);
  166. }
  167. define('APPPATH', BASEPATH.$application_folder.'/');
  168. }
  169. /*
  170. * --------------------------------------------------------------------
  171. * LOAD THE BOOTSTRAP FILE
  172. * --------------------------------------------------------------------
  173. *
  174. * And away we go...
  175. *
  176. */
  177. require_once BASEPATH.'core/CodeIgniter.php';
  178. /* End of file index.php */
  179. /* Location: ./index.php */