35 lines
863 B
Plaintext
Executable File
35 lines
863 B
Plaintext
Executable File
<?php
|
|
|
|
/* [1] Launches external script
|
|
=========================================================*/
|
|
function syscall($dependency=null){
|
|
|
|
// cut in words
|
|
$words = explode(' ', $dependency);
|
|
|
|
/* (1) Check file */
|
|
if( is_null($dependency) || !file_exists($words[0]) )
|
|
return false;
|
|
|
|
/* (2) Call and catch output */
|
|
$out = shell_exec("$dependency 2> /dev/null;");
|
|
|
|
/* (3) Clean output */
|
|
$out = preg_replace('/^\s+/', '', $out);
|
|
$out = preg_replace('/\s+$/', '', $out);
|
|
|
|
/* (4) Manage result */
|
|
if( is_numeric($out) ) return ("$out"==="0");
|
|
else return $out;
|
|
}
|
|
|
|
/* [2] Log management
|
|
=========================================================*/
|
|
function slog($message="unknown error", $feature="main", $flag="daemon"){
|
|
|
|
file_put_contents(LOG_DIR."/$flag.log", time()." [$feature] $message\n", FILE_APPEND);
|
|
|
|
}
|
|
|
|
?>
|