News:

The "Support Requests" forum is now viewable by guests.

Main Menu

Denied permission to modify my own files

Started by J-Factor, October 06, 2006, 07:06:04 AM

Previous topic - Next topic

J-Factor

Hi.

I was playing with the idea of making an admin php script to automate adding content to my site. However, all of the files that I upload using my script are no longer able to be modified by me (either using FTP or the FreePgs online file manager).

My FreePgs username is jfactor. Could an admin please modify the permissions of these directories (and contained files) to allow me to access them:

/dat/soul+fighter/
/dat/transition/
/dat/test/


Also, has anyone else implemented this kind of system successfully? Here's a chunk of my script:

// Create directory
mkdir("/fpgs/fpgshttpd/jfactor/dat/$dir");

// Upload zip
if (is_uploaded_file($_FILES['file_zip']['tmp_name']))
	
{
	
move_uploaded_file($_FILES['file_zip']['tmp_name'],"/fpgs/fpgshttpd/jfactor/dat/$dir/".$_FILES['file_zip']['name']);
	
}


Mostly pieced together from a few online examples and does't have any security implace (other than being placed in a password'd directory). Anything wrong with it? I assume the problem is the fact that I'm uploading to the 'root' directory, but this was the solution given to someone else in a topic I found with the search.

brainiac744

The problem is that files and folders created with PHP have different permissions on them (that don't allow them to be editted from FTP, etc). The way to remedy that would simply be to use the chmod() function to change the permissions on the folder/file after creating them.

J-Factor

Thanks, that worked.

I read on php.net that mkdir() defaults the chmod to 0777. Weird.

brainiac744

Yeah, there was some kind of change of the default permissions of PHP a while back after a big hacking thing. Anyway, glad to hear it worked for you :)

mstram

Quote from: brainiac744 on October 06, 2006, 02:37:28 PM
The problem is that files and folders created with PHP have different permissions on them (that don't allow them to be editted from FTP, etc). The way to remedy that would simply be to use the chmod() function to change the permissions on the folder/file after creating them.

I've just run into the same problem and have found that I am able to chmod the files from a simple php script using the php chmod() command.   I don't understand how the permissions can be "differerent" (between net2ftp and php).

Mike

brainiac744

Because the FTP/server user and the PHP user are two seperate things on this system. The permissions aren't "different" it's just that the there are two seperate users, so the owner of the files is the first bit, then the group is the second, and world is the last, so if it was just 700, only the owner of the file would have permission to access it, and if the owner was php, ftp wouldn't be able to see it and vice versa (sp?). Anyway, PHP and FTP are in the same user group. Hopefully I haven't mangled that explanation too badly.

Ben

The "Owner" column in net2ftp basically says the owner of the file. Any file marked "501" is a user's file. Almost all of these files can be edited (the main exception being .ftpquota). Any file marked "48" is a PHP created file, and you'd have to use php to change it.

There are two options here: chmod it using the PHP chmod() function, or request through the contact form to have the file chown'd to your account. I don't think the PHP chown() function works on this server, however, feel free to try it.
--Ben
Ben@freepgs.com

mstram

Quote from: Ben on May 05, 2007, 06:49:30 PM
The "Owner" column in net2ftp basically says the owner of the file. Any file marked "501" is a user's file. Almost all of these files can be edited (the main exception being .ftpquota). Any file marked "48" is a PHP created file, and you'd have to use php to change it.

Ok, thx, that removes the mystery :)

Mike