PageRenderTime 26ms CodeModel.GetById 40ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/Cake/bootstrap.php

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