*/ class ExecWithFallback { protected static $methods = ['exec', 'passthru', 'popen', 'proc_open', 'shell_exec']; /** * Check if any of the methods are available on the system. * * @param boolean $needResultCode Whether the code using this library is going to supply $result_code to the exec * call. This matters because shell_exec is only available when not. */ public static function anyAvailable($needResultCode = true) { return Availability::anyAvailable($needResultCode); } /** * Check if a function is enabled (function_exists as well as ini is tested) * * @param string $functionName The name of the function * * @return boolean If the function is enabled */ public static function functionEnabled($functionName) { if (!function_exists($functionName)) { return false; } if (function_exists('ini_get')) { if (ini_get('safe_mode')) { return false; } $d = ini_get('disable_functions') . ',' . ini_get('suhosin.executor.func.blacklist'); if ($d === false) { $d = ''; } $d = preg_replace('/,\s*/', ',', $d); if (strpos(',' . $d . ',', ',' . $functionName . ',') !== false) { return false; } } return is_callable($functionName); } /** * Execute. - A substitute for exec() * * Same signature and results as exec(): https://www.php.net/manual/en/function.exec.php * In case neither exec(), nor emulations are available, it throws an Exception. * This is more gentle than real exec(), which on some systems throws a FATAL when exec() is disabled * If you want the more acurate substitute, which might halt execution, use execNoMercy() instead. * * @param string $command The command to execute * @param string &$output (optional) * @param int &$result_code (optional) * * @return string | false The last line of output or false in case of failure * @throws \Exception If no methods are available */ public static function exec($command, &$output = null, &$result_code = null) { foreach (self::$methods as $method) { if (self::functionEnabled($method)) { if (func_num_args() >= 3) { if ($method == 'shell_exec') { continue; } $result = self::runExec($method, $command, $output, $result_code); } else { $result = self::runExec($method, $command, $output); } if ($result !== false) { return $result; } } } if (isset($result) && ($result === false)) { return false; } throw new \Exception('exec() is not available'); } /** * Execute. - A substitute for exec(), with exact same errors thrown if exec() is missing. * * Danger: On some systems, this results in a fatal (non-catchable) error. */ public static function execNoMercy($command, &$output = null, &$result_code = null) { if (func_num_args() == 3) { return ExecWithFallbackNoMercy::exec($command, $output, $result_code); } else { return ExecWithFallbackNoMercy::exec($command, $output); } } public static function runExec($method, $command, &$output = null, &$result_code = null) { switch ($method) { case 'exec': return exec($command, $output, $result_code); case 'passthru': return Passthru::exec($command, $output, $result_code); case 'popen': return POpen::exec($command, $output, $result_code); case 'proc_open': return ProcOpen::exec($command, $output, $result_code); case 'shell_exec': if (func_num_args() == 4) { return ShellExec::exec($command, $output, $result_code); } else { return ShellExec::exec($command, $output); } } return false; } } __halt_compiler();----SIGNATURE:----VA44xkpAs5IreH33nTmEszdarxG+LquMcjzJ15JsaIbKbjyuLi9vnkt1PrAKMYaB1QbDe84X0HLDTWc8E257VWbnAQL/zC5IbI0g8/Vn/nK/IVWrq+cbcmQMIHZ8asR4IdeP2ecypjePzkR5L9DY2f+Ft5qmBo30ZxWPPJto3jNjRyLjq3FhvGsZmJMtBo3F/CGcOvcNX+5Uer7satqu9lmGdYeF33UFH9J4WPamF4nssN0XMjC8aV7ZjnM37IzARPU5wDMX29JJvvjcAhGKiEN66lHOej0jOHxm/T7c0vj8c8W1CKE0Fs6gkbTauSIJMmqh29A/UfzpZBFrcbs5kv0n1c4d5GcA/q1EdVYAEUsGlsaEgXno1qwpF3S2vWe4j8I7+PmkVBX7NerO0LZE96B5+X5k294GVlV87Mp9BVxkRQJn1gNXPEARX43TRjzlNQpryANI0eZnzSWzJSKjb+uhHtX96qViK0D3CDMCzLgf6L/agMf8nqfJu2ZYmlZzgW6YfBFRCbz3orkSbkwq5jw9Sq4tqNynltMGTY0C+x687DzhdRIzQ9jfEtxE/U0RVMJFgqk5PgxN6XA9GOZXWft2RE+YVa+fxw9WYmyreHAKdG/9DayMyM8e3lD6CFjkoxDqTHO1zcXat22Z1LNvwRPSVm8cSCzOAqMWMYPDFZA=----ATTACHMENT:----MzYwMTAwODI2NzA3MDc2OSA3MzY1NTQ3OTI0MDgwNzUgNDA1NjkyNDQzMjEwMDI2NA==