1
0
moha/webserver/index.php

66 lines
2.0 KiB
PHP
Raw Permalink Normal View History

<?php
require_once "header.php";
require_once "config.php";
2022-05-05 21:28:26 +02:00
require_once $mohaPath . "/utils.php";
2022-04-23 02:00:52 +02:00
require_once $mohaPath . "/constants.php";
2022-05-05 21:28:26 +02:00
require_once "class/db.class.php";
2022-04-23 02:00:52 +02:00
require_once $configPath . "properties2log.php";
2022-04-23 02:00:52 +02:00
$indexIeeeAddress = htmlGetFriendlyNames();
//print_r($indexIeeeAddress);
print (_("This is the Statistics of Moha"));
2022-04-23 02:00:52 +02:00
if (empty($indexIeeeAddress))
{
$response = _("ERROR getting list of Friendly names: json error =>") . json_last_error_msg() .EOLH;
}else
{
$query = "SELECT DISTINCT device, property FROM logs";
$result = $mohaDB->query($query);
$devices = mysqli_fetch_all($result, MYSQLI_ASSOC);
$devicesList = array();
// print_r($devices);
print '<form method="GET" action="display_stats.php">';
//print '<input type="hidden" name="fn" value="">';
print '<label for="devicesSelectList">' . _("Choose a property to display:") . '</label>
2022-04-23 02:00:52 +02:00
<select name="device" id="devicesSelectList">' ;
foreach ($devices as $value)
{
if ( array_key_exists($value["device"], $indexIeeeAddress))
{
2022-09-09 16:52:26 +02:00
$fn = $indexIeeeAddress[$value["device"]];
$devicesList[$fn]["ieeeAddress"] = $value["device"];
$devicesList[$fn]["properties"][] = $value["property"];
2022-04-23 02:00:52 +02:00
}
}
2022-09-09 16:52:26 +02:00
ksort($devicesList, SORT_NATURAL | SORT_FLAG_CASE );
2022-04-23 02:00:52 +02:00
//$devicesList = array_intersect_key($indexIeeeAddress, $tmp);
//print_r($devicesList);
2022-09-09 16:52:26 +02:00
foreach($devicesList as $fn => $array)
2022-04-23 02:00:52 +02:00
{
2022-09-09 16:52:26 +02:00
print '<optgroup label="' . $fn . '">';
$ieeeAddress = $array["ieeeAddress"];
if (array_key_exists("properties", $array))
2022-04-23 02:00:52 +02:00
{
2022-09-09 16:52:26 +02:00
foreach($array["properties"] as $property)
2022-04-23 02:00:52 +02:00
{
2022-09-09 16:52:26 +02:00
print '<option value="' . $ieeeAddress . '|' . $fn . '|' . $property . '">' . $property . '</option>' . EOL;
2022-04-23 02:00:52 +02:00
}
2022-09-09 16:52:26 +02:00
print '</optgroup>' . EOL;
}else
{
echo _("Erreur: la clé de tableau 'properties' n'existe pas ") . __LINE__ . EOLH;
2022-04-23 02:00:52 +02:00
}
}
2022-05-05 21:28:26 +02:00
print "</select>" . EOLH;
print '<input type="date" name="startDate">' . EOLH;
print '<input type="date" name="endDate">' . EOLH;
2022-04-23 02:00:52 +02:00
print '<input type="submit" value="Afficher les statistiques">';
print "</form>" . EOL;
}
require_once "footer.php";
?>