deleteDir
This commit is contained in:
parent
529f86c873
commit
fec70444ee
@ -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));
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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 (
|
||||
|
@ -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
|
||||
|
@ -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([
|
||||
|
@ -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]);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)]);
|
||||
}
|
||||
|
@ -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)]);
|
||||
}
|
||||
|
@ -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']);
|
||||
|
Loading…
x
Reference in New Issue
Block a user