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.
Comments
This would just replace one requirement with another, so I'll try to find a better way around it...
The way you can integrate this for yourself, though, is pretty easy. Just put the above function into functions.php, add your FTP username and password, and then in the admin.php where the upload takes place, replace the original `mkdir` with your new `mkdir_` (just add an underscore). That might just work! Good luck.
Warning: ftp_mkdir(): /usr/home/user/domains/domain/public_html/zenphoto/albums/webtest: No such file or directory in /usr/home/user/domains/domain/public_html/zenphoto/zen/functions.php on line 313
Oh well, I will just keep creating the folders with smartftp until there is a definite solution for this safe mode issue.
Oh well. Yeah, we'll try to get the safe mode stuff working in the future, until then, be happy you can just FTP them in!