open_basedir restriction

Hi all!
it’s me again with the bank repport import module…
I upgraded my server yesterday from SME 7.5.1 to SME 8.0(b6)
Everithing with dolibarr went ok and all is working as it is expected. (at least for now) but…
My module isn’t there is an error report of my server…(apache with php 5.2.1)

PHP Warning: Unknown: open_basedir restriction in effect. File(/tmp) is not within the allowed path(s): (/home/e-smith/files/ibays/dolitest/) in Unknown on line 0
PHP Warning: File upload error - unable to create a temporary file in Unknown on line 0
PHP Warning: fopen() [<a href=‘function.fopen’>function.fopen</a>]: Filename cannot be empty in /home/e-smith/files/ibays/dolitest/html/htdocs/MCCImport/index.php on line 115
PHP Warning: fgets(): supplied argument is not a valid stream resource in /home/e-smith/files/ibays/dolitest/html/htdocs/MCCImport/index.php on line 131
Invalid argument supplied for foreach() in /home/e-smith/files/ibays/dolitest/html/htdocs/MCCImport/index.php on line 361.

Obviously the first PHP warning is enough to see the problem.
I can manage to make this work with a tweak of my server,but it works just for one dolibarr/mymodule instance and I actually need two or tree instances fo testing-develop and production
Anyway my problem is that I know there is something wrong just because dolibar doesn’t need that tweak!
My guess is that something is missing in the module to enable the module to use /tmp. maybe I can add it in modMymoduleclass.php or something to let it enabled by deffault. I have been looking arround all include hierachy but I cant find where to describe this or enable.
I’ve been reading php help and references but I need some help again.
Where (if possible) should I change or edit something to enable my module run without modifying server side php.

this is line 115 of my module: $file = fopen($_FILES[‘uploadFile’][‘tmp_name’], “r”);

Any help is always welcome!!!
Many thanks in advance
Alejandro

mccimport looks to be an external module.
all files (even temporary) must be stored into
$conf->module->dir_output or $conf->module->dir_temp and not into /tmp
This need a fix into mccimport module.

Thanks Eldy, as always you are wright!

I dont know how to change this, even more my module (MCCImport) was working fine on 3.0.1 but is not workign on 3.1.0.

I’ve managed to define tmp files inside installation dir (with phpbasedir setting, but here goes another PHP warning message:

PHP Warning: realpath() [<a href=‘function.realpath’>function.realpath</a>]: open_basedir restriction in effect. File(/home/e-smith/files/ibays/wvilder/html) is not within the allowed path(s): (/home/e-smith/files/ibays/doliverti/:/tmp/) in /home/e-smith/files/ibays/doliverti/html/htdocs/filefunc.inc.php on line 141

I think this is dolibarr 3.1 looking for my logo outside it’s dir.
this filefunc.inc.php has changed between versions and now it shows me that every file needs to be inside “phpbasedir”

As always , any comment on this could help me a lot!
thanks in advance
Alejandro

could it defined in modMymodule.class.php?

No need to be defined.
conf->mccimport->dir_temp at conf->mccimport->dir_output is automatically defined to
…/mccimport and …/mccimport/temp

eldy wrote:

I’m really trying hard to understand…
So Eldy:
should I replace this line in my module:
$file = fopen($_FILES[‘uploadFile’][‘tmp_name’], “r”);
for something like this:?
$file = fopen($conf->MCCImport->dir_temp.[‘uploadFile’][‘tmp_name’], “r”);

I know, you must be thinking that I should take at least a php/mysql basic course (maybe too late for me)

Thanks for your time…
Ale

No
File is saved automatically by php into $_FILES[‘uploadFile’][‘tmp_name’].
Dir where this file is saved is automatically allowed to PHP if PHP installed is done correctly.
But once file is uploaded, your program must make a move to move files from
$_FILES[‘uploadFile’][‘tmp_name’]
to a directory that is $conf->global->mccimport->dir_outputdir
This can be done using function
dol_move_uploaded_file

If error is during upload (so before the move), the pb is not into module code but into php install/setup.