bnicolaescu Posted July 26, 2007 Share Posted July 26, 2007 Hello everybody, how can one automatically check a site is up? I tried some php functions: if (!fsockopen($_POST['url'], 80)) ....... and if (!file_get_contents(....) ) ............. but there are some sites that are not correctly validated. for instance this one: honeybeauty.ro. The php functions above return null and the site is up... thanks a lot! Quote Link to comment Share on other sites More sharing options...
mpharo Posted July 26, 2007 Share Posted July 26, 2007 There is a great open source project called Smokeping http://oss.oetiker.ch/smokeping/ It uses functions like echoping to actually bring up a web page at a set interval to check for up or downtime. You can also set up e-mail notifications for a certain threashold. Quote Link to comment Share on other sites More sharing options...
bnicolaescu Posted July 26, 2007 Author Share Posted July 26, 2007 but I just need to check if the site is up just one time... for some sites php functions used to open connections fail.... Quote Link to comment Share on other sites More sharing options...
bnicolaescu Posted July 26, 2007 Author Share Posted July 26, 2007 Warning: fsockopen() [function.fsockopen]: unable to connect to www.honeybeauty.ro:80 (No route to host) in /home/etesterr/public_html/clickme/ping.php on line 5 Quote Link to comment Share on other sites More sharing options...
Crow Posted July 26, 2007 Share Posted July 26, 2007 <?php $url = 'google.com'; $url = gethostbyname($url); echo (@fsockopen($url,'80')) ? 'Online' : 'Offline'; ?> If you use @ before fsockopen you can suppress the error messages from the socket -Steve EDIT: Shortened the code a little >_> Quote Link to comment 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.