i have checked this years newbie-q and not found an answer. maybe someone can help.
i run server A and server B. basicly i want server A to check if server B is online. the servers does not have the same domain.
this is my idéa:
i want a script on server A to either read a textfile or execute a script that will return a variable from server B.
i have tried with fopen and file_exists (together and alone) and the script works fine when data.txt and the script is on the same server but not when tha path to data.txt is to another server (server😎
<?PHP
$fileName = "http://www.serverB.com/data.txt";
if (file_exists($fileName)) {
$filePointer = fopen ($fileName, "r");
$array = file ($fileName);
$status = $array[0];
print ($status);
fclose ($filePointer);
} else {
print ("offline");
}
?>
i have also managed to include a script from server B that sets a variable and this works when server B is online, but that is just what i want to check, so when it is offline i get an error, saying the file to include cant be found.
like this:
server B says:
<?php
$status = true;
?>
when server A asks:
<?php
include("http://serverB.com/index.php");
(status)? print "serverstatus=ONLINE": print "serverstatus=OFFLINE";
?>
does theese command not work across servers?
thanks.