Compare commits

...

16 Commits

Author SHA1 Message Date
Fred Tempez 162bf27617 Changement de branche, changes.md 2023-03-21 15:50:28 +01:00
Fred Tempez 832e0b535f Encode des messages d'erreur lors de l'installation 2023-03-21 15:48:42 +01:00
Fred Tempez 47c98e25e4 Merge branch '12303-temp' into 12303-valid 2023-03-20 19:10:32 +01:00
Fred Tempez f9c866dadb Deux lignes pour les JS 2023-03-20 14:46:46 +01:00
Fred Tempez 3a74afcb18 New 12303 2023-03-20 13:38:50 +01:00
Fred Tempez 6973442e4a changes 2023-03-19 10:11:14 +01:00
Fred Tempez 61379d2db1 Règle le problème des champs CSS et JS commentés 2023-03-19 09:59:11 +01:00
Fred Tempez 4b7611f830 SMTP test in progress 2023-03-17 13:58:38 +01:00
Fred Tempez 41e654c142 Error message 2023-03-17 08:48:54 +01:00
Fred Tempez dc5484aa0a message 2023-03-17 08:44:19 +01:00
Fred Tempez cc990de539 error message 2023-03-17 08:39:38 +01:00
Fred Tempez 5d81b3d244 update avec messages 2023-03-16 15:56:19 +01:00
Fred Tempez e8075dbbc8 mode test 2023-03-16 15:17:58 +01:00
Fred Tempez 7e426cfb5d init 2023-03-16 15:13:52 +01:00
Fred Tempez 9f8f9fd786 Supprime des echos 2023-03-15 18:08:15 +01:00
Fred Tempez ac13356737 init 2023-03-15 17:53:49 +01:00
12 changed files with 81 additions and 24 deletions

View File

@ -1,5 +1,10 @@
# Changelog
## Version 12.3.03
- Corrige le problème d'affichage lors de l'édition d'une page contenant une feuille style commentée.
- Corrige des problèmes d'interprétation des scripts intégrés dans une page.
- Améliore l'affichage des erreurs lors de la mise à jour automatique. L'échec de la vérification de la clé MD5SUM de l'archive d'installation provoque l'arrêt de l'installation au lieu d'un message en fin d'installation.
## Version 12.3.02
- Amélioration de l'obfuscation.
- Corrige la limitation de 500 caractères des scripts JS et du style CSS stockés avec la page.

View File

@ -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.

View File

@ -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.

View File

@ -539,6 +539,10 @@ class helper
$css = preg_replace(['(( )+{)', '({( )+)'], '{', $css);
$css = preg_replace(['(( )+})', '(}( )+)', '(;( )*})'], '}', $css);
$css = preg_replace(['(;( )+)', '(( )+;)'], ';', $css);
// Convertir les codes entités
$css = htmlspecialchars_decode($css);
// Supprime les balises HTML
$css = strip_tags($css);
// Retourne le css minifié
return $css;
}

View File

@ -142,7 +142,7 @@ class JsonDb extends \Prowebcraft\Dot
*/
public function save()
{
$v = json_encode($this->data, JSON_UNESCAPED_UNICODE | LOCK_EX);
$v = json_encode($this->data, JSON_UNESCAPED_UNICODE);
$l = strlen($v);
$t = 0;
while ($t < 5) {

View File

@ -1043,7 +1043,8 @@ class layout extends common
if ($this->core->output['inlineScript']) {
$inlineScript = implode($this->core->output['inlineScript']);
}
echo '<script defer>' . helper::minifyJs($coreScript . $this->core->output['script'] . htmlspecialchars_decode($inlineScript)) . '</script>';
echo '<script defer>' . helper::minifyJs($coreScript . $this->core->output['script'] ) . '</script>';
echo '<script defer>' . htmlspecialchars_decode(helper::minifyJs($inlineScript)) . '</script>';
}
/**
@ -1070,7 +1071,7 @@ class layout extends common
if ($this->core->output['inlineStyle']) {
foreach ($this->core->output['inlineStyle'] as $style) {
if ($style) {
echo '<style type="text/css">' . helper::minifyCss($style) . '</style>';
echo '<style type="text/css">' . helper::minifyCss(htmlspecialchars_decode($style)) . '</style>';
}
}

View File

@ -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;
@ -61,10 +61,6 @@ class common
const ZWII_UPDATE_URL = 'https://forge.chapril.org/ZwiiCMS-Team/update/raw/branch/master/';
const ZWII_UPDATE_CHANNEL = "v12";
// Constantes de test
//const ZWII_UPDATE_URL = 'http://localhost/update/';
//const ZWII_UPDATE_CHANNEL = "test";
// URL langues de l'UI en ligne
const ZWII_UI_URL = 'https://forge.chapril.org/ZwiiCMS-Team/zwiicms-translations/raw/branch/master/';
@ -1118,15 +1114,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']);
}
}

View File

@ -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 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 mise à jour précédente';
}
// Valeurs en sortie
$this->addOutput([
'display' => self::DISPLAY_JSON,
'content' => [
'success' => $success,
'data' => null
'data' => $success ? null : json_encode($message, JSON_UNESCAPED_UNICODE)
]
]);
break;
@ -296,14 +300,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('Erreur de téléchargement ou de somme de contrôle', JSON_UNESCAPED_UNICODE)
]
]);
break;
@ -341,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
@ -361,6 +366,7 @@ class install extends common
$fileContent
);
$success = $r === false ? false : true;
$message = $r === false ? 'Le fichier htaccess n\'a pas été restauré' : null;
}
// Recopie htaccess
if (
@ -396,7 +402,7 @@ class install extends common
'display' => self::DISPLAY_JSON,
'content' => [
'success' => $success,
'data' => null
'data' => json_encode($message, JSON_UNESCAPED_UNICODE)
]
]);
}

View File

@ -1,6 +1,7 @@
function step(i, data) {
var errors = ["<?php echo helper::translate('Préparation de la mise à jour'); ?>", "<?php echo helper::translate('Téléchargement et validation de l\'archive'); ?>", "<?php echo helper::translate('Installation'); ?>", "<?php echo helper::translate('Configuration'); ?>"];
$(".installUpdateProgressText").hide(), $(".installUpdateProgressText[data-id=" + i + "]").show(), $.ajax({
$(".installUpdateProgressText").hide(), $(".installUpdateProgressText[data-id=" + i + "]").show();
$.ajax({
type: "POST",
url: "<?php echo helper::baseUrl(false); ?>?install/steps",
data: {
@ -8,13 +9,41 @@ 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));
function showError(step, message, errors) {
$("#installUpdateErrorStep").text(errors[step]);
$("#installUpdateError").show();
$("#installUpdateEnd").removeClass("disabled");
$("#installUpdateProgress").hide();
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() {
step(1, null);
});

View File

@ -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);
}
}

View File

@ -644,7 +644,7 @@ $("#pageEditParentPageId").on("change", function() {
function buildPagesList(extraPosition) {
var hierarchy = <?php echo json_encode($this->getHierarchy()); ?>;
var pages = <?php echo json_encode($this->getData(['page'])); ?>;
var pages = <?php echo $module->getPageInfo(); ?>;
var positionInitial = <?php echo $this->getData(['page',$this->getUrl(2),"position"]); ?>;
var extraPosition = $("#pageEditExtraPosition").val();
var positionDOM = $("#pageEditPosition");

View File

@ -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;