Jump to content

Users Online


Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.