1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-12-03 19:47:25 +01:00
vichan/inc/functions/interop.php
2024-02-03 17:17:14 +01:00

29 lines
731 B
PHP

<?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;
}