PageRenderTime 30ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/Cake/bootstrap.php

https://gitlab.com/manuperazafa/elsartenbackend
PHP | 440 lines | 162 code | 72 blank | 206 comment | 38 complexity | 2722de96f7e2bf6c3d90623553db2dfa MD5 | raw file
  1. <?php
  2. /**
  3. * Basic CakePHP functionality.
  4. *
  5. * Handles loading of core files needed on every request
  6. *
  7. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  8. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  9. *
  10. * Licensed under The MIT License
  11. * For full copyright and license information, please see the LICENSE.txt
  12. * Redistributions of files must retain the above copyright notice.
  13. *
  14. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  15. * @link http://cakephp.org CakePHP(tm) Project
  16. * @package Cake
  17. * @since CakePHP(tm) v 0.2.9
  18. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  19. */
  20. define('TIME_START', microtime(true));
  21. if (!defined('E_DEPRECATED')) {
  22. define('E_DEPRECATED', 8192);
  23. }
  24. if (!defined('E_USER_DEPRECATED')) {
  25. define('E_USER_DEPRECATED', E_USER_NOTICE);
  26. }
  27. error_reporting(E_ALL & ~E_DEPRECATED);
  28. if (!defined('CAKE_CORE_INCLUDE_PATH')) {
  29. define('CAKE_CORE_INCLUDE_PATH', dirname(dirname(__FILE__)));
  30. }
  31. if (!defined('CORE_PATH')) {
  32. define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
  33. }
  34. if (!defined('WEBROOT_DIR')) {
  35. define('WEBROOT_DIR', 'webroot');
  36. }
  37. /**
  38. * Path to the cake directory.
  39. */
  40. define('CAKE', CORE_PATH . 'Cake' . DS);
  41. /**
  42. * Path to the application's directory.
  43. */
  44. if (!defined('APP')) {
  45. define('APP', ROOT . DS . APP_DIR . DS);
  46. }
  47. /**
  48. * Path to the application's libs directory.
  49. */
  50. define('APPLIBS', APP . 'Lib' . DS);
  51. /**
  52. * Path to the public CSS directory.
  53. */
  54. if (!defined('CSS')) {
  55. define('CSS', WWW_ROOT . 'css' . DS);
  56. }
  57. /**
  58. * Path to the public JavaScript directory.
  59. */
  60. if (!defined('JS')) {
  61. define('JS', WWW_ROOT . 'js' . DS);
  62. }
  63. /**
  64. * Path to the public images directory.
  65. */
  66. if (!defined('IMAGES')) {
  67. define('IMAGES', WWW_ROOT . 'img' . DS);
  68. }
  69. /**
  70. * Path to the tests directory.
  71. */
  72. if (!defined('TESTS')) {
  73. define('TESTS', APP . 'Test' . DS);
  74. }
  75. /**
  76. * Path to the temporary files directory.
  77. */
  78. if (!defined('TMP')) {
  79. define('TMP', APP . 'tmp' . DS);
  80. }
  81. /**
  82. * Path to the logs directory.
  83. */
  84. if (!defined('LOGS')) {
  85. define('LOGS', TMP . 'logs' . DS);
  86. }
  87. /**
  88. * Path to the cache files directory. It can be shared between hosts in a multi-server setup.
  89. */
  90. if (!defined('CACHE')) {
  91. define('CACHE', TMP . 'cache' . DS);
  92. }
  93. /**
  94. * Path to the vendors directory.
  95. */
  96. if (!defined('VENDORS')) {
  97. define('VENDORS', ROOT . DS . 'vendors' . DS);
  98. }
  99. /**
  100. * Web path to the public images directory.
  101. */
  102. if (!defined('IMAGES_URL')) {
  103. define('IMAGES_URL', 'img/');
  104. }
  105. /**
  106. * Web path to the CSS files directory.
  107. */
  108. if (!defined('CSS_URL')) {
  109. define('CSS_URL', 'css/');
  110. }
  111. /**
  112. * Web path to the js files directory.
  113. */
  114. if (!defined('JS_URL')) {
  115. define('JS_URL', 'js/');
  116. }
  117. require CAKE . 'basics.php';
  118. require CAKE . 'Core' . DS . 'App.php';
  119. require CAKE . 'Error' . DS . 'exceptions.php';
  120. spl_autoload_register(array('App', 'load'));
  121. App::uses('ErrorHandler', 'Error');
  122. App::uses('Configure', 'Core');
  123. App::uses('CakePlugin', 'Core');
  124. App::uses('Cache', 'Cache');
  125. App::uses('Object', 'Core');
  126. App::uses('Multibyte', 'I18n');
  127. /**
  128. * Full URL prefix
  129. */
  130. if (!defined('FULL_BASE_URL')) {
  131. $s = null;
  132. if (env('HTTPS')) {
  133. $s = 's';
  134. }
  135. $httpHost = env('HTTP_HOST');
  136. if (isset($httpHost)) {
  137. define('FULL_BASE_URL', 'http' . $s . '://' . $httpHost);
  138. Configure::write('App.fullBaseUrl', FULL_BASE_URL);
  139. }
  140. unset($httpHost, $s);
  141. }
  142. Configure::write('App.imageBaseUrl', IMAGES_URL);
  143. Configure::write('App.cssBaseUrl', CSS_URL);
  144. Configure::write('App.jsBaseUrl', JS_URL);
  145. App::$bootstrapping = true;
  146. Configure::bootstrap(isset($boot) ? $boot : true);
  147. if (function_exists('mb_internal_encoding')) {
  148. $encoding = Configure::read('App.encoding');
  149. if (!empty($encoding)) {
  150. mb_internal_encoding($encoding);
  151. }
  152. if (!empty($encoding) && function_exists('mb_regex_encoding')) {
  153. mb_regex_encoding($encoding);
  154. }
  155. }
  156. if (!function_exists('mb_stripos')) {
  157. /**
  158. * Find position of first occurrence of a case-insensitive string.
  159. *
  160. * @param string $haystack The string from which to get the position of the first occurrence of $needle.
  161. * @param string $needle The string to find in $haystack.
  162. * @param int $offset The position in $haystack to start searching.
  163. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
  164. * @return int|bool The numeric position of the first occurrence of $needle in the $haystack string, or false
  165. * if $needle is not found.
  166. */
  167. function mb_stripos($haystack, $needle, $offset = 0, $encoding = null) {
  168. return Multibyte::stripos($haystack, $needle, $offset);
  169. }
  170. }
  171. if (!function_exists('mb_stristr')) {
  172. /**
  173. * Finds first occurrence of a string within another, case insensitive.
  174. *
  175. * @param string $haystack The string from which to get the first occurrence of $needle.
  176. * @param string $needle The string to find in $haystack.
  177. * @param bool $part Determines which portion of $haystack this function returns.
  178. * If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle.
  179. * If set to false, it returns all of $haystack from the first occurrence of $needle to the end,
  180. * Default value is false.
  181. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
  182. * @return string|bool The portion of $haystack, or false if $needle is not found.
  183. */
  184. function mb_stristr($haystack, $needle, $part = false, $encoding = null) {
  185. return Multibyte::stristr($haystack, $needle, $part);
  186. }
  187. }
  188. if (!function_exists('mb_strlen')) {
  189. /**
  190. * Get string length.
  191. *
  192. * @param string $string The string being checked for length.
  193. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
  194. * @return int The number of characters in string $string having character encoding encoding.
  195. * A multi-byte character is counted as 1.
  196. */
  197. function mb_strlen($string, $encoding = null) {
  198. return Multibyte::strlen($string);
  199. }
  200. }
  201. if (!function_exists('mb_strpos')) {
  202. /**
  203. * Find position of first occurrence of a string.
  204. *
  205. * @param string $haystack The string being checked.
  206. * @param string $needle The position counted from the beginning of haystack.
  207. * @param int $offset The search offset. If it is not specified, 0 is used.
  208. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
  209. * @return int|bool The numeric position of the first occurrence of $needle in the $haystack string.
  210. * If $needle is not found, it returns false.
  211. */
  212. function mb_strpos($haystack, $needle, $offset = 0, $encoding = null) {
  213. return Multibyte::strpos($haystack, $needle, $offset);
  214. }
  215. }
  216. if (!function_exists('mb_strrchr')) {
  217. /**
  218. * Finds the last occurrence of a character in a string within another.
  219. *
  220. * @param string $haystack The string from which to get the last occurrence of $needle.
  221. * @param string $needle The string to find in $haystack.
  222. * @param bool $part Determines which portion of $haystack this function returns.
  223. * If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle.
  224. * If set to false, it returns all of $haystack from the last occurrence of $needle to the end,
  225. * Default value is false.
  226. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
  227. * @return string|bool The portion of $haystack. or false if $needle is not found.
  228. */
  229. function mb_strrchr($haystack, $needle, $part = false, $encoding = null) {
  230. return Multibyte::strrchr($haystack, $needle, $part);
  231. }
  232. }
  233. if (!function_exists('mb_strrichr')) {
  234. /**
  235. * Finds the last occurrence of a character in a string within another, case insensitive.
  236. *
  237. * @param string $haystack The string from which to get the last occurrence of $needle.
  238. * @param string $needle The string to find in $haystack.
  239. * @param bool $part Determines which portion of $haystack this function returns.
  240. * If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle.
  241. * If set to false, it returns all of $haystack from the last occurrence of $needle to the end,
  242. * Default value is false.
  243. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
  244. * @return string|bool The portion of $haystack. or false if $needle is not found.
  245. */
  246. function mb_strrichr($haystack, $needle, $part = false, $encoding = null) {
  247. return Multibyte::strrichr($haystack, $needle, $part);
  248. }
  249. }
  250. if (!function_exists('mb_strripos')) {
  251. /**
  252. * Finds position of last occurrence of a string within another, case insensitive
  253. *
  254. * @param string $haystack The string from which to get the position of the last occurrence of $needle.
  255. * @param string $needle The string to find in $haystack.
  256. * @param int $offset The position in $haystack to start searching.
  257. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
  258. * @return int|bool The numeric position of the last occurrence of $needle in the $haystack string,
  259. * or false if $needle is not found.
  260. */
  261. function mb_strripos($haystack, $needle, $offset = 0, $encoding = null) {
  262. return Multibyte::strripos($haystack, $needle, $offset);
  263. }
  264. }
  265. if (!function_exists('mb_strrpos')) {
  266. /**
  267. * Find position of last occurrence of a string in a string.
  268. *
  269. * @param string $haystack The string being checked, for the last occurrence of $needle.
  270. * @param string $needle The string to find in $haystack.
  271. * @param int $offset May be specified to begin searching an arbitrary number of characters into the string.
  272. * Negative values will stop searching at an arbitrary point prior to the end of the string.
  273. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
  274. * @return int|bool The numeric position of the last occurrence of $needle in the $haystack string.
  275. * If $needle is not found, it returns false.
  276. */
  277. function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null) {
  278. return Multibyte::strrpos($haystack, $needle, $offset);
  279. }
  280. }
  281. if (!function_exists('mb_strstr')) {
  282. /**
  283. * Finds first occurrence of a string within another
  284. *
  285. * @param string $haystack The string from which to get the first occurrence of $needle.
  286. * @param string $needle The string to find in $haystack
  287. * @param bool $part Determines which portion of $haystack this function returns.
  288. * If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle.
  289. * If set to false, it returns all of $haystack from the first occurrence of $needle to the end,
  290. * Default value is FALSE.
  291. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
  292. * @return string|bool The portion of $haystack, or true if $needle is not found.
  293. */
  294. function mb_strstr($haystack, $needle, $part = false, $encoding = null) {
  295. return Multibyte::strstr($haystack, $needle, $part);
  296. }
  297. }
  298. if (!function_exists('mb_strtolower')) {
  299. /**
  300. * Make a string lowercase
  301. *
  302. * @param string $string The string being lowercased.
  303. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
  304. * @return string with all alphabetic characters converted to lowercase.
  305. */
  306. function mb_strtolower($string, $encoding = null) {
  307. return Multibyte::strtolower($string);
  308. }
  309. }
  310. if (!function_exists('mb_strtoupper')) {
  311. /**
  312. * Make a string uppercase
  313. *
  314. * @param string $string The string being uppercased.
  315. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
  316. * @return string with all alphabetic characters converted to uppercase.
  317. */
  318. function mb_strtoupper($string, $encoding = null) {
  319. return Multibyte::strtoupper($string);
  320. }
  321. }
  322. if (!function_exists('mb_substr_count')) {
  323. /**
  324. * Count the number of substring occurrences
  325. *
  326. * @param string $haystack The string being checked.
  327. * @param string $needle The string being found.
  328. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
  329. * @return int The number of times the $needle substring occurs in the $haystack string.
  330. */
  331. function mb_substr_count($haystack, $needle, $encoding = null) {
  332. return Multibyte::substrCount($haystack, $needle);
  333. }
  334. }
  335. if (!function_exists('mb_substr')) {
  336. /**
  337. * Get part of string
  338. *
  339. * @param string $string The string being checked.
  340. * @param int $start The first position used in $string.
  341. * @param int $length The maximum length of the returned string.
  342. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
  343. * @return string The portion of $string specified by the $string and $length parameters.
  344. */
  345. function mb_substr($string, $start, $length = null, $encoding = null) {
  346. return Multibyte::substr($string, $start, $length);
  347. }
  348. }
  349. if (!function_exists('mb_encode_mimeheader')) {
  350. /**
  351. * Encode string for MIME header
  352. *
  353. * @param string $str The string being encoded
  354. * @param string $charset specifies the name of the character set in which str is represented in.
  355. * The default value is determined by the current NLS setting (mbstring.language).
  356. * @param string $transferEncoding specifies the scheme of MIME encoding.
  357. * It should be either "B" (Base64) or "Q" (Quoted-Printable). Falls back to "B" if not given.
  358. * @param string $linefeed specifies the EOL (end-of-line) marker with which
  359. * mb_encode_mimeheader() performs line-folding
  360. * (a ยป RFC term, the act of breaking a line longer than a certain length into multiple lines.
  361. * The length is currently hard-coded to 74 characters). Falls back to "\r\n" (CRLF) if not given.
  362. * @param int $indent [definition unknown and appears to have no affect]
  363. * @return string A converted version of the string represented in ASCII.
  364. */
  365. function mb_encode_mimeheader($str, $charset = 'UTF-8', $transferEncoding = 'B', $linefeed = "\r\n", $indent = 1) {
  366. return Multibyte::mimeEncode($str, $charset, $linefeed);
  367. }
  368. }