slushpuppie Posted February 6, 2008 Share Posted February 6, 2008 working on a project for a client where we copied a form onto our page which passes over to another domain. they want me to write something on my page though that can check the status of their server, make sure the page is active. and if it's not i'm supposed to hide my form and put up a message basically saying "out of order"... they offered to put something on their page like a meta tag that either says "active" or "inactive" and want me to parse their page for this... does anyone have a better idea? or anything? any input appreciated. thanks! Quote Link to comment https://forums.phpfreaks.com/topic/89776-best-way-to-check-the-status-of-another-site-looking-for-ideas/ Share on other sites More sharing options...
s0c0 Posted February 11, 2008 Share Posted February 11, 2008 Damn dude I wrote something like this a whole back to have it check my primary server from a remote host. If the connection took longer than 20 seconds it would fire off an SMS message to my cell phone. Haha found it: $fo = fsockopen('domain.com', 80); if(!$fo) { mail('email@email.com', 'site down', 'unable to connect on port 80 @ '.$date('H:m:s')); } I've seen some fancier stuff on phpclasses.org but I wanted something quick and dirty and thats exactly what this is. You could use something like curl and use its functionality for the exact HTTP code if this is a web server, but anyways there are plenty of ways to skin this one. Hope that works for you. Quote Link to comment https://forums.phpfreaks.com/topic/89776-best-way-to-check-the-status-of-another-site-looking-for-ideas/#findComment-463831 Share on other sites More sharing options...
Daniel0 Posted February 11, 2008 Share Posted February 11, 2008 The problem with doing that is that users will have to wait a long time for the page to load in case the remote server is down. Quote Link to comment https://forums.phpfreaks.com/topic/89776-best-way-to-check-the-status-of-another-site-looking-for-ideas/#findComment-464033 Share on other sites More sharing options...
keeB Posted February 12, 2008 Share Posted February 12, 2008 Cant you set a low socket timeout? http://us3.php.net/manual/en/function.fsockopen.php resource fsockopen ( string $hostname [, int $port [, int &$errno [, string &$errstr [, float $timeout ]]]] ) Quote Link to comment https://forums.phpfreaks.com/topic/89776-best-way-to-check-the-status-of-another-site-looking-for-ideas/#findComment-464639 Share on other sites More sharing options...
Daniel0 Posted February 12, 2008 Share Posted February 12, 2008 Here is what I would do: Show the form always. Hide and disable it using javascript when the page loads. Check the server status using AJAX. If the server responds then show the form using javascript, otherwise give them the message saying the server is down. Quote Link to comment https://forums.phpfreaks.com/topic/89776-best-way-to-check-the-status-of-another-site-looking-for-ideas/#findComment-464645 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.