Page 1 of 1

Include php file from remote domain

Posted: Mon Nov 17, 2008 6:53 pm
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.

Re: Include php file from remote domain

Posted: Mon Nov 17, 2008 8:44 pm
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

Re: Include php file from remote domain

Posted: Mon Nov 17, 2008 8:47 pm
by Eran
Are all those sites on the same physical server by any chance?