diff options
| author | ShevAbam <shevabam@gmail.com> | 2014-12-19 18:06:37 +0100 |
|---|---|---|
| committer | ShevAbam <shevabam@gmail.com> | 2014-12-19 18:06:37 +0100 |
| commit | c3ec82dd6f60ac8057cc50d9bf6274738db9c02e (patch) | |
| tree | fc078a574caa7c746879398fd725cdd092fc1d0e /libs/Utils | |
| parent | 258e0edbaad8e767060fa224c37f6594fea715a2 (diff) | |
Rewriting the network module (#12 and #16)
Some issues with Arch or old Ubuntu
Diffstat (limited to 'libs/Utils')
| -rw-r--r-- | libs/Utils/Misc.class.php | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/libs/Utils/Misc.class.php b/libs/Utils/Misc.class.php index d77bbf5..ae4b6d1 100644 --- a/libs/Utils/Misc.class.php +++ b/libs/Utils/Misc.class.php @@ -38,6 +38,31 @@ class Misc return $_SERVER['SERVER_ADDR']; } + + /** + * Returns a command that exists in the system among $cmds + */ + public static function whichCommand($cmds, $args = '', $returnWithArgs = true) + { + $return = ''; + + foreach ($cmds as $cmd) + { + if (trim(shell_exec($cmd.$args)) != '') + { + $return = $cmd; + + if ($returnWithArgs) + $return .= $args; + + break; + } + } + + return $return; + } + + /** * Allows to pluralize a word based on a number * Ex : echo 'mot'.Misc::pluralize(5); ==> prints mots |
