Forum Moderators: coopster

Message Too Old, No Replies

Calling another script/template from another server

         

internetheaven

2:24 pm on Mar 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is there some code that calls a script from another site safely?

e.g. if www.example.com/folder/file.php
www.example2.com/fold/files.php
www.example3.com/der/file3.php
www.example4.com/folders/file.php

called the script at:

www.example5.com/folder/file.php

to find out what information to display? Basically, there are several pages on around 100 sites of mine that have information that needs updating every so often or the template/scripting adjusting. Each time I have to go to each site and make the changes.

If I could have one script and one template in one place and only edit them it would obviously save hours of work. The information is only entered in one database (it is things like contact phone numbers, product codes etc.) but if I need to make changes to the templates/scripting that calls that information I need to do it on every site every time.

(Did I make sense?)

omoutop

2:47 pm on Mar 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Although i haven't use it ever, I know that this kind of work can be accomplished by using curl.

Can't often more help, but i hope this will put you on the track.

cmarshall

2:51 pm on Mar 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not sure if I completely understand. It sounds like you want a standard include/require [us3.php.net], but maybe you need to render and filter the rendered [X]HTML. If so, try something like this:

ob_start();
include("[i]URI of Page to Render[/i]");
$xhtml = ob_get_contents();
ob_end_clean();
echo WhateverFilterYouWant($xhtml);

I use almost exactly this technique to reformat pages for cellphones.

Marcia

3:04 pm on Mar 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I once had a site on space that didn't support CGI, and called a Perl script from another site that did, and it worked beautifully. I just can't remember how it was done, but would love to do it now, with scripts in either Perl or PHP.

cmarshall

3:14 pm on Mar 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just to expand upon my comment a bit:

PHP's include() function [us3.php.net] will render a URI in the default installation.

This means that you can have a script that is:

<?php include("http://www.webmasterworld.com");?>

PHP seems to be the only active language with such simple support for this. I can't find it anywhere in other languages, and I've looked, because I have published a site SDK that relied upon this functionality.

This may be turned off by some hosts, as it can be construed as a security issue (although, if you run it like I showed you, it shouldn't be). However, it is on by default in most PHP installations [us3.php.net].

This requires the following two lines in your php.ini file:

allow_url_fopen = On
allow_url_include = On