Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help to see if a server is alive and display image if not!

Status
Not open for further replies.

andybid

Vendor
Dec 7, 2010
23
GB
Hi

I am hosting livezilla on my site, it is on a free account but have got it to work by hosting the server on my home pc, with a web address.

The problem I have is that the php decides if you online or not, if not an offline image is displayed.

The problem I have is that if my pc is off, the offline image does not display as it cant get to it.

How do i check if an address is live, if it is carry on, if it isn't - load image x

Thanks
 
Place your image somewhere it can be found by the PHP.



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
The problem I got is this
:
<code>
<img src="</code>

That is what displays the image. Image.php contains code to see if the server alive or not. This file is on my PC and not the webserver. If I put it on the web server and not my pc, the image is always offline.

I was thinking that I could write a line to see if my own address to my pc madandi.gotdns.com is alive or dead, if dead it displays an offline image on the web server, if alive it lets that line above run.
 
You could try to ping your PC's address and check the response for instance:

Code:
$execres=exec("ping addresstopc.com",$output,$result);
  if($result==0){
   if(isset($output[9])){
    $values=explode(",",$output[9]); 
	$Lost=explode("=",$values[2]);
	if($Lost[1]==0){ echo '<img  src="[URL unfurl="true"]http://madandi.gotdns.com/0lx.net/fast-host.co.cc/htdocs/live/image.php?id=03">';[/URL] }
    
  }
}

else{ echo "Offline"; }

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
$execres=exec("ping addresstopc.com",$output,$result); if($result==0){ if(isset($output[9])){ $values=explode(",",$output[9]); $Lost=explode("=",$values[2]); if($Lost[1]==0){ echo '<img src=" }

Right,

I think I get how that works, how do I get it to work onsite?

I tried on my local server and it just outputted the text with the image!
 
Surround it with PHP tags.
Code:
<?PHP
...
?>




----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
DOH!!!

Yes, sorry, didn't realise it wasn't

Stupid stupid me.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top