|
@ -43,9 +43,11 @@ class SessionModel extends Model |
|
|
preg_match('/user\|.+s:2:"id";s:(\d+):"(\d+)"/', $data, $match); |
|
|
preg_match('/user\|.+s:2:"id";s:(\d+):"(\d+)"/', $data, $match); |
|
|
$user_id = empty($match) ? 0 : (int) $match[2]; |
|
|
$user_id = empty($match) ? 0 : (int) $match[2]; |
|
|
|
|
|
|
|
|
$sql = 'INSERT INTO ' . $this->table() . ' (`id`, `expires`, `user_id`, `data`)' |
|
|
|
|
|
. ' VALUES(' . $this->quote($id) . ', UNIX_TIMESTAMP() + ' . (int) $this->life_time . ', ' . $user_id . ', ' . $this->quote($data) . ')' |
|
|
|
|
|
. ' ON DUPLICATE KEY UPDATE `expires`=UNIX_TIMESTAMP() + ' . (int) $this->life_time . ', `user_id`=' . $user_id . ', `data`=' . $this->quote($data); |
|
|
|
|
|
|
|
|
$ip = Env::Server('HTTP_X_FORWARDED_FOR', Env::Server('REMOTE_ADDR')); |
|
|
|
|
|
|
|
|
|
|
|
$sql = 'INSERT INTO ' . $this->table() . ' (`id`, `expires`, `ip`, `user_id`, `data`)' |
|
|
|
|
|
. ' VALUES(' . $this->quote($id) . ', UNIX_TIMESTAMP() + ' . (int) $this->life_time . ', INET_ATON(' . $this->quote($ip) . '), ' . $user_id . ', ' . $this->quote($data) . ')' |
|
|
|
|
|
. ' ON DUPLICATE KEY UPDATE `expires`=UNIX_TIMESTAMP() + ' . (int) $this->life_time . ', `ip`=INET_ATON(' . $this->quote($ip) . '), `user_id`=' . $user_id . ', `data`=' . $this->quote($data); |
|
|
$affected = $this->db->query($sql)->affectedRows(); |
|
|
$affected = $this->db->query($sql)->affectedRows(); |
|
|
return (bool) ($this->getInsertId()) ? $this->getInsertId() : $affected; |
|
|
return (bool) ($this->getInsertId()) ? $this->getInsertId() : $affected; |
|
|
} |
|
|
} |
|
|