index.php 10 KB

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