session.inc.php (ISPConfig-3.2.6) | : | session.inc.php (ISPConfig-3.2.7) | ||
---|---|---|---|---|
skipping to change at line 73 | skipping to change at line 73 | |||
if (!empty($this->session_array)) { | if (!empty($this->session_array)) { | |||
$result = $this->gc(ini_get('session.gc_maxlifetime')); | $result = $this->gc(ini_get('session.gc_maxlifetime')); | |||
return $result; | return $result; | |||
} | } | |||
return false; | return false; | |||
} | } | |||
function read ($session_id) { | function read ($session_id) { | |||
if($this->timeout > 0) { | if($this->timeout > 0) { | |||
$rec = $this->db->queryOneRecord("SELECT * FROM sys_sessi on WHERE session_id = ? AND (`permanent` = 'y' OR last_updated >= DATE_SUB(NOW() , INTERVAL ? MINUTE))", $session_id, $this->timeout); | $rec = $this->db->queryOneRecord("SELECT * FROM sys_sessi on WHERE session_id = ? AND (`permanent` = 'y' OR last_updated >= DATE_SUB(NOW() , INTERVAL ? MINUTE))", (string)$session_id, $this->timeout); | |||
} else { | } else { | |||
$rec = $this->db->queryOneRecord("SELECT * FROM sys_sessi on WHERE session_id = ?", $session_id); | $rec = $this->db->queryOneRecord("SELECT * FROM sys_sessi on WHERE session_id = ?", (string)$session_id); | |||
} | } | |||
if (is_array($rec)) { | if (is_array($rec)) { | |||
$this->session_array = $rec; | $this->session_array = $rec; | |||
return $this->session_array['session_data']; | return $this->session_array['session_data']; | |||
} else { | } else { | |||
return ''; | return ''; | |||
} | } | |||
} | } | |||
function write ($session_id, $session_data) { | function write ($session_id, $session_data) { | |||
if (!empty($this->session_array) && $this->session_array['session _id'] != $session_id) { | if (!empty($this->session_array) && $this->session_array['session _id'] != $session_id) { | |||
$this->session_array = array(); | $this->session_array = array(); | |||
} | } | |||
// Dont write session_data to DB if session data has not been cha nged after reading it. | // Dont write session_data to DB if session data has not been cha nged after reading it. | |||
if(isset($this->session_array['session_data']) && $this->session_ array['session_data'] != '' && $this->session_array['session_data'] == $session_ data) { | if(isset($this->session_array['session_data']) && $this->session_ array['session_data'] != '' && $this->session_array['session_data'] == $session_ data) { | |||
$this->db->query("UPDATE sys_session SET last_updated = N OW() WHERE session_id = ?", $session_id); | $this->db->query("UPDATE sys_session SET last_updated = N OW() WHERE session_id = ?", (string)$session_id); | |||
return true; | return true; | |||
} | } | |||
if (@$this->session_array['session_id'] == '') { | if (@$this->session_array['session_id'] == '') { | |||
$sql = "REPLACE INTO sys_session (session_id,date_created ,last_updated,session_data,permanent) VALUES (?,NOW(),NOW(),?,?)"; | $sql = "REPLACE INTO sys_session (session_id,date_created ,last_updated,session_data,permanent) VALUES (?,NOW(),NOW(),?,?)"; | |||
$this->db->query($sql, $session_id, $session_data, ($this ->permanent ? 'y' : 'n')); | $this->db->query($sql, (string)$session_id, $session_data , ($this->permanent ? 'y' : 'n')); | |||
} else { | } else { | |||
$sql = "UPDATE sys_session SET last_updated = NOW(), sess ion_data = ?" . ($this->permanent ? ", `permanent` = 'y'" : "") . " WHERE sessio n_id = ?"; | $sql = "UPDATE sys_session SET last_updated = NOW(), sess ion_data = ?" . ($this->permanent ? ", `permanent` = 'y'" : "") . " WHERE sessio n_id = ?"; | |||
$this->db->query($sql, $session_data, $session_id); | $this->db->query($sql, $session_data, (string)$session_id ); | |||
} | } | |||
return true; | return true; | |||
} | } | |||
function destroy ($session_id) { | function destroy ($session_id) { | |||
$sql = "DELETE FROM sys_session WHERE session_id = ?"; | $sql = "DELETE FROM sys_session WHERE session_id = ?"; | |||
$this->db->query($sql, $session_id); | $this->db->query($sql, (string)$session_id); | |||
return true; | return true; | |||
} | } | |||
function gc ($max_lifetime) { | function gc ($max_lifetime) { | |||
$sql = "DELETE FROM sys_session WHERE last_updated < DATE_SUB(NOW (), INTERVAL ? SECOND) AND `permanent` != 'y'"; | $sql = "DELETE FROM sys_session WHERE last_updated < DATE_SUB(NOW (), INTERVAL ? SECOND) AND `permanent` != 'y'"; | |||
$this->db->query($sql, intval($max_lifetime)); | $this->db->query($sql, intval($max_lifetime)); | |||
/* delete very old even if they are permanent */ | /* delete very old even if they are permanent */ | |||
End of changes. 6 change blocks. | ||||
6 lines changed or deleted | 6 lines changed or added |