Solved

User created folders and limitting folder sizes.

Posted on 2006-06-12
5
249 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
Comment Utility
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
Comment Utility
Are you on a shared host or dedicated?  If it's dedicated, you could use quotas.
0
 

Author Comment

by:cbonnock
Comment Utility
I had a similar idea for keeping track of size.

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

Expert Comment

by:ClickCentric
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now