SATS/lib/include/php/func

39 lines
921 B
Plaintext
Raw Normal View History

<?php
2017-01-27 14:54:30 +00:00
/* [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]) )
2017-01-27 14:54:30 +00:00
return false;
/* (2) Call and catch output */
2017-02-18 10:09:49 +00:00
$out = shell_exec("$dependency 2> /dev/null;");
/* (3) Clean output */
$out = preg_replace('/^\s+/', '', $out);
$out = preg_replace('/\s+$/', '', $out);
2017-01-27 14:54:30 +00:00
/* (4) Manage result */
2017-10-12 17:19:46 +00:00
if( is_numeric($out) && $out === "0" )
return true;
elseif( is_numeric($out) && $out === "127" )
return false;
2017-10-12 17:19:46 +00:00
else
return $out;
}
/* [2] Log management
=========================================================*/
2017-01-30 09:59:52 +00:00
function slog($message="unknown error", $feature="main", $flag="daemon"){
file_put_contents(LOG_DIR."/$flag.log", time()." [$feature] $message\n", FILE_APPEND);
}
?>