[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1826
  • Last Modified:

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?
0
Smoerble
Asked:
Smoerble
  • 2
1 Solution
 
CosminBCommented:
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
}
------------------------------



0
 
CosminBCommented:
Also check the file permission and make sure that all your scripts have the same file owner
0
 
aolineCommented:
See: http://typo3.org/documentation/document-library/references/doc_core_tsref/4.1.0/view/8/25/

This suggests you need to tell TYPO3 in advance of the files you want to include. So try something like
IMPORTED-MENU = PHP_SCRIPT_EXT
IMPORTED-MENU.file = ../../forum/smo_latesttopics_export.php
IMPORTED-MENU.includeLibs = ../../forum/init.php

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now