Skip to content

Instantly share code, notes, and snippets.

@gsdevme
Created January 13, 2012 23:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gsdevme/1609322 to your computer and use it in GitHub Desktop.
Save gsdevme/1609322 to your computer and use it in GitHub Desktop.
<?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