-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathdelete.json.php
47 lines (40 loc) · 1.16 KB
/
delete.json.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
<?php
function rrmdir($dir) {
if (is_dir($dir)) {
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object != "." && $object != "..") {
if (is_dir($dir . "/" . $object))
rrmdir($dir . "/" . $object);
else
unlink($dir . "/" . $object);
}
}
rmdir($dir);
}
}
require_once './configuration.php';
header('Content-Type: application/json');
$obj = new stdClass();
$obj->error = true;
$obj->msg = "";
$obj->aVideoStorageURL = $global['aVideoStorageURL'];
$obj->filename = "";
if (empty($_REQUEST['secret']) || $_REQUEST['secret'] !== $global['secret']) {
$obj->msg = "Invalid secret";
} else if (empty($_REQUEST['filename'])) {
$obj->msg = "Empty filename";
} else {
$filename = $_REQUEST['filename'];
$files = glob("{$global['videos_directory']}*{$filename}*"); // get all file names
foreach ($files as $file) { // iterate files
if (is_file($file))
unlink($file); // delete file
else {
rrmdir($file);
}
}
$obj->error = false;
}
die(json_encode($obj));
?>