DTux
/
dtux__moha
Archived
1
0
Fork 0
This repository has been archived on 2023-11-30. You can view files and clone it, but cannot push or open issues or pull requests.
dtux__moha/hooks/scripts/rdc_portes_ouvertes.php

64 lines
1.6 KiB
PHP

<?php
require_once "events.php";
class alerte_intrusion extends hook
{
public $hookName = "alerte_intrusion";
public $active = true;
protected $devicelist = array(
ENTREE_PORTE => "contact",
GARAGE_PORTE => "contact",
RDC_CHAMBRE_BAIE => "contact",
RDC_SALON_BAIE => "contact",
GARAGE_PORTAIL => "contact"
);
function installHooks(&$indexDevices)
{
return $this->installHooksFunction($indexDevices);
}
// callback fonction. Is called with these 4 parameters
public function callBack($device, $property, $value)
{
logger(DEBUG, sprintf(_("property=%s, value=%s"), $property, $value), __FILE__ . ":" . __LINE__);
switch($property)
{
case "contact":
if ($value == false)
{
logger(ALERT, sprintf(_("%s est ouverte alors que personne n'est présent"), $device->friendlyName), __FILE__ . ":" . __LINE__);
}
break;
}
}
public function testPortes()
{
global $indexDevices;
logger(DEBUG, _("Function alerte_intrusion->testPorte"), __FILE__ . ":" . __LINE__);
$msg = "";
foreach ($this->devicelist as $device => $property)
{
if($indexDevices[$device]->properties[$property] != false)
{
$msg .= $indexDevices[$device]->friendlyName . " is open" . EOL;
}
}
if (!empty($msg))
{
logger(ALERT, $msg, __FILE__ . ":" . __LINE__);
}
return nl2br($msg);
}
}
$hooks["alerte_intrusion"] = new alerte_intrusion();
logger(DEBUG, _("Initializing event"), __FILE__ . ":" . __LINE__);
$function = array($hooks["alerte_intrusion"], "testPortes");
setRecurrentEvent($function, 0, 0, 0, 0, 0, 0, 21, 0, 0, 1, 0, 0, 0);
?>