Update exectool.php

This commit is contained in:
Namhyeon Go 2018-09-26 20:46:26 +09:00 committed by GitHub
parent a94501b20a
commit 00e5681bca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -107,6 +107,32 @@ if(!function_exists("exec_command")) {
function exec_command($command, $method="shell_exec", $options=array()) {
$return = false;
// command cache
if(array_key_equals("cache", $options, true)) {
// set command cache filename
$filename = get_hashed_text($command, array(
"salt" => true,
"2p" => true
));
// read command cache
$return = read_storage_file($filename, array(
"storage_type" => "cache"
));
// write command cache
if(!$return) {
$options['cache'] = false;
$return = exec_command($command, $method, $options);
write_stroage_file($return, array(
"storage_type" => "cache",
"filename" => $filename
));
}
return $return;
}
if ($method == "") {
// ob_start() will turn on output buffering to collect all output from
// exec_test() and ob_end_clean() will clean the buffer afterwards ("garbage collection")
@ -175,15 +201,6 @@ if(!function_exists("exec_command")) {
$return = ob_get_clean();
// save to cache
$fw = write_stroage_file($return, array(
"storage_type" => "cache",
"filename" => get_hashed_text($return, array(
"salt" => true,
"2p" => true
))
));
return $return;
}
}