Link to home
Start Free TrialLog in
Avatar of Smoerble
SmoerbleFlag for Germany

asked on

typo3 PHP_SCRIPT_EXT include problem

I want to include the outcome of a PHP script in Typo3. It works fine, if I use a script that has no other includes. Typo3 script I use:
------------------------------
IMPORTED-MENU = PHP_SCRIPT_EXT
IMPORTED-MENU {
 file = fileadmin/smo_latesttopics_export.php
}
------------------------------

The problem I have now is, that I want to use PHP scripts, that are related to a forum.
If I run the script like this:
------------------------------
http://www.mydomain.com/forum/smo_latesttopics_export.php
------------------------------
It works as planned.


If I add use the following in typo3script (the double ../ is correct in my test case), nothing gets displayed in the template at the particluar area.
------------------------------
IMPORTED-MENU = PHP_SCRIPT_EXT
IMPORTED-MENU {
 file = ../../forum/smo_latesttopics_export.php
}
------------------------------


If I use copy the script to fileadmin folder and correct all paths inside the script, I get the following error:
------------------------------
IMPORTED-MENU = PHP_SCRIPT_EXT
IMPORTED-MENU {
 file = fileadmin/smo_latesttopics_export.php
}
------------------------------
error:
------------------------------
Warning: main() [function.main]: open_basedir restriction in effect. File(../../forum/init.php) is not within the allowed path(s): (/var/www/vhosts/mydomain.com/httpdocs:/tmp) in /var/www/vhosts/mydomain.com/httpdocs/typo3-test/fileadmin/smo_latesttopics_export.php on line 2
------------------------------

Reason:
------------------------------
require_once( '../../forum/init.php' );
------------------------------


So how can I include a php script from a different folder but the typo3/fileadmin please?
Avatar of CosminB
CosminB

Use absolute paths for inclusion. You can find the absolute path of a php script with the php_info() function or using the following script.
<?php
echo __FILE__;
?>



Create the above script in the same directory as you file, then use the full path for inclussion:

------------------------------
IMPORTED-MENU = PHP_SCRIPT_EXT
IMPORTED-MENU {
 file = /full/path/to/fileadmin/smo_latesttopics_export.php
}
------------------------------



Also check the file permission and make sure that all your scripts have the same file owner
ASKER CERTIFIED SOLUTION
Avatar of aoline
aoline

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Smoerble

ASKER

Arg.
Sorry, I wanted to split the points :(.
Thanks for both solutions, as both work fine!