-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathdelete.php
More file actions
executable file
·48 lines (34 loc) · 881 Bytes
/
delete.php
File metadata and controls
executable file
·48 lines (34 loc) · 881 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/*
// http://php.net/manual/en/function.unlink.php
// zibi at nora dot pl 24-Sep-2010 02:01
putraworks.wordpress.com/2006/02/27/php-delete-a-file-or-a-folder-and-its-contents/
*/
function rmdirr($dirname)
{
// Sanity check
if (!file_exists($dirname)) {
return false;
}
// Simple delete for a file
if (is_file($dirname)) {
return unlink($dirname);
}
// Loop through the folder
$dir = dir($dirname);
while (false !== $entry = $dir->read()) {
// Skip pointers
if ($entry == '.' || $entry == '..') {
continue;
}
// Recurse
rmdirr("$dirname/$entry");
}
// Clean up
$dir->close();
return rmdir($dirname);
}
if (isset($_POST["name"])){
$name = stripslashes($_POST["name"]);
rmdirr($name);
}