-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcleanup.php
64 lines (56 loc) · 1.36 KB
/
cleanup.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
<?php
function rrmdir($dir)
{
if (is_dir($dir))
{
$objects = scandir($dir);
foreach ($objects as $object)
{
if ($object != "." && $object != "..")
{
if (filetype($dir."/".$object) == "dir")
rrmdir($dir."/".$object);
else
unlink($dir."/".$object);
}
}
reset($objects);
rmdir($dir);
}
}
$sql = sqlite_open("configs/data");
$info_results = sqlite_query($sql, "SELECT * FROM info");
$info = sqlite_fetch_all($info_results);
$dirs = scandir($info[3]['Value']);
foreach ($dirs as $dir)
{
if ($dir != "." && $dir != "..")
{
if (time()-filectime($info[3]['Value']."/$dir") > 3600) // 1 hour
{
rrmdir($info[3]['Value']."/$dir");
}
}
}
$dirs = scandir($info[4]['Value']);
foreach ($dirs as $dir)
{
if ($dir != "." && $dir != "..")
{
if (time()-filectime($info[4]['Value']."/$dir") > 3600) // 1 hour
{
rrmdir($info[4]['Value']."/$dir");
}
}
}
$compile_results = sqlite_query($sql, "SELECT * FROM compile");
$compile = sqlite_fetch_all($compile_results);
foreach ($compile as $id)
{
if (!is_dir($info[4]['Value']."/".$id['ID']))
{
sqlite_exec($sql, "DELETE FROM compile WHERE ID = ".$id['ID']);
}
}
sqlite_close($sql);
?>