Solved

User created folders and limitting folder sizes.

Posted on 2006-06-12
5
252 Views
Last Modified: 2010-04-06
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
Comment
Question by:cbonnock
  • 2
5 Comments
 
LVL 17

Accepted Solution

by:
BogoJoker earned 350 total points
ID: 16891440
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
 
LVL 10

Assisted Solution

by:ClickCentric
ClickCentric earned 150 total points
ID: 16891504
Are you on a shared host or dedicated?  If it's dedicated, you could use quotas.
0
 

Author Comment

by:cbonnock
ID: 16892933
I had a similar idea for keeping track of size.

ClickCentric: I am on a dedicated server.
0
 
LVL 10

Expert Comment

by:ClickCentric
ID: 16895700
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Snap images to the bottom of a div 5 67
Web Development Tools for MVC 3 98
Swiper slider stops between pages 11 51
.php tree directory? 5 83
It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question