FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Check if a site is online (up)





Dougie1
How would I go about checking if a site was online or if it wasn't. Thanks in advance. Very Happy
Hogwarts
Dougie1 wrote:
How would I go about checking if a site was online or if it wasn't. Thanks in advance. Very Happy

Code:
<?php
if ($handle = fopen("http://www.site.com/index.html")) {
     echo "It's online";
     fclose($handle);
else {
     echo "It's not online";
}

Should work, although it may need some tweaking.
roboguyspacedude
lol. that is very simple. otherwise I would suggest doing a manual check of the server and changing the status manually. of course you would only care to do it manually if it is a big site.
jabapyth
can't you just ping it?
Hogwarts
jabapyth wrote:
can't you just ping it?

He's posting this in the PHP and MySQL forum, so he's probably looking for something dynamic Wink

Read your sig? Razz

Also, doing server stats manually is a bad idea. To do it every hour or minute would be impossible, too.
Mgccl
here, is a ping script
dude this guys knows good network stuff

http://www.theworldsend.net/
fromegame
Code:

<?php
$file = fsockopen("http://www.google.nl/");
if($file = -1) {
// offline
}else{
// online
}
?>
Dougie1
Is there any way to check this every 30 minutes then? Thanks for the help guys.
jabapyth
to do something 'every 30 min' you'll want a cronjob, not PHP. PHP only executes when somebody goes onto that site. What would you do with the knowledge? make a log? an Image (like theyv got here)?
Related topics
Make my site appear in google searchs
PHP Functions...
My web site - Promotional forum! Advertising
What is your computer related obsession?
Stop - Word
How to add a new site?
Frihost banner contest
My Subdomain still not working :(
Free SEO: Quality Websites Only Please
Gone for a month
spanish section
better hosting system
admin ,i see somebody's post points less than -10.00,but ...
Wow.
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.