Proper way to fix CSRF in /schedule/backup/

This commit is contained in:
myvesta 2021-08-29 00:54:57 +02:00
parent 0336e8b8d0
commit 11f1cfcf4e
2 changed files with 8 additions and 4 deletions

View file

@ -1,14 +1,18 @@
<?php
// Preventing CSRF
prevent_post_csrf(true);
// Init
error_reporting(NULL);
ob_start();
session_start();
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
// Check token
if ((!isset($_GET['token'])) || ($_SESSION['token'] != $_GET['token'])) {
die($_SESSION['token']);
header('location: /login/');
exit();
}
$v_username = escapeshellarg($user);
exec (VESTA_CMD."v-schedule-user-backup ".$v_username, $output, $return_var);
if ($return_var == 0) {

View file

@ -1,6 +1,6 @@
<div class="l-center">
<div class="l-sort clearfix noselect">
<a href="/schedule/backup/" class="l-sort__create-btn" title="<?=__('Create Backup')?>"></a>
<a href="/schedule/backup/?token=<?=$_SESSION['token']?>" class="l-sort__create-btn" title="<?=__('Create Backup')?>"></a>
<div class="l-sort-toolbar clearfix">
<table>
<tr>