Knowledgebase

php include to a file on another server

Posted by tranceformer, 12-29-2007, 11:14 AM
Is it possible to include a file on SERVER_a in a file on SERVER_b? for example, can this line: be included in the file without getting the following error: My ultimate goal here, obviously, is to display results from SERVER_a on SERVER_b, and I naturally own both SERVER_a and SERVER_b, but they are with separate companies. Thanks! Last edited by tranceformer; 12-29-2007 at 11:17 AM.

Posted by Steve_Arm, 12-29-2007, 11:48 AM
It's possible if php permits remote url fopen. A high security risk though. A better way is to call it as a web service with an authentication key.

Posted by tranceformer, 12-29-2007, 12:48 PM
How might I do that/what would the php code look like?

Posted by Rich, 12-29-2007, 07:13 PM
As far as I understand this is not possible. fopen, file_get_contents, and the like all execute and read the output, so there wouldn't be an easy way to do this in PHP. If you wanted a real sloppy way of doing it... provided that, like you said, you own both the sites. Have your code download the file first. First, FTP into server_B from server_A and then download the file for inclusion. It's sloppy and probably doesn't make sense from an efficient standpoint with what you are trying to do.. but it would be the only way I can think of to literally INCLUDE a file from another server. Edit: Ok here's another sloppy idea. Can you make duplicates of your files on server_B? Put them in a secure directory with a .phps extension. On server_A, fetch the file from the secure directory into a variable, then exec() the variable. Last edited by Rich; 12-29-2007 at 07:23 PM.



Was this answer helpful?

Add to Favourites Add to Favourites

Print this Article Print this Article

Also Read
InterServer down (Views: 656)
reduce backup load (Views: 597)


Language:

Client Login

Email

Password

Remember Me

Search