Created
January 13, 2012 23:23
-
-
Save gsdevme/1609322 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class System | |
{ | |
public static function run() | |
{ | |
$args = func_get_args(); | |
if (!empty($args)) { | |
$command = escapeshellcmd(array_shift($args)); | |
$length = count($args); | |
for($i=0;$i<$length;++$i){ | |
$args[$i] = escapeshellarg(preg_replace('/[^a-z0-9.\-\/]+/i', null, $args[$i])); | |
} | |
var_dump($args); | |
$r = null; | |
exec($command . ' ' . implode(' ', $args), $r); | |
return $r; | |
} | |
throw new SystemException('System command was not well formatted'); | |
} | |
} | |
class SystemException extends Exception | |
{ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment