1: | <?php
|
2: | |
3: | |
4: | |
5: | |
6: | |
7: | |
8: | |
9: | |
10: | |
11: | |
12: | |
13: |
|
14: |
|
15: | use LucidFrame\Core\SchemaManager;
|
16: |
|
17: | |
18: | |
19: |
|
20: | define('FILE_RESIZE_BOTH', 'both');
|
21: | |
22: | |
23: |
|
24: | define('FILE_RESIZE_HEIGHT', 'height');
|
25: | |
26: | |
27: |
|
28: | define('FILE_RESIZE_WIDTH', 'width');
|
29: | |
30: | |
31: |
|
32: | define('FILE_UPLOAD_ERR_MOVE', 100);
|
33: | |
34: | |
35: |
|
36: | define('FILE_UPLOAD_ERR_IMAGE_CREATE', 101);
|
37: | |
38: | |
39: |
|
40: | define('LC_FETCH_ASSOC', 1);
|
41: | define('LC_FETCH_ARRAY', 2);
|
42: | define('LC_FETCH_OBJECT', 3);
|
43: | |
44: | |
45: |
|
46: | define('LC_CONSOLE_OPTION_REQUIRED', 4);
|
47: | define('LC_CONSOLE_OPTION_OPTIONAL', 5);
|
48: | define('LC_CONSOLE_OPTION_NOVALUE', 6);
|
49: |
|
50: | |
51: | |
52: | |
53: | |
54: |
|
55: | $lc_httpStatusCode = 200;
|
56: | |
57: | |
58: | |
59: | |
60: |
|
61: | $lc_sitewideWarnings = array();
|
62: | |
63: | |
64: | |
65: | |
66: |
|
67: | $lc_autoload = array();
|
68: | |
69: | |
70: | |
71: | |
72: |
|
73: | $lc_namespace = '';
|
74: | |
75: | |
76: | |
77: | |
78: |
|
79: | $lc_cleanRoute = '';
|
80: | |
81: | |
82: | |
83: | |
84: |
|
85: | $lc_jsVars = array();
|
86: | |
87: | |
88: | |
89: | |
90: |
|
91: | $lc_canonical = '';
|
92: | |
93: | |
94: | |
95: | |
96: |
|
97: | $lc_envParameters = null;
|
98: | |
99: | |
100: | |
101: | |
102: |
|
103: | $_meta = array();
|
104: | |
105: | |
106: | |
107: | |
108: |
|
109: | global $db_builtQueries;
|
110: | $db_builtQueries = array();
|
111: | $db_printQuery = false;
|
112: |
|
113: |
|
114: |
|
115: |
|
116: |
|
117: | |
118: | |
119: | |
120: | |
121: |
|
122: | function __prerequisite()
|
123: | {
|
124: | if (version_compare(phpversion(), '5.3.0', '<')) {
|
125: | die('PHPLucidFrame requires at least PHP 5.3.0. Your PHP installation is ' . phpversion() . '.');
|
126: | }
|
127: |
|
128: | |
129: | |
130: |
|
131: | if (!file_exists(INC . 'config.php')) {
|
132: | copy(INC . 'config.default.php', INC . 'config.php');
|
133: | }
|
134: |
|
135: | if (PHP_SAPI !== 'cli') {
|
136: | register_shutdown_function('__kernelShutdownHandler');
|
137: | }
|
138: | }
|
139: |
|
140: | |
141: | |
142: | |
143: | |
144: | |
145: | |
146: | |
147: | |
148: | |
149: | |
150: | |
151: | |
152: | |
153: |
|
154: | function __dotNotationToArray($key, $scope = 'global', $value = '', $serialize = false)
|
155: | {
|
156: | if (empty($key)) {
|
157: | return null;
|
158: | }
|
159: |
|
160: | if (!in_array($scope, array('global', 'session')) && !is_array($scope)) {
|
161: | return null;
|
162: | }
|
163: |
|
164: | if (is_array($scope)) {
|
165: | $input = &$scope;
|
166: | }
|
167: |
|
168: | $type = count(func_get_args()) > 2 ? 'setter' : 'getter';
|
169: | $keys = explode(".", $key);
|
170: |
|
171: | $firstKey = array_shift($keys);
|
172: |
|
173: | $lastKey = end($keys);
|
174: |
|
175: | $count = count($keys);
|
176: | $justOneLevelKey = ($count === 0);
|
177: |
|
178: | if ($type == 'getter' && $justOneLevelKey) {
|
179: |
|
180: | if ($scope == 'session') {
|
181: | $firstKey = S_PREFIX . $firstKey;
|
182: | return (array_key_exists($firstKey, $_SESSION)) ? $_SESSION[$firstKey] : null;
|
183: | } elseif ($scope == 'global') {
|
184: | return (array_key_exists($firstKey, $GLOBALS)) ? $GLOBALS[$firstKey] : null;
|
185: | } elseif (is_array($scope) && isset($input)) {
|
186: | return (array_key_exists($firstKey, $input)) ? $input[$firstKey] : null;
|
187: | }
|
188: | }
|
189: |
|
190: | $current = null;
|
191: | if ($scope == 'session') {
|
192: | $firstKey = S_PREFIX . $firstKey;
|
193: | if (!array_key_exists($firstKey, $_SESSION)) {
|
194: | $_SESSION[$firstKey] = null;
|
195: | }
|
196: | $current = &$_SESSION[$firstKey];
|
197: | } elseif ($scope == 'global') {
|
198: | if (!array_key_exists($firstKey, $GLOBALS)) {
|
199: | $GLOBALS[$firstKey] = null;
|
200: | }
|
201: | $current = &$GLOBALS[$firstKey];
|
202: | } elseif (is_array($scope) && isset($input)) {
|
203: | if (!array_key_exists($firstKey, $input)) {
|
204: | $input[$firstKey] = null;
|
205: | }
|
206: | $current = &$input[$firstKey];
|
207: | }
|
208: |
|
209: | $theLastHasValue = false;
|
210: | if (($type == 'setter' && $count) || ($type == 'getter' && $count > 1)) {
|
211: |
|
212: | foreach ($keys as $k) {
|
213: | if ($k == $lastKey && isset($current[$lastKey])) {
|
214: | if ($type === 'getter') {
|
215: | return $current[$lastKey];
|
216: | }
|
217: |
|
218: | $theLastHasValue = true;
|
219: | if ($scope != 'session') {
|
220: |
|
221: | $current[$lastKey] = is_array($current[$k]) ? $current[$k] : array($current[$k]);
|
222: | }
|
223: | break;
|
224: | }
|
225: | if ($count && !isset($current[$k]) && !is_array($current)) {
|
226: | $current = array($k => null);
|
227: | }
|
228: | $current = &$current[$k];
|
229: | }
|
230: | }
|
231: |
|
232: | if ($type == 'setter') {
|
233: | if (is_array($current) && $theLastHasValue) {
|
234: |
|
235: | $current[$lastKey] = ($serialize) ? serialize($value) : $value;
|
236: | } else {
|
237: | $current = ($serialize) ? serialize($value) : $value;
|
238: | }
|
239: | return $current;
|
240: | } elseif ($type == 'getter') {
|
241: |
|
242: | return $count ? (isset($current[$lastKey]) ? $current[$lastKey] : null) : $current;
|
243: | }
|
244: | return null;
|
245: | }
|
246: |
|
247: | |
248: | |
249: | |
250: | |
251: | |
252: | |
253: | |
254: | |
255: |
|
256: | function __envLoader()
|
257: | {
|
258: | global $lc_languages;
|
259: | global $lc_baseURL;
|
260: | global $lc_sites;
|
261: | global $lc_env;
|
262: | global $lc_debugLevel;
|
263: | global $lc_minifyHTML;
|
264: | global $lc_timeZone;
|
265: | global $lc_memoryLimit;
|
266: | global $lc_maxExecTime;
|
267: |
|
268: | |
269: | |
270: |
|
271: | ini_set('magic_quotes_runtime', '0');
|
272: | |
273: | |
274: | |
275: |
|
276: | ini_set('memory_limit', $lc_memoryLimit);
|
277: | |
278: | |
279: | |
280: |
|
281: | ini_set('max_execution_time', $lc_maxExecTime);
|
282: |
|
283: | |
284: | |
285: |
|
286: | date_default_timezone_set($lc_timeZone);
|
287: |
|
288: | $lc_env = strtolower($lc_env);
|
289: | if (!in_array($lc_env, __envList())) {
|
290: | $lc_env = ENV_PROD;
|
291: | }
|
292: | if ($lc_env == ENV_PROD) {
|
293: | error_reporting(0);
|
294: | ini_set('display_errors', 0);
|
295: | ini_set('display_startup_errors', 0);
|
296: | } else {
|
297: | $lc_minifyHTML = false;
|
298: | switch($lc_debugLevel) {
|
299: | case 1:
|
300: | error_reporting(E_ERROR | E_PARSE);
|
301: | ini_set('display_errors', 1);
|
302: | ini_set('display_startup_errors', 0);
|
303: | break;
|
304: | case 2:
|
305: | error_reporting(E_ERROR | E_PARSE | E_NOTICE | E_WARNING);
|
306: | ini_set('display_errors', 1);
|
307: | ini_set('display_startup_errors', 1);
|
308: | break;
|
309: | case 3:
|
310: | error_reporting(E_ALL);
|
311: | ini_set('display_errors', 1);
|
312: | ini_set('display_startup_errors', 1);
|
313: | break;
|
314: | default:
|
315: | error_reporting($lc_debugLevel);
|
316: | ini_set('display_errors', 1);
|
317: | ini_set('display_startup_errors', 1);
|
318: | }
|
319: | }
|
320: |
|
321: | if (empty($lc_languages) || !is_array($lc_languages)) {
|
322: | $lc_languages = array('en' => 'English');
|
323: | }
|
324: |
|
325: | $REQUEST_URI = $_SERVER['REQUEST_URI'];
|
326: |
|
327: | $requestURI = substr($REQUEST_URI, strpos($REQUEST_URI, '/'.$lc_baseURL) + strlen($lc_baseURL) + 1);
|
328: | $requestURI = ltrim($requestURI, '/');
|
329: | $request = explode('/', $requestURI);
|
330: | $lc_namespace = $request[0];
|
331: |
|
332: |
|
333: | if (array_key_exists($lc_namespace, $lc_languages)) {
|
334: | array_shift($request);
|
335: | $requestURI = ltrim(ltrim($requestURI, $lc_namespace), '/');
|
336: | $lc_namespace = count($request) ? $request[0] : '';
|
337: | }
|
338: |
|
339: | if (!(isset($lc_sites) && is_array($lc_sites) && array_key_exists($lc_namespace, $lc_sites))) {
|
340: | $lc_namespace = '';
|
341: | }
|
342: |
|
343: |
|
344: | define('REQUEST_URI', trim($requestURI, '/'));
|
345: |
|
346: | define('LC_NAMESPACE', $lc_namespace);
|
347: |
|
348: | unset($requestURI);
|
349: | unset($request);
|
350: | }
|
351: |
|
352: | |
353: | |
354: | |
355: | |
356: | |
357: | |
358: |
|
359: | function __secret($file = null)
|
360: | {
|
361: | if ($file !== null && is_file($file) && file_exists($file)) {
|
362: | return trim(file_get_contents($file));
|
363: | }
|
364: |
|
365: | $file = INC . '.secret';
|
366: | return (is_file($file) && file_exists($file)) ? trim(file_get_contents($file)) : '';
|
367: | }
|
368: |
|
369: | |
370: | |
371: | |
372: | |
373: | |
374: |
|
375: | function __env()
|
376: | {
|
377: | $defaultEnv = ENV_DEV;
|
378: |
|
379: | $oldFile = ROOT . '.env';
|
380: | if (is_file($oldFile) && file_exists($oldFile)) {
|
381: | $defaultEnv = trim(file_get_contents($oldFile));
|
382: | if (in_array($defaultEnv, __envList())) {
|
383: | unlink($oldFile);
|
384: | }
|
385: | }
|
386: |
|
387: | $file = ROOT . FILE_ENV;
|
388: | if (!(is_file($file) && file_exists($file))) {
|
389: | file_put_contents($file, $defaultEnv);
|
390: | }
|
391: |
|
392: | $env = trim(file_get_contents($file));
|
393: | if (!in_array($env, __envList())) {
|
394: | $env = ENV_PROD;
|
395: | }
|
396: |
|
397: | return $env;
|
398: | }
|
399: |
|
400: | |
401: | |
402: | |
403: | |
404: | |
405: |
|
406: | function __envList()
|
407: | {
|
408: | return array(ENV_PROD, ENV_STAGING, ENV_DEV, ENV_TEST, 'dev', 'prod');
|
409: | }
|
410: |
|
411: | |
412: | |
413: | |
414: | |
415: | |
416: | |
417: | |
418: | |
419: | |
420: | |
421: | |
422: |
|
423: | function __kernelErrorHandler($code, $message, $file, $line)
|
424: | {
|
425: | if (!(error_reporting() & $code)) {
|
426: |
|
427: |
|
428: | return false;
|
429: | }
|
430: |
|
431: | $type = __kernelErrorTypes($code);
|
432: | $trace = array_reverse(debug_backtrace());
|
433: |
|
434: | $status = _g('httpStatusCode');
|
435: | if (empty($status) || $status == 200) {
|
436: | $status = 500;
|
437: | _g('httpStatusCode', $status);
|
438: | }
|
439: |
|
440: | _header($status);
|
441: |
|
442: | include( _i('inc/tpl/exception.php') );
|
443: | exit;
|
444: | }
|
445: |
|
446: | |
447: | |
448: | |
449: | |
450: | |
451: |
|
452: | function __kernelShutdownHandler()
|
453: | {
|
454: | $error = error_get_last();
|
455: |
|
456: | if (is_array($error)) {
|
457: | __kernelErrorHandler($error['type'], $error['message'], $error['file'], $error['line']);
|
458: | }
|
459: | }
|
460: |
|
461: | |
462: | |
463: | |
464: | |
465: | |
466: | |
467: | |
468: |
|
469: | function __kernelErrorTypes($code)
|
470: | {
|
471: | switch($code) {
|
472: | case E_ERROR:
|
473: | return 'E_ERROR: Fatal error';
|
474: |
|
475: | case E_WARNING:
|
476: | return 'E_WARNING: Warning';
|
477: |
|
478: | case E_PARSE:
|
479: | return 'E_PARSE: Parse error';
|
480: |
|
481: | case E_NOTICE:
|
482: | return 'E_NOTICE: Notice';
|
483: |
|
484: | case E_CORE_ERROR:
|
485: | return 'E_CORE_ERROR: Fatal error';
|
486: |
|
487: | case E_CORE_WARNING:
|
488: | return 'E_CORE_WARNING: Warning';
|
489: |
|
490: | case E_COMPILE_ERROR:
|
491: | return 'E_COMPILE_ERROR: Fatal error';
|
492: |
|
493: | case E_COMPILE_WARNING:
|
494: | return 'E_COMPILE_WARNING: Warning';
|
495: |
|
496: | case E_USER_ERROR:
|
497: | return 'E_USER_ERROR: User-generated error';
|
498: |
|
499: | case E_USER_WARNING:
|
500: | return 'E_USER_WARNING: User-generated warning';
|
501: |
|
502: | case E_USER_NOTICE:
|
503: | return 'E_USER_NOTICE: User-generated notice';
|
504: |
|
505: | case E_STRICT:
|
506: | return 'E_STRICT: Information';
|
507: |
|
508: | case E_RECOVERABLE_ERROR:
|
509: | return 'E_RECOVERABLE_ERROR: Catchable fatal error';
|
510: |
|
511: | case E_DEPRECATED:
|
512: | return 'E_DEPRECATED: Deprecated warning';
|
513: |
|
514: | case E_USER_DEPRECATED:
|
515: | return 'E_USER_DEPRECATED: User-generated deprecated warning';
|
516: | }
|
517: |
|
518: | return 'E_ERROR, Error';
|
519: | }
|
520: |
|
521: | |
522: | |
523: | |
524: |
|
525: | function __autoloadHelper($modules)
|
526: | {
|
527: | $modules = is_array($modules) ? $modules : array($modules);
|
528: | $helperDirs = _baseDirs('helpers');
|
529: |
|
530: | foreach ($modules as $helper) {
|
531: | foreach ($helperDirs as $dir) {
|
532: | $moduleFile = $dir . $helper . '_helper.php';
|
533: | if (is_file($moduleFile) && file_exists($moduleFile)) {
|
534: | include($moduleFile);
|
535: | }
|
536: | }
|
537: | }
|
538: | }
|
539: |
|
540: | |
541: | |
542: | |
543: | |
544: | |
545: | |
546: |
|
547: | function __dbLoadable()
|
548: | {
|
549: | global $argv;
|
550: |
|
551: | return !(PHP_SAPI == 'cli' && $argv[0] === 'lucidframe' && in_array($argv[1], ['list', 'env', 'secret:generate']));
|
552: | }
|
553: |
|
554: |
|
555: |
|
556: |
|
557: |
|
558: | |
559: | |
560: | |
561: | |
562: | |
563: | |
564: | |
565: | |
566: | |
567: | |
568: | |
569: | |
570: | |
571: | |
572: | |
573: | |
574: | |
575: | |
576: |
|
577: | function _schema($dbNamespace = 'default', $cache = false)
|
578: | {
|
579: | $files = array();
|
580: | if ($cache) {
|
581: | $files[] = SchemaManager::getSchemaLockFileName($dbNamespace);
|
582: | $files[] = SchemaManager::getSchemaLockFileName();
|
583: | }
|
584: |
|
585: | $files[] = DB."schema.{$dbNamespace}.php";
|
586: | $files[] = DB."schema.php";
|
587: |
|
588: | foreach ($files as $f) {
|
589: | if (is_file($f) && file_exists($f)) {
|
590: | $file = $f;
|
591: | if (pathinfo($file, PATHINFO_EXTENSION) == 'lock') {
|
592: | return unserialize(file_get_contents($file));
|
593: | } else {
|
594: | $schema = include($file);
|
595: | return is_array($schema) ? $schema : null;
|
596: | }
|
597: | }
|
598: | }
|
599: |
|
600: | return false;
|
601: | }
|
602: |
|
603: | |
604: | |
605: | |
606: | |
607: | |
608: | |
609: | |
610: | |
611: |
|
612: | function _i($file, $recursive = true)
|
613: | {
|
614: | global $lc_baseURL;
|
615: | global $lc_sites;
|
616: | global $lc_languages;
|
617: |
|
618: | $ext = strtolower(substr($file, strrpos($file, '.')+1));
|
619: | if (in_array($ext, array('js', 'css'))) {
|
620: | $appRoot = WEB_APP_ROOT;
|
621: | $root = WEB_ROOT;
|
622: | } else {
|
623: | $appRoot = APP_ROOT;
|
624: | $root = ROOT;
|
625: | }
|
626: |
|
627: | if (!is_array($lc_languages)) {
|
628: | $lc_languages = array('en' => 'English');
|
629: | }
|
630: |
|
631: | $REQUEST_URI = $_SERVER['REQUEST_URI'];
|
632: |
|
633: | $requestURI = trim(ltrim($REQUEST_URI, '/'.$lc_baseURL));
|
634: | $request = explode('/', $requestURI);
|
635: |
|
636: | $needle = $request[0];
|
637: |
|
638: | if (array_key_exists($needle, $lc_languages)) {
|
639: | array_shift($request);
|
640: | }
|
641: |
|
642: | $folders = array();
|
643: | if (LC_NAMESPACE == '') {
|
644: |
|
645: | $folders = array(
|
646: | APP_ROOT => $appRoot,
|
647: | ROOT => $root
|
648: | );
|
649: | }
|
650: |
|
651: | if (isset($lc_sites) && is_array($lc_sites) && count($lc_sites)) {
|
652: | if (array_key_exists(LC_NAMESPACE, $lc_sites)) {
|
653: |
|
654: | $folders = array(
|
655: | APP_ROOT.$lc_sites[LC_NAMESPACE]._DS_ => $appRoot . $lc_sites[LC_NAMESPACE] . _DS_,
|
656: | APP_ROOT => $appRoot,
|
657: | ROOT => $root
|
658: | );
|
659: | }
|
660: | }
|
661: |
|
662: |
|
663: |
|
664: | foreach ($folders as $key => $value) {
|
665: | if ($key === ROOT && substr($file, 0, 7) === 'helpers') {
|
666: | $fileWithPath = LIB . $file;
|
667: | $libHelper = true;
|
668: | } else {
|
669: | $fileWithPath = $key . $file;
|
670: | $libHelper = false;
|
671: | }
|
672: |
|
673: | if (is_file($fileWithPath) && file_exists($fileWithPath)) {
|
674: | if ($libHelper === false) {
|
675: | $fileWithPath = $value . $file;
|
676: | }
|
677: |
|
678: | return $fileWithPath;
|
679: | }
|
680: |
|
681: | if ($recursive == false) {
|
682: | break;
|
683: | }
|
684: | }
|
685: |
|
686: | if (strstr($_SERVER['PHP_SELF'], APP_DIR)) {
|
687: | if ($recursive == true) {
|
688: | if ($root === ROOT && substr($file, 0, 7) === 'helpers') {
|
689: | $file = LIB . $file;
|
690: | } else {
|
691: | $file = $root . $file;
|
692: | }
|
693: | } else {
|
694: | $file = $root . $file;
|
695: | }
|
696: |
|
697: | if (is_file($file) && file_exists($file)) {
|
698: | return $file;
|
699: | }
|
700: | }
|
701: |
|
702: | return '';
|
703: | }
|
704: |
|
705: | |
706: | |
707: |
|
708: | function _host()
|
709: | {
|
710: | return !isset($_SERVER['HTTP_HOST']) ? isset($_SERVER['SERVER_NAME'])
|
711: | ? $_SERVER['SERVER_NAME'] : php_uname('n') : $_SERVER['HTTP_HOST'];
|
712: | }
|
713: | |
714: | |
715: | |
716: | |
717: | |
718: | |
719: |
|
720: | function _cfg($key, $value = '')
|
721: | {
|
722: | if (strrpos($key, 'lc_') === 0) {
|
723: | $key = substr($key, 3);
|
724: | }
|
725: |
|
726: | $key = 'lc_' . $key;
|
727: |
|
728: | return count(func_get_args()) == 2 ? __dotNotationToArray($key, 'global', $value) : __dotNotationToArray($key, 'global');
|
729: | }
|
730: |
|
731: | |
732: | |
733: | |
734: | |
735: | |
736: | |
737: |
|
738: | function _cfgOption($name, $key)
|
739: | {
|
740: | $config = _cfg($name);
|
741: |
|
742: | return isset($config[$key]) ? $config[$key] : null;
|
743: | }
|
744: |
|
745: | |
746: | |
747: | |
748: | |
749: | |
750: | |
751: |
|
752: | function _p($name = 'env')
|
753: | {
|
754: | if ($name == 'env') {
|
755: | return __env();
|
756: | }
|
757: |
|
758: | global $argv;
|
759: |
|
760: | if (PHP_SAPI == 'cli' && $argv[0] === 'lucidframe') {
|
761: |
|
762: | $env = _cfg('env');
|
763: | } elseif (PHP_SAPI == 'cli' || stripos($_SERVER['REQUEST_URI'], 'tests/') !== false) {
|
764: |
|
765: |
|
766: | $env = 'test';
|
767: | _cfg('env', $env);
|
768: | } else {
|
769: |
|
770: | $env = _cfg('env');
|
771: | }
|
772: |
|
773: | if (!in_array($env, __envList())) {
|
774: | die(sprintf('Wrong environment configuration. Use "%s" or "%s" or "%s" or "%s".', ENV_DEV, ENV_STAGING, ENV_PROD, ENV_TEST));
|
775: | }
|
776: |
|
777: | $param = include(INC . 'parameter/' . $env . '.php');
|
778: |
|
779: | return __dotNotationToArray($name, $param);
|
780: | }
|
781: |
|
782: | |
783: | |
784: | |
785: | |
786: | |
787: |
|
788: | function _env($name, $default = '')
|
789: | {
|
790: | global $lc_envParameters;
|
791: |
|
792: | if ($lc_envParameters === null) {
|
793: | $file = INC . 'parameter/parameter.env.inc';
|
794: | if (is_file($file) && file_exists($file)) {
|
795: | $lc_envParameters = include($file);
|
796: | } else {
|
797: | return $default;
|
798: | }
|
799: | }
|
800: |
|
801: | $value = __dotNotationToArray($name, $lc_envParameters);
|
802: |
|
803: | return $value ?: $default;
|
804: | }
|
805: |
|
806: | |
807: | |
808: | |
809: |
|
810: | function _baseUrlWithProtocol()
|
811: | {
|
812: | if (isset($_SERVER['SERVER_PROTOCOL'])) {
|
813: | $baseUrl = _cfg('baseURL');
|
814: | $protocol = _cfg('ssl') ? 'https' : 'http';
|
815: | $base = strtolower($protocol) . '://' . $_SERVER['HTTP_HOST'];
|
816: | if ($baseUrl) {
|
817: | $base .= '/' . $baseUrl;
|
818: | }
|
819: |
|
820: | return $base;
|
821: | }
|
822: |
|
823: | return false;
|
824: | }
|
825: |
|
826: | |
827: | |
828: | |
829: | |
830: |
|
831: | function _baseDirs($subDir = '')
|
832: | {
|
833: | $folders = array();
|
834: |
|
835: | $namespace = LC_NAMESPACE;
|
836: | if (!empty($_GET['lc_namespace'])) {
|
837: | $namespace = $_GET['lc_namespace'];
|
838: | }
|
839: |
|
840: | $sites = _cfg('sites');
|
841: | if (count($sites) && array_key_exists($namespace, $sites)) {
|
842: | $folders[] = rtrim(APP_ROOT . $sites[$namespace] . _DS_ . $subDir, _DS_) . _DS_;
|
843: | }
|
844: |
|
845: | $folders[] = rtrim(APP_ROOT . $subDir, _DS_) . _DS_;
|
846: | $folders[] = rtrim(LIB . $subDir, _DS_) . _DS_;
|
847: |
|
848: | return $folders;
|
849: | }
|
850: |
|
851: |
|
852: | __prerequisite();
|
853: | |