|
Posted by J.O. Aho on 12/13/06 13:38
The87Boy wrote:
> J.O. Aho skrev:
>> If you have the right to include external files, then you could try to include
>> or open a remote file, if that works you have connection, if not than you
>> don't or the remote machine is down.
>
> What if I check it with more than one server?
Of course the more servers you check against the more reliable you will have,
of course when a servers is down or the path to them has some problem the
longer it will take to run the script.
> What about fsockopen('google.com', 80)
function test_internet() {
if(!$fp=fsockopen('www.google.com', 80)) {
if(!$fp=fsockopen('www.whitehouse.gov', 80)) {
if(!$fp=fsockopen('www.microsoft.com', 80)) {
if(!$fp=fsockopen('www.novell.com', 80)) {
return false;
}
}
}
}
fclose($fp);
return true;
}
if(test_internet()) {
"internet";
} else {
"the internet is dead";
}
Think that should work for you.
--
//Aho
Navigation:
[Reply to this message]
|