From 839981c313ee806ea8cc263a081e911a164d1c4f Mon Sep 17 00:00:00 2001 From: polo Date: Sun, 30 Apr 2023 16:25:08 +0200 Subject: bricoles --- controller/admin.php | 4 ++-- controller/ajax.php | 57 ++++++++++++------------------------------------- controller/backup.php | 3 ++- controller/ckeditor.php | 16 +++++++------- 4 files changed, 26 insertions(+), 54 deletions(-) (limited to 'controller') diff --git a/controller/admin.php b/controller/admin.php index f3eeeca..038d4c3 100644 --- a/controller/admin.php +++ b/controller/admin.php @@ -31,7 +31,7 @@ function pageArticlesSimplesAdmin(string $page, string $title, string $headerPai { // nom de l'article ciblé (objet et session) $Articles->fileCode = $fileCode; - $_SESSION['target'] = $Articles->fileCode; + $_SESSION['file_code'] = $Articles->fileCode; if($suppression) { @@ -212,7 +212,7 @@ function albumEdit($fileCode, int $suppression) { $page = 'album'; $Albums->readOne(); - $_SESSION['target'] = $fileCode; + $_SESSION['file_code'] = $fileCode; $title = "Modifier un album"; for($i = 0; $i < $Albums->fileListCount; $i++) diff --git a/controller/ajax.php b/controller/ajax.php index 26aa9c6..ed840cd 100644 --- a/controller/ajax.php +++ b/controller/ajax.php @@ -38,48 +38,6 @@ if(isset($_GET['action']) && isset($_GET['page']) && $_GET['action'] == 'upload_ } -// inversion des positions de deux éléments d'une page -/*if(isset($_GET['action']) && isset($_GET['page']) && ($_GET['action'] == 'monter' || $_GET['action'] == 'descendre') && isset($_GET['file_code']) && !empty($_GET['file_code'])) -{ - // sécurité !! - if(!isset($_SESSION['admin']) || $_SESSION['admin'] != 1) - { - header('Location: index.php?erreur=interdit'); - } - else - { - require('controller/admin.php'); - require('model/Article.php'); - - $pagesArticlesSimples = ['menu', 'melaine', 'musique', 'presse', 'livres', 'jaime', 'peinture', 'archives', 'legal']; - $sens = 0; - - if($_GET['action'] == 'monter') - { - $sens = 1; - } - if($_GET['action'] == 'descendre') - { - $sens = 0; - } - - if(in_array($_GET['page'], $pagesArticlesSimples)) - { - // 1 pour monter - inversionPositions($_GET['page'], $_GET['file_code'], 'Article', $sens); - } - elseif($_GET['page'] == 'discographie') - { - require('model/Album.php'); - - // 1 pour monter - inversionPositions($_GET['page'], $_GET['file_code'], 'Album', $sens); - } - } - exit(); // stop !! -}*/ - - // page restauration quand le fichier zip est lourd // -> input file onchange if(isset($_GET['action']) && $_GET['action'] == 'restauration' @@ -114,4 +72,17 @@ if(isset($_GET['action']) && $_GET['action'] == 'restauration' echo('file send'); exit(); // stop !! } -} \ No newline at end of file +} + +// nettoyage +if(!isset($_GET['action']) || $_GET['action'] != 'restauration') +{ + if(isset($_SESSION['fileName'])) + { + unset($_SESSION['fileName']); + } + if(isset($_SESSION['fileSize'])) + { + unset($_SESSION['fileSize']); + } +} diff --git a/controller/backup.php b/controller/backup.php index df0cf86..73438b4 100644 --- a/controller/backup.php +++ b/controller/backup.php @@ -165,7 +165,8 @@ function pageRestauration($from) global $maxWeight; // recharger la même page en écrivant les données - if(isset($_SESSION['fileName']) && isset($_SESSION['fileSize']) && $_SESSION['fileSize'] > $maxWeight) + if(isset($_SESSION['fileName']) && isset($_SESSION['fileSize']) && $_SESSION['fileSize'] > $maxWeight + && file_exists('data/tmp/' . $_SESSION['fileName'])) { // une copie du zip est conservée dans data/ au cas où $path = 'data/' . $_SESSION['fileName']; diff --git a/controller/ckeditor.php b/controller/ckeditor.php index f73107d..4d4639d 100644 --- a/controller/ckeditor.php +++ b/controller/ckeditor.php @@ -68,9 +68,9 @@ function submitCKeditor() $Album = new Album($_GET['page'], 'discographie'); // on retrouve les données si nécessaire - if(isset($_SESSION['target']) && $_SESSION['target'] != '') + if(isset($_SESSION['file_code']) && $_SESSION['file_code'] != '') { - $Album->fileCode = $_SESSION['target']; + $Album->fileCode = $_SESSION['file_code']; $Album->readOne(); } @@ -79,7 +79,7 @@ function submitCKeditor() if(!empty($_FILES['upload']['name'])) { $nouvellePochette = $_FILES['upload']['name']; - $nouvellePochetteMini = pathinfo($_FILES['upload']['name'], PATHINFO_FILENAME) . '-mini.' . pathinfo($_FILES['upload']['name'], PATHINFO_EXTENSION); + $nouvellePochetteMini = pathinfo($_FILES['upload']['name'], PATHINFO_FILENAME) . '-mini.' . pathinfo($_FILES['upload']['name'], PATHINFO_EXTENSION); } else { @@ -90,7 +90,7 @@ function submitCKeditor() //var_dump($nouvellePochetteMini); die(); // enregistrement nouvel album - if(!isset($_SESSION['target']) || $_SESSION['target'] == '') + if(!isset($_SESSION['file_code']) || $_SESSION['file_code'] == '') { // page disco $Album->createVignette($nouveauTitre, $nouvelleAnnee, $nouvellePochette, $nouvellePochetteMini); @@ -105,7 +105,7 @@ function submitCKeditor() // modification else { - $Album->albumCode = $_SESSION['target']; + $Album->albumCode = $_SESSION['file_code']; // page disco $Album->format = 'json'; @@ -124,7 +124,7 @@ function submitCKeditor() { $Article = new Article($_GET['page'], $_GET['page']); - if(!isset($_SESSION['target']) || $_SESSION['target'] === '') + if(!isset($_SESSION['file_code']) || $_SESSION['file_code'] === '') { $Article->create($html); @@ -132,7 +132,7 @@ function submitCKeditor() } else { - $Article->fileCode = $_SESSION['target']; // erreur ici? + $Article->fileCode = $_SESSION['file_code']; // erreur ici? $Article->update($html); // update html-mini @@ -140,7 +140,7 @@ function submitCKeditor() } // nettoyage - unset($_SESSION['target']); + unset($_SESSION['file_code']); if($_GET['page'] === 'discographie' || $_GET['page'] === 'album') { -- cgit v1.2.3