$value){ $$key = $value; } if ($_SESSION['name'] != ""){ $sSession = mysql_query("SELECT * FROM user WHERE userID=".$_SESSION['id'].""); $rSession = mysql_fetch_array($sSession); if (session_id() != $rSession['sessionID']){ echo ""; $_SESSION['type'] = ""; $_SESSION['id'] = ""; $_SESSION['name'] = ""; } } if ($action == "logout"){ $_SESSION['type'] = ""; $_SESSION['id'] = ""; $_SESSION['name'] = ""; } //from here, start of counting who's online $ip = $_SERVER['REMOTE_ADDR']; $time = time(); $ip_check = 'SELECT ip FROM `online` WHERE ip = \''.$_SERVER['REMOTE_ADDR'].'\''; $ip_query = mysql_query($ip_check); $num_rows = mysql_num_rows($ip_query); if(!$num_rows) { //if no rows, meaning no ip's in db matched theirs, we will add them. $insert_new = mysql_query("INSERT INTO `online` (ip, time) VALUES ('$ip', '$time')"); } //end if NOT THERE //this means that they're already in there, so we update info. if($num_rows > 0) { $update = mysql_query('UPDATE `online` SET time=\''.time().'\' WHERE ip = \''.$_SERVER['REMOTE_ADDR'].'\''); if(!$update) die(mysql_error()); } // end UPDATE //if time now - start time > 300 then its been 5 minutes, so we delete $delete_old = mysql_query("DELETE FROM `online` WHERE ((".time()."-time) > 300)"); if(!$delete_old) die(mysql_error()); //end of whos online count // delete inactive users whos registration is more than 7 days $xToday = date('ymd'); $sExpired = mysql_query("SELECT * FROM user WHERE regExpire='".$xToday."' AND status IS NULL"); $nExpired = mysql_num_rows($sExpired); if ($nExpired != 0){ $dExpired = mysql_query("DELETE FROM user WHERE regExpire='".$xToday."' AND status IS NULL"); } ?> Motor Traders Association of Singapore onUnleoad="Javascript:window.location.href='index.php?action=logout';">
 
 
 
 
 
 
 
 
Main Page | Privacy Policy | Contact Us

Copyright 2013 Motor Traders Association of Singapore.
All rights reserved.