Forum Moderators: coopster

Message Too Old, No Replies

Cross domain includes

Including PHP output across domains

         

ucs308

4:59 am on Mar 18, 2003 (gmt 0)

10+ Year Member



I have a commercial website hosted on Window servers by Interland. PHP is not available on the plan I use, and I don't want to switch plans right now, but I am more comfortable with PHP as my scripting language. I need to make some minor updates to the site and want to get the main content from a remote domain (which does support PHP).

Essentially the headers and footers for a page will come from the main domain, but I then want to run a PHP script that resides on a different domain, actually a different host altogether. The main domain has Perl as its main scripting language.

My questions are:

1. How can I include the output of the remote PHP script in my HTML pages, when I have only HTML and perl available on the main domain?

2. What pitfalls are there to doing this?

3. Is this considered a 'no-no' in terms of security or privacy?

Thanks.

gethan

6:12 am on Mar 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



welcome to WebmasterWorld ucs308

I'll get the ball rolling here - interesting situation you have :)

1) Yes - you can use libwww-perl to go off and get pages, and include them in your output. More details here: [linpro.no...] also check out CPAN for more options...

2) You are dependent on two hosts to produce one page, content duplication, submiting forms ... lots of them.

3) Really depends what you're doing - one example - if you are running over https and then use a non secure connection from your main site then the benefits of encryption would be lost. (plus you're on an NT server ;) )

It depends so much on the specifics of your project here:

If you are running a content driven site that has little or no user customisation I would suggest a different approach - run the entire site on a php enabled server (not necessarily publicly accessible), spider it - grab all the outputted html and host that on your win-NT server as a static site.

You should get plenty more ideas soon - good luck

toadhall

6:57 am on Mar 18, 2003 (gmt 0)

10+ Year Member



There's always the old javascript "web-bug" trick. Actually I don't know as it's old, but...

Use the external javascript call in your html to run the php script on the remote server:

<script language="javascript" src="http://www.domain.com/whatever.php"> </script>

... and use the write method of the document object to return the output from whatever.php:

<?
echo "document.write('IP: $REMOTE_ADDR / Linked from: $HTTP_REFERER / UA: $HTTP_USER_AGENT');";
?>

... the sample is a tracking method - IP, etc. - but you can "write" whatever you like. Take care you don't mix up the two languages. Escape where necessary.

Best of luck!

T