Code to show ping results on a webpage included in the 2 -files ping.php
and output.php
Greets,
DaViper
Maybe this can help you
At 15:03 10/01/2001 +0600, you wrote:
>Dear list,
>I have this proposal: I work in ISP where we have a web site. On our web
>site, we would like to ping, say 3 other distant web sites at every
>interval of 10 minutes. We would like to have the result like say " The
>internet is down" message displayed on our homepage if the PING doesn't
>get reply. If there is a reply, then nothing should be displayed. So I
>would like to know the PHP functions/code to do that (i.e the PING
>function). I am sure that can be done in PHP. Could someone please
>instruct me how to go about it.
>Thanks.
>
>NOBBY
<?php
require "output.php";
function pingHost($host,$num=3)
{
exec("ping -c $num $host",$results);
foreach($results as $result) {
$tmp .= "$result<br>";
}
Return $tmp;
}
$starttime = exec("date");
$resultaat = pingHost($input,5);
$endtime = exec("date");
$port="";
printit($starttime, $endtime, $resultaat, $input, $port);
?>
<?php
function printheader() {
printf ("<title>PHP Webtools</title>");
printf ("<body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#336699\" alink=\"#FFFFFF\"
vlink=\"#990033\">");
printf ("<div align=\"center\"><p><u><b><font size=\"7\">PHP
Webtools</div></p></u></b></font>\n");
printf ("<font face=\"arial,helvetica\" size=2>");
}
function printfooter() {
printf ("<div align=\"center\">© copyright 2000 <a
href=\"mailto:[EMAIL PROTECTED]\">Ruben Vanhoutte</a><br>");
printf ("<p align=center>Powered by:</a><br>\n");
/*
printf ("<p><b> <a href=\"http://www.slackware.com\" target=\"_blank\"><img
src=\"/images/dpinguin.gif\" width=\"60\" height=\"80\"border=\"0\"
align=\"middle\"></a></b>");
printf ("<a href=\"http://www2.php.net\" target=\"_blank\"><img
src=\"/images/php.gif\" width=\"59\" height=\"80\" border=\"0\">");
printf ("<a href=\"http://www.apache.org\" target=\"_blank\"><img
src=\"/images/apache_pb.gif\" width=\"129\" height=\"40\"
border=\"0\"></a></div></p>");
*/
printf (" <table width=\"22\" border=\"0\" height=\"41\">");
printf (" <tr>");
printf (" <td width=\"22\">");
printf (" <p align=center>");
printf (" <p><b> <a href=\"http://www.slackware.com\" target=\"_blank\"><img
src=\"/images/dpinguin.gif\" width=\"60\" height=\"80\"border=\"0\"
align=\"middle\"></a></b>");
printf (" <a href=\"http://www.apache.org\" target=\"_blank\"> </a>");
printf (" </td>");
printf (" <td width=\"22\"><a href=\"http://www.apache.org\"
target=\"_blank\"><img src=\"/images/php.gif\" width=\"59\" height=\"80\"
border=\"0\"></a></td>");
printf (" <td width=\"56\"><a href=\"http://www.apache.org\"
target=\"_blank\"><img src=\"/images/apache_pb.gif\" width=\"129\" height=\"40\"
border=\"0\"></a></td>");
printf (" </tr>");
printf (" </table>");
}
function printit($starttime, $stoptime, $result, $host, $port) {
$spaces = "<font color=\"#FFFFFF\"> </font>";
printheader();
printf ("<b>Date Started: </b>%s <br>\n",$starttime);
printf ("<b>Date Ended: </b>%s <br>\n",$stoptime);
if ($port != "") {
printf ("<p><b>Host: </b>%s<b> Port: </b>%s</p>\n",$host,$port);
}
else
printf ("<p><b>Host: </b>%s</p>\n",$host);
printf ("<b><u>Data returned:</b></u><br>\n");
printf ("%s",$result);
printfooter();
}
?>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]