FIX : uploading modules for open_basedir restricted hosts
Posted: Mon Mar 03, 2008 4:46 am
Hi, just started with CMS Simple, very happy so far! 
I wanted to install FCKeditorX and found that because my host uses open_basedir, CMSMS threw an error on uploading the xml file.
This was due to a call to 'file_get_contents( )' trying to directly access the uploaded file in the default PHP upload temp file directory which is out of my basedir path.
What should really happen is the that file is uploaded and then first moved using 'move_uploaded_file( )' into an accessible dir, then operated on from there.
So, the relevant code ( hack ) I have used is below ::
FILE :: admin/listmodules.php
Original Code line ( 110 ) ::
I replaced this with the below code, and it worked nicely ::
Nb :: I moved the file to the 'uploades' dir, maybe 'tmp' is better, or something else ...
It is removed immediately after anyway.
Cheers.

I wanted to install FCKeditorX and found that because my host uses open_basedir, CMSMS threw an error on uploading the xml file.
This was due to a call to 'file_get_contents( )' trying to directly access the uploaded file in the default PHP upload temp file directory which is out of my basedir path.
What should really happen is the that file is uploaded and then first moved using 'move_uploaded_file( )' into an accessible dir, then operated on from there.
So, the relevant code ( hack ) I have used is below ::
FILE :: admin/listmodules.php
Original Code line ( 110 ) ::
Code: Select all
$xml = file_get_contents( $file['tmp_name'] );
Code: Select all
$movedFileName = dirname( __FILE__ )."/../uploads/".$file['name'];
if( move_uploaded_file( $file['tmp_name'], $movedFileName ) ) {
$xml = file_get_contents( $movedFileName );
unlink( $movedFileName );
} else {
echo "<br /><br />Could not Move uploaded file from PHP's temp file upload area : \$_FILE VAR dump ::<br /><br />\n\n";
print_r($_FILES);
exit;
}
It is removed immediately after anyway.
Cheers.