-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunlink.php
44 lines (30 loc) · 949 Bytes
/
unlink.php
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
session_start();
$filepath = $_GET['filepath'];
if (!unlink($filepath)) {
$msg = "Error deleting" . $filepath;
} else {
include("connect.php");
$query = "DELETE FROM `diaries` WHERE `path` = '" . mysqli_real_escape_string($link, $filepath) . "'";
if (mysqli_query($link, $query)) {
$msg = "File is deleted";
} else {
$msg = "Error deleting: " . mysqli_error($link);
}
}
echo $msg;
echo '
<script type="text/javascript">
//Save the value of msg to the sessionStorage, so we can display it
//in the other pages
if (typeof(Storage) !== "undefined") {
// Store the value of $msg to sessionStorage
sessionStorage.setItem("unlink", `<? echo $msg; ?>`);
sessionStorage.setItem("index","viewEntry");
}else{
sessionStorage.setItem("unlink", `Browser does not support this message`);
}
</script>
';
header("Location: diary.php");
?>