phplinuxquota

return User Quota with PHP from Linux OS


I need to find out quota details for the current user,

I`ve tried exec("quota 'username'", $retParam) and also system() but nothing is returned.

Any ideas ?

Thank you.


Solution

  • The user PHP runs under is probably not allowed to get other users' quotas - maybe not even its own, or maybe it's not even allowed to execute external commands. Depending on your server setup, you may be able to change PHP's configuration (remove safe_mode for example) and elevate the rights of the PHP user, but I don't know whether that's a wise thing to do. If you are on shared hosting, you would have to speak to your provider whether anything can be done.

    This blog entry outlines a clever way to get around PHP's limitations by collecting all quotas in a text file in an external cron job, and parsing that file with PHP. Works only if you have access to the server, of course, or can set up cron jobs with more liberal permissions than the PHP user.