ajout rechargement auto des fichiers de conf modifié.
This commit is contained in:
		
							
								
								
									
										50
									
								
								configWatch.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								configWatch.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,50 @@
 | 
			
		||||
<?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__);
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
?>
 | 
			
		||||
		Reference in New Issue
	
	Block a user