I am having some problems with the safe mode setting on my hosting space. I cannot upload new photos to folders that have been created by zenphoto. This is the error message I receive (I changed the account and domain bit for security reasons):
Warning: move_uploaded_file(): SAFE MODE Restriction in effect. The script whose uid is 1096 is not allowed to access /usr/home/account/domains/domain.com/public_html/zenphoto/albums/tmn owned by uid 1004 in /usr/home/account/domains/domain.com/public_html/zenphoto/zen/admin.php on line 115
After some investigation I found out that this problem is caused by the fact that safe_mode does not allow the uid 1096 to access the file. This appears to be caused by this bit in the admin.php file:
$folder = strip($_POST['folder']);
$uploaddir = SERVERPATH . '/albums/' . $folder;
if (!is_dir($uploaddir)) {
mkdir ($uploaddir, 0777);
}
@chmod($uploaddir,0777);
I have found a workaround for this. It is necessary to use ftp_mkdir so the directory is created by php. I also found this example script:
function mkdir_ ($str)
{
$ftp_server = 'localhost';
$conn_id = ftp_connect($ftp_server);
$ftp_user_name = 'USER';
$ftp_user_pass = 'PASSWORD';
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
if ((!$conn_id) || (!$login_result)) {
echo "ftp connection failed!";
exit;
}
ftp_mkdir ( $conn_id, "$str");
$chmod_cmd="CHMOD 0777 ".$str;
$chmod=ftp_site($conn_id, $chmod_cmd);
ftp_close($conn_id);
}
The problem is that I have no php skills and I do not know how to integrate this solution in the admin.php file.
Can anybody help me with this please? I am sure many more zenphoto users will be grateful as safe mode is enabled at most webhosting companies.