Include php file from remote 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
enkay
Forum Newbie
Posts: 2
Joined: Mon Nov 17, 2008 6:40 pm

Include php file from remote domain

Post by enkay »

I have a main website and many "satellite" websites. I have a php file that I update very often on the main website and I want to include that file on all my other domains. Updating the file on each domain would require way too much time and be too much of a hassle.

I know some of you will say this is not a good idea because of security reasons but unless I figure out a better way to update hundreds of sites at once, it will have to do.

I have allow_url_include = 1.

The problem is that using the php include function makes the script run on the remote machine and only outputs the "result" onto the domain the user is accessing. Any variable or function declared in the included php file will be unsusable in the rest of the code.

Simple exemple of what I'm trying to do.

Content of: mainwebsite.com/include.php

Code: Select all

<?
$something = "yes";
?>
Content of: remotewebsite.com/index.php

Code: Select all

<?
include("http://mainwebsite.com/include.php");
echo $something;
?>
Desired output when accessing remotewebsite.com/index.php
the word "yes" written on the screen.




I'm open to any suggestion to make this work but please don't suggest something that would imply completely re-writing the way the website works.

Can it be done using some kind of ftp include? Is there anyway to make the domain on which the include file is stored appear as "local" to all my remote domains and therefore include would work as if the files were stored locally?

Thanks for you time and suggestions.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Include php file from remote domain

Post by alex.barylski »

Use an Apache module...can't remember the name of it...proxy I think?

Or do as you have done...but you'll need url's enabled in includes option
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Include php file from remote domain

Post by Eran »

Are all those sites on the same physical server by any chance?
Post Reply