bob_the _builder Posted June 19, 2007 Share Posted June 19, 2007 Hi I have made a script to show how many people on line and the most users at one time: <?php putenv("TZ=Pacific/Auckland"); $insertdate = date('Y-m-d H:i:s'); $limit_time = time() - 300; if(!session_is_registered('online')){ mysql_query("INSERT INTO ppl_online (session_id, activity, ip_address, refurl, user_agent) VALUES ('".session_id()."', '$insertdate', '".$_SERVER['REMOTE_ADDR']."', '".$_SERVER['HTTP_REFERER']."', '".$_SERVER['HTTP_USER_AGENT']."')"); session_register('online'); } if(session_is_registered('online')){ mysql_query("UPDATE ppl_online SET activity='$insertdate' WHERE session_id='".session_id()."'"); } $inactive = time() - 1800; mysql_query ("DELETE FROM ppl_online WHERE UNIX_TIMESTAMP(activity) < $inactive"); $total = mysql_query("SELECT * FROM ppl_online WHERE UNIX_TIMESTAMP(activity) >= $limit_time GROUP BY ip_address"); $totalonline = mysql_num_rows($total); $most = mysql_query("SELECT * FROM most_users"); while($row = mysql_fetch_array($most)){ $most_users = $row['total']; $most_date = date('D dS M Y, h:i a', strtotime($row['date'])); } if ($totalonline > $most_users) { $sql = mysql_query("UPDATE most_users SET total='$totalonline', date='$insertdate' WHERE id=1"); } ?> Since adding: putenv("TZ=Pacific/Auckland"); $insertdate = date('Y-m-d H:i:s'); To the script it seems to total all the users that have been online even it it was 10 minutes ago. How can I fix this? Thanks Link to comment https://forums.phpfreaks.com/topic/56148-users-online/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.