forked from ZwiiCMS-Team/ZwiiCMS
Correction CSRF en effacement de la page
This commit is contained in:
parent
5d300c93d6
commit
995278c753
@ -77,33 +77,43 @@ class page extends common {
|
||||
* Suppression
|
||||
*/
|
||||
public function delete() {
|
||||
// $url prend l'adresse sans le token
|
||||
$url = explode('&',$this->getUrl(2));
|
||||
// La page n'existe pas
|
||||
if($this->getData(['page', $this->getUrl(2)]) === null) {
|
||||
if($this->getData(['page', $url[0]]) === null) {
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'access' => false
|
||||
]);
|
||||
}
|
||||
// Impossible de supprimer la page d'accueil
|
||||
elseif($this->getUrl(2) === $this->getData(['config', 'homePageId'])) {
|
||||
elseif($url[0] === $this->getData(['config', 'homePageId'])) {
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'redirect' => helper::baseUrl() . 'page/edit/' . $this->getUrl(2),
|
||||
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
|
||||
'notification' => 'Impossible de supprimer la page d\'accueil'
|
||||
]);
|
||||
}
|
||||
// Impossible de supprimer une page contenant des enfants
|
||||
elseif($this->getHierarchy($this->getUrl(2))) {
|
||||
// Jeton incorrect
|
||||
elseif($_GET['csrf'] !== $_SESSION['csrf']) {
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'redirect' => helper::baseUrl() . 'page/edit/' . $this->getUrl(2),
|
||||
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
|
||||
'notification' => 'Suppression non autorisée'
|
||||
]);
|
||||
}
|
||||
// Impossible de supprimer une page contenant des enfants
|
||||
elseif($this->getHierarchy($url[0])) {
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
|
||||
'notification' => 'Impossible de supprimer une page contenant des enfants'
|
||||
]);
|
||||
}
|
||||
// Suppression
|
||||
else {
|
||||
$this->deleteData(['page', $this->getUrl(2)]);
|
||||
$this->deleteData(['module', $this->getUrl(2)]);
|
||||
$this->deleteData(['page', $url[0]]);
|
||||
$this->deleteData(['module', $url[0]]);
|
||||
// Valeurs en sortie
|
||||
$this->addOutput([
|
||||
'redirect' => helper::baseUrl(false),
|
||||
|
@ -13,7 +13,7 @@
|
||||
<div class="col2 offset6">
|
||||
<?php echo template::button('pageEditDelete', [
|
||||
'class' => 'buttonRed',
|
||||
'href' => helper::baseUrl() . 'page/delete/' . $this->getUrl(2),
|
||||
'href' => helper::baseUrl() . 'page/delete/' . $this->getUrl(2) . '&csrf=' . $_SESSION['csrf'],
|
||||
'value' => 'Supprimer',
|
||||
'ico' => 'cancel'
|
||||
]); ?>
|
||||
|
Loading…
Reference in New Issue
Block a user