-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdelete.php
65 lines (44 loc) · 1.28 KB
/
delete.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
session_start();
require('class.php');
include("json.php");
function folderDelete($path){
$list = preg_grep('/^([^.])/', scandir($path));
foreach ($list as $element) {
if (is_dir($path.$element)) {
folderDelete($path.$element."/");
}
else {
unlink($path.$element);
}
}
rmdir($path);
}
if (isset($_GET["file"])){
$path = decypher($_GET["file"], 1, TRUE);
$filepath = dirname($path);
$filename = basename($path);
$stat = (is_dir($path))? "directory" : "file";
if ((((int)(microtime(true) * 1000)) - $_SESSION['auth']) < 300000){
if (file_exists($path)){
if (!is_dir($path)){
if (!unlink($path)) {
$result = new info("error", "An error occured; You may not have permission to delete this");
} else {
informJSON($path, "", 1);
$result = new info("prompt", "File delete succesful");
}
} else {
folderDelete($path);
$result = new info("prompt", "Folder delete succesful");
}
}else {
$result = new info("error", "The ".$stat." ".$filename." does not exist");
}
}else {
$result = new info("alert","You need to be logged in to perform this task");
}
$delete = json_encode($result);
echo $delete;
}
?>