1
sklic
Re: Session Bug Patch
  • 2004/1/13 7:58

  • sklic

  • Just popping in

  • Posts: 1

  • Since: 2004/1/13


I ran into the same problem, as well as the problem that when I login as a Member, the Anonymous version of me still stays in the who's online, so I end up with multiple copies of my IP address in the who's online "more..." window. I changed the session.php file as follows and it seems to have fixed all these problems. It makes the online module track a user based on not only uid but also ip address. That way Anonymous users are automatically replaced when a user logs in from that IP addy, and visa versa. I'm not sure what this will do if multiple computers use the same IP address, such as some NAT/firewall instance. But here was my fix for kernel/online.php:

Quote:

function write($uid, $uname, $time, $module, $ip)
{
$uid = intval($uid);
$sql = "SELECT COUNT(*) FROM ".$this->db->prefix('online')." WHERE online_ip='".$ip."'";
//if ($uid > 0) {
// $sql = "SELECT COUNT(*) FROM ".$this->db->prefix('online')." WHERE online_uid=".$uid;
//} else {
// $sql = "SELECT COUNT(*) FROM ".$this->db->prefix('online')." WHERE online_uid=".$uid." AND online_ip='".$ip."'";
//}
list($count) = $this->db->fetchRow($this->db->queryF($sql));
if ( $count > 0 ) {
$sql = "UPDATE ".$this->db->prefix('online')." SET online_uid=".$uid.", online_uname='".$uname."', online_updated=".$time.", online_module = ".$module." WHERE online_ip = '".$ip."'";
//$sql = "UPDATE ".$this->db->prefix('online')." SET online_updated=".$time.", online_module = ".$module." WHERE online_uid = ".$uid;
//if ($uid == 0) {
// $sql .= "AND online_ip='".$ip."'";
//}
} else {
$sql = sprintf("INSERT INTO %s (online_uid, online_uname, online_updated, online_ip, online_module) VALUES (%u, %s, %u, %s, %u)", $this->db->prefix('online'), $uid, $this->db->quoteString($uname), $time, $this->db->quoteString($ip), $module);
}
if (!$this->db->queryF($sql)) {
return false;
}
return true;
}

I'm sure the professionals can find a cleaner way to do this, and one that incorporates firewall issues. I think the Who's Online section definitely needs some of this kind of work considering how many problems have been posting regarding problems with it.




TopTop



Login

Who's Online

247 user(s) are online (174 user(s) are browsing Support Forums)


Members: 0


Guests: 247


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits