Forum Moderators: coopster

Message Too Old, No Replies

including external php file and executing a command

         

asantos

12:43 am on Apr 14, 2007 (gmt 0)

10+ Year Member



hi
i have two different servers, and i need to call a php of server B from server A, so i did this:

SERVER A:
index.php has:
include('http://server-b/file.php');

The content of file.php is:
phpinfo();

... but phpinfo() throws info about server B instead of its parent file SERVER A.

Is there any way to accomplish that?

coopster

2:04 am on Apr 14, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



No, you cannot read the code from the file when including via HTTP. The included file will always be parsed by the server. You could script some workarounds though on server B that would push the code out to you instead of the PHP-parsed document.

borntobeweb

1:10 am on Apr 15, 2007 (gmt 0)

10+ Year Member



Try using file_get_contents(), so:

SERVER A:
$output = file_get_contents('http://server-b/file.php');
print $output;

asantos

10:04 pm on Apr 25, 2007 (gmt 0)

10+ Year Member



borntobeweb: mm that would not work, because i need the code to be executed by managing SERVER A's files.