Default Group / User 99 Permission Issue

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
Spartan101
Forum Newbie
Posts: 12
Joined: Mon Feb 25, 2008 4:56 pm
Location: Manchester (UK)

Default Group / User 99 Permission Issue

Post by Spartan101 »

I've written some code to dynamically create a signature image that users of a phpBB3 forum can use in their own signature on our forums. This all works fine. My problem is when I use fopen() in php it saves the image with permission user / group of 99 rather than the user that I want. I'd like for people to be able to view these images from a browser or paste the URL into their forum signature linking to the image, so they would need appropriate permissions.

I've read somewhere that by default php creates files with ownership taken from the owner of apache. This solution is hosted so would I need to request the Host to alter the php configuration of default files or is it possible for me to get around this by adding a .htaccess file with appropriate permissions in the folder where these files are created?!?!

To give you an idea of what i'm doing here's some of my GD lib php code:-

Code: Select all

 
$path = "/home/rhtest/public_html/dynsig/images/signatures/";
$image_name = $pfuser. ".png";
$fpath = $path.$image_name;
if(($handle = fopen($fpath,'w+b')) === FALSE){
        die('Failed to open file for writing!');
} else {
chown($fpath, "rhtest");
chmod($fpath, 0777);
fwrite($handle, $im);
fclose($handle);
//imagepng($im, $fpath,0,NULL);
@imagecreatefrompng($fpath);
imagepng($im);
imagedestroy($im);
}
 
Any help here is appreciated. What do I need to ask of the Host if I do need these permissions changing? Is there any other workaround to get around this (assuming not if permission 99 is the system user)?
Post Reply