PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 3.2.5
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v3.2.5
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
wp-optimize / vendor / rosell-dk / exec-with-fallback / src / ExecWithFallbackNoMercy.php

ExecWithFallbackNoMercy.php in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance 3.2.5, at vendor/rosell-dk/exec-with-fallback/src/ExecWithFallbackNoMercy.php

57 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ExecWithFallback;
3
4 /**
5 * Execute command with exec(), open_proc() or whatever available
6 *
7 * @package ExecWithFallback
8 * @author Bjørn Rosell <[email protected]>
9 */
10 class ExecWithFallbackNoMercy
11 {
12
13 /**
14 * Execute. - A substitute for exec()
15 *
16 * Same signature and results as exec(): https://www.php.net/manual/en/function.exec.php
17 *
18 * This is our hardcore version of our exec(). It does not merely throw an Exception, if
19 * no methods are available. It calls exec().
20 * This ensures exactly same behavior as normal exec() - the same error is thrown.
21 * You might want that. But do you really?
22 * DANGER: On some systems, calling a disabled exec() results in a fatal (non-catchable) error.
23 *
24 * @param string $command The command to execute
25 * @param string &$output (optional)
26 * @param int &$result_code (optional)
27 *
28 * @return string | false The last line of output or false in case of failure
29 * @throws \Exception|\Error If no methods are available. Note: On some systems, it is FATAL!
30 */
31 public static function exec($command, &$output = null, &$result_code = null)
32 {
33 foreach (self::$methods as $method) {
34 if (self::functionEnabled($method)) {
35 if (func_num_args() >= 3) {
36 if ($method == 'shell_exec') {
37 continue;
38 }
39 $result = self::runExec($method, $command, $output, $result_code);
40 } else {
41 $result = self::runExec($method, $command, $output);
42 }
43 if ($result !== false) {
44 return $result;
45 }
46 }
47 }
48 if (isset($result) && ($result === false)) {
49 return false;
50 }
51 // MIGHT THROW FATAL!
52 return exec($command, $output, $result_code);
53 }
54
55
56 }
57