PageRenderTime 54ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/api/index.php

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