Compare commits

..

No commits in common. "162bf2761705454c3017a01a060d1a218b7b94a7" and "e49b5c16c1450232fadc85fe26f4400ff61443c4" have entirely different histories.

12 changed files with 24 additions and 81 deletions

View File

@ -1,10 +1,5 @@
# 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.03
# ZwiiCMS 12.3.02
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.03
# ZwiiCMS 12.3.02
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,10 +539,6 @@ 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);
$v = json_encode($this->data, JSON_UNESCAPED_UNICODE | LOCK_EX);
$l = strlen($v);
$t = 0;
while ($t < 5) {

View File

@ -1043,8 +1043,7 @@ 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'] ) . '</script>';
echo '<script defer>' . htmlspecialchars_decode(helper::minifyJs($inlineScript)) . '</script>';
echo '<script defer>' . helper::minifyJs($coreScript . $this->core->output['script'] . htmlspecialchars_decode($inlineScript)) . '</script>';
}
/**
@ -1071,7 +1070,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(htmlspecialchars_decode($style)) . '</style>';
echo '<style type="text/css">' . helper::minifyCss($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.03';
const ZWII_VERSION = '12.3.02';
const ZWII_DATAVERSION = 12301;
@ -61,6 +61,10 @@ 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/';
@ -1114,19 +1118,15 @@ 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,7 +268,6 @@ 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
@ -276,23 +275,20 @@ 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' => $success ? null : json_encode($message, JSON_UNESCAPED_UNICODE)
'data' => null
]
]);
break;
@ -300,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' => $md5origin[0] === $md5target ? null : json_encode('Erreur de téléchargement ou de somme de contrôle', JSON_UNESCAPED_UNICODE)
'data' => null
]
]);
break;
@ -345,7 +341,6 @@ 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
@ -366,7 +361,6 @@ 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 (
@ -402,7 +396,7 @@ class install extends common
'display' => self::DISPLAY_JSON,
'content' => [
'success' => $success,
'data' => json_encode($message, JSON_UNESCAPED_UNICODE)
'data' => null
]
]);
}

View File

@ -1,7 +1,6 @@
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: {
@ -9,41 +8,13 @@ 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 () {
if (4 === i) {
$("#installUpdateSuccess").show();
$("#installUpdateEnd").removeClass("disabled");
$("#installUpdateProgress").hide();
} else {
step(i + 1, result.data);
}
!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, "")))
}), 2e3)
},
error: function (xhr) {
// Appel de la fonction de gestion d'erreur
showError(1, xhr.responseText, errors);
$("#installUpdateErrorStep").text(errors[1]), $("#installUpdateError").show(), $("#installUpdateEnd").removeClass("disabled"), $("#installUpdateProgress").hide(), console.error(xhr.responseText), $("#installUpdateErrorMessage").text(xhr.responseText.replace(/<[^p].*?>/g, ""))
}
});
})
}
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);
});
$(window).on("load", step(1, null));

View File

@ -632,18 +632,4 @@ 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 $module->getPageInfo(); ?>;
var pages = <?php echo json_encode($this->getData(['page'])); ?>;
var positionInitial = <?php echo $this->getData(['page',$this->getUrl(2),"position"]); ?>;
var extraPosition = $("#pageEditExtraPosition").val();
var positionDOM = $("#pageEditPosition");

View File

@ -10,6 +10,7 @@
if (typeof (privateKey) == 'undefined') {
var privateKey = null;
};
console.log(getCookie('ZWII_UI'));
tinymce.init({
// Classe où appliquer l'éditeur
selector: ".editorWysiwyg",
@ -330,6 +331,7 @@ 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;