<?php


date_default_timezone_set('Africa/Gaborone');
$entry_date = date("Y-m-d H:i:s", time()); 
$time = strtotime(date("H:i:s", time())); 

$active_query = "SELECT username, log_in, last_active  FROM active_users  ";
$active_result = mySQL_query($active_query);
$active_num = mysql_num_rows($active_result);
$i=0;

while ($i<$active_num) {
	$a0 = mysql_result($active_result, $i, "username");
	$a1 = mysql_result($active_result, $i, "log_in");
	$a2 = mysql_result($active_result, $i, "last_active");
	
	
	$last_time=strtotime($a2);
	
	$a10 = ($time - $last_time);
		
	if ( $a10 > 3000) {
		  
		  $delete_query = "DELETE FROM active_users WHERE username='".$a0." ' ";
		  execsql($delete_query);
		 
		  //$table_name = "man_tracking_log_in";
//		  $action_query = "INSERT INTO $table_name (entry_date, user_name, action, details) VALUES ('".$entry_date."' ,'".$a0."','reset', 'not logged out properly' )";
//          execsql($action_query);
		  
	}
	
	$i++;
	
	
}

?>