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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I determine if an external web site is running through php? 1

Status
Not open for further replies.

ExcalibursZone

Programmer
Apr 12, 2002
2
US
This is the purpose of my question. My ISP allows me to use PHP, however, I am not able to write to disk on their server using PHP (obviously a security risk if implemented incorrectly). I would like to create a simple guest book that would allow me to save the entries to disk. I am running PHP at home and would like to find out if my server (my box) is running when someone wants to access the guestbook. If my server is up, I would like to display the fully functional guestbook. If my server is down, I would like to instead display a page that informs the visitor that the server is down.

Any help would be great.
 
<?php
$handle = fopen(&quot;
if (!$handle) {
____________DISPLAY_SERVER_DOWN_MSG____________________
} else {
echo &quot;<meta http-equiv=\&quot;refresh\&quot; content=\&quot;0; URL=http://your-dynamic-ip-at-home/guestbook.php\&quot;>&quot;;
}
?>

If fopen_wrapper is not defined (can find out with phpinfo() on your website), use fsockopen() as describes in the php reference at )

HTH, Sascha cu, Sascha
 
ExcalibursZone, a star might be in order for Sascha! That's some useful code!

I would rework as follows though:
Code:
<?
if(fopen(&quot;[URL unfurl="true"]http://your_ip&quot;,80))[/URL]
 {
 header(&quot;Location: [URL unfurl="true"]http://your_ip/gbook.php&quot;);[/URL]
 }
echo &quot;Site is down, sorry!&quot;;
?>
Just a cleaned up version, Sascha did the real work! -gerrygerry
Go To
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top