Solved

User created folders and limitting folder sizes.

Posted on 2006-06-12
5
255 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
RSS Feeds--IE 13 195
Programatically edit Web.config 8 45
CSS Question.. 3 104
Fulfillment API php code sample 1 95
Article by: Matthew
I am a very big proponent of technology compliance standards and strive to meet such criteria in all of my work. That includes my site, which is 100% XHTML 1.0 compliant as determined by the World Wide Web Consortium. https://www.matthewstevenkel…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

737 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