1
0
moha/presence.php

84 lines
1.5 KiB
PHP
Raw Permalink Normal View History

<?php
2022-08-28 23:44:21 +02:00
2022-09-05 13:47:41 +02:00
foreach($macAddresses as $mac => $nom)
2022-09-03 21:10:38 +02:00
{
$presence[$nom] = false;
}
function presence($argList)
2022-08-28 23:44:21 +02:00
{
global $presence;
2022-08-28 23:44:21 +02:00
if(array_key_exists("nom", $argList))
2022-08-28 23:44:21 +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;
}
if(array_key_exists("presence", $argList))
{
2022-09-01 18:48:20 +02:00
$key = $argList["presence"];
}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-05 13:47:41 +02:00
//var_dump($presence);
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-03 21:10:38 +02:00
$key = strval($key);
if ($key == 1)
{
2022-09-03 21:10:38 +02:00
echo "passed";
2022-09-01 18:48:20 +02:00
if ($presence[$name] == false)
{
2022-09-02 17:59:33 +02:00
logger(ALERT, $name . _(" est présent"), __FILE__ . ":" . __LINE__);
//echo $name . " est présent";
$presence[$name] = true;
}
2022-09-03 21:10:38 +02:00
}elseif ($presence[$name] == true and $key == "0")
{
$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
}
function isPresent($name = false, $returnNames = false)
{
global $presence;
$r = false;
2022-09-02 17:59:33 +02:00
$liste = "";
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
?>