-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathdelete_all_uploads.php
57 lines (49 loc) · 1.21 KB
/
delete_all_uploads.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
<?php
//can setup a password below like 'pass' instead of '' to only allow access like delete_all_uploads.php?password=pass
if ($_GET['password']!='') exit;
function deltree($path) {
if (is_dir($path)) {
if (version_compare(PHP_VERSION, '5.0.0') < 0) {
$entries = array();
if ($handle = opendir($path)) {
while (false !== ($file = readdir($handle))) $entries[] = $file;
closedir($handle);
}
} else {
$entries = @scandir($path);
if ($entries === false) $entries = array(); // just in case scandir fail...
}
foreach ($entries as $entry) {
if ($entry != '.' && $entry != '..') {
deltree($path.'/'.$entry);
}
}
return @rmdir($path);
} else {
return @unlink($path);
}
}
function cleanUp($dir)
{
echo "Deleting ...";
$k=0;
$handle=opendir($dir);
while (($file = readdir($handle))!==false)
{
if (($file != ".") && ($file != ".."))
{
if (is_dir("$dir/" . $file)) deltree($dir."/".$file);
else @unlink("$dir/" . $file);
$k++;
if ($k%50==0)
{
echo " .";
flush();
}
}
}
closedir($handle);
echo "<BR>Finished cleaning up $k rooms.";
}
cleanUp('uploads');
?>