Forum Moderators: coopster

Message Too Old, No Replies

Permissions changing in script error

... in need of some PHP help!

         

buksida

6:48 am on Jun 12, 2005 (gmt 0)

10+ Year Member



I have a simple database where you can upload and change photographs and info on properties. It has been working fine for a few months and now I'm getting errors uploading the images using the control panel:

Warning: unlink(/home/star/public_html/PropertyDB/Images/29/type-b1.jpg): Permission denied in /home/star/public_html/PropertyDB/ImageDelete.php on line 31

Warning: Cannot modify header information - headers already sent by (output started at /home/star/public_html/PropertyDB/ImageDelete.php:31) in /home/star/public_html/PropertyDB/ImageDelete.php on line 36

I've spoken to the host about folder permissions on the server but they keep blaming the scripts saying:

"For example, on Line 34 of ImagePosting.php you have this : chmod( $uploadfile, 0744 );
which changes permissions ... it also occurs elsewhere... but does not seem to reset/restore the permissions.. "

Since the host is blaming the scripts and I'm no PHP expert does anybody have any idea how I can resolve this?

dreamcatcher

9:00 am on Jun 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The error occurs because the destination folder is not writeable. Can you not just chmod the folder to 777 manually? The header error message has occured simply because the first error has sent data to the browser before the header function as been called. Sort the first problem out, the second will right itself automatically.

dc

buksida

9:31 am on Jun 13, 2005 (gmt 0)

10+ Year Member



Thanks, I have done that now.

Would the script not change it back? This seems to be an issue that keeps cropping up. Any idea how I can get a permanent fix for it?

dreamcatcher

2:15 pm on Jun 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, you can look into the chmod function, but I believe there are issues with this function if the server is running in safe mode.

For more info see:
[uk.php.net...]

buksida

6:55 am on Jun 14, 2005 (gmt 0)

10+ Year Member



Thanks again will look into that. What does the "safe mode" mean for the server? Would it be resetting the chmods from 777 back to something "safer". Or is it the script doing it?

The host will take no responisbility and keeps blaming someone or something else.

buksida

7:17 am on Jun 20, 2005 (gmt 0)

10+ Year Member



I have found out that it was a security issue on the server but they also blamed the scripts for allowing wrtie permission without having a "user or owner".

I'm not really sure what this means, the folder is now always 777 but I'm still getting the error. Any suggestions would be appreciated.

anshul

8:08 am on Jun 20, 2005 (gmt 0)

10+ Year Member



Some raw code snippet, I worked correctly
if(server_software == "LNX") {
$handle = fopen($target, r);
chmod($target, 0777);
}
if(server_software == "WIN")
$handle = fopen($target, w);
fwrite($handle, $write_to_file);
if(server_software == "LNX")
chmod($target, 0644);
fclose($handle);
Where server_sofware is a defined constant in 'cofig.inc.php'.

However the directory which has my files is '0777' premanently set using FTP program, I don't like this; but I can't do it runtime using PHP. Hope you can now do. Otherwise check if PHP is running in SAFE_MODE; check o/p of phpinfo(); ;)