Pages: [1]   Go Down
Print
Author Topic: Check if remote server is online and include file.  (Read 743 times)
isAdmin
The Administrator
Administrator
Newbie
*****
Offline Offline

Posts: 20


...Networking, Programming, Designing & Creating!


View Profile WWW
« on: April 01, 2009, 12:02:34 PM »

This little PHP snippet will allow you to check if a remote web server is online and include a file from the remote server. Because PHP's include command does not seem to work with remote servers we have used the readfile command to replace it.

Code:
<?php
if(fsockopen("remoteserver.com"80$errno$errstr2)){
 @
readfile("http://remoteserver.com/path/filename.ext");
 } else {
 
// do something else if server is not available...
}
?>

Logged

The Administrator


url: http://iservicesinc.net
admin[at]iservicesinc[dot]net
Pages: [1]   Go Up
Print
Jump to: