Create files & folders safe mode ON

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
oleg
Forum Newbie
Posts: 6
Joined: Thu Aug 28, 2008 2:51 am

Create files & folders safe mode ON

Post by oleg »

I have a server with safe mode on, I create folders via FTP and copy files with fwrite, so far it is a little mess but is working, if some one knows a class that can make it more simple I apreciate.

My problem is that if I want to copy files the folder must have chmod at 777. I try to change the chmod at the beggining and at the end of the copy, but I dont have the rigths to do it.

This is my first problem, my second is that once I create the file, this must require other file, the typical require_once sentence but I get this error

Warning: require_once() [function.require-once]: SAFE MODE Restriction in effect. The script whose uid is 48 is not allowed to access

This require has the data base configuration, therefore I put it out of the folder with 777 permissions.

Does anyone know a way to avoid or solve this problems?
I cant change the safe_mode because is not a private server.

Thanks in advance.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Create files & folders safe mode ON

Post by VladSun »

Try to add this line to the .htaccess file in your directory:

Code: Select all

php_admin_value safe_mode Off
About chmod ... only the owner and the super user (root) can change file permissions.
There are 10 types of people in this world, those who understand binary and those who don't
oleg
Forum Newbie
Posts: 6
Joined: Thu Aug 28, 2008 2:51 am

Re: Create files & folders safe mode ON

Post by oleg »

I cant change the safe mode via .htaccess, it give me a missconfiguration error.

The thing is that the user that created the folders is the owner and is the same user that Im using to change the permissions.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Create files & folders safe mode ON

Post by alex.barylski »

The only work around is to use FTP programmatically from PHP. Find a FTP class and goto town.

This is required because FTP runs under a different user than PHP/Apache. PITA I know.
Post Reply