Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-06-14 16:13:09

dl33
Member
Registered: 2006-06-17
Posts: 192
Website

PHP includes in textpattern

I tested some php in a standalone .php page, where it works fine. As soon as I use it inside a <txp:php> tag in a textpattern page i get the error <txp:php> -> Warning: require() [function.require]: open_basedir restriction in effect.

I assume that this has something to do with the variable scope, however, I am not quite sure how to change the code to accommodate for this.

 <txp:php> ->  Warning: require() [function.require]: open_basedir restriction in effect. File(/immo_api/ApiWrapper.php) is not within the allowed path(s): (/home/user:/tmp:/usr/someisp/web/pma:/var/someisp/scripting/php/4.4.8/lib/pear:/var/someisp/scripting/php/5.1.6/lib/pear:/var/someisp/scripting/php/5.2.5/lib/pear)  on line 3
textpattern/publish/taghandlers.php(3082) : eval()'d code:3 require()
textpattern/publish/taghandlers.php:3082 eval()
textpattern/publish.php:1090 php()
textpattern/publish.php:1025 processTags()
textpattern/publish.php:496 parse()
index.php:33 textpattern()

and the relevant code:

require("/immo_api/ApiWrapper.php");

Offline

#2 2009-06-14 16:29:37

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: PHP includes in textpattern

  1. Check your path. It should be absolute and inside of open_basedir setting’s file tree.
  2. Also you might want to use include_once if the file holds functions or classes.
  3. What is inside of the file?
  4. Also note that open_basedir can be modified or turned off like any other ini value in http.conf.
include_once /home/example/user/dir/of/public/[...];

Last edited by Gocom (2009-06-14 16:31:14)

Offline

#3 2009-06-14 17:26:38

dl33
Member
Registered: 2006-06-17
Posts: 192
Website

Re: PHP includes in textpattern

The problem was that path were not absolute: I am working with a third-party API and just had to go though 200 files changing relative includes to absolute ones.

While the code works, I am now getting lots of Notice: Undefined index warnings + a Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE or '$' at the top.

I assume that I will have to go through the files again and put global in front of some variables—yet I thought it be better to ask before I start changing everything again.

Offline

#4 2009-06-14 23:35:45

dl33
Member
Registered: 2006-06-17
Posts: 192
Website

Re: PHP includes in textpattern

I managed to hide the Notice: Undefined index, but still fighting the parse error. The problem is that there are over 200 files which I did not write and the location on the parse error is a bit vague.

Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE or '$' in /home/user/hosts/domain.com/textpattern/publish/taghandlers.php(3082) : eval()'d code on line 2

Does anyone have any advice on how to actually trace these errors? As in find out where they are coming from?

Offline

Board footer

Powered by FluxBB