hammerslane
02-24-2004, 10:11 AM
Hey people. I've been modifying this script over the space of about 2 months. It's a ping script, which tries to make a connection to the URLs in the array at the top, and echo's whether the fopen was sucessful.
<?php
//URL ARRAY
$links = array ("www.hammerslane.com","www.example.com");
function chkuri($link)
{
$churl = @fopen("http://".$link,'r');
if (!$churl) {
return false;
}else{
return true;
}
}
foreach($links AS $link)
{
if(!chkuri($link))
{
print"$link is down<br><br>";
}
else
{
print"$link is up<br><br>";
}
}
?>
If you go to this address... www.hammerslane.com/pingfo1.php you can see it in action. the obvious thing wrong with it, is that it says both addresses are down... (wrong, otherwise you couldn't visit the page, or this thread).
Can anyone tell me why this is happening? Is there an alteration to the code that I can make?
Many thanks!
<?php
//URL ARRAY
$links = array ("www.hammerslane.com","www.example.com");
function chkuri($link)
{
$churl = @fopen("http://".$link,'r');
if (!$churl) {
return false;
}else{
return true;
}
}
foreach($links AS $link)
{
if(!chkuri($link))
{
print"$link is down<br><br>";
}
else
{
print"$link is up<br><br>";
}
}
?>
If you go to this address... www.hammerslane.com/pingfo1.php you can see it in action. the obvious thing wrong with it, is that it says both addresses are down... (wrong, otherwise you couldn't visit the page, or this thread).
Can anyone tell me why this is happening? Is there an alteration to the code that I can make?
Many thanks!