Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
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
Re: PHP includes in textpattern
- Check your path. It should be absolute and inside of
open_basedir
setting’s file tree. - Also you might want to use
include_once
if the file holds functions or classes. - What is inside of the file?
- 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
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
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
Pages: 1