2017-01-27 11:21:32 +00:00
|
|
|
<?php
|
|
|
|
|
2017-01-27 14:54:30 +00:00
|
|
|
/* [1] Launches external script
|
|
|
|
=========================================================*/
|
2017-01-27 19:41:02 +00:00
|
|
|
function syscall($dependency=null){
|
2017-01-27 11:21:32 +00:00
|
|
|
/* (1) Check file */
|
2017-01-27 19:41:02 +00:00
|
|
|
if( is_null($dependency) || !file_exists($dependency) )
|
2017-01-27 14:54:30 +00:00
|
|
|
return false;
|
2017-01-27 11:21:32 +00:00
|
|
|
|
|
|
|
/* (2) Call and catch output */
|
2017-01-27 19:41:02 +00:00
|
|
|
$out = shell_exec($dependency);
|
2017-01-27 11:21:32 +00:00
|
|
|
|
2017-01-27 19:41:02 +00:00
|
|
|
/* (3) Clean output */
|
|
|
|
$out = preg_replace('/^\s+/', '', $out);
|
|
|
|
$out = preg_replace('/\s+$/', '', $out);
|
2017-01-27 14:54:30 +00:00
|
|
|
|
|
|
|
/* (4) Manage result */
|
|
|
|
if( is_numeric($out) ) return ($out==0);
|
|
|
|
else return $out;
|
2017-01-27 11:21:32 +00:00
|
|
|
}
|
|
|
|
|
2017-01-27 19:41:02 +00:00
|
|
|
/* [2] Log management
|
|
|
|
=========================================================*/
|
|
|
|
function slog($message="unknown error...", $feature="default", $flag="daemon"){
|
|
|
|
|
2017-01-27 20:00:06 +00:00
|
|
|
file_put_contents(LOG_DIR."/$flag.log", time()." [$feature] $message\n", FILE_APPEND);
|
2017-01-27 19:41:02 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-01-27 11:21:32 +00:00
|
|
|
?>
|