• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 268
  • Last Modified:

User created folders and limitting folder sizes.

Hello,

How can I have a folder made automatically on the server with the users name (like myspace, tagworld) and how can I limit the size of the total content in the folder? they will save images, etc, inside it and I want to track/limit the account size (ala hotmail).

Web languages preferred: PHP, mySQL.

Thanks.
0
cbonnock
Asked:
cbonnock
  • 2
2 Solutions
 
BogoJokerCommented:
Hi cbonnock,

Lets see.  With PHP/mySQL if your running on a linux box you can natively execute a command (on the linux terminal) to make a directory.  To moniter the file size you could have a variable in the user's account (stored in the mysql database).

For instance, lets say user 'joe' wants to make a folder 'stuff' of size 10 MB.  You would run the exec() funtion in php (shortcut if you use backtick characters ` but I won't show that here) to make the directory on the server.

<?php
// PHP code to execute on the actual server to make a folder
exec('mkdir /path/to/userdirectory/stuff');
?>

Then you could have a few ways of watching the 10 MB limit.
1) Store a file default file in /stuff/ directory called 'size.txt'.  That file could contain some real limited data.  The max size of the folder, in this case 10 MB.  And the current size.  Starts out 0, when you add files you increase based on the size of the file and so on.
2) Store this same information instead of in a file, in the database under the user 'joe'
3) Execute a linux command to check the current size of the folder.  Somewhere you must store the 10 MB limit, using either of the top two methods.  The linux command would be: du -hs /path/to/directory (which you would then exec())

I am just making this idea up off the top of my head, I do not know the perferred or suggested methods to do this.  Just curious and so I am suggesting how I would have taken an approach at this.

Joe P
0
 
ClickCentricCommented:
Are you on a shared host or dedicated?  If it's dedicated, you could use quotas.
0
 
cbonnockAuthor Commented:
I had a similar idea for keeping track of size.

ClickCentric: I am on a dedicated server.
0
 
ClickCentricCommented:
If it's a dedicated server, you could just use disk quotas.  Now, be forewarned that this is a complex approach as you have to create a user for each user of the site and you have to be particularly careful to inhibit their ability to log into the system directly.  I'm not entirely sure I like the idea, myself...just was an 'off the top of my head' type of suggestion.  But, it would be much easier than creating strict folder size enforcement in a scripting language.   If you use an ldap backend for the user storage and made sure that all of the security permissions that could possibly let them log into the system weren't available to them, it shouldn't be that bad, though.  Of course, for it to work, the homepage hierarchy would have to be modified for those users (shouldn't be too hard, just make them all a member of a given group).  Then you'd just have to set the file permissions accordingly.  
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now