View Full Version : disk usage

06-07-2004, 04:07 PM
hi everyone,

i am stuck in a situation, kindly help.

i am making a system in which there is multiple login (just like yahoo mail), now fixed disk quota has been assigned to the users (5 mb), users are allowed to upload certain images in their respective folders. now i want that the total size of the folder does not exceed the 5 mb limit. how can i know that user's folder has occupied n number of bytes or n number or MB of space.

i want to show to the user that - you have consumed this much % of space, just like yahoo mail shows.


06-07-2004, 05:53 PM
not sure if PHP's disk_free_space() (http://www.php.net/disk_free_space) will be of any use , probably not

else use the shell ,

exec('du -hs /home/user/mail/directory',$yaks);

06-07-2004, 06:28 PM
And a note about using php to run system commands. If you're going to use user data, (POST, GET info for example) make sure the input is clean.

Otherwise you could end up with something like this...

$cmd = $_GET['command'];

And the user types:

And they just deleted your file system! :eek:

06-09-2004, 12:24 AM
webmin has function to show this data. It uses cgi-scripts (perl I think).
But that runs as root, so I don't know about running it as the webservers' user.
maybe you could take a look at the webmin-code

06-09-2004, 04:01 AM
.. I doubt that webmin does any more than execute 'du' ?

also Bcarls point is very important , something I really should have noted :o