diff options
Diffstat (limited to 'it.class')
-rw-r--r-- | it.class | 35 |
1 files changed, 25 insertions, 10 deletions
@@ -444,7 +444,7 @@ static function filter_keys($array, $keys, $p = array()) /** - * Construct shell command, log it, execute it and return output as string. + * Construct shell command using it::shell_command, log it, execute it and return output as string. * Keywords {keyword} are replace a la ET(), {-opts} takes an array and * inserts options a la it_html attributes (value, true, false or null) * @param $cmd Format string with {keywords} replace a la ET() @@ -454,6 +454,29 @@ static function filter_keys($array, $keys, $p = array()) static function exec(/* $cmd, $values1 = array(), ... */) { $args = func_get_args(); + $cmd = call_user_func_array('it::shell_command', $args); + + $s = gettimeofday(); + $result = EDC('noexec') ? "" : (string)shell_exec($cmd); + $e = gettimeofday(); + $msec= intval(($e['sec'] - $s['sec']) * 1000 + ($e['usec'] - $s['usec']) / 1000); + + @it::log('exec', "$msec\t$cmd"); + + return $result; +} + +/** + * Construct shell command + * Keywords {keyword} are replace a la ET(), {-opts} takes an array and + * inserts options a la it_html attributes (value, true, false or null) + * @param $cmd Format string with {keywords} replace a la ET() + * @param $values (zero, one or more arrays can be passed) + * @return output of command. shell errors not detectable, see error_log in /www/server/logs + */ +static function shell_command(/* $cmd, $values1 = array(), ... */) +{ + $args = func_get_args(); $cmd = array_shift($args); $values = array(); @@ -490,15 +513,7 @@ static function exec(/* $cmd, $values1 = array(), ... */) $cmd = strtr($cmd, (array)$replacements); # Use strtr behaviour of going through source string once setlocale(LC_CTYPE, $oldlocale); - - $s = gettimeofday(); - $result = EDC('noexec') ? "" : (string)shell_exec($cmd); - $e = gettimeofday(); - $msec= intval(($e['sec'] - $s['sec']) * 1000 + ($e['usec'] - $s['usec']) / 1000); - - @it::log('exec', "$msec\t$cmd"); - - return $result; + return $cmd; } #fails with C locale!!! |