REQUEST: file manager quota thing

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
rapaddict_dot_com
Forum Commoner
Posts: 27
Joined: Tue Mar 16, 2004 4:54 pm

REQUEST: file manager quota thing

Post 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
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post 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;
}
rapaddict_dot_com
Forum Commoner
Posts: 27
Joined: Tue Mar 16, 2004 4:54 pm

thanks!

Post by rapaddict_dot_com »

:D :) thanks bro...

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

login: demo
password: demo

tell me what you think... and some suggestions!
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: thanks!

Post by Weirdan »

rapaddict_dot_com wrote:tell me what you think... and some suggestions!
Insecure.
rapaddict_dot_com
Forum Commoner
Posts: 27
Joined: Tue Mar 16, 2004 4:54 pm

Post 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
rapaddict_dot_com
Forum Commoner
Posts: 27
Joined: Tue Mar 16, 2004 4:54 pm

Post by rapaddict_dot_com »

done, it now uses an sql database
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post 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)
rapaddict_dot_com
Forum Commoner
Posts: 27
Joined: Tue Mar 16, 2004 4:54 pm

Post by rapaddict_dot_com »

ohhhhhhhh
Post Reply