<?php

header("Refresh:60");
session_start();
if (!isset($_SESSION['uname'])) {
    header("location:index.php");
}
include "php_scripts/functions.php";
$host_details = getHostDetails(null);
$dns1 = getpacketloss('10.16.25.13', '1');
$dns2 = getpacketloss('10.16.25.15', '1');
$status_array = array();
array_push($status_array, $dns1, $dns2);
foreach ($status_array as $value) {
    if ($value > 0) {
        $status = '1';
    } else {
        $status = '0';
    }
}
$_SESSION['status'] = $status;
?>
<!DOCTYPE HTML>
<html>
<head>
<title>IISc Network Monitor V.2</title>
<!--Internet Bandwidth Start-->
    
<!--Internet Bandwidth End-->
<link type="image/gif" rel="icon" href="<?php 
if ($status == '0') {
<?php

header("Refresh:60");
session_start();
if (!isset($_SESSION['uname'])) {
    header("location:index.php");
}
include "php_scripts/functions.php";
$host_details = getHostDetails(null);
$s1 = getpacketloss('10.16.40.111', '1');
$s2 = getpacketloss('10.16.40.112', '1');
$s3 = getpacketloss('10.16.40.113', '1');
$status_array = array();
array_push($status_array, $s1, $s2, $s3);
foreach ($status_array as $value) {
    if ($value > 0) {
        $status = '1';
    } else {
        $status = '0';
    }
}
$_SESSION['status'] = $status;
?>
<!DOCTYPE HTML>
<html>
<head>
<title>IISc Network Monitor V.2</title>
<!--Internet Bandwidth Start-->
    
<!--Internet Bandwidth End-->
<link type="image/gif" rel="icon" href="<?php 
    ?>
</td>
                                <td><?php 
    echo $row['ip'];
    ?>
</td>
                                <td><?php 
    if (isset($row['fname'])) {
        echo $row['fname'];
    } else {
        echo $row['sname'];
    }
    ?>
</td>
                                <td><?php 
    $ps = getpacketloss($row['ip'], '1');
    if ($ps == '0') {
        echo "<span style='color:green;'>UP</span>";
    } else {
        echo "<span style='color:red;'>DOWN</span>";
    }
    ?>
</td>
                                <td><a href="">Delete</a></td>
                            </tr>
                            <?php 
}
?>
                </table>
	        </div>
	       </div>