From adf0ac8f806255ed44a7af947c1547ead125a9d1 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Tue, 20 Jun 2023 20:04:30 +0200 Subject: [PATCH] Page duplicate --- core/module/page/page.php | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/core/module/page/page.php b/core/module/page/page.php index ab1fa535..f9f81e4d 100644 --- a/core/module/page/page.php +++ b/core/module/page/page.php @@ -72,44 +72,38 @@ class page extends common public function duplicate() { // Adresse sans le token - $url = explode('&', $this->getUrl(2)); + $page = $this->getUrl(2); // La page n'existe pas - if ($this->getData(['page', $url[0]]) === null) { + if ($this->getData(['page', $page]) === null) { // Valeurs en sortie $this->addOutput([ 'access' => false ]); } // Jeton incorrect - elseif (!isset($_GET['csrf'])) { + elseif ($this->checkCSRF()) { // Valeurs en sortie $this->addOutput([ - 'redirect' => helper::baseUrl() . 'page/edit/' . $url[0], + 'redirect' => helper::baseUrl() . 'page/edit/' . $page, 'notification' => helper::translate('Jeton invalide') ]); - } elseif ($_GET['csrf'] !== $_SESSION['csrf']) { - // Valeurs en sortie - $this->addOutput([ - 'redirect' => helper::baseUrl() . 'page/edit/' . $url[0], - 'notification' => helper::translate('Suppression interdite') - ]); } // Duplication de la page - $pageTitle = $this->getData(['page', $url[0], 'title']); + $pageTitle = $this->getData(['page', $page, 'title']); $pageId = helper::increment(helper::filter($pageTitle, helper::FILTER_ID), $this->getData(['page'])); $pageId = helper::increment($pageId, self::$coreModuleIds); $pageId = helper::increment($pageId, self::$moduleIds); $data = $this->getData([ 'page', - $url[0] + $page ]); // Ecriture $this->setData(['page', $pageId, $data]); $notification = helper::translate('Page dupliquée'); // Duplication du module présent - if ($this->getData(['page', $url[0], 'moduleId'])) { + if ($this->getData(['page', $page, 'moduleId'])) { $data = $this->getData([ 'module', - $url[0] + $page ]); // Ecriture $this->setData(['module', $pageId, $data]);