Page 1 of 1

REQUEST: file manager quota thing

Posted: Tue Mar 16, 2004 4:54 pm
by rapaddict_dot_com
I have a file manager as part of my website for users to upload images for their signatures and audio files for rap battles


the file manager ive made is at http://www.rapaddict.com/users/

I need a snippet to get the total size of the users directory so I can limit the amount of space they have.


Is there some sort of way of cycling through each director in ~user and if its a file add up the size and if its a directory then add all the files inside the directory etc...


thanks, - treez

Posted: Tue Mar 16, 2004 8:23 pm
by timvw
If you have a filesystem as ext2 , you could use quota to set limits ;)

with the program "du" you can lookup how much disk space something is using.

Posted: Tue Mar 16, 2004 9:43 pm
by Weirdan
[php_man]opendir[/php_man],[php_man]filesize[/php_man]

Code: Select all

function dir_size($dir){
  $size=0;
  if (is_dir($dir)) { 
     if ($dh = opendir($dir)) { 
         while (($file = readdir($dh)) !== false) { 
             if($file=="."||$file=="..") continue;
             $size+=dir_size($dir."/".$file);
         } 
         closedir($dh); 
     } 
  } 
  if(is_file($dir))
     $size+=filesize($dir);
  return $size;
}

thanks!

Posted: Thu Mar 18, 2004 4:18 pm
by rapaddict_dot_com
:D :) thanks bro...

http://www.rapaddict.com/users/

login: demo
password: demo

tell me what you think... and some suggestions!

Re: thanks!

Posted: Thu Mar 18, 2004 7:39 pm
by Weirdan
rapaddict_dot_com wrote:tell me what you think... and some suggestions!
Insecure.

Posted: Fri Mar 19, 2004 11:10 pm
by rapaddict_dot_com
what I wanna do is change it so instead of using the data file it uses my SQL database...

but when I tried changing it it just keeps popping up with the login screen.

I dont think the sessions are registereing right

Posted: Sat Mar 20, 2004 1:26 am
by rapaddict_dot_com
done, it now uses an sql database

Posted: Sat Mar 20, 2004 12:01 pm
by Weirdan
rapaddict_dot_com wrote:done, it now uses an sql database
Great, but the security hole at your site is indeed in different place. Editor does not honour the path restrictions, so 'enabled' user can edit whatever he/she wants (for example, index.php :D)

Posted: Mon Mar 22, 2004 11:16 pm
by rapaddict_dot_com
ohhhhhhhh