-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete.php
More file actions
62 lines (52 loc) · 1.68 KB
/
Copy pathdelete.php
File metadata and controls
62 lines (52 loc) · 1.68 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
session_start();
if (!isset($_SESSION["user"]) || !isset($_GET["item"])) {
header("Location: index.php");
exit();
}
$user = $_SESSION["user"];
$item = $_GET["item"];
$target = "storage/" . $user . "/" . $item;
// Delete folder (recursive)
function deleteAll($path) {
if (is_dir($path)) {
$files = scandir($path);
foreach ($files as $f) {
if ($f != "." && $f != "..") {
deleteAll($path . "/" . $f);
}
}
rmdir($path);
} else {
unlink($path);
}
}
if (isset($_POST["confirm_delete"])) {
if (file_exists($target)) {
deleteAll($target);
}
header("Location: files.php?view=trash");
exit();
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Confirm Delete</title>
<link rel="stylesheet" href="style.css">
</head>
<body class="center-page"> <div class="container" style="text-align: center; max-width: 450px;">
<h2 id='confirm-delete-head' style="color: #d32f2f; margin-bottom: 20px;">Confirm Deletion</h2>
<p style="font-size: 16px;">Are you sure you want to permanently delete:</p>
<br>
<p style="font-size: 18px; color: #333; word-break: break-all;">
<strong><?php echo htmlspecialchars(basename($item)); ?></strong>?
</p>
<br><br>
<form method="POST">
<button id='yes-delete-it' type="submit" name="confirm_delete" style="background: #d32f2f;">Yes, Delete it</button>
</form>
<a class="action-btn" style="background: #777;" href="files.php<?php echo (dirname($item) != '.' ? '?folder='.dirname($item) : ''); ?>">No, Cancel</a>
</div>
</body>
</html>