Getting user quota stats
I think you should use escapeshellarg to secure that $user does not do damage through your exec call. Also, you should check if your $arr actually has the required data.

As for optimization, replacing multiple spaces and dashes with single spaces and then exploding such strings seems to me slower than just splitting the string right away, using preg_split:

$arr = preg_split("/[\s-]+/", $quota);


However, you should still check that count($arr) &gt; 3.

I must say that I am a bit surprised to see this work for you. That means that the user under which PHP is running has the permission to see other users' quota. IMO, web server should not be allowed as much.

A better way to do this is to dump all users' quotas in some text file (i.e., using repquota command; see an example on how to use it here), via a cron job run as root, and then make the script that only parses that file.

Or, quite similarly, your cron job can make a file with all the data, i.e., create quota-data.php like this:

&lt;?php

$quota_data = array(
  'zuul' =&gt; array(
    'total' =&gt; ...,
    'used'  =&gt; ...,
    'free'  =&gt; ...,
  ),
  ...
);

?&gt;


which you then just include in your script and use the data.

Which of these two approaches is better depends on how often the data is read from the web. If rarely, the text file approach is better, so that parsing is done only when really needed; if often, the second approach is better, as it parses the data only once per update.