From c10ad5d5dac6b8074610c66ae7db1a3c336a7dd6 Mon Sep 17 00:00:00 2001 From: SylvainLelievre Date: Thu, 25 Feb 2021 07:53:57 +0100 Subject: [PATCH] Modification de la constante UPDATE --- core/class/helper.class.php | 2 +- core/module/addon/addon.php | 25 +++++++++++++++---------- module/blog/blog.php | 3 +-- module/form/form.php | 4 ++-- module/gallery/gallery.php | 4 ++-- module/news/news.php | 4 ++-- module/redirection/redirection.php | 4 ++-- module/search/search.php | 2 +- 8 files changed, 26 insertions(+), 22 deletions(-) diff --git a/core/class/helper.class.php b/core/class/helper.class.php index 8701bfa6..503ea941 100755 --- a/core/class/helper.class.php +++ b/core/class/helper.class.php @@ -161,7 +161,7 @@ class helper { if (array_key_exists('UPDATE', $class_constants)) { $update = $value::UPDATE; } else { - $update = true; + $update = '0.0'; } // Constante DELETE if (array_key_exists('DELETE', $class_constants)) { diff --git a/core/module/addon/addon.php b/core/module/addon/addon.php index da819d60..a1521575 100644 --- a/core/module/addon/addon.php +++ b/core/module/addon/addon.php @@ -159,7 +159,8 @@ class addon extends common { // Lecture de la version et de la validation d'update du module pour validation de la mise à jour // Pour une version <= version installée l'utilisateur doit cocher 'Mise à jour forcée' $version = '0.0'; - $update = false; + $update = '0.0'; + $valUpdate = false; $file = file_get_contents( $moduleDir.'/'.$moduleName.'/'.$moduleName.'.php'); $file = str_replace(' ','',$file); $file = str_replace("\t",'',$file); @@ -171,13 +172,12 @@ class addon extends common { } $pos1 = strpos($file, 'constUPDATE'); if( $pos1 !== false){ - $posdeb = strpos($file, "=", $pos1); - $posend = strpos($file, ";", $posdeb + 1); - $strUpdate = substr($file, $posdeb + 1, $posend - $posdeb - 1); - if( strpos( $strUpdate,"true",0) !== false){ - $update = true; - } + $posdeb = strpos($file, "'", $pos1); + $posend = strpos($file, "'", $posdeb + 1); + $update = substr($file, $posdeb + 1, $posend - $posdeb - 1); } + // Si version actuelle >= version indiquée dans UPDATE la mise à jour est validée + if( $infoModules[$moduleName]['update'] >= $update ) $valUpdate = true; // Module déjà installé ? $moduleInstal = false; @@ -193,7 +193,7 @@ class addon extends common { $valInstalVersion = floatval( $infoModules[$moduleName]['version'] ); $newVersion = false; if( $valNewVersion > $valInstalVersion ) $newVersion = true; - $validMaj = $update && ( $newVersion || $checkValidMaj); + $validMaj = $valUpdate && ( $newVersion || $checkValidMaj); // Nouvelle installation ou mise à jour du module if( ! $moduleInstal || $validMaj ){ @@ -215,8 +215,13 @@ class addon extends common { else{ $notification = ' Version détectée '.$version.' < à celle installée '.$infoModules[$moduleName]['version']; } - if( $update === false){ - $notification = ' Mise à jour par ce procédé interdite par le concepteur du module'; + if( $valUpdate === false){ + if( $infoModules[$moduleName]['update'] === $update ){ + $notification = ' Mise à jour par ce procédé interdite par le concepteur du module'; + } + else{ + $notification = ' Mise à jour par ce procédé interdite, votre version est trop ancienne'; + } } } } diff --git a/module/blog/blog.php b/module/blog/blog.php index a7cbe478..560086b3 100755 --- a/module/blog/blog.php +++ b/module/blog/blog.php @@ -18,7 +18,7 @@ class blog extends common { const VERSION = '4.4'; const REALNAME = 'Blog'; const DELETE = true; - const UPDATE = true; + const UPDATE = '0.0'; const DATADIRECTORY = []; // Contenu localisé inclus par défaut (page.json et module.json) const EDIT_OWNER = 'owner'; @@ -763,4 +763,3 @@ class blog extends common { } } } - diff --git a/module/form/form.php b/module/form/form.php index 21daf0bc..77d416d8 100755 --- a/module/form/form.php +++ b/module/form/form.php @@ -19,7 +19,7 @@ class form extends common { const VERSION = '2.8'; const REALNAME = 'Formulaire'; const DELETE = true; - const UPDATE = true; + const UPDATE = '0.0'; const DATADIRECTORY = []; // Contenu localisé inclus par défaut (page.json et module.json) public static $actions = [ @@ -290,7 +290,7 @@ class form extends common { if( $this->getData(['module', $this->getUrl(0), 'config', 'captcha']) // AND $this->getInput('formcaptcha', helper::FILTER_INT) !== $this->getInput('formcaptchaFirstNumber', helper::FILTER_INT) + $this->getInput('formcaptchaSecondNumber', helper::FILTER_INT)) - AND password_verify($this->getInput('formCaptcha', helper::FILTER_INT), $this->getInput('formCaptchaResult') ) === false ) + AND password_verify($this->getInput('formCaptcha', helper::FILTER_INT), $this->getInput('formCaptchaResult') ) === false ) { self::$inputNotices['formCaptcha'] = 'Incorrect'; diff --git a/module/gallery/gallery.php b/module/gallery/gallery.php index 53c2b091..9434387f 100755 --- a/module/gallery/gallery.php +++ b/module/gallery/gallery.php @@ -20,7 +20,7 @@ class gallery extends common { const VERSION = '2.6'; const REALNAME = 'Galerie'; const DELETE = true; - const UPDATE = true; + const UPDATE = '0.0'; const DATADIRECTORY = []; // Contenu localisé inclus par défaut (page.json et module.json) const SORT_ASC = 'SORT_ASC'; @@ -698,4 +698,4 @@ class galleriesHelper extends helper { } return $dirContent; } -} \ No newline at end of file +} diff --git a/module/news/news.php b/module/news/news.php index f0685aab..6675ec37 100755 --- a/module/news/news.php +++ b/module/news/news.php @@ -18,7 +18,7 @@ class news extends common { const VERSION = '2.1'; const REALNAME = 'Actualités'; const DELETE = true; - const UPDATE = true; + const UPDATE = '0.0'; const DATADIRECTORY = []; // Contenu localisé inclus par défaut (page.json et module.json) public static $actions = [ @@ -334,4 +334,4 @@ class news extends common { return $this->getData(['user', $userId, 'firstname']); } } -} \ No newline at end of file +} diff --git a/module/redirection/redirection.php b/module/redirection/redirection.php index 58c4e1b7..0d1a704d 100755 --- a/module/redirection/redirection.php +++ b/module/redirection/redirection.php @@ -18,7 +18,7 @@ class redirection extends common { const VERSION = '1.5'; const REALNAME = 'Redirection'; const DELETE = true; - const UPDATE = true; + const UPDATE = '0.0'; const DATADIRECTORY = []; // Contenu localisé inclus par défaut (page.json et module.json) public static $actions = [ @@ -76,4 +76,4 @@ class redirection extends common { ]); } } -} \ No newline at end of file +} diff --git a/module/search/search.php b/module/search/search.php index 894df277..ed9a5815 100755 --- a/module/search/search.php +++ b/module/search/search.php @@ -21,7 +21,7 @@ class search extends common { const VERSION = '1.3'; const REALNAME = 'Recherche'; const DELETE = true; - const UPDATE = true; + const UPDATE = '0.0'; const DATADIRECTORY = []; // Contenu localisé inclus par défaut (page.json et module.json) public static $actions = [