From c6842777861264a7fdecdb5961a9b5aa5d857c14 Mon Sep 17 00:00:00 2001 From: "o.pinke" Date: Wed, 25 Aug 2021 13:57:35 +0200 Subject: [PATCH] add check for php-mbstring extension fix typos --- conlite/external/edit_area/class.edit_area.php | 3 +-- conlite/includes/functions.file.php | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/conlite/external/edit_area/class.edit_area.php b/conlite/external/edit_area/class.edit_area.php index fee937a..f9df410 100644 --- a/conlite/external/edit_area/class.edit_area.php +++ b/conlite/external/edit_area/class.edit_area.php @@ -260,5 +260,4 @@ class EditArea { return $sJsResult; } -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/conlite/includes/functions.file.php b/conlite/includes/functions.file.php index b6d9dd7..5e19455 100644 --- a/conlite/includes/functions.file.php +++ b/conlite/includes/functions.file.php @@ -209,7 +209,11 @@ function fileEdit($filename, $sCode, $path) { if (is_writable($path . $filename)) { if (strlen(stripslashes(trim($sCode))) > 0) { if (!empty($sCode)) { - $sCode = mb_convert_encoding($sCode, 'UTF-8', 'OLD-ENCODING'); + if (extension_loaded('mbstring')) { + $sCode = mb_convert_encoding($sCode, 'UTF-8', 'OLD-ENCODING'); + } else { + $oNot->displayNotification("warning", i18n("PHP-mbstring extension is not activated or installed!")); + } } cFileHandler::write($path . $filename, $sCode); return true; @@ -232,9 +236,14 @@ function fileEdit($filename, $sCode, $path) { * @return (string|void) Either content of file o nothing */ function getFileContent($filename, $path) { + $oNot = new Contenido_Notification(); $sCode = cFileHandler::read($path . $filename); if (!empty($sCode)) { - $sCode = mb_convert_encoding($sCode, 'UTF-8', 'OLD-ENCODING'); + if (extension_loaded('mbstring')) { + $sCode = mb_convert_encoding($sCode, 'UTF-8', 'OLD-ENCODING'); + } else { + $oNot->displayNotification("warning", i18n("PHP-mbstring extension is not activated or installed!")); + } } return $sCode; } @@ -323,6 +332,4 @@ function fileValidateFilename($filename, $notifyAndExitOnFailure = true) { return false; } return true; -} - -?> \ No newline at end of file +} \ No newline at end of file