From 8b6fd78dfd7e6fb2d022d75d55a88bca175702fc Mon Sep 17 00:00:00 2001 From: Ali Shahidi Date: Wed, 6 Jul 2022 01:44:12 +0430 Subject: [PATCH] bug fix and add some package for html encode --- composer.json | 3 ++- system/Helpers/Helpers.php | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b7a01d8..9d25b12 100755 --- a/composer.json +++ b/composer.json @@ -17,6 +17,7 @@ "gregwar/captcha": "^1.1", "morilog/jalali": "^3.3", "symfony/finder": "^6.0", - "symfony/filesystem": "^6.0" + "symfony/filesystem": "^6.0", + "ezyang/htmlpurifier": "^4.14" } } diff --git a/system/Helpers/Helpers.php b/system/Helpers/Helpers.php index 12f6509..1726bfc 100755 --- a/system/Helpers/Helpers.php +++ b/system/Helpers/Helpers.php @@ -57,6 +57,15 @@ function oldEqualValue($oldName, $value) } } +if (!function_exists("oldOrEqualValue")) { + function oldOrEqualValue($oldName, $value, $mainValue) + { + if(isset($_SESSION["tmp_old"][$oldName])) + return $_SESSION["tmp_old"][$oldName] === $value ? true : false; + return $value === $mainValue ? true : false; + } +} + if (!function_exists("oldOr")) { function oldOr($name, $value) { @@ -310,6 +319,22 @@ function d($value) } } +if (!function_exists("hp")) { + function hp($value) + { + $config = HTMLPurifier_Config::createDefault(); + $purifier = new HTMLPurifier($config); + return $purifier->purify($value); + } +} + +if (!function_exists("hpd")) { + function hpd($value) + { + d(hp($value)); + } +} + if (!function_exists("setOr")) { function setOr($issetValue, $replaceValue) {