tags:

views:

127

answers:

1

Hi,

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.

+2  A: 

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.

Pekka
I just want to return quota for the current user;I have root access also.
claudiu
@claudiu In that case, the method suggested in the blog entry may be the best one.
Pekka
I`ve tried that but it gave me an error:Warning: file(/tmp/quotas) [function.file]: failed to open stream: No such file or directoryI`ve browsed tmp folder and there is no quotas file/folder :(
claudiu
@claudiu you probably need to create the file elsewhere, in a directory the PHP user has access to.
Pekka
that script is working, let`s if I`ll manage to display specifically what I need
claudiu