How to include file from external domain

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
arathi
Forum Newbie
Posts: 6
Joined: Fri Jul 20, 2007 1:40 am

How to include file from external domain

Post by arathi »

Hi
I want to include file from external domain.
for example i have 2 domains http://www.hiox.com and http://www.withfriendship.com i have a php script on example.com which i want to include in another script on example2.com.

I tried to just simply include the script:

include('http://www.hiox.com/testscript.php');

but this does not seem to work. When I checked the manual it said that this is possible as long as the php version is greater than 4.3.0 (which mine is on both domains) and allow_url_fopen is enabled ehich it is on both domains.

am i missing something? or is there another way of doing this?
Last edited by arathi on Fri Jul 20, 2007 5:04 am, edited 1 time in total.
MalikBB
Forum Newbie
Posts: 11
Joined: Fri Jul 20, 2007 4:34 am
Contact:

Post by MalikBB »

it-s impossible

because another site is another site.

with same result you can include google.com/index.php :)
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

arathi wrote:include('http://www.hiox.com/testscript.php');
if the webserver at hiox.com has php installed your script will only include the output of testscript.php
e.g.

Code: Select all

// testscript.php
if ( isset($a) ) {
  echo $a;
}
else {
  echo 'default';
}
and your script:

Code: Select all

$a = 'xyz';
include include('http://www.hiox.com/testscript.php');
Your script will only receive default as data for inclusion.
Phoenixheart
Forum Contributor
Posts: 123
Joined: Tue Nov 16, 2004 7:46 am
Contact:

Post by Phoenixheart »

:D If only we could include() something from other sites :lol: I'd be a hacker master... or not? Since no security, no hacker. :lol:
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Also be aware that including from off site will often significantly slow the execution of the page and creates a security hole by allowing an attacker compromise one site and compromise another for free.
Post Reply