A basic implementation would be
PHP Code:
<?php
$host = 'your domain name';
if($socket = fsockopen($host, 80, $errno, $errstr, 30)) {
echo 'The content you want to insert';
fclose($socket);
}
?>
This simply attempts to connect to the address (name or IP) identified in host. If the connection succeeds, a string will be written into the location of the code. I take it that the IP address of your server is static?
The host name should be just a name: don't add a scheme (i.e. http://).
The last argument in the fsockopen call is the timeout before the connection aborts. You'll probably want lower than 30 (otherwise users might be waiting for thirty seconds before they get a complete response from your server), but don't make it too low otherwise you'll get a false-positive if network traffic is high. In my brief tests, my local Web server automatically cut out before the timeout (at around twenty two seconds) so you can't specify an excessive timeout period anyway.
I don't guarantee that this will work: though I didn't find any security restrictions mentioned, there might be some of which I'm not aware.
Mike
Bookmarks