-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsrv.php
More file actions
26 lines (25 loc) · 856 Bytes
/
Copy pathsrv.php
File metadata and controls
26 lines (25 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
//Comprovem sel csrf_token
session_start();
$accionsPermeses = array('save');
$action = filter_input(INPUT_POST, 'action', FILTER_SANITIZE_STRING);
$csrf_token = filter_input(INPUT_POST, 'csrf_token', FILTER_SANITIZE_STRING);
$content = filter_input(INPUT_POST, 'content', FILTER_SANITIZE_STRING);
if ($_SESSION["csrf_token"]!=$csrf_token) {
header("HTTP/1.0 403 Forbidden");
echo 'error: "csrf_token incorrecte"';
die();
}
if (!in_array($action,$accionsPermeses)) {
header("HTTP/1.0 404 Not Found");
echo 'error: "Acció no trobada"';
die();
}
if ($action='save') {
copy ('file.txt.old3','file.txt.old4');
copy ('file.txt.old2','file.txt.old3');
copy ('file.txt.old1','file.txt.old2');
copy ('file.txt.old','file.txt.old1');
copy ('file.txt','file.txt.old');
echo 'result: '.(file_put_contents ( 'file.txt' , $content ));
}