Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

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