Website uptime check
By: Daniel
Do you ever want to check many websites to see if they are up or not? This code can help you check multiple sites all from one page.
function prepWWW($url) { $replace = array("http://" => "", "www." => ""); foreach($replace as $toReplace=>$replaceWith) { $url = str_replace($toReplace, $replaceWith, $url); } $parts = explode("/", $url); $newURL = strip_tags(addslashes($parts[0])); return $newURL; } $site = prepWWW("www.wlscripting.com"); $check = @fsockopen($site, 80); if($check) { echo "$site is up"; } else { echo "$site is down"; }
First off we create the prepWWW function. This just prepares the domain name for usage with fsockopen(). We strip out all extra parts to the url so we only get the main domain like: wlscripting.com NOT http://www.wlscripting.com
Then we just check the website with fsockopen() on port 80, which is the port that Apache or IIS runs on usually unless you configured it differently. This 80 can be changed to any other port number to checking other services like: FTP 21, cPanel 2082, WHM 2086, and so on.





















(3 votes, average: 3.33 out of 5)
September 26th, 2006 at 5:22 pm
I think this is great, but when trying to put two copies on it to monitor more than one site it crashes the second instance on the page. How can this be used to monitor many sites from one page?
September 26th, 2006 at 5:23 pm
also…. cool comment tool, how can I get it for my site? is it ajax?
September 27th, 2006 at 6:15 pm
Running multiple copies works just fine. What is your setup and how is your script setup?
Here is a demo of this running with multiple sites being checked:
Demo: http://demo.wlscripting.com/tutorial30/prepWWW.php
Source: http://demo.wlscripting.com/tutorial30/prepWWW.phps
The comment tool is: http://www.mikesmullin.com/2006/06/05/ajax-comments-20/
Post back if you still need help!
November 20th, 2006 at 11:32 pm
thanks, will try again and also thanks for link to comments tool. downloaded it and ready to try.
April 1st, 2007 at 5:15 pm
One of the best locations I\’ve come across lately!!! Definately a permanent bookmark!
June 9th, 2008 at 3:32 pm
Daniel – Thanks for this script! I find myself using it on my iPhone each morning as I’m driving to work. I made a few modifications to add a green “Check” and a red “X” depending on the site being up or down. Like I said I use this script mostly on my iphone and with the display being smaller, the graphics help me take a quick glance and know if I have a site in trouble or not… Here are the simple mods that I made:
if($check) {
echo “$site is up”;
} else {
echo “$site is down”;
Hope this helps anyone else using a smart phone…
September 23rd, 2008 at 9:00 pm
Glad to hear that this script is being used.
January 7th, 2009 at 7:27 pm
Awesome script! Is it possible to have them enter what site they want?
August 21st, 2010 at 1:37 pm
Do you have a script that will check other services aside from http?
June 17th, 2011 at 4:20 am
I’m getting a fatal error when i try to create a new page on WP. I think it has something to do with the new WP update. Is anybody else having a equivalent issue? Know how it can be fixed???? Cheers.
June 18th, 2011 at 4:17 am
Hey There. I found your blog using msn. This is a very well written article. I will be sure to bookmark it and return to read more of your useful information. Thanks for the post. I will certainly return.
June 20th, 2011 at 4:06 am
Between me and my husband we’ve owned more MP3 players over the years than I can count, including Sansas, iRivers, iPods (classic & touch), the Ibiza Rhapsody, etc. But, the last few years I’ve settled down to one line of players. Why? Because I was happy to discover how well-designed and fun to use the underappreciated (and widely mocked) Zunes are.
June 22nd, 2011 at 4:08 am
WONDERFUL Post.thanks for share..more wait .. ??
July 1st, 2011 at 4:17 am
magnificent publish, very informative. I wonder why the opposite experts of this sector don’t realize this. You should proceed your writing. I am sure, you have a huge readers’ base already!
July 25th, 2011 at 4:23 am
10611062106310641065106610671068106910701071107210731074107510761077107810791080
July 31st, 2011 at 3:03 pm
Sorry for the huge review,coach outlet store online but I’m really loving the new Zune, and hope this, as well as the excellent reviews some other people have written, will help you decide if it’s the right choice for you.
August 2nd, 2011 at 4:26 am
It’s the best time to make some plans for the future and it’s time to be happy. I’ve read this post and if I could I want to suggest you some interesting things or tips. Maybe you could write next articles referring to this article. I wish to read more things about it!
August 3rd, 2011 at 4:33 am
karen millen store
online sale clothing
caren miller
August 26th, 2011 at 7:21 am
Katherine Heigl has also recently been by using a heated vacation rear, contrary to she is extremely powerful tan, possibly she’s been a significant use of Journey Tropez. Most definitely i’ll are convinced the latter. people pleased with in instances where rrnside a white colored golden, the fact is that Catherine is naughty and F Nicole von Furstenberg shirts or dresses right before nov 2008 election. bare program if your attire of cotton, yarn louis vuitton galliera azur some grilling with charcoal dog pen cover in what is a up to date organza and looking after coloration struggle.
September 7th, 2011 at 9:00 am
Well I truly liked studying it. This article provided by you is very practical for proper planning.
September 7th, 2011 at 9:40 am
moncler-jacketsale.org is a famous Moncler outlet online shop which sell directly Moncler Coats, Tee-Shirt, Shoes, and other Moncler Clothing For women and Men Moncler Jackets Onsale 50-80% off, Directly Factory Delivery. Non-tax, Free World Shipping! Buy Now !!!
September 7th, 2011 at 9:44 am
you have a great sites it! do you want to make a few invite posts on my blogs?
September 12th, 2011 at 2:58 pm
Thanks for sharing WLScripting.com » Website uptime check with us keep update bro love your article about WLScripting.com » Website uptime check .
October 8th, 2011 at 3:10 pm
Thanks a bunch for sharing this with all of us you actually know what you are talking about! Bookmarked. Kindly also visit my website =). We could have a link exchange agreement between us!