Solved

User created folders and limitting folder sizes.

Posted on 2006-06-12
5
258 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
The viewer will learn how to dynamically set the form action using jQuery.
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…

726 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