-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadmin_dbsize.php
67 lines (63 loc) · 1.59 KB
/
admin_dbsize.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
66
67
<?php
// Ultimate PHP Board
// Author: Tim Hoeppner aka RR_Pilot, FixITguy
// Website: http://www.myupb.com
// Version: 2.0
// Using textdb Version: 4.3.2
//list old search files too
require_once("includes/upb.initialize.php");
if(!$tdb->is_logged_in() || $_COOKIE["power_env"] < 3)
{
die("You are not authorized to be here");
}
else
{
$size = 0;
$files = array();
dbsize($size, $files);
$size = round($size / 1024, 2);
echo "Total db size: $size KB<br />";
$oldsize = 0;
$oldfiles = array();
dbsize($oldsize, $oldfiles, true, 1);
$oldsize = round($oldsize / 1024, 2);
echo "Files older than 1 days: $oldsize KB<br />";
for($i = 0; $i < count($oldfiles); $i++) {
echo "$oldfiles[$i]<br />";
}
echo "done!";
}
function dbsize(&$size, &$filearr, $getold = false, $days = 30) {
$dbdir = opendir(DB_DIR);
while ($p = readdir($dbdir)) {
if (is_file("./db/".$p)) {
if ($getold) {
} else {
$size += filesize(DB_DIR."/".$p);
$filearr[] = DB_DIR."/".$p;
}
}
if (is_dir(DB_DIR."/".$p) && $p != "." && $p != "..") {
$dir = opendir(DB_DIR."/".$p);
while ($d = readdir($dir)) {
if (is_file(DB_DIR."/$p/".$d)) {
if ($getold) {
if (fileatime(DB_DIR."/$p/".$d) + (60 * 60 * 24 * $days) < time()) {
if (is_numeric($p)) {
$size += filesize(DB_DIR."/$p/".$d);
$filearr[] = DB_DIR."/$p/".$d;
}
}
} else {
$size += filesize(DB_DIR."/$p/".$d);
$filearr[] = DB_DIR."/$p/".$d;
}
}
}
closedir($dir);
}
}
closedir($dbdir);
}
// sec * min * hr * days
?>