ajout de la détection de présence par présence de téléphone en Wifi
This commit is contained in:
parent
6a333acc9f
commit
373bb6c228
@ -9,6 +9,7 @@
|
||||
$deviceTable = array(
|
||||
"0x00124b0022ebac5c" => "RDC_SALON_MVMT2",
|
||||
"0x588e81fffe2cf695" => "RDC_SALON_MVMT",
|
||||
"0xe0798dfffe4ffa2c" => "RDC_SALON_PRESENCE",
|
||||
"0x00124b001f900753" => "RDC_ENTREE_PORTE",
|
||||
"0x00158d0001923c21" => "RDC_CHAMBRE_RADIATEUR",
|
||||
"0x04cf8cdf3c78aff0" => "RDC_SALON_LUMINOSITE",
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
macAdressses = array(
|
||||
|
||||
$macAddresses = array(
|
||||
"Daniel" => "84:CF:BF:8E:E6:A6"
|
||||
);
|
||||
|
||||
|
78
presence.php
78
presence.php
@ -1,18 +1,78 @@
|
||||
<?php require "config/liste_telephones.php";
|
||||
<?php
|
||||
|
||||
function presence()
|
||||
function presence($argList)
|
||||
{
|
||||
$result = array();
|
||||
$command = "sudo nmap -n -sP 192.168.1.*";
|
||||
global $presence;
|
||||
|
||||
exec($command, $result);
|
||||
var_dump($result);
|
||||
foreach ($macAddresses as $name =>$value)
|
||||
if(array_key_exists("nom", $argList))
|
||||
{
|
||||
$key = array_search($value, $result);
|
||||
$name = $argList["nom"];
|
||||
}else
|
||||
{
|
||||
return "Le paramètre 'nom' est obligatoire\npresent&nom=<nom>&presence=<true/false>" . EOLH;
|
||||
}
|
||||
if(array_key_exists("presence", $argList))
|
||||
{
|
||||
$key= $argList["presence"];
|
||||
}else
|
||||
{
|
||||
return "Le paramètre 'presence' est obligatoire\npresent&nom=<nom>&presence=<true/false>" . EOLH;
|
||||
}
|
||||
$key = $argList["presence"];
|
||||
if (!array_key_exists($name, $presence))
|
||||
{
|
||||
$presence[] = $name;
|
||||
$presence[$name] = false;
|
||||
}
|
||||
|
||||
if ($key === true)
|
||||
{
|
||||
if ($presence[$name] === false)
|
||||
{
|
||||
logger(ALERT, $name . _(" est présent"), null, $device);
|
||||
//echo $name . " est présent";
|
||||
$presence[$name] = true;
|
||||
}
|
||||
}elseif ($presence[$name] === true)
|
||||
{
|
||||
$presence[$name] = false;
|
||||
logger(ALERT, $name . _(" est présent"), null, $device);
|
||||
}
|
||||
}
|
||||
|
||||
presence();
|
||||
|
||||
function isPresent($name = false, $returnNames = false)
|
||||
{
|
||||
global $presence;
|
||||
|
||||
$r = false;
|
||||
$list = "";
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user