switch $action à terminer.

This commit is contained in:
Fred Tempez 2022-10-18 18:51:36 +02:00
parent 03d27a5ee4
commit 7ff51d24fb
1 changed files with 26 additions and 18 deletions

View File

@ -569,7 +569,7 @@ class plugin extends common
mkdir($tmpFolder, 0755); mkdir($tmpFolder, 0755);
} }
$target = $this->getUrl(2); $action = $this->getUrl(2);
$moduleId = $this->getUrl(3); $moduleId = $this->getUrl(3);
// Descripteur de l'archive // Descripteur de l'archive
@ -586,7 +586,7 @@ class plugin extends common
// Construire l'archive // Construire l'archive
$this->makeZip($tmpFolder . '/' . $fileName, self::MODULE_DIR . $moduleId); $this->makeZip($tmpFolder . '/' . $fileName, self::MODULE_DIR . $moduleId);
switch ($target) { switch ($action) {
case 'filemanager': case 'filemanager':
if (!file_exists(self::FILE_DIR . 'source/modules')) { if (!file_exists(self::FILE_DIR . 'source/modules')) {
mkdir(self::FILE_DIR . 'source/modules'); mkdir(self::FILE_DIR . 'source/modules');
@ -661,7 +661,7 @@ class plugin extends common
public function dataExport() public function dataExport()
{ {
// Jeton incorrect // Jeton incorrect
if ($this->getUrl(5) !== $_SESSION['csrf']) { if ($this->getUrl(6) !== $_SESSION['csrf']) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . 'plugin', 'redirect' => helper::baseUrl() . 'plugin',
@ -676,8 +676,10 @@ class plugin extends common
mkdir($tmpFolder, 0755); mkdir($tmpFolder, 0755);
} }
$moduleId = $this->getUrl(3); $action = $this->getUrl(2);
$pageId = $this->getUrl(4); $lang = $this->getUrl(3);
$moduleId = $this->getUrl(4);
$pageId = $this->getUrl(5);
// DOnnèes du module de la page sléectionnée // DOnnèes du module de la page sléectionnée
$moduleData = $this->getData(['module', $pageId]); $moduleData = $this->getData(['module', $pageId]);
@ -697,19 +699,25 @@ class plugin extends common
// création du zip // création du zip
if ($success) { if ($success) {
$fileName = $this->getUrl(2) . '-' . $moduleId . '-' . $pageId . '.zip'; switch ($action) {
$this->makeZip($fileName, $tmpFolder); case 'filemanager':
if (file_exists($fileName)) {
ob_start(); case 'download':
header('Content-Type: application/octet-stream'); default:
header('Content-Disposition: attachment; filename="' . $fileName . '"'); $fileName = $lang . '-' . $moduleId . '-' . $pageId . '.zip';
header('Content-Length: ' . filesize($fileName)); $this->makeZip($fileName, $tmpFolder);
ob_clean(); if (file_exists($fileName)) {
ob_end_flush(); ob_start();
readfile($fileName); header('Content-Type: application/octet-stream');
unlink($fileName); header('Content-Disposition: attachment; filename="' . $fileName . '"');
$this->removeDir($tmpFolder); header('Content-Length: ' . filesize($fileName));
exit(); ob_clean();
ob_end_flush();
readfile($fileName);
unlink($fileName);
$this->removeDir($tmpFolder);
exit();
}
} }
} else { } else {
// Valeurs en sortie // Valeurs en sortie