From ac1335673795c055a093977bf2bdc5daff22de18 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Wed, 15 Mar 2023 17:53:49 +0100 Subject: [PATCH 01/10] init --- LISEZMOI.md | 2 +- README.md | 2 +- core/core.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/LISEZMOI.md b/LISEZMOI.md index 01073475..fdfcb7b2 100644 --- a/LISEZMOI.md +++ b/LISEZMOI.md @@ -1,4 +1,4 @@ -# ZwiiCMS 12.3.02 +# ZwiiCMS 12.3.03 Zwii est un CMS sans base de données (flat-file) qui permet de créer et gérer facilement un site web sans aucune connaissance en programmation. diff --git a/README.md b/README.md index 9636a164..b7374707 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# ZwiiCMS 12.3.02 +# ZwiiCMS 12.3.03 Zwii is a database-less (flat-file) CMS that allows you to easily create and manage a web site without any programming knowledge. diff --git a/core/core.php b/core/core.php index f8d57d4b..eb35c604 100644 --- a/core/core.php +++ b/core/core.php @@ -53,7 +53,7 @@ class common const ACCESS_TIMER = 1800; // Numéro de version et branche pour l'auto-update - const ZWII_VERSION = '12.3.02'; + const ZWII_VERSION = '12.3.03'; const ZWII_DATAVERSION = 12301; From 9f8f9fd78680e86ad4a1b3925f6f9599bb6fccee Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Wed, 15 Mar 2023 18:08:15 +0100 Subject: [PATCH 02/10] Supprime des echos --- core/vendor/tinymce/init.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/core/vendor/tinymce/init.js b/core/vendor/tinymce/init.js index 836f3130..423f8508 100755 --- a/core/vendor/tinymce/init.js +++ b/core/vendor/tinymce/init.js @@ -10,7 +10,6 @@ if (typeof (privateKey) == 'undefined') { var privateKey = null; }; -console.log(getCookie('ZWII_UI')); tinymce.init({ // Classe où appliquer l'éditeur selector: ".editorWysiwyg", @@ -331,7 +330,6 @@ function getCookie(name) { for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') c = c.substring(1, c.length); - if (c.indexOf(nameEQ) == 0) console.log(c.substring(nameEQ.length, c.length)); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); } return null; From 7e426cfb5dffaf5b097d9468f808461c7405c81e Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Thu, 16 Mar 2023 15:13:52 +0100 Subject: [PATCH 03/10] init --- core/module/install/install.php | 4 +-- core/module/install/view/update/update.js.php | 35 ++++++++++++++++--- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/core/module/install/install.php b/core/module/install/install.php index 997c5fd1..c612c25d 100644 --- a/core/module/install/install.php +++ b/core/module/install/install.php @@ -296,14 +296,14 @@ class install extends common case 2: file_put_contents(self::TEMP_DIR . 'update.tar.gz', helper::getUrlContents(common::ZWII_UPDATE_URL . common::ZWII_UPDATE_CHANNEL . '/update.tar.gz')); $md5origin = helper::getUrlContents(common::ZWII_UPDATE_URL . common::ZWII_UPDATE_CHANNEL . '/update.md5'); - $md5origin = (explode(' ', $md5origin)); + $md5origin = explode(' ', $md5origin); $md5target = md5_file(self::TEMP_DIR . 'update.tar.gz'); // Valeurs en sortie $this->addOutput([ 'display' => self::DISPLAY_JSON, 'content' => [ 'success' => $md5origin[0] === $md5target, - 'data' => null + 'data' => $md5origin[0] === $md5target ? null : json_encode("Checksum error") ] ]); break; diff --git a/core/module/install/view/update/update.js.php b/core/module/install/view/update/update.js.php index 0252e321..25cc24f2 100644 --- a/core/module/install/view/update/update.js.php +++ b/core/module/install/view/update/update.js.php @@ -1,6 +1,7 @@ function step(i, data) { var errors = ["", "", "", ""]; - $(".installUpdateProgressText").hide(), $(".installUpdateProgressText[data-id=" + i + "]").show(), $.ajax({ + $(".installUpdateProgressText").hide(), $(".installUpdateProgressText[data-id=" + i + "]").show(); + $.ajax({ type: "POST", url: "?install/steps", data: { @@ -8,13 +9,37 @@ function step(i, data) { data: data }, success: function (result) { + if (!result.success) { // Vérification de la propriété "success" + // Appel de la fonction de gestion d'erreur + showError(i, result, errors); + return; + } setTimeout((function () { - !0 === result.success ? 4 === i ? ($("#installUpdateSuccess").show(), $("#installUpdateEnd").removeClass("disabled"), $("#installUpdateProgress").hide()) : step(i + 1, result.data) : ($("#installUpdateErrorStep").text(errors[i]), $("#installUpdateError").show(), $("#installUpdateEnd").removeClass("disabled"), $("#installUpdateProgress").hide(), console.error(result), $("#installUpdateErrorMessage").text(result.replace(/<[^p].*?>/g, ""))) + if (4 === i) { + $("#installUpdateSuccess").show(); + $("#installUpdateEnd").removeClass("disabled"); + $("#installUpdateProgress").hide(); + } else { + step(i + 1, result.data); + } }), 2e3) }, error: function (xhr) { - $("#installUpdateErrorStep").text(errors[1]), $("#installUpdateError").show(), $("#installUpdateEnd").removeClass("disabled"), $("#installUpdateProgress").hide(), console.error(xhr.responseText), $("#installUpdateErrorMessage").text(xhr.responseText.replace(/<[^p].*?>/g, "")) + // Appel de la fonction de gestion d'erreur + showError(1, xhr.responseText, errors); } - }) + }); } -$(window).on("load", step(1, null)); \ No newline at end of file + +function showError(step, message, errors) { + $("#installUpdateErrorStep").text(errors[step]); + $("#installUpdateError").show(); + $("#installUpdateEnd").removeClass("disabled"); + $("#installUpdateProgress").hide(); + console.error(message); + $("#installUpdateErrorMessage").text(message.replace(/<[^p].*?>/g, "")); +} + +$(window).on("load", function() { + step(1, null); +}); From e8075dbbc8cce6556beb18ce19673aed8282afec Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Thu, 16 Mar 2023 15:17:58 +0100 Subject: [PATCH 04/10] mode test --- core/core.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/core.php b/core/core.php index eb35c604..503fb41f 100644 --- a/core/core.php +++ b/core/core.php @@ -59,7 +59,7 @@ class common // URL autoupdate const ZWII_UPDATE_URL = 'https://forge.chapril.org/ZwiiCMS-Team/update/raw/branch/master/'; - const ZWII_UPDATE_CHANNEL = "v12"; + const ZWII_UPDATE_CHANNEL = "test"; // Constantes de test //const ZWII_UPDATE_URL = 'http://localhost/update/'; From 5d81b3d2441a8835615b37f515dc66c258c32cb7 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Thu, 16 Mar 2023 15:56:19 +0100 Subject: [PATCH 05/10] update avec messages --- core/module/install/install.php | 8 ++++++-- core/module/install/view/update/update.js.php | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/core/module/install/install.php b/core/module/install/install.php index c612c25d..66cafae5 100644 --- a/core/module/install/install.php +++ b/core/module/install/install.php @@ -268,6 +268,7 @@ class install extends common // Préparation case 1: $success = true; + $message = ''; // RAZ la mise à jour auto $this->setData(['core', 'updateAvailable', false]); // Backup du dossier Data @@ -275,20 +276,23 @@ class install extends common // Sauvegarde htaccess if ($this->getData(['config', 'autoUpdateHtaccess'])) { $success = copy('.htaccess', '.htaccess' . '.bak'); + $message = 'Erreur de copie du fichier htaccess'; } // Nettoyage des fichiers d'installation précédents if (file_exists(self::TEMP_DIR . 'update.tar.gz') && $success) { $success = $success || unlink(self::TEMP_DIR . 'update.tar.gz'); + $message = 'Impossible d\'effacer la précédente mise à jour'; } if (file_exists(self::TEMP_DIR . 'update.tar') && $success) { $success = $success || unlink(self::TEMP_DIR . 'update.tar'); + $message = 'Impossible d\'effacer la précédente mise à jour'; } // Valeurs en sortie $this->addOutput([ 'display' => self::DISPLAY_JSON, 'content' => [ 'success' => $success, - 'data' => null + 'data' => $success ? null : json_encode($message) ] ]); break; @@ -303,7 +307,7 @@ class install extends common 'display' => self::DISPLAY_JSON, 'content' => [ 'success' => $md5origin[0] === $md5target, - 'data' => $md5origin[0] === $md5target ? null : json_encode("Checksum error") + 'data' => $md5origin[0] === $md5target ? null : json_encode('Erreur de téléchargement ou de somme de contôle') ] ]); break; diff --git a/core/module/install/view/update/update.js.php b/core/module/install/view/update/update.js.php index 25cc24f2..baff6248 100644 --- a/core/module/install/view/update/update.js.php +++ b/core/module/install/view/update/update.js.php @@ -36,8 +36,12 @@ function showError(step, message, errors) { $("#installUpdateError").show(); $("#installUpdateEnd").removeClass("disabled"); $("#installUpdateProgress").hide(); - console.error(message); - $("#installUpdateErrorMessage").text(message.replace(/<[^p].*?>/g, "")); + if (typeof message === 'object' && message.data) { + var errorMessage = message.data.replace(/"/g, ""); + $("#installUpdateErrorMessage").text(errorMessage); + } else { + $("#installUpdateErrorMessage").text(message.replace(/<[^p].*?>/g, "")); + } } $(window).on("load", function() { From cc990de539482e19c6e90cf8bc09f0df4577073e Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Fri, 17 Mar 2023 08:39:38 +0100 Subject: [PATCH 06/10] error message --- core/module/install/install.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/module/install/install.php b/core/module/install/install.php index 66cafae5..e32ca731 100644 --- a/core/module/install/install.php +++ b/core/module/install/install.php @@ -307,7 +307,7 @@ class install extends common 'display' => self::DISPLAY_JSON, 'content' => [ 'success' => $md5origin[0] === $md5target, - 'data' => $md5origin[0] === $md5target ? null : json_encode('Erreur de téléchargement ou de somme de contôle') + 'data' => $md5origin[0] === $md5target ? null : json_encode('Erreur de téléchargement ou de somme de contrôle') ] ]); break; @@ -365,6 +365,7 @@ class install extends common $fileContent ); $success = $r === false ? false : true; + $message = $r === false ? 'Le fichier htaccess n\'a pas été restauré' : ''; } // Recopie htaccess if ( @@ -400,7 +401,7 @@ class install extends common 'display' => self::DISPLAY_JSON, 'content' => [ 'success' => $success, - 'data' => null + 'data' => $success ? $message : null ] ]); } From dc5484aa0aa710685e877b4f7511f20c3fb75265 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Fri, 17 Mar 2023 08:44:19 +0100 Subject: [PATCH 07/10] message --- core/module/install/install.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/module/install/install.php b/core/module/install/install.php index e32ca731..e828bade 100644 --- a/core/module/install/install.php +++ b/core/module/install/install.php @@ -345,6 +345,7 @@ class install extends common // Configuration case 4: $success = true; + $message = null; $rewrite = $this->getInput('data'); // Réécriture d'URL if ($rewrite === "true") { // Ajout des lignes dans le .htaccess @@ -365,7 +366,7 @@ class install extends common $fileContent ); $success = $r === false ? false : true; - $message = $r === false ? 'Le fichier htaccess n\'a pas été restauré' : ''; + $message = $r === false ? 'Le fichier htaccess n\'a pas été restauré' : null; } // Recopie htaccess if ( @@ -401,7 +402,7 @@ class install extends common 'display' => self::DISPLAY_JSON, 'content' => [ 'success' => $success, - 'data' => $success ? $message : null + 'data' => $message ] ]); } From 41e654c1423c09941be3eb922088b5d31312efc7 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Fri, 17 Mar 2023 08:48:54 +0100 Subject: [PATCH 08/10] Error message --- core/module/install/install.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/module/install/install.php b/core/module/install/install.php index e828bade..17ff6f64 100644 --- a/core/module/install/install.php +++ b/core/module/install/install.php @@ -281,11 +281,11 @@ class install extends common // Nettoyage des fichiers d'installation précédents if (file_exists(self::TEMP_DIR . 'update.tar.gz') && $success) { $success = $success || unlink(self::TEMP_DIR . 'update.tar.gz'); - $message = 'Impossible d\'effacer la précédente mise à jour'; + $message = 'Impossible d\'effacer la mise à jour précédente'; } if (file_exists(self::TEMP_DIR . 'update.tar') && $success) { $success = $success || unlink(self::TEMP_DIR . 'update.tar'); - $message = 'Impossible d\'effacer la précédente mise à jour'; + $message = 'Impossible d\'effacer la mise à jour précédente'; } // Valeurs en sortie $this->addOutput([ From 4b7611f830215e49d29bcccccac04af736f44762 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Fri, 17 Mar 2023 13:58:38 +0100 Subject: [PATCH 09/10] SMTP test in progress --- core/core.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/core.php b/core/core.php index 503fb41f..cf89e5c6 100644 --- a/core/core.php +++ b/core/core.php @@ -1118,15 +1118,19 @@ class common try { // Paramètres SMTP perso if ($this->getdata(['config', 'smtp', 'enable'])) { - //$mail->SMTPDebug = PHPMailer\PHPMailer\SMTP::DEBUG_SERVER; + $mail->SMTPDebug = PHPMailer\PHPMailer\SMTP::DEBUG_SERVER; $mail->isSMTP(); $mail->SMTPAutoTLS = false; + $mail->SMTPSecure = false; + $mail->SMTPAuth = false; $mail->Host = $this->getdata(['config', 'smtp', 'host']); $mail->Port = (int) $this->getdata(['config', 'smtp', 'port']); if ($this->getData(['config', 'smtp', 'auth'])) { + $mail->SMTPAutoTLS = true; + $mail->SMTPSecure = true; + $mail->SMTPAuth = $this->getData(['config', 'smtp', 'auth']); $mail->Username = $this->getData(['config', 'smtp', 'username']); $mail->Password = helper::decrypt($this->getData(['config', 'smtp', 'username']), $this->getData(['config', 'smtp', 'password'])); - $mail->SMTPAuth = $this->getData(['config', 'smtp', 'auth']); $mail->SMTPSecure = $this->getData(['config', 'smtp', 'secure']); } } From 61379d2db17deeca257e12322777993e03d04613 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Sun, 19 Mar 2023 09:59:11 +0100 Subject: [PATCH 10/10] =?UTF-8?q?R=C3=A8gle=20le=20probl=C3=A8me=20des=20c?= =?UTF-8?q?hamps=20CSS=20et=20JS=20comment=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/module/page/page.php | 14 ++++++++++++++ core/module/page/view/edit/edit.js.php | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/core/module/page/page.php b/core/module/page/page.php index e7b636b8..9c747c43 100644 --- a/core/module/page/page.php +++ b/core/module/page/page.php @@ -632,4 +632,18 @@ class page extends common 'view' => 'jsEditor' ]); } + + /** + * Retourne les informations sur les pages en omettant les clés CSS et JS qui occasionnent des bugs d'affichage dans l'éditeur de page + * @return array tableau associatif des pages dans le menu + */ + public function getPageInfo() { + $p = $this->getData(['page']); + $d = array_map(function($d) { + unset($d["css"], $d["js"]); + return $d; + }, $p); + return json_encode($d); + + } } \ No newline at end of file diff --git a/core/module/page/view/edit/edit.js.php b/core/module/page/view/edit/edit.js.php index 93fb5dde..0f1def16 100644 --- a/core/module/page/view/edit/edit.js.php +++ b/core/module/page/view/edit/edit.js.php @@ -644,7 +644,7 @@ $("#pageEditParentPageId").on("change", function() { function buildPagesList(extraPosition) { var hierarchy = getHierarchy()); ?>; - var pages = getData(['page'])); ?>; + var pages = getPageInfo(); ?>; var positionInitial = getData(['page',$this->getUrl(2),"position"]); ?>; var extraPosition = $("#pageEditExtraPosition").val(); var positionDOM = $("#pageEditPosition");