Pinglist

Pinglist

Pinglist

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>Ping list</title>
    <link rel = "icon" href ="pinglist.jpg" type ="image/x-icon">
  <body>
    <style>
    .block {
      display: block;
      width: 5%;
      border: 1px solid #808080;
      background-color: #2F4F4F;
      color: white;
      padding: 25px 15px;
      font-size: 18px;
      margin: 3px 2px;
      cursor: pointer;
      text-align: center;
      text-decoration: none;
      float: left;
    }

    .block:hover {
      background-color: #2F4F4F;
      color: white;
    }
  </style>
  <h1>Pinglist</h1>

<h2>
<?php
$iplist =array
(
array("1.1.1.1", "FIREWALL - Ping1"),
array("1.0.0.1", "SERVER - Ping2"),
array("1.1.1.2", "SWITCH 1 - Ping3"),
array("1.1.1.3", "SWITCH 2 - Ping4"),

);
$i = count($iplist);
$results = [];
for ($j=0;$j<$i;$j++) {
$ip =$iplist[$j] [0];
$ping =exec("ping -n 1 $ip",$output,$status);
$results[] = $status;

}
//Table
echo "<body style='background-color: #22292c; color:white;'>";
echo '<font face=sans-serif>';
echo "<table border=1 style=border-collapse:collapse>
<th colspan=4></th>
<tr>
<td align=right with=20>#</td>
<td width=150>IP</td>
<td width=110>STATUS</td>
<td width=280>DEVICE</td>
</tr>";
foreach($results as $item =>$k) {
echo '<tr>';
echo '<td align=right>'.$item.'</td>';
echo '<td>'.$iplist[$item][0].'</td>';
if ($results[$item]==0){
    echo '<td style=color:green>Online</td>';
}
else{
    echo '<td style=color:red>Offline</td>';
}
echo '<td>'.$iplist[$item][1].'</td>';
echo '</tr>';

}
echo "</table>";
?>
</h2>

<a href="home.php" <button class="block">Go Back</button></a>

</body>
</html>