-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhistogram_backend.php
More file actions
44 lines (36 loc) · 3.36 KB
/
histogram_backend.php
File metadata and controls
44 lines (36 loc) · 3.36 KB
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
<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
header("Cache-Control: no-cache, no-store, must-revalidate");
require_once("dbroconf.php");
require_once("helper_php/time.php");
foreach ($db_ro_confs as $conf) {
if ($_GET["fs"] == $conf["fs"]) {
$conn = new mysqli($conf["host"], $conf["user"], $conf["pass"], $conf["db"]);
$sql = array();
array_push($sql, "SELECT COUNT(*) AS number,SUM(size) AS size FROM ENTRIES WHERE ENTRIES.type='file' AND ENTRIES.uid LIKE BINARY '" . $_GET["owner"] . "' AND ENTRIES.last_access>" . $thirtydaysago);
array_push($sql, "SELECT COUNT(*) AS number,SUM(size) AS size FROM ENTRIES WHERE ENTRIES.type='file' AND ENTRIES.uid LIKE BINARY '" . $_GET["owner"] . "' AND ENTRIES.last_access<=" . $thirtydaysago . " AND ENTRIES.last_access>" . $sixtydaysago);
array_push($sql, "SELECT COUNT(*) AS number,SUM(size) AS size FROM ENTRIES WHERE ENTRIES.type='file' AND ENTRIES.uid LIKE BINARY '" . $_GET["owner"] . "' AND ENTRIES.last_access<=" . $sixtydaysago . " AND ENTRIES.last_access>" . $ninetydaysago);
array_push($sql, "SELECT COUNT(*) AS number,SUM(size) AS size FROM ENTRIES WHERE ENTRIES.type='file' AND ENTRIES.uid LIKE BINARY '" . $_GET["owner"] . "' AND ENTRIES.last_access<=" . $ninetydaysago . " AND ENTRIES.last_access>" . $sixmonthsago);
array_push($sql, "SELECT COUNT(*) AS number,SUM(size) AS size FROM ENTRIES WHERE ENTRIES.type='file' AND ENTRIES.uid LIKE BINARY '" . $_GET["owner"] . "' AND ENTRIES.last_access<=" . $sixmonthsago . " AND ENTRIES.last_access>" . $oneyearago);
array_push($sql, "SELECT COUNT(*) AS number,SUM(size) AS size FROM ENTRIES WHERE ENTRIES.type='file' AND ENTRIES.uid LIKE BINARY '" . $_GET["owner"] . "' AND ENTRIES.last_access<=" . $oneyearago . " AND ENTRIES.last_access>" . $twoyearsago);
array_push($sql, "SELECT COUNT(*) AS number,SUM(size) AS size FROM ENTRIES WHERE ENTRIES.type='file' AND ENTRIES.uid LIKE BINARY '" . $_GET["owner"] . "' AND ENTRIES.last_access<=" . $twoyearsago . " AND ENTRIES.last_access>" . $threeyearsago);
array_push($sql, "SELECT COUNT(*) AS number,SUM(size) AS size FROM ENTRIES WHERE ENTRIES.type='file' AND ENTRIES.uid LIKE BINARY '" . $_GET["owner"] . "' AND ENTRIES.last_access<=" . $threeyearsago . " AND ENTRIES.last_access>" . $fiveyearsago);
array_push($sql, "SELECT COUNT(*) AS number,SUM(size) AS size FROM ENTRIES WHERE ENTRIES.type='file' AND ENTRIES.uid LIKE BINARY '" . $_GET["owner"] . "' AND ENTRIES.last_access<=" . $fiveyearsago);
$selectsql = $sql[$_GET["id"]];
$outp = "[";
$result = $conn->query($selectsql) or trigger_error($conn->error."[$selectsql]");
$results_age = array("<30 Days", "30 - 60 Days", "60 - 90 Days", "90 Days - 6 Months", "6 Months - 1 Year", "1 - 2 Years", "2 - 3 Years", "3 - 5 Years", ">5 Years");
$rs = $result->fetch_array(MYSQLI_ASSOC);
if ($outp != "[") {$outp .= ",";}
$outp .= '{"File_System":"' . $conf["fs"] . '",';
$outp .= '"Age":"' . $results_age[$_GET["id"]] . '",';
$outp .= '"Number_of_Files":' . (is_null($rs["number"]) ? 0 : $rs["number"]) . ',';
$outp .= '"Percentage_of_Total_Files":' . "0,";
$outp .= '"Size_of_Files":' . (is_null($rs["size"]) ? 0 : $rs["size"]) . ',';
$outp .= '"Percentage_of_Total_Size":' . "0}";
$outp .= "]";
echo($outp);
}
}
?>