PageRenderTime 44ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/index.php

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