FreeBSD-Updates - Webinterface

You can use gethostname() (or php_uname()), no need to call external binaries for that.

You also want to escape your shell commands, for example:

Code:
shell_exec("/usr/sbin/pkg info -d $pkg_name 2>&1");

Should really be:

Code:
shell_exec(sprintf("/usr/sbin/pkg info -d %s 2>&1",
    escapeshellarg($pkg_name)));

You also do this on a number of occasions:
Code:
shell_exec("cat $filename 2>&1")

Just use file_get_contents() or file() ... ?

PHP_EOL will always be \n on FreeBSD, only on Windows it's \r\n. I don't expect anyone to ever run this on Windows. (And even on Windows using PHP_EOL is a bad idea IMHO)

I also recommend against using full pathnames, such as /usr/sbin/pkg. Just use pkg and trust your PATH, or set the PATH if you don't trust it. This is really much more robust.
 
Back
Top