-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathaction.php.template
65 lines (54 loc) · 1.79 KB
/
action.php.template
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
<?php
/// ---------------------------------------------------------
///
/// ShadowNET's Seedbox
/// By TheSyndicate ---> https://github.com/The-Syndicate/
///
/// ---------------------------------------------------------
require_once( '../../php/util.php' );
if(!isset($quotaUser)) {
$quotaUser = '';
}
$homeUser = $topDirectory.'/'.$quotaUser;
$homeBase = $topDirectory;
$quotaEnabled = FALSE;
if (isset($quotaUser) and !Empty($quotaUser) and file_exists($homeBase.'/aquota.user')) {
$quotaEnabled = myGetDirs($quotaUser, &$homeUser, &$homeBase); /// get the real home dir
}
if ($quotaEnabled) {
$total = shell_exec("/usr/bin/sudo /usr/sbin/repquota -u $homeBase | grep ^".$quotaUser." | awk '{print \$4}'") * 1024;
$used = shell_exec("/usr/bin/sudo /usr/sbin/repquota -u $homeBase | grep ^".$quotaUser." | awk '{print \$3}'") * 1024;
if ($total == 0) {
$total = disk_total_space($topDirectory);
}
$free = ($total - $used);
} else {
$total = disk_total_space($topDirectory);
$free = disk_free_space($topDirectory);
}
cachedEcho('{ "total": '.$total.', "free": ' .$free.' }',"application/json");
function myGetDirs($username, $homeUser, $homeBase) {
$passwd = file('/etc/passwd');
$path = false;
foreach ($passwd as $line) {
if (strstr($line, $username) !== false) {
$parts = explode(':', $line);
$path = $parts[5];
break;
}
}
$ret = TRUE;
$U = realpath($path); /// expand
$B = realpath($path."/.."); /// home is the previous path
if (isset($U) and !Empty($U) and is_dir($U)) {
$homeUser = $U;
} else {
$ret = FALSE;
}
if (isset($B) and !Empty($B) and is_dir($B)) {
$homeBase = $B;
} else {
$ret = FALSE;
}
return $ret;
}