FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


php include





afracsass
looks like some servers does not allow including a file that is not on the same server.
I mean that it only accepts relative address.(something like ../../abc.php)
Can this be fixed?

Does it need to change php.ini or something? than there's no hope...
cavey
You could use f.ex. fopen() to read the contents of abc.php.
Ducksteina
allow_url_fopen must be set to 1 in order to include files of other servers.
roeenoy
you dont need to do any change in php.info if this is your problem
openaasman
if you getting this problem then i have one solution is to open input stream and then read the content and include it into your page. this procedure may work if you are not getting any other solution.
afracsass
Ducksteina wrote:
allow_url_fopen must be set to 1 in order to include files of other servers.


how do you set "allow_url_fopen" to 1?
do i need to change php.ini of the server? or i can do it thourogh .htacess?
thanks,
BlackSkad
"allow_url_fopen" is one of those settings from the php.ini file that can not be changed by using ini_set(), due to security reasons. So only the admin can change it.
If "allow_url_fopen" is set to false, you might want to use the file()-function instead. I didn't find any references to allow_url_fopen or any other ini-setting, so it should work just fine (but i'm not sure).
Code:
<?php
//read
$content = file("http://somewhere.com/abc.php");
$content = implode ("", $content);
//execute
eval ($content);
?>


I do have to warn you. Executing code that comes from another server is not save! If you're not the owner of the file abc.php, you'll never know for sure what the content is. It could be some code that harms your server. So a last warning: use this script only when you're sure that the content is save!
afracsass
Thank you for your advice. file function does not work either though.
The php code is not an execution script. it's just a simple header and footer html which i wrote by myself. so don't worry about it.

thanks,






BlackSkad wrote:
"allow_url_fopen" is one of those settings from the php.ini file that can not be changed by using ini_set(), due to security reasons. So only the admin can change it.
If "allow_url_fopen" is set to false, you might want to use the file()-function instead. I didn't find any references to allow_url_fopen or any other ini-setting, so it should work just fine (but i'm not sure).
Code:
<?php
//read
$content = file("http://somewhere.com/abc.php");
$content = implode ("", $content);
//execute
eval ($content);
?>


I do have to warn you. Executing code that comes from another server is not save! If you're not the owner of the file abc.php, you'll never know for sure what the content is. It could be some code that harms your server. So a last warning: use this script only when you're sure that the content is save!
tony
afracsass wrote:
looks like some servers does not allow including a file that is not on the same server.
I mean that it only accepts relative address.(something like ../../abc.php)
Can this be fixed?

Does it need to change php.ini or something? than there's no hope...


This is because allowing include statements to use third-party scripts would be insecure. Imagine that the remote script contains unencrypted password/login info for a database server. Your include statement would execute the arbitrary code and you would know the passwords for the remote server.
Related topics
Including With PHP
php variables
PHP Toturail
HTTP AUTH with PHP and mySQL
Do we support php include and/or SSI?
php script in php nuke - need help!
PHP Navigation
php include path
Wonders of the include() in PHP.
PHP include code problem
PHP include()
Displaying A Default Page Not Found.
PHP Include
Help needed with images in php include files
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.