index.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <?php
  2. /*
  3. * This can be set to anything, but default usage is:
  4. *
  5. * development
  6. * testing
  7. * production
  8. */
  9. define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');
  10. switch (ENVIRONMENT)
  11. {
  12. case 'development':
  13. error_reporting(-1);
  14. ini_set('display_errors', 1);
  15. break;
  16. case 'testing':
  17. case 'production':
  18. ini_set('display_errors', 0);
  19. if (version_compare(PHP_VERSION, '5.3', '>='))
  20. {
  21. error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
  22. }
  23. else
  24. {
  25. error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
  26. }
  27. break;
  28. default:
  29. header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
  30. echo 'The application environment is not set correctly.';
  31. exit(1); // EXIT_ERROR
  32. }
  33. $core_path = 'core';
  34. $system_path = $core_path.'/CoreSys';
  35. $application_folder = $core_path.'/CoreApp';
  36. $view_folder = '';
  37. if (defined('STDIN'))
  38. {
  39. chdir(dirname(__FILE__));
  40. }
  41. if (($_temp = realpath($system_path)) !== FALSE)
  42. {
  43. $system_path = $_temp.DIRECTORY_SEPARATOR;
  44. }
  45. else
  46. {
  47. // Ensure there's a trailing slash
  48. $system_path = strtr(
  49. rtrim($system_path, '/\\'),
  50. '/\\',
  51. DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
  52. ).DIRECTORY_SEPARATOR;
  53. }
  54. // Is the system path correct?
  55. if ( ! is_dir($system_path))
  56. {
  57. header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
  58. echo 'Your system folder path does not appear to be set correctly. Please open the following file and correct this: '.pathinfo(__FILE__, PATHINFO_BASENAME);
  59. exit(3); // EXIT_CONFIG
  60. }
  61. /*
  62. * -------------------------------------------------------------------
  63. * Now that we know the path, set the main path constants
  64. * -------------------------------------------------------------------
  65. */
  66. // The name of THIS file
  67. define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
  68. // Path to the system directory
  69. define('BASEPATH', $system_path);
  70. // Path to the front controller (this file) directory
  71. define('FCPATH', dirname(__FILE__).DIRECTORY_SEPARATOR);
  72. // Name of the "system" directory
  73. define('SYSDIR', basename(BASEPATH));
  74. // The path to the "application" directory
  75. if (is_dir($application_folder))
  76. {
  77. if (($_temp = realpath($application_folder)) !== FALSE)
  78. {
  79. $application_folder = $_temp;
  80. }
  81. else
  82. {
  83. $application_folder = strtr(
  84. rtrim($application_folder, '/\\'),
  85. '/\\',
  86. DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
  87. );
  88. }
  89. }
  90. elseif (is_dir(BASEPATH.$application_folder.DIRECTORY_SEPARATOR))
  91. {
  92. $application_folder = BASEPATH.strtr(
  93. trim($application_folder, '/\\'),
  94. '/\\',
  95. DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
  96. );
  97. }
  98. else
  99. {
  100. header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
  101. echo 'Your application folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF;
  102. exit(3); // EXIT_CONFIG
  103. }
  104. define('APPPATH', $application_folder.DIRECTORY_SEPARATOR);
  105. // The path to the "views" directory
  106. if ( ! isset($view_folder[0]) && is_dir(APPPATH.'views'.DIRECTORY_SEPARATOR))
  107. {
  108. $view_folder = APPPATH.'views';
  109. }
  110. elseif (is_dir($view_folder))
  111. {
  112. if (($_temp = realpath($view_folder)) !== FALSE)
  113. {
  114. $view_folder = $_temp;
  115. }
  116. else
  117. {
  118. $view_folder = strtr(
  119. rtrim($view_folder, '/\\'),
  120. '/\\',
  121. DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
  122. );
  123. }
  124. }
  125. elseif (is_dir(APPPATH.$view_folder.DIRECTORY_SEPARATOR))
  126. {
  127. $view_folder = APPPATH.strtr(
  128. trim($view_folder, '/\\'),
  129. '/\\',
  130. DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
  131. );
  132. }
  133. else
  134. {
  135. header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
  136. echo 'Your view folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF;
  137. exit(3); // EXIT_CONFIG
  138. }
  139. define('VIEWPATH', $view_folder.DIRECTORY_SEPARATOR);
  140. require_once BASEPATH.'core/CodeIgniter.php';