Revision history for FilesActionSafeModeWorkaround


Revision [23060]

Last edited on 2016-05-20 07:38:45 by DarTar [Replaces old-style internal links with new pipe-split links.]
Additions:
[[http://www.php.net/features.safe-mode | PHP safe mode]] is activated, and the server and scripts run as different users.
Instead of mkdir(), we have to create the directories using FTP. The following code was found in the [[http://www.php.net/manual/en/function.mkdir.php#53684 | comments to the mkdir()]] function on www.php.net.
Deletions:
[[http://www.php.net/features.safe-mode PHP safe mode]] is activated, and the server and scripts run as different users.
Instead of mkdir(), we have to create the directories using FTP. The following code was found in the [[http://www.php.net/manual/en/function.mkdir.php#53684 comments to the mkdir()]] function on www.php.net.


Revision [18689]

Edited on 2008-01-28 00:12:18 by DarTar [Modified links pointing to docs server]

No Differences

Revision [12048]

Edited on 2005-11-29 13:09:22 by DarTar [changing main heading]
Additions:
=====Files cannot be uploaded=====
Deletions:
=====Files can't be uploaded=====


Revision [12047]

Edited on 2005-11-29 13:09:06 by DarTar [changing main heading]
Additions:
=====Files can't be uploaded=====
Deletions:
=====Problem description=====


Revision [12039]

Edited on 2005-11-29 00:52:02 by CyneBeald [Filled the template with the workaround]
Additions:
The FilesAction complains about not being able to sucesfully move_uploaded_file() after an upload, even though the upload directory has been created and has correct permissions:
##**Warning:** move_uploaded_file() [function.move-uploaded-file]: SAFE MODE Restriction in effect. The script whose uid is 24822 is not allowed to access ""/uploads/SandBox"" owned by uid 99 in **/actions/files.php** on line **127**
**There was an error uploading your file.**##
[[http://www.php.net/features.safe-mode PHP safe mode]] is activated, and the server and scripts run as different users.
Version 1.1.6.0 (and very probably all earlier and future versions, since this is a "property" of the environment where the Wikka is run). This solution can only be applied when you have FTP acess to your website.
Instead of mkdir(), we have to create the directories using FTP. The following code was found in the [[http://www.php.net/manual/en/function.mkdir.php#53684 comments to the mkdir()]] function on www.php.net.
Open the file **actions/files.php** and before the mkdir_r() function definition, add the following code:
%%(php)
// create directory through FTP connection
function FtpMkdir($path, $newDir) {

$server='ftp.server.com'; // ftp server
$connection = ftp_connect($server); // connection


// login to ftp server
$user = "me";
$pass = "pass";
$result = ftp_login($connection, $user, $pass);

// check if connection was made
if ((!$connection) || (!$result)) {
return false;
exit();
} else {
ftp_chdir($connection, $path); // go to destination dir
if(ftp_mkdir($connection, $newDir)) { // create directory
ftp_site($connection, "CHMOD 775 $newDir") or die("FTP SITE CMD failed.");
return $newDir;
} else {
return false;
}
ftp_close($connection); // close connection
}
}
%%
Change the login information accordingly.
Now, find the following code (still in **actions/files.php**)
%%(php)
if (! function_exists('mkdir_r')) {
function mkdir_r ($dir) {
if (strlen($dir) == 0) return 0;
if (is_dir($dir)) return 1;
elseif (dirname($dir) == $dir) return 1;
return (mkdir_r(dirname($dir)) and mkdir($dir));
}
}
%%
and change it to
%%(php)
if (! function_exists('mkdir_r')) {
function mkdir_r ($dir) {
if (strlen($dir) == 0) return 0;
if (is_dir($dir)) return 1;
elseif (dirname($dir) == $dir) return 1;
return (mkdir_r(dirname($dir)) and FtpMkdir('/PathToWikkaDirOnFTP',$dir));
}
}
%%
(**Note:** Don't forget to change the ""'/PathToWikkaDirOnFTP'"" according to your set-up. I believe that a simple '/' will probably sufficient in the majority of cases)
This could be refined so that a new FTP connection isn't created for every directory we're creating recursively. Also, the parameters could probably be placed in **wikka.config.php** but since this is a very specific fix for a very specific situation, I don't think it's worth the effort. And lastly, the ""FtpMkdir()"" function could be placed in a conditional block to prevent it from being redeclared (but how real that possibility is, I don't know).
Deletions:
//This page is a **template** intended for documentation of **workarounds** for unusual Wikka problems. This page belongs to CategoryTemplate (which contains more handy templates). To create a Wikka **workaround** page, [[http://wikka.jsnx.com/WorkaroundTemplate/clone clone this page]] (most workaround page names end in 'Workaround' so it's useful to stick to that convention) and replace the title with a problem description (in a few words). Then remove this paragraph and provide actual page content in the outline below.//


Revision [12038]

The oldest known version of this page was created on 2005-11-28 23:56:16 by CyneBeald [Filled the template with the workaround]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki