<?php
require('../config/dbcon.php');
    $query = "SELECT timeout from timeout_mst";
    $rs = mysqli_query($connect, $query) or die("Cannot execute query: $query\n");
    while ($row = mysqli_fetch_assoc($rs)) {
    	$timeout = $row['timeout'];
    }
session_start();
if(isset($_SESSION["user"]))
{
 if((time() - $_SESSION['last_time']) > $timeout) // Time in Seconds
 {
 header("location:../login/logout.php");
 }
 else
 {
 $_SESSION['last_time'] = time();
 //echo "<h1 align='center'>Welcome ".$_SESSION["user"]. "</h1>";
 //echo "<h3 align='center'>Automatic Logout after 1 minute of inactive</h3>";
 //echo "<p align='center'><a href='../login/logout.php'>Logout</a></p>";
 //echo "<p align='center'><a href='../main/welcome.php'>Welcome1</a></p>";
 }
}
else
{
 header('Location:../login/index.php');
}
?>
<html>
<head>
	<title>IMS-Utility</title>
</head>
    <script type="text/javascript">
    	function preventBack() {
    		window.history.forward();
    	}
    	setTimeout("preventBack()", 0);
    	window.onunload = function() {
    		null
    	};
    </script>
<script src='../js/jquery-3.1.1.min.js' type='text/javascript'></script>
<script src='../js/jquery-ui.min.js' type='text/javascript'></script>
<link href="../css/style.css" rel="stylesheet" />
<link href="../css/style1.css" rel="stylesheet" />
<link href='../css/jquery-ui.min.css' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="../css/all.css">
<link href="../css/bootstrap.min.css" rel="stylesheet" />

<body>
	<nav class="navbar navbar-default" style = "background-color: #007bff; height : 60px;">		
		<h1 style="color:white; font-size:24px;" class="text-primary" align="center">Utility</h1>
		<a href="../main/index.php" style = "font-size:24px; margin-top :-50px; color:white;" class="navbar-brand">Home</a>
		
	</nav>	
	<div class="container" style = "width:100%;">
	<form class="form-inline" method="POST" action="">		
	<center>
		<tr>			
			<a href="index.php" type="button" name="action" id="action" href="index.php" class="btn btn-success btn-xs" ><span style="height:29px;" class = "btn btn-success">Refresh<span></a>			
		</tr>
	</center>
	</div>	
	<div style="margin-top : 0px; margin-left : 10px; height:50%; margin-right: 10px; margin-top: 0px; overflow:auto;" id="result" class="table-responsive"  align="center"></div>
	<div style="height: 60px; margin-left:0px; margin-top:0px; font-size:30px;" class="success"></div>
	<div style="height: 60px; margin-left:0px; margin-top:0px; font-size:30px;" class="error"></div>
</body>

</html>
<!--script src='js/app.js' type='text/javascript'></script-->
<script>
	$(document).ready(function() {		
		$('#action').click(function() {					
		var action = $('#action').text();
			$.ajax({
				url: "action.php",
				method: "POST",
				data: {											
					action: action
				},				
			});
		});
		
		
	});
</script>