aboutsummaryrefslogtreecommitdiff
path: root/admin/api/getQuota.php
blob: 1d647372b5e18c3b0a3f8801aa53780b5bca5595 (plain)
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
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . "/admin/private/header.api.php";

if (isset($_GET['_']) && strpos($_GET['_'], "/") === false) {
    $arg = $_GET['_'];
} else {
    die();
}

$webs = scandir("/mnt/minteckrolt-cloud");

if (in_array($arg, $webs)) {
    $tier = trim(file_get_contents("/mnt/minteckrolt-cloud/" . $arg . "/Tier"));

    exec("du -hs /mnt/minteckrolt-cloud/" . $arg, $ret);
    $parts = explode("	", $ret[0]);

    exec("du -s /mnt/minteckrolt-cloud/" . $arg, $ret2);
    $parts2 = explode("	", $ret2[0]);

    if ($tier === "3") {
        $perc = ($parts2[0] / 100000) * 100;
        if ($perc > 75) {
            die("<span class='text-danger'>" . l("Using", "Utilise") . " " . $parts[0] . "/100M (" . round($perc, 2) . "%)</span>");
        } else if ($perc > 50) {
            die("<span class='text-warning'>" . l("Using", "Utilise") . " " . $parts[0] . "/100M (" . round($perc, 2) . "%)</span>");
        } else {
            die("<span class='text-success'>" . l("Using", "Utilise") . " " . $parts[0] . "/100M (" . round($perc, 2) . "%)</span>");
        }
    } else if ($tier === "5") {
        $perc = ($parts2[0] / 250000) * 100;
        if ($perc > 75) {
            die("<span class='text-danger'>" . l("Using", "Utilise") . " " . $parts[0] . "/250M (" . round($perc, 2) . "%)</span>");
        } else if ($perc > 50) {
            die("<span class='text-warning'>" . l("Using", "Utilise") . " " . $parts[0] . "/250M (" . round($perc, 2) . "%)</span>");
        } else {
            die("<span class='text-success'>" . l("Using", "Utilise") . " " . $parts[0] . "/250M (" . round($perc, 2) . "%)</span>");
        }
    } else if ($tier === "7") {
        $perc = ($parts2[0] / 500000) * 100;
        if ($perc > 75) {
            die("<span class='text-danger'>" . l("Using", "Utilise") . " " . $parts[0] . "/500M (" . round($perc, 2) . "%)</span>");
        } else if ($perc > 50) {
            die("<span class='text-warning'>" . l("Using", "Utilise") . " " . $parts[0] . "/500M (" . round($perc, 2) . "%)</span>");
        } else {
            die("<span class='text-success'>" . l("Using", "Utilise") . " " . $parts[0] . "/500M (" . round($perc, 2) . "%)</span>");
        }
    } else {
        die("<span class='text-success'>" . l("Using", "Utilise") . " " . $parts[0] . "</span>");
    }
}

die("Unable to calculate data usage");