1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
14:
15: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
16:
17: cInclude('includes', 'functions.file.php');
18:
19: 20: 21: 22: 23: 24: 25: 26: 27: 28:
29: function getAvailableContentTypes($idartlang) {
30: global $db, $cfg, $a_content, $a_description;
31:
32: $sql = "SELECT
33: *
34: FROM
35: " . $cfg["tab"]["content"] . " AS a,
36: " . $cfg["tab"]["art_lang"] . " AS b,
37: " . $cfg["tab"]["type"] . " AS c
38: WHERE
39: a.idtype = c.idtype AND
40: a.idartlang = b.idartlang AND
41: b.idartlang = " . (int) $idartlang;
42:
43: $db->query($sql);
44:
45: while ($db->nextRecord()) {
46: $a_content[$db->f('type')][$db->f('typeid')] = $db->f('value');
47: $a_description[$db->f('type')][$db->f('typeid')] = i18n($db->f('description'));
48: }
49: }
50:
51: 52: 53: 54: 55: 56: 57: 58:
59: function isArtInMultipleUse($idart) {
60: global $cfg;
61:
62: $db = cRegistry::getDb();
63: $sql = "SELECT idart FROM " . $cfg["tab"]["cat_art"] . " WHERE idart = " . (int) $idart;
64: $db->query($sql);
65:
66: return ($db->affectedRows() > 1);
67: }
68:
69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80:
81: function isAlphanumeric($test, $umlauts = true) {
82: return cString::isAlphanumeric($test, $umlauts);
83: }
84:
85: 86: 87: 88: 89: 90: 91: 92:
93: function isUtf8($input) {
94: return cString::isUtf8($input);
95: }
96:
97: 98: 99: 100: 101: 102:
103: function getCanonicalMonth($month) {
104: switch ($month) {
105: case 1:
106: return (i18n("January"));
107: break;
108: case 2:
109: return (i18n("February"));
110: break;
111: case 3:
112: return (i18n("March"));
113: break;
114: case 4:
115: return (i18n("April"));
116: break;
117: case 5:
118: return (i18n("May"));
119: break;
120: case 6:
121: return (i18n("June"));
122: break;
123: case 7:
124: return (i18n("July"));
125: break;
126: case 8:
127: return (i18n("August"));
128: break;
129: case 9:
130: return (i18n("September"));
131: break;
132: case 10:
133: return (i18n("October"));
134: break;
135: case 11:
136: return (i18n("November"));
137: break;
138: case 12:
139: return (i18n("December"));
140: break;
141: }
142: }
143:
144: 145: 146: 147: 148: 149: 150: 151:
152: function getCanonicalDay($iDay) {
153: switch ($iDay) {
154: case 1:
155: return (i18n("Monday"));
156: break;
157: case 2:
158: return (i18n("Tuesday"));
159: break;
160: case 3:
161: return (i18n("Wednesday"));
162: break;
163: case 4:
164: return (i18n("Thursday"));
165: break;
166: case 5:
167: return (i18n("Friday"));
168: break;
169: case 6:
170: return (i18n("Saturday"));
171: break;
172: case 0:
173: return (i18n("Sunday"));
174: break;
175: default:
176: break;
177: }
178: }
179:
180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191:
192: function displayDatetime($timestamp = "", $date = false, $time = false) {
193: if ($timestamp == "") {
194: $timestamp = time();
195: } else {
196: $timestamp = strtotime($timestamp);
197: }
198:
199: $ret = "";
200:
201: if ($date && !$time) {
202: $ret = date(getEffectiveSetting("dateformat", "date", "Y-m-d"), $timestamp);
203: } else if ($time && !$date) {
204: $ret = date(getEffectiveSetting("dateformat", "time", "H:i:s"), $timestamp);
205: } else {
206: $ret = date(getEffectiveSetting("dateformat", "full", "Y-m-d H:i:s"), $timestamp);
207: }
208: return $ret;
209: }
210:
211: 212: 213: 214: 215: 216: 217:
218: function getIDForArea($area) {
219: if (!is_numeric($area)) {
220: $oArea = new cApiArea();
221: if ($oArea->loadBy('name', $area)) {
222: $area = $oArea->get('idarea');
223: }
224: }
225:
226: return $area;
227: }
228:
229: 230: 231: 232: 233: 234:
235: function getParentAreaId($area) {
236: $oAreaColl = new cApiAreaCollection();
237: return $oAreaColl->getParentAreaID($area);
238: }
239:
240: 241: 242: 243: 244: 245: 246: 247: 248:
249: function ($menuitem, $return = false) {
250: global $changeview;
251:
252: if (!isset($changeview) || 'prev' !== $changeview) {
253:
254: $str = <<<JS
255: <script type="text/javascript">
256: var id = 'c_{$menuitem}';
257: if ('undefined' !== typeof(Con)) {
258: Con.markSubmenuItem(id);
259: } else {
260: // Contenido backend but with frozen article
261: // Check if submenuItem is existing and mark it
262: if (parent.parent.frames.right.frames.right_top.document.getElementById(id)) {
263: menuItem = parent.parent.frames.right.frames.right_top.document.getElementById(id).getElementsByTagName('a')[0];
264: // load the new tab now
265: parent.parent.frames.right.frames.right_top.Con.Subnav.clicked(menuItem, true);
266: }
267: }
268: </script>
269: JS;
270: } else {
271:
272: $str = <<<JS
273: <script type="text/javascript">
274: (function(id) {
275: var menuItem;
276: try {
277: // Check if we are in a dual-frame or a quad-frame
278: if (parent.parent.frames[0].name == 'header') {
279: if (parent.frames.right_top.document.getElementById(id)) {
280: menuItem = parent.frames.right_top.document.getElementById(id).getElementsByTagName('a')[0];
281: parent.frames.right_top.Con.Subnav.clicked(menuItem);
282: }
283: } else {
284: // Check if submenuItem is existing and mark it
285: if (parent.parent.frames.right.frames.right_top.document.getElementById(id)) {
286: menuItem = parent.parent.frames.right.frames.right_top.document.getElementById(id).getElementsByTagName('a')[0];
287: parent.parent.frames.right.frames.right_top.Con.Subnav.clicked(menuItem);
288: }
289: }
290: } catch (e) {}
291: })('c_{$menuitem}');
292: </script>
293: JS;
294: }
295:
296: if ($return) {
297: return $str;
298: } else {
299: echo $str;
300: }
301: }
302:
303: 304: 305: 306: 307: 308: 309:
310: function conMakeInlineScript($content) {
311: $script = <<<JS
312: <script type="text/javascript">
313: (function(Con, $) {
314: {$content}
315: })(Con, Con.$);
316: </script>
317: JS;
318: return $script;
319: }
320:
321: 322: 323: 324: 325: 326:
327: function backToMainArea($send) {
328: if ($send) {
329:
330: global $area, $sess, $idart, $idcat, $idartlang, $idcatart, $frame;
331:
332:
333: $oAreaColl = new cApiAreaCollection();
334: $parent = $oAreaColl->getParentAreaID($area);
335:
336:
337: $url_str = 'main.php?' . 'area=' . $parent . '&' . 'idcat=' . $idcat . '&' . 'idart=' . $idart . '&' . 'idartlang=' . $idartlang . '&' . 'idcatart=' . $idcatart . '&' . 'force=1&' . 'frame=' . $frame;
338: $url = $sess->url($url_str);
339:
340:
341: header("location: $url");
342: }
343: }
344:
345: 346: 347: 348: 349: 350:
351: function getLanguagesByClient($client) {
352: $oClientLangColl = new cApiClientLanguageCollection();
353: return $oClientLangColl->getLanguagesByClient($client);
354: }
355:
356: 357: 358: 359: 360: 361: 362: 363:
364: function getLanguageNamesByClient($client) {
365: $oClientLangColl = new cApiClientLanguageCollection();
366: return $oClientLangColl->getLanguageNamesByClient($client);
367: }
368:
369: 370: 371: 372: 373: 374: 375: 376:
377: function set_magic_quotes_gpc(&$code) {
378: cDeprecated('This method is deprecated and is not needed any longer');
379:
380: global $cfg;
381: if (!$cfg['simulate_magic_quotes']) {
382: if (get_magic_quotes_gpc() == 0) {
383: $code = addslashes($code);
384: }
385: }
386: }
387:
388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399:
400: function getAllClientsAndLanguages() {
401: global $db, $cfg;
402:
403: $sql = "SELECT
404: a.idlang as idlang,
405: a.name as langname,
406: b.name as clientname,
407: b.idclient as idclient
408: FROM
409: " . $cfg["tab"]["lang"] . " as a,
410: " . $cfg["tab"]["clients_lang"] . " as c,
411: " . $cfg["tab"]["clients"] . " as b
412: WHERE
413: a.idlang = c.idlang AND
414: c.idclient = b.idclient";
415: $db->query($sql);
416:
417: $aRs = array();
418: while ($db->nextRecord()) {
419: $aRs[] = array(
420: 'idlang' => $db->f('idlang'),
421: 'langname' => $db->f('langname'),
422: 'idclient' => $db->f('idclient'),
423: 'clientname' => $db->f('clientname')
424: );
425: }
426: return $aRs;
427: }
428:
429: 430: 431: 432:
433: function getmicrotime() {
434: list($usec, $sec) = explode(' ', microtime());
435: return ((float) $usec + (float) $sec);
436: }
437:
438: 439: 440: 441: 442:
443: function isGroup($uid) {
444: $user = new cApiUser();
445: if ($user->loadByPrimaryKey($uid) === false) {
446: return true;
447: } else {
448: return false;
449: }
450: }
451:
452: 453: 454: 455: 456:
457: function getGroupOrUserName($uid) {
458: $user = new cApiUser();
459: if ($user->loadByPrimaryKey($uid) === false) {
460: $group = new cApiGroup();
461:
462: if ($group->loadByPrimaryKey($uid) === false) {
463: return false;
464: } else {
465: return $group->getGroupName(true);
466: }
467: } else {
468: return $user->getField('realname');
469: }
470: }
471:
472: 473: 474: 475: 476: 477: 478: 479:
480: function isValidMail($email, $strict = false) {
481: $validator = cValidatorFactory::getInstance('email');
482: return $validator->isValid($email);
483: }
484:
485: 486: 487: 488: 489:
490: function htmldecode($string) {
491: $trans_tbl = conGetHtmlTranslationTable(HTML_ENTITIES);
492: $trans_tbl = array_flip($trans_tbl);
493: $ret = strtr($string, $trans_tbl);
494: return $ret;
495: }
496:
497: 498: 499: 500: 501: 502: 503: 504: 505: 506: 507: 508: 509: 510: 511:
512: function updateClientCache($idclient = 0, $htmlpath = '', $frontendpath = '') {
513:
514: global $cfg, $cfgClient, $errsite_idcat, $errsite_idart;
515:
516: if (!is_array($cfgClient)) {
517: $cfgClient = array();
518: }
519:
520: if ($idclient != 0 && $htmlpath != '' && $frontendpath != '') {
521: $cfgClient[$idclient]['path']['frontend'] = cSecurity::escapeString($frontendpath);
522: $cfgClient[$idclient]['path']['htmlpath'] = cSecurity::escapeString($htmlpath);
523: }
524:
525:
526: $htmlpaths = array();
527: $frontendpaths = array();
528: foreach ($cfgClient as $id => $aclient) {
529: if (is_array($aclient)) {
530: $htmlpaths[$id] = $aclient["path"]["htmlpath"];
531: $frontendpaths[$id] = $aclient["path"]["frontend"];
532: }
533: }
534: unset($cfgClient);
535: $cfgClient = array();
536:
537:
538:
539:
540:
541:
542:
543:
544:
545: $db = cRegistry::getDb();
546: $db->query('
547: SELECT idclient
548: , name
549: , errsite_cat
550: , errsite_art
551: FROM ' . $cfg['tab']['clients']);
552:
553: while ($db->nextRecord()) {
554: $iClient = $db->f('idclient');
555: $cfgClient['set'] = 'set';
556:
557:
558: if (isset($htmlpaths[$iClient])) {
559: $cfgClient[$iClient]["path"]["htmlpath"] = $htmlpaths[$iClient];
560: }
561: if (isset($frontendpaths[$iClient])) {
562: $cfgClient[$iClient]["path"]["frontend"] = $frontendpaths[$iClient];
563: }
564:
565: $cfgClient[$iClient]['name'] = conHtmlSpecialChars(str_replace(array(
566: '*/',
567: '/*',
568: '//'
569: ), '', $db->f('name')));
570:
571: $errsite_idcat[$iClient] = $db->f('errsite_cat');
572: $errsite_idart[$iClient] = $db->f('errsite_art');
573: $cfgClient[$iClient]["errsite"]["idcat"] = $errsite_idcat[$iClient];
574: $cfgClient[$iClient]["errsite"]["idart"] = $errsite_idart[$iClient];
575:
576: $cfgClient[$iClient]['images'] = $cfgClient[$iClient]['path']['htmlpath'] . 'images/';
577: $cfgClient[$iClient]['upload'] = 'upload/';
578:
579: $cfgClient[$iClient]['htmlpath']['frontend'] = $cfgClient[$iClient]['path']['htmlpath'];
580:
581: $cfgClient[$iClient]['upl']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'upload/';
582: $cfgClient[$iClient]['upl']['htmlpath'] = $cfgClient[$iClient]['htmlpath']['frontend'] . 'upload/';
583: $cfgClient[$iClient]['upl']['frontendpath'] = 'upload/';
584:
585: $cfgClient[$iClient]['css']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'css/';
586:
587: $cfgClient[$iClient]['js']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'js/';
588:
589: $cfgClient[$iClient]['tpl']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'templates/';
590:
591: $cfgClient[$iClient]['cache']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'cache/';
592: $cfgClient[$iClient]['cache']['frontendpath'] = 'cache/';
593:
594: $cfgClient[$iClient]['code']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'cache/code/';
595: $cfgClient[$iClient]['code']['frontendpath'] = 'cache/code/';
596:
597: $cfgClient[$iClient]['xml']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'xml/';
598: $cfgClient[$iClient]['xml']['frontendpath'] = 'xml/';
599:
600: $cfgClient[$iClient]['template']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'templates/';
601: $cfgClient[$iClient]['template']['frontendpath'] = 'templates/';
602:
603: $cfgClient[$iClient]['data']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'data/';
604:
605: $cfgClient[$iClient]['module']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'data/modules/';
606: $cfgClient[$iClient]['module']['frontendpath'] = 'data/modules/';
607:
608: $cfgClient[$iClient]['config']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'data/config/' . CON_ENVIRONMENT . '/';
609: $cfgClient[$iClient]['config']['frontendpath'] = 'data/config/';
610:
611: $cfgClient[$iClient]['layout']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'data/layouts/';
612: $cfgClient[$iClient]['layout']['frontendpath'] = 'data/layouts/';
613:
614: $cfgClient[$iClient]['log']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'data/logs/';
615: $cfgClient[$iClient]['log']['frontendpath'] = 'data/logs/';
616:
617: $cfgClient[$iClient]['version']['path'] = $cfgClient[$iClient]['path']['frontend'] . 'data/version/';
618: $cfgClient[$iClient]['version']['frontendpath'] = 'data/version/';
619: }
620:
621: $aConfigFileContent = array();
622: $aConfigFileContent[] = '<?php';
623: $aConfigFileContent[] = 'global $cfgClient;';
624: $aConfigFileContent[] = '';
625:
626: foreach ($cfgClient as $iIdClient => $aClient) {
627: if ((int) $iIdClient > 0 && is_array($aClient)) {
628:
629: $aConfigFileContent[] = '/* ' . $aClient['name'] . ' */';
630: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["name"] = "' . $aClient['name'] . '";';
631: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["errsite"]["idcat"] = "' . $aClient["errsite"]["idcat"] . '";';
632: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["errsite"]["idart"] = "' . $aClient["errsite"]["idart"] . '";';
633: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["images"] = "' . $aClient["path"]["htmlpath"] . 'images/";';
634: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["upload"] = "upload/";';
635:
636: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["path"]["frontend"] = "' . $aClient["path"]["frontend"] . '";';
637:
638: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["htmlpath"]["frontend"] = "' . $aClient["path"]["htmlpath"] . '";';
639:
640: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["upl"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "upload/";';
641: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["upl"]["htmlpath"] = "' . $aClient["htmlpath"]["frontend"] . 'upload/";';
642: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["upl"]["frontendpath"] = "upload/";';
643:
644: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["css"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "css/";';
645:
646: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["js"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "js/";';
647:
648: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["tpl"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "templates/";';
649:
650: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["cache"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "cache/";';
651: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["cache"]["frontendpath"] = "cache/";';
652:
653: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["code"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "cache/code/";';
654: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["code"]["frontendpath"] = "cache/code/";';
655:
656: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["xml"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "xml/";';
657: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["xml"]["frontendpath"] = "xml/";';
658:
659: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["template"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "templates/";';
660: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["template"]["frontendpath"] = "templates/";';
661:
662: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["data"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "data/";';
663:
664: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["module"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "data/modules/";';
665: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["module"]["frontendpath"] = "data/modules/";';
666:
667: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["config"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "data/config/' . CON_ENVIRONMENT . '/";';
668: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["config"]["frontendpath"] = "data/config/";';
669:
670: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["layout"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "data/layouts/";';
671: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["layout"]["frontendpath"] = "data/layouts/";';
672:
673: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["log"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "data/logs/";';
674: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["log"]["frontendpath"] = "data/logs/";';
675:
676: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["version"]["path"] = $cfgClient[' . $iIdClient . ']["path"]["frontend"] . "data/version/";';
677: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["version"]["frontendpath"] = "data/version/";';
678: $aConfigFileContent[] = '$cfgClient[' . $iIdClient . ']["path"]["htmlpath"] = "' . $aClient['path']['htmlpath'] . '";';
679: $aConfigFileContent[] = '';
680: }
681: }
682: $aConfigFileContent[] = '$cfgClient["set"] = "set";';
683: $aConfigFileContent[] = '?>';
684:
685: cFileHandler::write($cfg['path']['contenido_config'] . 'config.clients.php', implode(PHP_EOL, $aConfigFileContent));
686:
687: return $cfgClient;
688: }
689:
690: 691: 692: 693: 694: 695: 696: 697: 698: 699: 700: 701: 702: 703: 704: 705:
706: function setSystemProperty($type, $name, $value, $idsystemprop = 0) {
707: if ($type == '' || $name == '') {
708: return false;
709: }
710:
711: $idsystemprop = (int) $idsystemprop;
712:
713: $systemPropColl = new cApiSystemPropertyCollection();
714:
715: if ($idsystemprop == 0) {
716: $prop = $systemPropColl->setValueByTypeName($type, $name, $value);
717: } else {
718: $prop = $systemPropColl->setTypeNameValueById($type, $name, $value, $idsystemprop);
719: }
720: }
721:
722: 723: 724: 725: 726: 727: 728: 729: 730:
731: function deleteSystemProperty($type, $name) {
732: $systemPropColl = new cApiSystemPropertyCollection();
733: $systemPropColl->deleteByTypeName($type, $name);
734: }
735:
736: 737: 738: 739: 740: 741: 742: 743: 744: 745: 746: 747: 748: 749: 750: 751: 752:
753: function getSystemProperties($bGetPropId = false) {
754: $return = array();
755:
756: $systemPropColl = new cApiSystemPropertyCollection();
757: $props = $systemPropColl->fetchAll('type ASC, name ASC, value ASC');
758: foreach ($props as $prop) {
759: $item = $prop->toArray();
760:
761: if ($bGetPropId) {
762: $return[$item['type']][$item['name']]['value'] = $item['value'];
763: $return[$item['type']][$item['name']]['idsystemprop'] = $item['idsystemprop'];
764: } else {
765: $return[$item['type']][$item['name']] = $item['value'];
766: }
767: }
768:
769: return $return;
770: }
771:
772: 773: 774: 775: 776: 777: 778: 779: 780: 781:
782: function getSystemProperty($type, $name) {
783: $systemPropColl = new cApiSystemPropertyCollection();
784: $prop = $systemPropColl->fetchByTypeName($type, $name);
785: return ($prop) ? $prop->get('value') : false;
786: }
787:
788: 789: 790: 791: 792: 793: 794: 795: 796:
797: function getSystemPropertiesByType($type) {
798: $return = array();
799:
800: $systemPropColl = new cApiSystemPropertyCollection();
801: $props = $systemPropColl->fetchByType($type);
802: foreach ($props as $prop) {
803: $return[$prop->get('name')] = $prop->get('value');
804: }
805: if (count($return) > 1) {
806: ksort($return);
807: }
808: return $return;
809: }
810:
811: 812: 813: 814: 815: 816: 817: 818: 819: 820: 821: 822: 823: 824: 825: 826: 827: 828: 829: 830:
831: function getEffectiveSetting($type, $name, $default = '') {
832: return cEffectiveSetting::get($type, $name, $default);
833: }
834:
835: 836: 837: 838: 839: 840: 841: 842: 843: 844: 845: 846:
847: function getEffectiveSettingsByType($type) {
848: return cEffectiveSetting::getByType($type);
849: }
850:
851: 852: 853: 854: 855: 856:
857: function getArtspec() {
858: global $db, $cfg, $lang, $client;
859: $sql = "SELECT artspec, idartspec, online, artspecdefault FROM " . $cfg['tab']['art_spec'] . "
860: WHERE client = " . (int) $client . " AND lang = " . (int) $lang . " ORDER BY artspec ASC";
861: $db->query($sql);
862:
863: $artspec = array();
864:
865: while ($db->nextRecord()) {
866: $artspec[$db->f("idartspec")]['artspec'] = $db->f("artspec");
867: $artspec[$db->f("idartspec")]['online'] = $db->f("online");
868: $artspec[$db->f("idartspec")]['default'] = $db->f("artspecdefault");
869: }
870: return $artspec;
871: }
872:
873: 874: 875: 876: 877: 878: 879: 880:
881: function addArtspec($artspectext, $online) {
882: global $db, $cfg, $lang, $client;
883:
884: if (isset($_POST['idartspec'])) {
885: $fields = array(
886: 'artspec' => $artspectext,
887: 'online' => (int) $online
888: );
889: $where = array(
890: 'idartspec' => (int) $_POST['idartspec']
891: );
892: $sql = $db->buildUpdate($cfg['tab']['art_spec'], $fields, $where);
893: } else {
894: $fields = array(
895: 'client' => (int) $client,
896: 'lang' => (int) $lang,
897: 'artspec' => $artspectext,
898: 'online' => 0,
899: 'artspecdefault' => 0
900: );
901: $sql = $db->buildInsert($cfg['tab']['art_spec'], $fields);
902: }
903: $db->query($sql);
904: }
905:
906: 907: 908: 909: 910: 911:
912: function deleteArtspec($idartspec) {
913: global $db, $cfg;
914: $sql = "DELETE FROM " . $cfg['tab']['art_spec'] . " WHERE idartspec = " . (int) $idartspec;
915: $db->query($sql);
916:
917: $sql = "UPDATE " . $cfg["tab"]["art_lang"] . " SET artspec = 0 WHERE artspec = " . (int) $idartspec;
918: $db->query($sql);
919: }
920:
921: 922: 923: 924: 925: 926: 927: 928: 929: 930: 931:
932: function setArtspecOnline($idartspec, $online) {
933: global $db, $cfg;
934: $sql = "UPDATE " . $cfg['tab']['art_spec'] . " SET online = " . (int) $online . " WHERE idartspec = " . (int) $idartspec;
935: $db->query($sql);
936: }
937:
938: 939: 940: 941: 942: 943: 944: 945: 946:
947: function setArtspecDefault($idartspec) {
948: global $db, $cfg, $lang, $client;
949: $sql = "UPDATE " . $cfg['tab']['art_spec'] . " SET artspecdefault=0 WHERE client = " . (int) $client . " AND lang = " . (int) $lang;
950: $db->query($sql);
951:
952: $sql = "UPDATE " . $cfg['tab']['art_spec'] . " SET artspecdefault = 1 WHERE idartspec = " . (int) $idartspec;
953: $db->query($sql);
954: }
955:
956: 957: 958: 959: 960: 961: 962: 963: 964: 965: 966: 967:
968: function buildArticleSelect($sName, $iIdCat, $sValue) {
969: global $cfg, $lang;
970:
971: $db = cRegistry::getDb();
972:
973: $selectElem = new cHTMLSelectElement($sName, "", $sName);
974: $selectElem->appendOptionElement(new cHTMLOptionElement(i18n("Please choose"), ""));
975:
976: $sql = "SELECT b.title, b.idart FROM
977: " . $cfg["tab"]["art"] . " AS a, " . $cfg["tab"]["art_lang"] . " AS b, " . $cfg["tab"]["cat_art"] . " AS c
978: WHERE c.idcat = " . (int) $iIdCat . "
979: AND b.idlang = " . (int) $lang . " AND b.idart = a.idart and b.idart = c.idart
980: ORDER BY b.title";
981:
982: $db->query($sql);
983:
984: while ($db->nextRecord()) {
985: if ($sValue != $db->f('idart')) {
986: $selectElem->appendOptionElement(new cHTMLOptionElement($db->f('title'), $db->f('idart')));
987: } else {
988: $selectElem->appendOptionElement(new cHTMLOptionElement($db->f('title'), $db->f('idart'), true));
989: }
990: }
991:
992: return $selectElem->toHtml();
993: }
994:
995: 996: 997: 998: 999: 1000: 1001: 1002: 1003: 1004: 1005: 1006: 1007: 1008:
1009: function buildCategorySelect($sName, $sValue, $sLevel = 0, $sClass = '') {
1010: global $cfg, $client, $lang;
1011:
1012: $db = cRegistry::getDb();
1013: $db2 = cRegistry::getDb();
1014:
1015: $selectElem = new cHTMLSelectElement($sName, "", $sName);
1016: $selectElem->setClass($sClass);
1017: $selectElem->appendOptionElement(new cHTMLOptionElement(i18n("Please choose"), ""));
1018:
1019: if ($sLevel > 0) {
1020: $addString = "AND c.level < " . (int) $sLevel;
1021: }
1022:
1023: $sql = "SELECT a.idcat AS idcat, b.name AS name, c.level FROM
1024: " . $cfg["tab"]["cat"] . " AS a, " . $cfg["tab"]["cat_lang"] . " AS b,
1025: " . $cfg["tab"]["cat_tree"] . " AS c WHERE a.idclient = " . (int) $client . "
1026: AND b.idlang = " . (int) $lang . " AND b.idcat = a.idcat AND c.idcat = a.idcat " . $addString . "
1027: ORDER BY c.idtree";
1028:
1029: $db->query($sql);
1030:
1031: $categories = array();
1032:
1033: while ($db->nextRecord()) {
1034: $categories[$db->f("idcat")]["name"] = $db->f("name");
1035:
1036: $sql2 = "SELECT level FROM " . $cfg["tab"]["cat_tree"] . " WHERE idcat = " . (int) $db->f("idcat");
1037: $db2->query($sql2);
1038:
1039: if ($db2->nextRecord()) {
1040: $categories[$db->f("idcat")]["level"] = $db2->f("level");
1041: }
1042:
1043: $sql2 = "SELECT a.title AS title, b.idcatart AS idcatart FROM
1044: " . $cfg["tab"]["art_lang"] . " AS a, " . $cfg["tab"]["cat_art"] . " AS b
1045: WHERE b.idcat = '" . $db->f("idcat") . "' AND a.idart = b.idart AND
1046: a.idlang = " . (int) $lang;
1047:
1048: $db2->query($sql2);
1049:
1050: while ($db2->nextRecord()) {
1051: $categories[$db->f("idcat")]["articles"][$db2->f("idcatart")] = $db2->f("title");
1052: }
1053: }
1054:
1055: foreach ($categories as $tmpidcat => $props) {
1056: $spaces = " ";
1057:
1058: for ($i = 0; $i < $props["level"]; $i++) {
1059: $spaces .= " ";
1060: }
1061:
1062: $tmp_val = $tmpidcat;
1063:
1064: if ($sValue != $tmp_val) {
1065: $selectElem->appendOptionElement(new cHTMLOptionElement($spaces . ">" . $props["name"], $tmp_val));
1066: } else {
1067: $selectElem->appendOptionElement(new cHTMLOptionElement($spaces . ">" . $props["name"], $tmp_val, true));
1068: }
1069: }
1070:
1071: return $selectElem->toHtml();
1072: }
1073:
1074: 1075: 1076: 1077: 1078: 1079: 1080:
1081: function humanReadableSize($number) {
1082: $base = 1024;
1083: $suffixes = array(
1084: 'Bytes',
1085: 'KiB',
1086: 'MiB',
1087: 'GiB',
1088: 'TiB',
1089: 'PiB',
1090: 'EiB'
1091: );
1092:
1093: $usesuf = 0;
1094: $n = (float) $number;
1095: while ($n >= $base) {
1096: $n /= (float) $base;
1097: $usesuf++;
1098: }
1099:
1100: $places = 2 - floor(log10($n));
1101: $places = max($places, 0);
1102: $retval = number_format($n, cSecurity::toInteger($places), '.', '') . ' ' . $suffixes[$usesuf];
1103: return $retval;
1104: }
1105:
1106: 1107: 1108: 1109: 1110: 1111: 1112:
1113: function machineReadableSize($sizeString) {
1114:
1115:
1116: if (cSecurity::isInteger($sizeString)) {
1117: return $sizeString;
1118: }
1119:
1120: $val = trim($sizeString);
1121: $last = strtolower($val[strlen($val) - 1]);
1122: $val = (float) substr($val, 0, strlen($val) - 1);
1123: switch ($last) {
1124: case 'g':
1125: $val *= 1024;
1126: case 'm':
1127: $val *= 1024;
1128: case 'k':
1129: $val *= 1024;
1130: }
1131:
1132: return $val;
1133: }
1134:
1135: 1136: 1137: 1138: 1139: 1140:
1141: function isRunningFromWeb() {
1142: if ($_SERVER['PHP_SELF'] == '' || php_sapi_name() == 'cgi' || php_sapi_name() == 'cli') {
1143: return false;
1144: }
1145:
1146: return true;
1147: }
1148:
1149: 1150: 1151: 1152: 1153: 1154: 1155: 1156: 1157: 1158: 1159: 1160: 1161: 1162: 1163: 1164: 1165: 1166: 1167: 1168:
1169: function scanPlugins($entity) {
1170: global $cfg;
1171:
1172: $basedir = cRegistry::getBackendPath() . $cfg['path']['plugins'] . $entity . '/';
1173: if (is_dir($basedir) === false) {
1174: return;
1175: }
1176:
1177: $pluginorder = getSystemProperty('plugin', $entity . '-pluginorder');
1178: $lastscantime = (int) getSystemProperty('plugin', $entity . '-lastscantime');
1179:
1180: $plugins = array();
1181:
1182:
1183: if ($pluginorder != '') {
1184: $plugins = explode(',', $pluginorder);
1185: foreach ($plugins as $key => $plugin) {
1186: $plugins[$key] = trim($plugin);
1187: }
1188: }
1189:
1190:
1191: if ($lastscantime + 300 < time()) {
1192: setSystemProperty('plugin', $entity . '-lastscantime', time());
1193: if (is_dir($basedir)) {
1194: if (false !== ($handle = cDirHandler::read($basedir))) {
1195: foreach ($handle as $file) {
1196: if (is_dir($basedir . $file) && $file != 'includes' && cFileHandler::fileNameIsDot($file) === false) {
1197: if (!in_array($file, $plugins)) {
1198: if (cFileHandler::exists($basedir . $file . '/' . $file . '.php')) {
1199: $plugins[] = $file;
1200: }
1201: }
1202: }
1203: }
1204: }
1205: }
1206:
1207: foreach ($plugins as $key => $value) {
1208: if (!is_dir($basedir . $value) || !cFileHandler::exists($basedir . $value . '/' . $value . '.php')) {
1209: unset($plugins[$key]);
1210: }
1211: }
1212:
1213: sort($plugins);
1214:
1215: $oldPlugins = explode(',', getSystemProperty('plugin', 'frontendusers-pluginorder'));
1216: sort($oldPlugins);
1217:
1218: $diff = array_diff($oldPlugins, $plugins);
1219:
1220: if (!empty($diff)) {
1221: $pluginorder = implode(',', $plugins);
1222: setSystemProperty('plugin', $entity . '-pluginorder', $pluginorder);
1223: }
1224: }
1225:
1226: foreach ($plugins as $key => $value) {
1227: if (!is_dir($basedir . $value) || !cFileHandler::exists($basedir . $value . '/' . $value . '.php')) {
1228: unset($plugins[$key]);
1229: } else {
1230: i18nRegisterDomain($entity . '_' . $value, $basedir . $value . '/locale/');
1231: }
1232: }
1233:
1234: $cfg['plugins'][$entity] = $plugins;
1235: }
1236:
1237: 1238: 1239: 1240: 1241: 1242:
1243: function includePlugins($entity) {
1244: global $cfg;
1245:
1246: if (is_array($cfg['plugins'][$entity])) {
1247: foreach ($cfg['plugins'][$entity] as $plugin) {
1248: plugin_include($entity, $plugin . '/' . $plugin . '.php');
1249: }
1250: }
1251: }
1252:
1253: 1254: 1255: 1256: 1257: 1258:
1259: function callPluginStore($entity) {
1260: global $cfg;
1261:
1262:
1263: if (is_array($cfg['plugins'][$entity])) {
1264: foreach ($cfg['plugins'][$entity] as $plugin) {
1265: if (function_exists($entity . '_' . $plugin . '_wantedVariables') && function_exists($entity . '_' . $plugin . '_store')) {
1266: $wantVariables = call_user_func($entity . '_' . $plugin . '_wantedVariables');
1267:
1268: if (is_array($wantVariables)) {
1269: $varArray = array();
1270: foreach ($wantVariables as $value) {
1271: $varArray[$value] = stripslashes($GLOBALS[$value]);
1272: }
1273: }
1274: $store = call_user_func($entity . '_' . $plugin . '_store', $varArray);
1275: }
1276: }
1277: }
1278: }
1279:
1280: 1281: 1282: 1283: 1284: 1285: 1286: 1287:
1288: function createRandomName($nameLength) {
1289: $NameChars = 'abcdefghijklmnopqrstuvwxyz';
1290: $Vouel = 'aeiou';
1291: $Name = '';
1292:
1293: for ($index = 1; $index <= $nameLength; $index++) {
1294: if ($index % 3 == 0) {
1295: $randomNumber = rand(1, strlen($Vouel));
1296: $Name .= substr($Vouel, $randomNumber - 1, 1);
1297: } else {
1298: $randomNumber = rand(1, strlen($NameChars));
1299: $Name .= substr($NameChars, $randomNumber - 1, 1);
1300: }
1301: }
1302:
1303: return $Name;
1304: }
1305:
1306: 1307: 1308: 1309: 1310: 1311: 1312: 1313:
1314: function getJsHelpContext($area) {
1315: global $cfg;
1316:
1317: if ($cfg['help'] == true) {
1318: $hc = "parent.parent.parent.frames[0].document.getElementById('help').setAttribute('data', '$area');";
1319: } else {
1320: $hc = '';
1321: }
1322:
1323: return $hc;
1324: }
1325:
1326: 1327: 1328: 1329: 1330: 1331: 1332: 1333:
1334: function defineIfNotDefined($constant, $value) {
1335: if (!defined($constant)) {
1336: define($constant, $value);
1337: }
1338: }
1339:
1340: 1341: 1342: 1343: 1344: 1345: 1346: 1347: 1348: 1349: 1350:
1351: function cDie($file, $line, $message) {
1352: cError($file, $line, $message);
1353: die("$file $line: $message");
1354: }
1355:
1356: 1357: 1358: 1359: 1360: 1361: 1362: 1363: 1364: 1365: 1366:
1367: function buildStackString($startlevel = 2) {
1368: $e = new Exception();
1369: $stack = $e->getTrace();
1370:
1371: $msg = '';
1372:
1373: for ($i = $startlevel; $i < count($stack); $i++) {
1374: $filename = basename($stack[$i]['file']);
1375:
1376: $msg .= "\t" . $stack[$i]['function'] . "() called in file " . $filename . "(" . $stack[$i]['line'] . ")\n";
1377: }
1378:
1379: return $msg;
1380: }
1381:
1382: 1383: 1384: 1385: 1386: 1387: 1388: 1389: 1390: 1391: 1392: 1393: 1394: 1395:
1396: function cWarning() {
1397: global $cfg;
1398:
1399: $args = func_get_args();
1400: if (count($args) == 3) {
1401:
1402: $file = $args[0];
1403: $line = $args[1];
1404: $message = $args[2];
1405: } else {
1406:
1407: $file = '';
1408: $line = '';
1409: $message = $args[0];
1410: }
1411:
1412: $msg = "[" . date("Y-m-d H:i:s") . "] ";
1413: $msg .= "Warning: \"" . $message . "\" at ";
1414:
1415: $e = new Exception();
1416: $stack = $e->getTrace();
1417: $function_name = $stack[1]['function'];
1418:
1419: $msg .= $function_name . "() [" . basename($stack[0]['file']) . "(" . $stack[0]['line'] . ")]\n";
1420:
1421: if ($cfg['debug']['log_stacktraces'] == true) {
1422: $msg .= buildStackString();
1423: $msg .= "\n";
1424: }
1425:
1426: cFileHandler::write($cfg['path']['contenido_logs'] . 'errorlog.txt', $msg, true);
1427:
1428: trigger_error($message, E_USER_WARNING);
1429: }
1430:
1431: 1432: 1433: 1434: 1435: 1436: 1437: 1438: 1439: 1440: 1441: 1442: 1443: 1444:
1445: function cError($message) {
1446: global $cfg;
1447:
1448: $args = func_get_args();
1449: if (count($args) == 3) {
1450:
1451: $file = $args[0];
1452: $line = $args[1];
1453: $message = $args[2];
1454: } else {
1455:
1456: $file = '';
1457: $line = '';
1458: $message = $args[0];
1459: }
1460:
1461: $msg = "[" . date("Y-m-d H:i:s") . "] ";
1462: $msg .= "Error: \"" . $message . "\" at ";
1463:
1464: $e = new Exception();
1465: $stack = $e->getTrace();
1466: $function_name = $stack[1]['function'];
1467:
1468: $msg .= $function_name . "() called in " . basename($stack[1]['file']) . "(" . $stack[1]['line'] . ")\n";
1469:
1470: if ($cfg['debug']['log_stacktraces'] == true) {
1471: $msg .= buildStackString();
1472: $msg .= "\n";
1473: }
1474:
1475: cFileHandler::write($cfg['path']['contenido_logs'] . 'errorlog.txt', $msg, true);
1476:
1477: trigger_error($message, E_USER_ERROR);
1478: }
1479:
1480: 1481: 1482: 1483: 1484: 1485:
1486: function cDeprecated($message = '') {
1487: global $cfg;
1488:
1489: if (isset($cfg['debug']['log_deprecations']) && $cfg['debug']['log_deprecations'] == false) {
1490: return;
1491: }
1492:
1493: $e = new Exception();
1494: $stack = $e->getTrace();
1495: $function_name = $stack[1]['function'];
1496:
1497: $msg = "Deprecated call: " . $function_name . "() [" . basename($stack[0]['file']) . "(" . $stack[0]['line'] . ")]: ";
1498: if ($message != '') {
1499: $msg .= "\"" . $message . "\"" . "\n";
1500: } else {
1501: $msg .= "\n";
1502: }
1503:
1504: if ($cfg['debug']['log_stacktraces'] == true) {
1505: $msg .= buildStackString(2);
1506: $msg .= "\n";
1507: }
1508:
1509: cFileHandler::write($cfg['path']['contenido_logs'] . 'deprecatedlog.txt', $msg, true);
1510: }
1511:
1512: 1513: 1514: 1515: 1516: 1517: 1518: 1519: 1520: 1521:
1522: function getNamedFrame($frame) {
1523: switch ($frame) {
1524: case 1:
1525: return 'left_top';
1526: break;
1527: case 2:
1528: return 'left_bottom';
1529: break;
1530: case 3:
1531: return 'right_top';
1532: break;
1533: case 4:
1534: return 'right_bottom';
1535: break;
1536: default:
1537: return '';
1538: break;
1539: }
1540: }
1541:
1542: 1543: 1544: 1545: 1546: 1547: 1548: 1549: 1550: 1551:
1552: function startTiming($function, $parameters = array()) {
1553: global $_timings, $cfg;
1554:
1555: if ($cfg['debug']['functiontiming'] == false) {
1556: return '';
1557: }
1558:
1559:
1560: $uuid = md5(uniqid(rand(), true));
1561:
1562: if (!is_array($parameters)) {
1563: cWarning(__FILE__, __LINE__, "Warning: startTiming's parameters parameter expects an array");
1564: $parameters = array();
1565: }
1566:
1567: $_timings[$uuid]['parameters'] = $parameters;
1568: $_timings[$uuid]['function'] = $function;
1569:
1570: $_timings[$uuid]['start'] = getmicrotime();
1571:
1572: return $uuid;
1573: }
1574:
1575: 1576: 1577: 1578: 1579: 1580:
1581: function endAndLogTiming($uuid) {
1582: global $_timings, $cfg;
1583:
1584: if ($cfg['debug']['functiontiming'] == false) {
1585: return;
1586: }
1587:
1588: $_timings[$uuid]['end'] = getmicrotime();
1589:
1590: $timeSpent = $_timings[$uuid]['end'] - $_timings[$uuid]['start'];
1591:
1592: $myparams = array();
1593:
1594:
1595: foreach ($_timings[$uuid]['parameters'] as $parameter) {
1596: switch (gettype($parameter)) {
1597: case 'string':
1598: $myparams[] = '"' . $parameter . '"';
1599: break;
1600: case 'boolean':
1601: if ($parameter == true) {
1602: $myparams[] = 'true';
1603: } else {
1604: $myparams[] = 'false';
1605: }
1606: break;
1607: default:
1608: if ($parameter == '') {
1609: $myparams[] = '"' . $parameter . '"';
1610: } else {
1611: $myparams[] = $parameter;
1612: }
1613: }
1614: }
1615:
1616: $parameterString = implode(', ', $myparams);
1617:
1618: cDebug::out('calling function ' . $_timings[$uuid]['function'] . '(' . $parameterString . ') took ' . $timeSpent . ' seconds');
1619: }
1620:
1621: 1622: 1623: 1624: 1625: 1626: 1627: 1628: 1629: 1630: 1631: 1632: 1633: 1634:
1635: function ($db, $cfg, $lang, $contentType = 'text/html') {
1636: if (isset($_GET['use_encoding'])) {
1637: $use_encoding = trim(strip_tags($_GET['use_encoding']));
1638: } elseif (isset($_POST['use_encoding'])) {
1639: $use_encoding = trim(strip_tags($_POST['use_encoding']));
1640: } else {
1641: $use_encoding = true;
1642: }
1643:
1644: if (is_string($use_encoding)) {
1645: $use_encoding = ($use_encoding == 'false') ? false : true;
1646: }
1647:
1648: if ($use_encoding != false) {
1649: $aLanguageEncodings = array();
1650:
1651: $oLangColl = new cApiLanguageCollection();
1652: $oLangColl->select();
1653: while (($oItem = $oLangColl->next()) !== false) {
1654: $aLanguageEncodings[$oItem->get('idlang')] = $oItem->get('encoding');
1655: }
1656:
1657: $charset = 'utf-8';
1658: if (isset($aLanguageEncodings[$lang])) {
1659: if (in_array($aLanguageEncodings[$lang], $cfg['AvailableCharsets'])) {
1660: $charset = $aLanguageEncodings[$lang];
1661: }
1662: }
1663: header('Content-Type: ' . $contentType . '; charset=' . $charset);
1664: }
1665: }
1666:
1667: 1668: 1669: 1670: 1671: 1672: 1673: 1674:
1675: function ipMatch($network, $mask, $ip) {
1676: bcscale(3);
1677: $ip_long = ip2long($ip);
1678: $mask_long = ip2long($network);
1679:
1680:
1681: if (preg_match('/^[0-9]+$/', $mask)) {
1682:
1683: $divider = bcpow(2, (32 - $mask));
1684: } else {
1685:
1686: $xmask = ip2long($mask);
1687: if ($xmask < 0) {
1688: $xmask = bcadd(bcpow(2, 32), $xmask);
1689: }
1690: $divider = bcsub(bcpow(2, 32), $xmask);
1691: }
1692:
1693: if (floor(bcdiv($ip_long, $divider)) == floor(bcdiv($mask_long, $divider))) {
1694:
1695: return true;
1696: } else {
1697:
1698: return false;
1699: }
1700: }
1701:
1702: 1703: 1704: 1705: 1706: 1707: 1708:
1709: function isFunctionDisabled($functionName) {
1710: static $disabledFunctions;
1711:
1712: if (empty($functionName)) {
1713: return true;
1714: }
1715:
1716: if (!isset($disabledFunctions)) {
1717: $disabledFunctions = array_map('trim', explode(',', ini_get('disable_functions')));
1718: }
1719:
1720: return (in_array($functionName, $disabledFunctions));
1721: }
1722:
1723: 1724: 1725: 1726: 1727: 1728: 1729: 1730: 1731: 1732: 1733: 1734:
1735: function renderBackendBreadcrumb($syncoptions, $showArticle = true, $return = false) {
1736: $tplBread = new cTemplate();
1737: $tplBread->set('s', 'LABEL', i18n("You are here"));
1738: $syncoptions = (int) $syncoptions;
1739:
1740: $helper = cCategoryHelper::getInstance();
1741: $categories = $helper->getCategoryPath(cRegistry::getCategoryId(), 1);
1742: $catIds = array_reverse($helper->getParentCategoryIds(cRegistry::getCategoryId()));
1743: $catIds[] = cRegistry::getCategoryId();
1744: $catCount = count($categories);
1745: $tplCfg = new cApiTemplateConfiguration();
1746: $sess = cRegistry::getSession();
1747: $cfg = cRegistry::getConfig();
1748: $lang = cRegistry::getLanguageId();
1749: $idart = cRegistry::getArticleId();
1750:
1751: for ($i = 0; $i < $catCount; $i++) {
1752: $idcat_tpl = 0;
1753: $idcat_bread = $categories[$i]->getField('idcat');
1754: $idcat_name = $categories[$i]->getField('name');
1755: $idcat_tplcfg = $categories[$i]->getField('idtplcfg');
1756: if ((int) $idcat_tplcfg > 0) {
1757: $tplCfg->loadByPrimaryKey($idcat_tplcfg);
1758: if ($tplCfg->isLoaded()) {
1759: $idcat_tpl = $tplCfg->getField('idtpl');
1760: }
1761: }
1762:
1763: $linkUrl = $sess->url(cRegistry::getBackendUrl() . "main.php?area=con&frame=4&idcat=$idcat_bread&idtpl=$idcat_tpl&syncoptions=$syncoptions&contenido=1");
1764:
1765: $disabled = false;
1766: if(!$categories[$i]->isLoaded() && $syncoptions > 0) {
1767: $idcat_name = sprintf(i18n("Unsynchronized category (%s)"), $catIds[$i]);
1768: $linkUrl = "#";
1769: $disabled = true;
1770: }
1771: $tplBread->set('d', 'LINK', $linkUrl);
1772: $tplBread->set('d', 'NAME', $idcat_name);
1773: $tplBread->set('d', 'DISABLED', $disabled ? 'disabled' : '');
1774:
1775: $sepArrow = '';
1776: if ($i < $catCount - 1) {
1777: $sepArrow = ' > ';
1778: } else {
1779: if ((int) $idart > 0 && $showArticle === true) {
1780: $art = new cApiArticleLanguage();
1781: $art->loadByArticleAndLanguageId($idart, $lang);
1782: if ($art->isLoaded()) {
1783: $name = $art->getField('title');
1784: $sepArrow = ' > ' . $name;
1785: }
1786: }
1787: }
1788: $tplBread->set('d', 'SEP_ARROW', $sepArrow);
1789:
1790: $tplBread->next();
1791: }
1792:
1793: return $tplBread->generate($cfg['path']['templates'] . $cfg['templates']['breadcrumb'], $return);
1794: }
1795: