[Vtigercrm-developers] Export to Excel

John Crisp john at reetspetit.net
Fri Oct 21 15:38:09 PDT 2011


I have been trying to get this working but on both my test machine and
my main system and I get the dreaded error :

class.writeexcel_worksheet.inc.php line 204 tempnam() [<a
href='function.tempnam'>function.tempnam</a>]: open_basedir restriction
in effect. File() is not within the allowed path(s):
(/home/e-smith/files/ibays/testbay/html/)

class.writeexcel_worksheet.inc.php line 205 - fopen() [<a
href='function.fopen'>function.fopen</a>]: Filename cannot be empty


I have read as much as I can find on the subject as there have been
others with the same situation. I have checked the permissions,
PHPbasedir directives, and Safe Mode is off on both systems.

The above is from the test machine and the phpbasedir is set to
/home/e-smith/files/ibays/testbay/html/   (I have several directories in
this space)

The root directory is
/home/e-smith/files/ibays/testbay/html/vtiger_521



It would seem that in CreateXL.php it creates the workbook without
problems as the $tmp_dir gets passed in $fname

But when it goes to create the worksheet, it has no temporary directory
set, checks with PHPBasedir and if that is not correct (no idea why it
still doesn't like mine) then it will fail.

Effectively it fails at Line 21 in CreateXL.php once it gets to
_initialize in class.writeexcel_worksheet.inc.php


>From CreateXL.php :

19 global $tmp_dir, $root_directory;

21 $fname = tempnam($root_directory.$tmp_dir, "merge2.xls");
22 $workbook = &new writeexcel_workbook($fname);
23 $worksheet =& $workbook->addworksheet();


So how do we get the $tmp_dir passed to  $tempdir in
class.writeexcel_worksheet.inc.php assuming that I don't want to modify
that file ?????


This would appear to be one answer from a post in the forums but this
means editing the class file, and surely it would be better to set the
$tempdir properly  ???? Also, if the $tempdir is set properly, it would
avoid the problems with the PHPbasedir ?

http://forums.vtiger.com/viewtopic.php?f=96&t=29369&hilit=open_basedir+class.writeexcel_worksheet.inc

"The problem is generated by open_basedir restrictions (normal php
protection that some servers have active) We can avoid that using the
sys_get_temp_dir() fucntion

to do it :go include\php_writeexcel\class.writeexcel_worksheet.inc.php
just between line 200-203 to obtain:

Code: Select all
    function _initialize() {
       $this->_tempdir=sys_get_temp_dir();
        # Open tmp file for storing Worksheet data.sys_get_temp_dir
        $this->_tmp_file_name = tempnam($this->_tempdir, "php_writeexcel");
"

However, I'm sure it must be possible by amending Line 23
$worksheet =& $workbook->addworksheet();

I just don;t know how to do it !

Sorry for the long post and hope it makes sense. Any advice on this
would be gratefully received - I've spent all day scratching my head on
this and have hit a brick wall !!!!


B. Rgds
John



More information about the vtigercrm-developers mailing list