1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
| <html>
<HEAD>
<link rel="stylesheet" href="css/style.css" TYPE="text/css">
<script>
function ChangeColor(index, color) {
document.getElementById("MyFont" + index).color=color
}
function ChangeTexte(index, HTML) {
document.getElementById("MyText" + index).innerHTML = HTML
}
</script>
</HEAD>
<BODY BACKGROUND="./img/fond.gif">
<?php
$ip_address='10.10.10.10';
$host_equipment=localhost';
$ini_array = parse_ini_file("../config/conf.ini");
echo '
<table border=1>
<tr>
<td>IP address</td>
<td>Host</td>
<td>Traceroute</td>
</tr>
<tr>
<td><FONT id="MyFont1">'.$ip_address.'</FONT></td>
<td><FONT id="MyFont2">'.$host_equipment.'</FONT></td>
<td><FONT id="MyFont3"><SPAN id="MyText1"></SPAN></FONT></td>
</tr>
</table>
';
?>
</body>
</html>
<?php
//PREMIERE ACTION
$ping=ping ($ini_array,$ip_address);
$color1="";
if (ereg ("!", $ping)) {$color1="#00D500";}
else{$color1="#FF0000";}
echo '<script>';
echo ("ChangeColor(1,'$color1');\n");
echo '</script>';
flush();
//DEUXIEME ACTION
$fping2=`fping $host_equipment`;
$color2="";
if (ereg ("unreachable", $fping2)) {$color2="#FF0000";}
else{$color2="#00D500";}
echo '<script>';
echo ("ChangeColor(2,'$color2');\n");
echo '</script>';
flush();
//TROISIEME ACTION
$resultat="";
$color3='';
if($color1=="#00D500" & $color2=="#00D500"){
$traceroute=traceroute($ini_array,$host_equipment,$ip_address,$type);
if(ereg("traceroute",$traceroute)){
$r=split("\n",$traceroute);
foreach($r as $l){
if(preg_match('/^ 2|^ 2/',$l,$matches)){$text="Nb HOPS > 1";$color3="#FF0000";break;}
else{$text="OK";$color3="#00D500";}
}
}
else{$text="ERROR";$color3="#FF0000";}
}
else{$text="NO PING";$color3="#FF0000";}
echo '<script>';
echo ("ChangeColor(3,'$color3');\n");
echo ("ChangeTexte(1,'$text');\n");
echo '</script>'; |
Partager