diff --git a/front/php/server/cache-bottom.php b/front/php/server/cache-bottom.php new file mode 100644 index 00000000..63ff81ca --- /dev/null +++ b/front/php/server/cache-bottom.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/front/php/server/cache-top.php b/front/php/server/cache-top.php new file mode 100644 index 00000000..17be21e8 --- /dev/null +++ b/front/php/server/cache-top.php @@ -0,0 +1,15 @@ +\n"; + readfile($cachefile); + exit; +} +ob_start(); // Start the output buffer +?> \ No newline at end of file diff --git a/front/php/server/devices.php b/front/php/server/devices.php index 0d05715c..dbfb6080 100644 --- a/front/php/server/devices.php +++ b/front/php/server/devices.php @@ -480,37 +480,20 @@ function PiaToggleArpScan() { function getDevicesTotals() { global $db; - // All - $result = $db->query('SELECT COUNT(*) FROM Devices '. getDeviceCondition ('all')); - $row = $result -> fetchArray (SQLITE3_NUM); - $devices = $row[0]; - - // On-Line - $result = $db->query('SELECT COUNT(*) FROM Devices '. getDeviceCondition ('connected') ); - $row = $result -> fetchArray (SQLITE3_NUM); - $connected = $row[0]; - - // Favorites - $result = $db->query('SELECT COUNT(*) FROM Devices '. getDeviceCondition ('favorites') ); - $row = $result -> fetchArray (SQLITE3_NUM); - $favorites = $row[0]; - - // New - $result = $db->query('SELECT COUNT(*) FROM Devices '. getDeviceCondition ('new') ); - $row = $result -> fetchArray (SQLITE3_NUM); - $newDevices = $row[0]; - - // Down Alerts - $result = $db->query('SELECT COUNT(*) FROM Devices '. getDeviceCondition ('down')); - $row = $result -> fetchArray (SQLITE3_NUM); - $downAlert = $row[0]; + // combined query + $result = $db->query( + 'SELECT + (SELECT COUNT(*) FROM Devices '. getDeviceCondition ('all').') as devices, + (SELECT COUNT(*) FROM Devices '. getDeviceCondition ('connected').') as connected, + (SELECT COUNT(*) FROM Devices '. getDeviceCondition ('favorites').') as favorites, + (SELECT COUNT(*) FROM Devices '. getDeviceCondition ('new').') as new, + (SELECT COUNT(*) FROM Devices '. getDeviceCondition ('down').') as down, + (SELECT COUNT(*) FROM Devices '. getDeviceCondition ('archived').') as archived + '); - // Archived - $result = $db->query('SELECT COUNT(*) FROM Devices '. getDeviceCondition ('archived')); - $row = $result -> fetchArray (SQLITE3_NUM); - $archived = $row[0]; + $row = $result -> fetchArray (SQLITE3_NUM); - echo (json_encode (array ($devices, $connected, $favorites, $newDevices, $downAlert, $archived))); + echo (json_encode (array ($row[0], $row[1], $row[2], $row[3], $row[4], $row[5]))); } diff --git a/front/php/templates/graph.php b/front/php/templates/graph.php index a2983aae..8b1a9751 100644 --- a/front/php/templates/graph.php +++ b/front/php/templates/graph.php @@ -29,4 +29,5 @@ function pia_graph_devices_data($Pia_Graph_Array) { } } $db->close(); + ?> \ No newline at end of file