2022-09-01 17:05:05 +02:00
|
|
|
<?php
|
2022-08-28 23:44:21 +02:00
|
|
|
|
2022-09-03 21:10:38 +02:00
|
|
|
foreach($macAddresses as $nom => $mac)
|
|
|
|
{
|
|
|
|
$presence[$nom] = false;
|
|
|
|
}
|
|
|
|
|
2022-09-01 17:05:05 +02:00
|
|
|
function presence($argList)
|
2022-08-28 23:44:21 +02:00
|
|
|
{
|
2022-09-01 17:05:05 +02:00
|
|
|
global $presence;
|
2022-08-28 23:44:21 +02:00
|
|
|
|
2022-09-01 17:05:05 +02:00
|
|
|
if(array_key_exists("nom", $argList))
|
2022-08-28 23:44:21 +02:00
|
|
|
{
|
2022-09-01 17:05:05 +02:00
|
|
|
$name = $argList["nom"];
|
|
|
|
}else
|
|
|
|
{
|
2022-09-01 18:48:20 +02:00
|
|
|
return _("Le paramètre 'nom' est obligatoire<br>present&nom=<nom>&presence=<true/false>") . EOLH;
|
2022-09-01 17:05:05 +02:00
|
|
|
}
|
|
|
|
if(array_key_exists("presence", $argList))
|
|
|
|
{
|
2022-09-01 18:48:20 +02:00
|
|
|
$key = $argList["presence"];
|
2022-09-01 17:05:05 +02:00
|
|
|
}else
|
|
|
|
{
|
2022-09-01 18:48:20 +02:00
|
|
|
return _("Le paramètre 'presence' est obligatoire<br>present&nom=<nom>&presence=<true/false>") . EOLH;
|
2022-09-01 17:05:05 +02:00
|
|
|
}
|
2022-09-03 21:10:38 +02:00
|
|
|
var_dump($presence);
|
2022-09-01 17:05:05 +02:00
|
|
|
if (!array_key_exists($name, $presence))
|
|
|
|
{
|
2022-09-01 18:48:20 +02:00
|
|
|
return sprintf(_("Ce nom (%s) n'existe pas dans la base."), $name) . EOLH;
|
2022-09-01 17:05:05 +02:00
|
|
|
}
|
2022-09-03 21:10:38 +02:00
|
|
|
$key = strval($key);
|
|
|
|
if ($key == 1)
|
2022-09-01 17:05:05 +02:00
|
|
|
{
|
2022-09-03 21:10:38 +02:00
|
|
|
echo "passed";
|
2022-09-01 18:48:20 +02:00
|
|
|
if ($presence[$name] == false)
|
2022-09-01 17:05:05 +02:00
|
|
|
{
|
2022-09-02 17:59:33 +02:00
|
|
|
logger(ALERT, $name . _(" est présent"), __FILE__ . ":" . __LINE__);
|
2022-09-01 17:05:05 +02:00
|
|
|
//echo $name . " est présent";
|
|
|
|
$presence[$name] = true;
|
|
|
|
}
|
2022-09-03 21:10:38 +02:00
|
|
|
}elseif ($presence[$name] == true and $key == "0")
|
2022-09-01 17:05:05 +02:00
|
|
|
{
|
|
|
|
$presence[$name] = false;
|
2022-09-02 17:59:33 +02:00
|
|
|
logger(ALERT, $name . _(" est présent"), __FILE__ . ":" . __LINE__);
|
2022-08-28 23:44:21 +02:00
|
|
|
}
|
2022-09-01 18:48:20 +02:00
|
|
|
return _("demande prise en compte");
|
2022-08-28 23:44:21 +02:00
|
|
|
}
|
|
|
|
|
2022-09-01 17:05:05 +02:00
|
|
|
|
|
|
|
function isPresent($name = false, $returnNames = false)
|
|
|
|
{
|
|
|
|
global $presence;
|
|
|
|
|
|
|
|
$r = false;
|
2022-09-02 17:59:33 +02:00
|
|
|
$liste = "";
|
2022-09-01 17:05:05 +02:00
|
|
|
|
|
|
|
if ($name === false)
|
|
|
|
{
|
|
|
|
foreach($presence as $name => $value)
|
|
|
|
{
|
|
|
|
if ($value === true)
|
|
|
|
{
|
|
|
|
$r &= true;
|
|
|
|
$liste .= $name . EOLH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}elseif (array_key_exists($name, $presence))
|
|
|
|
{
|
|
|
|
$r = $presence[$name];
|
|
|
|
}else
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($returnNames and !empty($liste))
|
|
|
|
{
|
|
|
|
return $liste;
|
|
|
|
}else
|
|
|
|
{
|
|
|
|
return $r;
|
|
|
|
}
|
|
|
|
}
|
2022-08-28 23:44:21 +02:00
|
|
|
?>
|