1
0
moha/configWatch.php

51 lines
1.2 KiB
PHP
Raw Normal View History

<?php
$cwfd = inotify_init();
if ($cwfd !== false)
{
$watch_descriptor = inotify_add_watch($cwfd, $configDir, IN_CLOSE_WRITE);
logger(ERROR, _("configWatchInit : Inotify retourne 'false'"), __FILE__ . ":" . __LINE__);
}
function configWatchInit()
{
global $cwfd;
logger(DEBUG, _("configWatchInit : Initialise la surveillance du dossier des configurations"), __FILE__ . ":" . __LINE__);
if ($cwfd !== false)
{
$read = array($cwfd);
$write = null;
$except = null;
stream_select($read, $write, $except,0);
stream_set_blocking($cwfd, 0);
}
}
function configWach() :void
{
global $cwfd, $configDir;
if ($cwfd !== false)
{
$input = inotify_read($cwfd); // Does no block, and return false if no events are pending
if ($input !== false)
{
foreach ($input as $event)
{
logger(DEBUG, _("configWatch : inclus ") . $configDir . "/" . $event["name"], __FILE__ . ":" . __LINE__);
if (pathinfo($event["name"], PATHINFO_EXTENSION) == "php")
{
include $configDir . "/" . $event["name"];
}else
{
logger(DEBUG, _("configWatch : mauvaise extension, n'inclus pas ") . $configDir . "/" . $event["name"], __FILE__ . ":" . __LINE__);
}
}
}
}
}
?>