Check Online Status?
Moderator: General Moderators
Check Online Status?
Hiya,
how can I with PHP test whether a side online is or offline is / does not exist?
Sorry for my english, I'm 14 and from Germany *s*
Thanks in Advance,
InX
how can I with PHP test whether a side online is or offline is / does not exist?
Sorry for my english, I'm 14 and from Germany *s*
Thanks in Advance,
InX
- AVATAr
- Forum Regular
- Posts: 524
- Joined: Tue Jul 16, 2002 4:19 pm
- Location: Uruguay -- Montevideo
- Contact:
Re: Check Online Status?
Do you mean a "site" http://www.something.com ?InternetX wrote:how can I with PHP test whether a side online is or offline is / does not exist?
- puckeye
- Forum Contributor
- Posts: 105
- Joined: Fri Dec 06, 2002 7:26 pm
- Location: Joliette, QC, CA
- Contact:
Well InX you could use the PHP function readfile() : http://www.php.net/manual/de/function.file.php (Made sure to send you to the German page)
Compare the content of the array it'll return to see if there's anything, you'll have to chack for 404 Document not found and domain name not found errors ...
If you have PHP 4.3.0 you could also use file_get_contents() : http://www.php.net/manual/de/function.f ... ntents.php
Compare the content of the array it'll return to see if there's anything, you'll have to chack for 404 Document not found and domain name not found errors ...
If you have PHP 4.3.0 you could also use file_get_contents() : http://www.php.net/manual/de/function.f ... ntents.php
If I use readfile() always it shows:
Warning: readfile("http://www.moonychat.de") - Success in /home/moony/htdocs/test.php on line 3
But not more... =/
Warning: readfile("http://www.moonychat.de") - Success in /home/moony/htdocs/test.php on line 3
But not more... =/
- puckeye
- Forum Contributor
- Posts: 105
- Joined: Fri Dec 06, 2002 7:26 pm
- Location: Joliette, QC, CA
- Contact:
Sorry InX I meant to write file() not readfile()... I started with readfile and then I checked the PHP manual and realized that it was file() not readfile() (hence the correct URL) but I guess I overlooked the function name I wrote right in front of the URL...
Try:
I just tested this further and it seems that it returns an error even if a 403 error is returned (I tried with http://www.moonychat.de/blah.html) So I think it's fair to assume that 404 errors will do the same.
Try:
Code: Select all
if (@file("http://www.moonychat.de"))
{
print "Yeah!"; // the page exists.
}
else
{
print "Doh!"; // the domain name doesn't exists.
}- puckeye
- Forum Contributor
- Posts: 105
- Joined: Fri Dec 06, 2002 7:26 pm
- Location: Joliette, QC, CA
- Contact:
Did you check the http://www.php.net/manual/en/ref.filesy ... -url-fopen and http://www.php.net/manual/en/wrappers.php pages?
Those URLs are pointe to in the Tipp box.
Those URLs are pointe to in the Tipp box.
This script works perfect, give up de url you want to check if it's online and you can even give up the port to scan, like 21,23,80 etc. so you can see witch service is online of the server....
http ftp etc.
greathings Skywalker
http ftp etc.
Code: Select all
<?php
$ip='www.demo.triv.nl';
$port=80;
$fp = fsockopen ($ip, $port, $errno, $errstr, 30);
if (!$fp) {
echo "<font color="#FF0000">img src="warning.gif"><b>System
Down</b><p>Error $errno: $errstr";
} else {
echo "<font color="#0000c0"><img src="online.gif"><b>All
systems are stable and running.</b>";
}
?>greathings Skywalker