Initial refactor of functions.php
This commit is contained in:
28
inc/functions/interop.php
Normal file
28
inc/functions/interop.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
defined('TINYBOARD') or exit;
|
||||
|
||||
|
||||
function shell_exec_error($command, $suppress_stdout = false) {
|
||||
global $config, $debug;
|
||||
|
||||
if ($config['debug']) {
|
||||
$start = microtime(true);
|
||||
}
|
||||
|
||||
$return = trim(shell_exec('PATH="' . escapeshellcmd($config['shell_path']) . ':$PATH";' .
|
||||
$command . ' 2>&1 ' . ($suppress_stdout ? '> /dev/null ' : '') . '&& echo "TB_SUCCESS"'));
|
||||
$return = preg_replace('/TB_SUCCESS$/', '', $return);
|
||||
|
||||
if ($config['debug']) {
|
||||
$time = microtime(true) - $start;
|
||||
$debug['exec'][] = array(
|
||||
'command' => $command,
|
||||
'time' => '~' . round($time * 1000, 2) . 'ms',
|
||||
'response' => $return ? $return : null
|
||||
);
|
||||
$debug['time']['exec'] += $time;
|
||||
}
|
||||
|
||||
return $return === 'TB_SUCCESS' ? false : $return;
|
||||
}
|
||||
Reference in New Issue
Block a user