From 055d597ba42bfe2edfeaccdb00f3c1fbc3177253 Mon Sep 17 00:00:00 2001 From: Thomas Ingles Date: Thu, 25 Jan 2024 04:06:23 +0100 Subject: [PATCH] DRY header location + Fix repost on reload page $redirect & $posted for AdminMediasPrepend hook Fix when move on folder & reload page after browser say : You want repost data? If click Ok, PluXml say : ``` Security error : invalid or expired token ``` --- core/admin/medias.php | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/core/admin/medias.php b/core/admin/medias.php index 87c72c19e..48b826a12 100644 --- a/core/admin/medias.php +++ b/core/admin/medias.php @@ -17,6 +17,9 @@ $_POST['folder']='.'; } +$redirect = 'medias.php'; +$posted = !empty($_POST); + # Hook Plugins eval($plxAdmin->plxPlugins->callHook('AdminMediasPrepend')); @@ -44,40 +47,26 @@ if($plxMedias->newDir($_POST['newfolder'])) { $_SESSION['folder'] = $_SESSION['folder'].$_POST['newfolder'].'/'; } - header('Location: medias.php'); - exit; } if(!empty($_POST['btn_renamefile']) AND !empty($_POST['newname'])) { $plxMedias->renameFile($_POST['oldname'], $_POST['newname']); - header('Location: medias.php'); - exit; } elseif(!empty($_POST['folder']) AND $_POST['folder']!='.' AND !empty($_POST['btn_delete'])) { if($plxMedias->deleteDir($_POST['folder'])) { $_SESSION['folder'] = ''; } - header('Location: medias.php'); - exit; } elseif(!empty($_POST['btn_upload'])) { $plxMedias->uploadFiles($_FILES, $_POST); - header('Location: medias.php'); - exit; } elseif(isset($_POST['selection']) AND ((!empty($_POST['btn_ok']) AND $_POST['selection']=='delete')) AND isset($_POST['idFile'])) { $plxMedias->deleteFiles($_POST['idFile']); - header('Location: medias.php'); - exit; } elseif(isset($_POST['selection']) AND ((!empty($_POST['btn_ok']) AND $_POST['selection']=='move')) AND isset($_POST['idFile'])) { $plxMedias->moveFiles($_POST['idFile'], $_SESSION['currentfolder'], $_POST['folder']); - header('Location: medias.php'); - exit; } elseif(isset($_POST['selection']) AND ((!empty($_POST['btn_ok']) AND $_POST['selection']=='thumbs')) AND isset($_POST['idFile'])) { $plxMedias->makeThumbs($_POST['idFile'], $plxAdmin->aConf['miniatures_l'], $plxAdmin->aConf['miniatures_h']); - header('Location: medias.php'); - exit; } # Tri de l'affichage des fichiers @@ -87,6 +76,11 @@ $sort = isset($_SESSION['sort_medias']) ? $_SESSION['sort_medias'] : 'title_asc'; } +if($posted) { + header('Location: ' . $redirect); + exit; +} + $sort_title = 'title_desc'; $sort_date = 'date_desc'; switch ($sort) {