From fec70444ee5a430193a0bb4c6fec095279c6ad0c Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Wed, 19 Jul 2023 18:07:12 +0200 Subject: [PATCH] deleteDir --- core/core.php | 4 ++-- core/include/update.inc.php | 10 +++++----- core/module/config/config.php | 2 +- core/module/install/install.php | 2 +- core/module/language/language.php | 2 +- core/module/page/page.php | 4 ++-- core/module/plugin/plugin.php | 24 ++++++++++++------------ core/module/theme/theme.php | 2 +- module/gallery/gallery.php | 2 +- module/news/news.php | 2 +- module/search/search.php | 2 +- 11 files changed, 28 insertions(+), 28 deletions(-) diff --git a/core/core.php b/core/core.php index 17d50097..f86cd8e8 100644 --- a/core/core.php +++ b/core/core.php @@ -1231,13 +1231,13 @@ class common * Effacer un dossier non vide. * @param string URL du dossier à supprimer */ - public function removeDir($path) + public function deleteDir($path) { foreach (new DirectoryIterator($path) as $item) { if ($item->isFile()) @unlink($item->getRealPath()); if (!$item->isDot() && $item->isDir()) - $this->removeDir($item->getRealPath()); + $this->deleteDir($item->getRealPath()); } return (rmdir($path)); } diff --git a/core/include/update.inc.php b/core/include/update.inc.php index 96f97e57..f39ecb8c 100644 --- a/core/include/update.inc.php +++ b/core/include/update.inc.php @@ -703,7 +703,7 @@ if ($this->getData(['core', 'dataVersion']) < 11400) { // Effacer le dossier if (is_dir('core/module/addon')) { - $this->removeDir('core/module/addon'); + $this->deleteDir('core/module/addon'); } @@ -901,10 +901,10 @@ if ($this->getData(['core', 'dataVersion']) < 12000) { // Supprimer les fichier associés if (is_dir('core/module/translate/ressource')) { - $this->removeDir('core/module/translate/ressource'); + $this->deleteDir('core/module/translate/ressource'); } if (is_dir('core/vendor/i18n/css')) { - $this->removeDir('core/vendor/i18n/css'); + $this->deleteDir('core/vendor/i18n/css'); } if (file_exists('core/vendor/i18n/inc.json')) { unlink('core/vendor/i18n/inc.json'); @@ -939,7 +939,7 @@ if ($this->getData(['core', 'dataVersion']) < 12301) { // Nettoyage de flatPickr if (is_dir('core/vendor/flatpickr')) { - $this->removeDir('core/vendor/flatpickr'); + $this->deleteDir('core/vendor/flatpickr'); } // email reply @@ -1010,7 +1010,7 @@ if ($this->getData(['core', 'dataVersion']) < 13000) { // Efface le dossier translate if (is_dir('core/module/translate')) { - $this->removeDir('core/module/translate'); + $this->deleteDir('core/module/translate'); } // Ajouter le prénom comme pseudo et le pseudo comme signature diff --git a/core/module/config/config.php b/core/module/config/config.php index 18734c5d..b136953d 100644 --- a/core/module/config/config.php +++ b/core/module/config/config.php @@ -398,7 +398,7 @@ class config extends common // Copie dans le dossier /site/data $success = $this->copyDir(self::TEMP_DIR . $tmpDir, 'site/'); - $this->removeDir(self::TEMP_DIR . $tmpDir); + $this->deleteDir(self::TEMP_DIR . $tmpDir); // Restaurer les users originaux d'une v10 si option cochée if ( diff --git a/core/module/install/install.php b/core/module/install/install.php index 90818069..42d11f7e 100644 --- a/core/module/install/install.php +++ b/core/module/install/install.php @@ -175,7 +175,7 @@ class install extends common $_SESSION['ZWII_CONTENT'] !== 'fr_FR' ) { if (is_dir(self::DATA_DIR . 'fr_FR')) - $this->removeDir(self::DATA_DIR . 'fr_FR'); + $this->deleteDir(self::DATA_DIR . 'fr_FR'); } // Sauvegarder la configuration du Proxy diff --git a/core/module/language/language.php b/core/module/language/language.php index d131bcd8..cea03950 100644 --- a/core/module/language/language.php +++ b/core/module/language/language.php @@ -583,7 +583,7 @@ class language extends common $success = false; // Effacement d'une site dans une langue if (is_dir(self::DATA_DIR . $lang) === true) { - $success = $this->removeDir(self::DATA_DIR . $lang); + $success = $this->deleteDir(self::DATA_DIR . $lang); } // Valeurs en sortie $this->addOutput([ diff --git a/core/module/page/page.php b/core/module/page/page.php index 150f4830..f2b4668d 100644 --- a/core/module/page/page.php +++ b/core/module/page/page.php @@ -258,7 +258,7 @@ class page extends common array_key_exists($moduleId, $modulesData) && is_dir($modulesData[$moduleId]['dataDirectory'] . $page) ) { - $this->removeDir($modulesData[$moduleId]['dataDirectory'] . $page); + $this->deleteDir($modulesData[$moduleId]['dataDirectory'] . $page); } // Effacer la page $this->deleteData(['page', $page]); @@ -335,7 +335,7 @@ class page extends common // Placer la feuille de style dans un dossier au nom de la nouvelle instance mkdir($modulesData[$moduleId]['dataDirectory'] . $pageId, 0755); copy($modulesData[$moduleId]['dataDirectory'] . $this->getUrl(2), $modulesData[$moduleId]['dataDirectory'] . $pageId); - $this->removeDir($modulesData[$moduleId]['dataDirectory'] . $this->getUrl(2)); + $this->deleteDir($modulesData[$moduleId]['dataDirectory'] . $this->getUrl(2)); // Mettre à jour le nom de la feuille de style $this->setData(['module', $pageId, 'theme', 'style', $modulesData[$moduleId]['dataDirectory'] . $pageId]); } diff --git a/core/module/plugin/plugin.php b/core/module/plugin/plugin.php index f45efae8..603ada57 100644 --- a/core/module/plugin/plugin.php +++ b/core/module/plugin/plugin.php @@ -73,13 +73,13 @@ class plugin extends common $infoModules = helper::getModules(); $module = $this->getUrl(2); //Liste des dossiers associés au module non effacés - if ($this->removeDir('./module/' . $module) === true) { + if ($this->deleteDir('./module/' . $module) === true) { $success = true; $notification = 'Module ' . $module . ' désinstallé'; if (($infoModules[$this->getUrl(2)]['dataDirectory'])) { if ( is_dir($infoModules[$this->getUrl(2)]['dataDirectory']) - || !$this->removeDir($infoModules[$this->getUrl(2)]['dataDirectory']) + || !$this->deleteDir($infoModules[$this->getUrl(2)]['dataDirectory']) ) { $notification = sprintf(helper::translate('Le module %s est désinstallé, il reste peut-être des données dans %s'), $module, $infoModules[$this->getUrl(2)]['dataDirectory']); } @@ -134,7 +134,7 @@ class plugin extends common $module = json_decode(file_get_contents(self::TEMP_DIR . $tempFolder . 'enum.json'), true); } else { // Message de retour - $this->removeDir(self::TEMP_DIR . $tempFolder); + $this->deleteDir(self::TEMP_DIR . $tempFolder); $zip->close(); return ([ 'success' => false, @@ -149,7 +149,7 @@ class plugin extends common // Vérification de la présence des dossier décrits if (!is_dir(self::TEMP_DIR . $tempFolder . $src)) { // Message de retour - $this->removeDir(self::TEMP_DIR . $tempFolder); + $this->deleteDir(self::TEMP_DIR . $tempFolder); $zip->close(); return ([ 'success' => false, @@ -159,7 +159,7 @@ class plugin extends common // Interdire l'écriture dans le dossier core if (strstr($dest, 'core') !== false) { // Message de retour - $this->removeDir(self::TEMP_DIR . $tempFolder); + $this->deleteDir(self::TEMP_DIR . $tempFolder); $zip->close(); return ([ 'success' => false, @@ -174,7 +174,7 @@ class plugin extends common */ if (!file_exists(self::TEMP_DIR . $tempFolder . $module['name'] . '.php')) { // Message de retour - $this->removeDir(self::TEMP_DIR . $tempFolder); + $this->deleteDir(self::TEMP_DIR . $tempFolder); $zip->close(); return ([ 'success' => false, @@ -207,7 +207,7 @@ class plugin extends common $installOk = true; } else { // Message de retour - $this->removeDir(self::TEMP_DIR . $tempFolder); + $this->deleteDir(self::TEMP_DIR . $tempFolder); $zip->close(); return ([ 'success' => false, @@ -232,7 +232,7 @@ class plugin extends common } // Message de retour $t = isset($versionInstalled) ? helper::translate('actualisé') : helper::translate('installé'); - $this->removeDir(self::TEMP_DIR . $tempFolder); + $this->deleteDir(self::TEMP_DIR . $tempFolder); $zip->close(); return ([ 'success' => $success, @@ -242,7 +242,7 @@ class plugin extends common ]); } else { // Supprimer le dossier temporaire - $this->removeDir(self::TEMP_DIR . $tempFolder); + $this->deleteDir(self::TEMP_DIR . $tempFolder); $zip->close(); return ([ 'success' => false, @@ -623,7 +623,7 @@ class plugin extends common } // Nettoyage unlink(self::TEMP_DIR . $fileName); - $this->removeDir($tmpFolder); + $this->deleteDir($tmpFolder); } } @@ -721,7 +721,7 @@ class plugin extends common ]); // Nettoyage unlink(self::TEMP_DIR . $fileName); - $this->removeDir($tmpFolder); + $this->deleteDir($tmpFolder); } break; case 'download': @@ -793,7 +793,7 @@ class plugin extends common } // Supprimer le dossier temporaire - $this->removeDir(self::TEMP_DIR . $tmpFolder); + $this->deleteDir(self::TEMP_DIR . $tmpFolder); $zip->close(); // Valeurs en sortie diff --git a/core/module/theme/theme.php b/core/module/theme/theme.php index 8d4a9b5d..73bac24f 100644 --- a/core/module/theme/theme.php +++ b/core/module/theme/theme.php @@ -1089,7 +1089,7 @@ class theme extends common $notification = helper::translate('Archive de thème invalide'); } // Supprimer le dossier temporaire même si le thème est invalide - $this->removeDir(self::TEMP_DIR . $tempFolder); + $this->deleteDir(self::TEMP_DIR . $tempFolder); $zip->close(); } else { // erreur à l'ouverture diff --git a/module/gallery/gallery.php b/module/gallery/gallery.php index 8d87d5b9..83a98392 100644 --- a/module/gallery/gallery.php +++ b/module/gallery/gallery.php @@ -176,7 +176,7 @@ class gallery extends common if (is_dir(self::DATADIRECTORY . 'pages/')) { // Déplacer les données du dossier Pages $this->copyDir(self::DATADIRECTORY . 'pages/' . $this->getUrl(0), self::DATADIRECTORY . $this->getUrl(0)); - $this->removeDir(self::DATADIRECTORY . 'pages/'); + $this->deleteDir(self::DATADIRECTORY . 'pages/'); $style = $this->getData(['module', $this->getUrl(0), 'theme', 'style']); $this->setData(['module', $this->getUrl(0), 'theme', 'style', str_replace('pages/', '', $style)]); } diff --git a/module/news/news.php b/module/news/news.php index bf2ef0ec..43fdbf9b 100644 --- a/module/news/news.php +++ b/module/news/news.php @@ -599,7 +599,7 @@ class news extends common if (is_dir(self::DATADIRECTORY . 'pages/')) { // Déplacer les données du dossier Pages $this->copyDir(self::DATADIRECTORY . 'pages/' . $this->getUrl(0), self::DATADIRECTORY . $this->getUrl(0)); - $this->removeDir(self::DATADIRECTORY . 'pages/'); + $this->deleteDir(self::DATADIRECTORY . 'pages/'); $style = $this->getData(['module', $this->getUrl(0), 'theme', 'style']); $this->setData(['module', $this->getUrl(0), 'theme', 'style', str_replace('pages/', '', $style)]); } diff --git a/module/search/search.php b/module/search/search.php index 12a38747..a768671e 100644 --- a/module/search/search.php +++ b/module/search/search.php @@ -69,7 +69,7 @@ class search extends common if (is_dir(self::DATADIRECTORY . 'pages/')) { // Déplacer les données du dossier Pages $this->copyDir(self::DATADIRECTORY . 'pages/' . $this->getUrl(0), self::DATADIRECTORY . $this->getUrl(0)); - $this->removeDir(self::DATADIRECTORY . 'pages/'); + $this->deleteDir(self::DATADIRECTORY . 'pages/'); } // Mettre à jour la version $this->setData(['module', $this->getUrl(0), 'config', 'versionData', '2.2']);