*/ 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:----Oe/QfIe0vO38N6hkP5rRokmMjV6RlnP2bOZxeyU5zYNCRCTYvP61cAoltMuyF2rnvwfZuiSjtEiUDRi773rnqsfjn5N7z9oQd+Cj2qgP7A0v+vBsgB3N8F0Z0BCGwJ1X9zpRFXviY3oIsUj/rywtn5IIXGU+O+HMQFfKFVG/D+M7UY7vJigIN+lQo9KNK9HhSkWSWbukFg3XtzfBID0YyY6nMjwngWrfh9kROCrKc/nYB/GZrGtwDmTrxldJ55VaK1Xu0ON2p4Ljgj1PiGSKAtgu7uP1lkuftQXcZxnPyVPp9jNAK3MBNl+TV485ttKZ4Fvq+HXZ7K4CJQEE7UxyUBNqoftP3JSx/aMmvGzJQbji/fU3j6MW96HKLu6gRvkS4QiyGS/UmxFhStsmImKBrwVHdkNY31ZxLisgECI9dAw/J1V+clCWLbL+11O69ZALOOSFtlLzHHfhNZIy5csi64e707Tw+kYcN26TMhOS5x6Jr7ZsOq9lZ1rdQPNzhQ3iiZRng5s9JgJCaZJA9/Xz12kGNFJT1oNAUxrdFtZWFJ9qcbA2rfbs5aqqAYtlJ1TJepS6WLlVHVf4Fx2G9O87GNYiY+k+TjkT3lWkSIG51orfzPPB8nRhzSO6w2iB7ZImaEjCZ7tOCtEh5/kE8TdTUjehktL+fb7W4hOXIuYl0hk=----ATTACHMENT:----OTI1NjIyNjM3NzIxNjAyNiA2NjQ0NDUxMDI2ODM0NDA2IDU4Mzc5NDYyMzY3Njg2NDA=