Rewriting the network module (#12 and #16)

Some issues with Arch or old Ubuntu
This commit is contained in:
ShevAbam
2014-12-19 18:06:37 +01:00
parent 258e0edbaa
commit c3ec82dd6f
2 changed files with 105 additions and 11 deletions
+25
View File
@@ -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