2021-12-30 16:18:32 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
function now()
|
|
|
|
{
|
|
|
|
return new DateTime("now");
|
|
|
|
}
|
|
|
|
|
2022-01-02 13:47:41 +01:00
|
|
|
function notify($message)
|
|
|
|
{
|
2022-01-02 18:14:13 +01:00
|
|
|
global $notificationMethods;
|
|
|
|
$result = false;
|
2022-01-02 13:47:41 +01:00
|
|
|
foreach($notificationMethods as $value)
|
|
|
|
{
|
2022-01-03 21:11:52 +01:00
|
|
|
$result = $result | $value->send($message);
|
2022-01-02 13:47:41 +01:00
|
|
|
}
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
2022-01-08 11:51:50 +01:00
|
|
|
function mktopic($device)
|
2022-01-02 13:47:41 +01:00
|
|
|
{
|
2022-01-08 11:51:50 +01:00
|
|
|
return $device->topic . "/" . $device->friendlyName;
|
2022-01-02 13:47:41 +01:00
|
|
|
}
|
2021-12-30 16:18:32 +01:00
|
|
|
|
2022-01-08 11:51:50 +01:00
|
|
|
logger(DEBUG, _("signal handling"), false);
|
|
|
|
//signal handling
|
|
|
|
function signalHandler($signal)
|
2022-01-03 21:11:52 +01:00
|
|
|
{
|
2022-01-08 11:51:50 +01:00
|
|
|
endMoha();
|
2022-01-03 21:11:52 +01:00
|
|
|
}
|
2022-01-08 11:51:50 +01:00
|
|
|
pcntl_signal(SIGTERM, 'signalHandler');// Termination ('kill' was called)
|
|
|
|
pcntl_signal(SIGHUP, 'signalHandler'); // Terminal log-out
|
|
|
|
pcntl_signal(SIGINT, 'signalHandler');
|
2021-12-30 16:18:32 +01:00
|
|
|
?>
|