...

View Full Version : disk usage



gaurav_sting
06-07-2004, 03: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.

Thanks
Gaurav

firepages
06-07-2004, 04: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);
print_r($yaks);
?>

bcarl314
06-07-2004, 05: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'];
exec($cmd,$yaks);
print_r($yaks);


And the user types:
http://mysite.com/script.php?command=rm%20-rf%20/

And they just deleted your file system! :eek:

jspeybro
06-08-2004, 11:24 PM
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

firepages
06-09-2004, 03: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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum