From b4717e3bb73d1f0ebd122c1861f21f6bd240d373 Mon Sep 17 00:00:00 2001 From: MilenGG Date: Thu, 20 Jan 2022 10:02:53 +0200 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D1=89=20=D0=BD=D0=B0=D1=87=D0=B8?= =?UTF-8?q?=D0=BD=20=D0=B7=D0=B0=20=D1=83=D0=BD=D0=B8=D0=BA=D0=B0=D0=BB?= =?UTF-8?q?=D0=BD=D0=BE=20=D0=98=D0=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/Html.class.php | 15 ++++++++++++--- hclean/JSSanitizer.class.php | 2 +- mejs/Adapter.class.php | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/core/Html.class.php b/core/Html.class.php index e56349e0747..d5e5fd7e367 100644 --- a/core/Html.class.php +++ b/core/Html.class.php @@ -1340,6 +1340,17 @@ public static function arrayToHtml($arr, $openLevels = 3, $viewLevels = 5) return $result; } + + /** + * Връща уникално id за хита започващо с подадения префикс + */ + public static function getUniqId($prefix = '') + { + static $id; + $id++; + + return $prefix . base_convert($id . rand(1000, 9999), 10, 36); + } /** @@ -1348,11 +1359,9 @@ public static function arrayToHtml($arr, $openLevels = 3, $viewLevels = 5) public static function setUniqId(&$attr) { if (!$attr['id']) { - static $id; - $id++; $name = $attr['name'] ? $attr['name'] : 'autoElement'; $name = str_replace(array('[', ']'), array('_', '_'), $name); - $attr['id'] = $name . rand(1000, 9999) . '_' .$id; + $attr['id'] = self::getUniqId($name); } } diff --git a/hclean/JSSanitizer.class.php b/hclean/JSSanitizer.class.php index 4ca0b605903..1b0ae23ee31 100644 --- a/hclean/JSSanitizer.class.php +++ b/hclean/JSSanitizer.class.php @@ -35,7 +35,7 @@ public static function sanitizeHtml($tpl, $link) $tpl->replace($sanitizer, 'SANITIZEJS'); // Генерираме уникално id за атрибута - $uniqId = core_Os::getUniqId('emb'); + $uniqId = ht::getUniqId('emb'); // Заместваме уникалното id $tpl->replace($uniqId, 'SANITIZEID'); diff --git a/mejs/Adapter.class.php b/mejs/Adapter.class.php index b5dad652a50..c7c5117a78c 100644 --- a/mejs/Adapter.class.php +++ b/mejs/Adapter.class.php @@ -75,7 +75,7 @@ public static function create($source, $type = 'video', $params = null, $fileTyp } // Генерираме уникално id - $id = core_Os::getUniqId('mejs'); + $id = ht::getUniqId('mejs'); // Шаблона, който ще връщаме $mTpl = new ET("