CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (GitHub)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • Slack
    • Paid Support
CakePHP

C CakePHP 2.3 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 2.3
      • 4.2
      • 4.1
      • 4.0
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Packages

  • Cake
    • Cache
      • Engine
    • Configure
    • Console
      • Command
        • Task
    • Controller
      • Component
        • Acl
        • Auth
    • Core
    • Error
    • Event
    • I18n
    • Log
      • Engine
    • Model
      • Behavior
      • Datasource
        • Database
        • Session
      • Validator
    • Network
      • Email
      • Http
    • Routing
      • Filter
      • Route
    • TestSuite
      • Coverage
      • Fixture
      • Reporter
    • Utility
    • View
      • Helper

Functions

  • __
  • __c
  • __d
  • __dc
  • __dcn
  • __dn
  • __n
  • am
  • cache
  • clearCache
  • config
  • convertSlash
  • debug
  • env
  • fileExistsInPath
  • h
  • LogError
  • mb_encode_mimeheader
  • mb_stripos
  • mb_stristr
  • mb_strlen
  • mb_strpos
  • mb_strrchr
  • mb_strrichr
  • mb_strripos
  • mb_strrpos
  • mb_strstr
  • mb_strtolower
  • mb_strtoupper
  • mb_substr
  • mb_substr_count
  • pluginSplit
  • pr
  • sortByKey
  • stripslashes_deep
  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       http://www.opensource.org/licenses/mit-license.php MIT License
 21:  */
 22: 
 23: define('TIME_START', microtime(true));
 24: 
 25: if (!defined('E_DEPRECATED')) {
 26:     define('E_DEPRECATED', 8192);
 27: }
 28: 
 29: if (!defined('E_USER_DEPRECATED')) {
 30:     define('E_USER_DEPRECATED', E_USER_NOTICE);
 31: }
 32: error_reporting(E_ALL & ~E_DEPRECATED);
 33: 
 34: if (!defined('CAKE_CORE_INCLUDE_PATH')) {
 35:     define('CAKE_CORE_INCLUDE_PATH', dirname(dirname(__FILE__)));
 36: }
 37: 
 38: if (!defined('CORE_PATH')) {
 39:     define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
 40: }
 41: 
 42: if (!defined('WEBROOT_DIR')) {
 43:     define('WEBROOT_DIR', 'webroot');
 44: }
 45: 
 46: /**
 47:  * Path to the cake directory.
 48:  */
 49:     define('CAKE', CORE_PATH . 'Cake' . DS);
 50: 
 51: /**
 52:  * Path to the application's directory.
 53:  */
 54: if (!defined('APP')) {
 55:     define('APP', ROOT . DS . APP_DIR . DS);
 56: }
 57: 
 58: /**
 59:  * Path to the application's libs directory.
 60:  */
 61:     define('APPLIBS', APP . 'Lib' . DS);
 62: 
 63: /**
 64:  * Path to the public CSS directory.
 65:  */
 66: if (!defined('CSS')) {
 67:     define('CSS', WWW_ROOT . 'css' . DS);
 68: }
 69: 
 70: /**
 71:  * Path to the public JavaScript directory.
 72:  */
 73: if (!defined('JS')) {
 74:     define('JS', WWW_ROOT . 'js' . DS);
 75: }
 76: 
 77: /**
 78:  * Path to the public images directory.
 79:  */
 80: if (!defined('IMAGES')) {
 81:     define('IMAGES', WWW_ROOT . 'img' . DS);
 82: }
 83: 
 84: /**
 85:  * Path to the tests directory.
 86:  */
 87: if (!defined('TESTS')) {
 88:     define('TESTS', APP . 'Test' . DS);
 89: }
 90: 
 91: /**
 92:  * Path to the temporary files directory.
 93:  */
 94: if (!defined('TMP')) {
 95:     define('TMP', APP . 'tmp' . DS);
 96: }
 97: 
 98: /**
 99:  * Path to the logs directory.
100:  */
101: if (!defined('LOGS')) {
102:     define('LOGS', TMP . 'logs' . DS);
103: }
104: 
105: /**
106:  * Path to the cache files directory. It can be shared between hosts in a multi-server setup.
107:  */
108: if (!defined('CACHE')) {
109:     define('CACHE', TMP . 'cache' . DS);
110: }
111: 
112: /**
113:  * Path to the vendors directory.
114:  */
115: if (!defined('VENDORS')) {
116:     define('VENDORS', ROOT . DS . 'vendors' . DS);
117: }
118: 
119: /**
120:  * Web path to the public images directory.
121:  */
122: if (!defined('IMAGES_URL')) {
123:     define('IMAGES_URL', 'img/');
124: }
125: 
126: /**
127:  * Web path to the CSS files directory.
128:  */
129: if (!defined('CSS_URL')) {
130:     define('CSS_URL', 'css/');
131: }
132: 
133: /**
134:  * Web path to the js files directory.
135:  */
136: if (!defined('JS_URL')) {
137:     define('JS_URL', 'js/');
138: }
139: 
140: require CAKE . 'basics.php';
141: require CAKE . 'Core' . DS . 'App.php';
142: require CAKE . 'Error' . DS . 'exceptions.php';
143: 
144: /**
145:  * Full URL prefix
146:  */
147: if (!defined('FULL_BASE_URL')) {
148:     $s = null;
149:     if (env('HTTPS')) {
150:         $s = 's';
151:     }
152: 
153:     $httpHost = env('HTTP_HOST');
154: 
155:     if (isset($httpHost)) {
156:         define('FULL_BASE_URL', 'http' . $s . '://' . $httpHost);
157:     }
158:     unset($httpHost, $s);
159: }
160: 
161: spl_autoload_register(array('App', 'load'));
162: 
163: App::uses('ErrorHandler', 'Error');
164: App::uses('Configure', 'Core');
165: App::uses('CakePlugin', 'Core');
166: App::uses('Cache', 'Cache');
167: App::uses('Object', 'Core');
168: App::uses('Multibyte', 'I18n');
169: App::$bootstrapping = true;
170: 
171: Configure::bootstrap(isset($boot) ? $boot : true);
172: 
173: if (function_exists('mb_internal_encoding')) {
174:     $encoding = Configure::read('App.encoding');
175:     if (!empty($encoding)) {
176:         mb_internal_encoding($encoding);
177:     }
178:     if (!empty($encoding) && function_exists('mb_regex_encoding')) {
179:         mb_regex_encoding($encoding);
180:     }
181: }
182: 
183: if (!function_exists('mb_stripos')) {
184: 
185: /**
186:  * Find position of first occurrence of a case-insensitive string.
187:  *
188:  * @param string $haystack The string from which to get the position of the first occurrence of $needle.
189:  * @param string $needle The string to find in $haystack.
190:  * @param integer $offset The position in $haystack to start searching.
191:  * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
192:  * @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string, or false
193:  *    if $needle is not found.
194:  */
195:     function mb_stripos($haystack, $needle, $offset = 0, $encoding = null) {
196:         return Multibyte::stripos($haystack, $needle, $offset);
197:     }
198: 
199: }
200: 
201: if (!function_exists('mb_stristr')) {
202: 
203: /**
204:  * Finds first occurrence of a string within another, case insensitive.
205:  *
206:  * @param string $haystack The string from which to get the first occurrence of $needle.
207:  * @param string $needle The string to find in $haystack.
208:  * @param boolean $part Determines which portion of $haystack this function returns.
209:  *    If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle.
210:  *    If set to false, it returns all of $haystack from the first occurrence of $needle to the end,
211:  *    Default value is false.
212:  * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
213:  * @return string|boolean The portion of $haystack, or false if $needle is not found.
214:  */
215:     function mb_stristr($haystack, $needle, $part = false, $encoding = null) {
216:         return Multibyte::stristr($haystack, $needle, $part);
217:     }
218: 
219: }
220: 
221: if (!function_exists('mb_strlen')) {
222: 
223: /**
224:  * Get string length.
225:  *
226:  * @param string $string The string being checked for length.
227:  * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
228:  * @return integer The number of characters in string $string having character encoding encoding.
229:  *    A multi-byte character is counted as 1.
230:  */
231:     function mb_strlen($string, $encoding = null) {
232:         return Multibyte::strlen($string);
233:     }
234: 
235: }
236: 
237: if (!function_exists('mb_strpos')) {
238: 
239: /**
240:  * Find position of first occurrence of a string.
241:  *
242:  * @param string $haystack The string being checked.
243:  * @param string $needle The position counted from the beginning of haystack.
244:  * @param integer $offset The search offset. If it is not specified, 0 is used.
245:  * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
246:  * @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string.
247:  *    If $needle is not found, it returns false.
248:  */
249:     function mb_strpos($haystack, $needle, $offset = 0, $encoding = null) {
250:         return Multibyte::strpos($haystack, $needle, $offset);
251:     }
252: 
253: }
254: 
255: if (!function_exists('mb_strrchr')) {
256: 
257: /**
258:  * Finds the last occurrence of a character in a string within another.
259:  *
260:  * @param string $haystack The string from which to get the last occurrence of $needle.
261:  * @param string $needle The string to find in $haystack.
262:  * @param boolean $part Determines which portion of $haystack this function returns.
263:  *    If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle.
264:  *    If set to false, it returns all of $haystack from the last occurrence of $needle to the end,
265:  *    Default value is false.
266:  * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
267:  * @return string|boolean The portion of $haystack. or false if $needle is not found.
268:  */
269:     function mb_strrchr($haystack, $needle, $part = false, $encoding = null) {
270:         return Multibyte::strrchr($haystack, $needle, $part);
271:     }
272: 
273: }
274: 
275: if (!function_exists('mb_strrichr')) {
276: 
277: /**
278:  * Finds the last occurrence of a character in a string within another, case insensitive.
279:  *
280:  * @param string $haystack The string from which to get the last occurrence of $needle.
281:  * @param string $needle The string to find in $haystack.
282:  * @param boolean $part Determines which portion of $haystack this function returns.
283:  *    If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle.
284:  *    If set to false, it returns all of $haystack from the last occurrence of $needle to the end,
285:  *    Default value is false.
286:  * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
287:  * @return string|boolean The portion of $haystack. or false if $needle is not found.
288:  */
289:     function mb_strrichr($haystack, $needle, $part = false, $encoding = null) {
290:         return Multibyte::strrichr($haystack, $needle, $part);
291:     }
292: 
293: }
294: 
295: if (!function_exists('mb_strripos')) {
296: 
297: /**
298:  * Finds position of last occurrence of a string within another, case insensitive
299:  *
300:  * @param string $haystack The string from which to get the position of the last occurrence of $needle.
301:  * @param string $needle The string to find in $haystack.
302:  * @param integer $offset The position in $haystack to start searching.
303:  * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
304:  * @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string,
305:  *    or false if $needle is not found.
306:  */
307:     function mb_strripos($haystack, $needle, $offset = 0, $encoding = null) {
308:         return Multibyte::strripos($haystack, $needle, $offset);
309:     }
310: 
311: }
312: 
313: if (!function_exists('mb_strrpos')) {
314: 
315: /**
316:  * Find position of last occurrence of a string in a string.
317:  *
318:  * @param string $haystack The string being checked, for the last occurrence of $needle.
319:  * @param string $needle The string to find in $haystack.
320:  * @param integer $offset May be specified to begin searching an arbitrary number of characters into the string.
321:  *    Negative values will stop searching at an arbitrary point prior to the end of the string.
322:  * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
323:  * @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string.
324:  *    If $needle is not found, it returns false.
325:  */
326:     function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null) {
327:         return Multibyte::strrpos($haystack, $needle, $offset);
328:     }
329: 
330: }
331: 
332: if (!function_exists('mb_strstr')) {
333: 
334: /**
335:  * Finds first occurrence of a string within another
336:  *
337:  * @param string $haystack The string from which to get the first occurrence of $needle.
338:  * @param string $needle The string to find in $haystack
339:  * @param boolean $part Determines which portion of $haystack this function returns.
340:  *    If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle.
341:  *    If set to false, it returns all of $haystack from the first occurrence of $needle to the end,
342:  *    Default value is FALSE.
343:  * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
344:  * @return string|boolean The portion of $haystack, or true if $needle is not found.
345:  */
346:     function mb_strstr($haystack, $needle, $part = false, $encoding = null) {
347:         return Multibyte::strstr($haystack, $needle, $part);
348:     }
349: 
350: }
351: 
352: if (!function_exists('mb_strtolower')) {
353: 
354: /**
355:  * Make a string lowercase
356:  *
357:  * @param string $string The string being lowercased.
358:  * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
359:  * @return string with all alphabetic characters converted to lowercase.
360:  */
361:     function mb_strtolower($string, $encoding = null) {
362:         return Multibyte::strtolower($string);
363:     }
364: 
365: }
366: 
367: if (!function_exists('mb_strtoupper')) {
368: 
369: /**
370:  * Make a string uppercase
371:  *
372:  * @param string $string The string being uppercased.
373:  * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
374:  * @return string with all alphabetic characters converted to uppercase.
375:  */
376:     function mb_strtoupper($string, $encoding = null) {
377:         return Multibyte::strtoupper($string);
378:     }
379: 
380: }
381: 
382: if (!function_exists('mb_substr_count')) {
383: 
384: /**
385:  * Count the number of substring occurrences
386:  *
387:  * @param string $haystack The string being checked.
388:  * @param string $needle The string being found.
389:  * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
390:  * @return integer The number of times the $needle substring occurs in the $haystack string.
391:  */
392:     function mb_substr_count($haystack, $needle, $encoding = null) {
393:         return Multibyte::substrCount($haystack, $needle);
394:     }
395: 
396: }
397: 
398: if (!function_exists('mb_substr')) {
399: 
400: /**
401:  * Get part of string
402:  *
403:  * @param string $string The string being checked.
404:  * @param integer $start The first position used in $string.
405:  * @param integer $length The maximum length of the returned string.
406:  * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
407:  * @return string The portion of $string specified by the $string and $length parameters.
408:  */
409:     function mb_substr($string, $start, $length = null, $encoding = null) {
410:         return Multibyte::substr($string, $start, $length);
411:     }
412: 
413: }
414: 
415: if (!function_exists('mb_encode_mimeheader')) {
416: 
417: /**
418:  * Encode string for MIME header
419:  *
420:  * @param string $str The string being encoded
421:  * @param string $charset specifies the name of the character set in which str is represented in.
422:  *    The default value is determined by the current NLS setting (mbstring.language).
423:  * @param string $transfer_encoding specifies the scheme of MIME encoding.
424:  *    It should be either "B" (Base64) or "Q" (Quoted-Printable). Falls back to "B" if not given.
425:  * @param string $linefeed specifies the EOL (end-of-line) marker with which
426:  *    mb_encode_mimeheader() performs line-folding
427:  *    (a ยป RFC term, the act of breaking a line longer than a certain length into multiple lines.
428:  *    The length is currently hard-coded to 74 characters). Falls back to "\r\n" (CRLF) if not given.
429:  * @param integer $indent [definition unknown and appears to have no affect]
430:  * @return string A converted version of the string represented in ASCII.
431:  */
432:     function mb_encode_mimeheader($str, $charset = 'UTF-8', $transferEncoding = 'B', $linefeed = "\r\n", $indent = 1) {
433:         return Multibyte::mimeEncode($str, $charset, $linefeed);
434:     }
435: 
436: }
437: 
OpenHub
Rackspace
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (GitHub)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • Slack
  • Paid Support

Generated using CakePHP API Docs