PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
[SOLVED]Problem with tempnam() in Excel Writer

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> File Formats
View previous topic :: View next topic  
Author Message
fredley



Joined: 06 Jan 2008
Posts: 5

PostPosted: Sun Jan 06, 2008 4:10 am    Post subject: [SOLVED]Problem with tempnam() in Excel Writer Reply with quote

Hi

My webhost recently changed their settings, my Excel Writer files no longer work. I have the excel writer package in my folder, but I use their PEAR files in the require()s as it doesn't work otherwise. What I am getting is an excel file containing the error
Code:

<b>Warning</b>:  tempnam() [<a href='function.tempnam'>function.tempnam</a>]: open_basedir restriction in effect. File() is not within the allowed path(s): (/home/www/3f06a4b88005aeb85bda322626fdf17d:/tmp:/opt/php/lib/php) in <b>/home/www/3f06a4b88005aeb85bda322626fdf17d/web/magsoc/Writer/Workbook.php</b> on line <b>88</b><br />



I can't work out what I need to change in order to overcome this. Can anyone give me some help? If you need me to provide more information just ask.

Fred[/code]


Last edited by fredley on Sun Jan 06, 2008 2:50 pm; edited 1 time in total
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1053

PostPosted: Sun Jan 06, 2008 11:33 am    Post subject: Reply with quote

http://www.php.net/manual/en/features.safe-mode.php#ini.open-basedir
Back to top
View user's profile Send private message
fredley



Joined: 06 Jan 2008
Posts: 5

PostPosted: Sun Jan 06, 2008 12:40 pm    Post subject: Reply with quote

Yes, I understand this, but I can't find what I need to change where in my excel_writer package files. I've investigated $_tmp_dir but I can't actually find out where this variable is set.

Fred

//edit - It might also be helpful to know why if I use my own PEAR and PPS files, and changes all the require()s appropriately I still get:
Code:
Fatal error: Cannot redeclare _pear_call_destructors() (previously declared in /home/www/3f06a4b88005aeb85bda322626fdf17d/web/magsoc/Writer/PEAR/PEAR.php:765) in /opt/php/lib/php/PEAR.php on line 802
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1053

PostPosted: Sun Jan 06, 2008 1:20 pm    Post subject: Reply with quote

fredley wrote:
Yes, I understand this, but I can't find what I need to change where in my excel_writer package files. I've investigated $_tmp_dir but I can't actually find out where this variable is set.


Ah, sorry, I thought it was a problem with the included files. If it's a problem with the temporary files, you'll just need to call $workbook->setTempDir(...); with the name of directory that you may access.

fredley wrote:
//edit - It might also be helpful to know why if I use my own PEAR and PPS files, and changes all the require()s appropriately I still get: [...]


Sorry, I don't understand this. But it isn't a good idea to change PEAR files anyway.
Back to top
View user's profile Send private message
fredley



Joined: 06 Jan 2008
Posts: 5

PostPosted: Sun Jan 06, 2008 1:49 pm    Post subject: Reply with quote

Sorry to be a pain, it's still not working. I have this in my excel.php file (the one which actually makes the excel file):
Code:

   include_once "Writer.php";
   $newdir = $workbook->setTempDir($_SERVER["DOCUMENT_ROOT"] . "magsoc/temp/");
   $xls =& new Spreadsheet_Excel_Writer();


I am using $_SERVER['DOCUMENT_ROOT'] as this is what my host has instructed me to do to avoid open_basedir errors. I still get the error:

Quote:

Fatal error: Call to a member function setTempDir() on a non-object in /home/www/3f06a4b88005aeb85bda322626fdf17d/web/magsoc/excel.php on line 4


Tom
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1053

PostPosted: Sun Jan 06, 2008 1:59 pm    Post subject: Reply with quote

fredley wrote:
Sorry to be a pain, it's still not working. I have this in my excel.php file (the one which actually makes the excel file):
Code:

   include_once "Writer.php";
   $newdir = $workbook->setTempDir($_SERVER["DOCUMENT_ROOT"] . "magsoc/temp/");
   $xls =& new Spreadsheet_Excel_Writer();



At first, the include_once call is wrong. This should be 'Spreadsheet/Excel/Writer.php' instead of 'Writer.php'. Correct your include_path if you had changed this because the files were not found.

$workbook was just an example because that's the name of the class. In your case, you'll have to call $xls->setTempDir(...);

Code:

require_once 'Spreadsheet/Excel/Writer.php';
$xls =& new Spreadsheet_Excel_Writer();
$xls->setTempDir($_SERVER["DOCUMENT_ROOT"] . "magsoc/temp/");
Back to top
View user's profile Send private message
fredley



Joined: 06 Jan 2008
Posts: 5

PostPosted: Sun Jan 06, 2008 2:04 pm    Post subject: Reply with quote

Well I'm just back to where I started now, an excel file with
Quote:
<b>Warning</b>: tempnam() [<a href='function.tempnam'>function.tempnam</a>]: open_basedir restriction in effect. File() is not within the allowed path(s): (/home/www/3f06a4b88005aeb85bda322626fdf17d:/tmp:/opt/php/lib/php) in <b>/home/www/3f06a4b88005aeb85bda322626fdf17d/web/magsoc/Writer/Workbook.php</b> on line <b>88</b><br />


The include path is correct, as are all the other include/require paths.

Tom
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1053

PostPosted: Sun Jan 06, 2008 2:09 pm    Post subject: Reply with quote

fredley wrote:
Well I'm just back to where I started now, an excel file with
Quote:
<b>Warning</b>: tempnam() [<a href='function.tempnam'>function.tempnam</a>]: open_basedir restriction in effect. File() is not within the allowed path(s): (/home/www/3f06a4b88005aeb85bda322626fdf17d:/tmp:/opt/php/lib/php) in <b>/home/www/3f06a4b88005aeb85bda322626fdf17d/web/magsoc/Writer/Workbook.php</b> on line <b>88</b><br />


Well, the temporary directory needs to be in one of the in the error message mentioned paths. Did you verify this?

fredley wrote:
The include path is correct, as are all the other include/require paths.


Okay, I just noticed the wrong path in your last example (include_once call).
Back to top
View user's profile Send private message
fredley



Joined: 06 Jan 2008
Posts: 5

PostPosted: Sun Jan 06, 2008 2:10 pm    Post subject: Reply with quote

From my host:
Quote:
The above errors usually appear when you try to access a path
which doesn't belong to your site or that doesn't exist or that might have incorrect
access permissions.

Please check the following points:

* use the relative path instead of the entire path; you should use

$path = $_SERVER["DOCUMENT_ROOT"] . "/myfolder/";

instead of

$path = "/home/site/www.../web/myfolder/";


Tom

//edit, I changed the path to the absloute path and it now works. Thanks for all your help.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> File Formats All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement

'Actiemonitor' online projectmanagement software