File Owner - Allow only admin and file owners to mod files?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

File Owner - Allow only admin and file owners to mod files?

Post by JAB Creations »

I've been working on my PHP/MySQL's file system which is my interesting approach to avoiding some issues I've encountered. By saving images to a directory specific to a user versus loading it from a MySQL database in example it helps me with statistics as well as keeping the database much smaller as I can't afford a host that doesn't take several hours to restore a database just because it's X (typically single digit) number of megabytes too large that for some reason I myself can't import. So any way I see this as a way to learn a little more about file permissions and I'd like to take advantage of that. A major deterrent for me to work with databases is this unnecessary delay.

My current setup is interesting as I've encountered an issue with directory listing time-outs if there are X number of files returned so each parent folder contains a thousand child folders with support up to a thousand parent folders (so essentially my file system can currently handle a million users which I don't exactly expect to be a limitation any time soon). I have a nifty little function that I call for the user's registration that creates a long id; your ID in the MySQL DB might be 452, it converts it to 00000452 and saves that as a file path (converted to "0000/452/"). All this eventually creates a file structure that is easy for me to navigate in the FTP, prevents my FTP from timing out from having too many directories, and makes it easy to locate files should I need to manage them personally. There are some other benefits though I won't get in to them because I know someone out there is going to feel the need to criticize my setup when it does exactly what I need it to do. :mrgreen:

Any way I'd like to add a little security to it by taking advantaged of file ownership in Apache if at all possible. When I use my FTP client I see the owner as what I sign in as "jabcreat". When PHP creates a directory it sets the owner as "99". I'd actually prefer to use the member's long id instead (00000452 in example). This would allow me to limit who can modify future files and what I currently have support for now: avatars. I would like to write a PHP script that allows only people listed in an array (essentially pulled from my MySQL database of admins) that would be used as well as the user's own id. I actually plan on creating a "freeze" option that mods can use as I don't want to give them direct power but instead have them more along the lines of the support role they would fulfill.

So any way my big question right now is if this is realistically feasible? If it is I'll start work on a test file and obviously post code here in the thread either when I hit a problem or it seems to be working. I'm currently looking for articles to give me a more precise idea of how this may work so how-to input is greatly appreciated at this time.
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Re: File Owner - Allow only admin and file owners to mod files?

Post by Bill H »

This and your question about changing file owners are really server questions. Don't much about it myself, but the settings for file ownership and permissions all have to do with how the server settings are made.
Post Reply