|
|
@ -38,11 +38,10 @@ function sess_read($key)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
global $DB, $SESS_CHANGED;
|
|
|
|
global $DB, $SESS_CHANGED;
|
|
|
|
|
|
|
|
|
|
|
|
$sql_result = $DB->query(sprintf("SELECT vars, ip, UNIX_TIMESTAMP(changed) AS changed
|
|
|
|
$sql_result = $DB->query("SELECT vars, ip, ".$DB->unixtimestamp('changed')." AS changed
|
|
|
|
FROM %s
|
|
|
|
FROM ".get_table_name('session')."
|
|
|
|
WHERE sess_id='%s'",
|
|
|
|
WHERE sess_id=?",
|
|
|
|
get_table_name('session'),
|
|
|
|
$key);
|
|
|
|
$key));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($sql_arr = $DB->fetch_assoc($sql_result))
|
|
|
|
if ($sql_arr = $DB->fetch_assoc($sql_result))
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -61,32 +60,29 @@ function sess_write($key, $vars)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
global $DB;
|
|
|
|
global $DB;
|
|
|
|
|
|
|
|
|
|
|
|
$sql_result = $DB->query(sprintf("SELECT 1
|
|
|
|
$sql_result = $DB->query("SELECT 1
|
|
|
|
FROM %s
|
|
|
|
FROM ".get_table_name('session')."
|
|
|
|
WHERE sess_id='%s'",
|
|
|
|
WHERE sess_id=?",
|
|
|
|
get_table_name('session'),
|
|
|
|
$key);
|
|
|
|
$key));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($DB->num_rows($sql_result))
|
|
|
|
if ($DB->num_rows($sql_result))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
session_decode($vars);
|
|
|
|
session_decode($vars);
|
|
|
|
$DB->query(sprintf("UPDATE %s
|
|
|
|
$DB->query("UPDATE ".get_table_name('session')."
|
|
|
|
SET vars='%s',
|
|
|
|
SET vars=?,
|
|
|
|
changed=NOW()
|
|
|
|
changed=NOW()
|
|
|
|
WHERE sess_id='%s'",
|
|
|
|
WHERE sess_id=?",
|
|
|
|
get_table_name('session'),
|
|
|
|
|
|
|
|
$vars,
|
|
|
|
$vars,
|
|
|
|
$key));
|
|
|
|
$key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$DB->query(sprintf("INSERT INTO %s
|
|
|
|
$DB->query("INSERT INTO ".get_table_name('session')."
|
|
|
|
(sess_id, vars, ip, created, changed)
|
|
|
|
(sess_id, vars, ip, created, changed)
|
|
|
|
VALUES ('%s', '%s', '%s', NOW(), NOW())",
|
|
|
|
VALUES (?, ?, ?, NOW(), NOW())",
|
|
|
|
get_table_name('session'),
|
|
|
|
|
|
|
|
$key,
|
|
|
|
$key,
|
|
|
|
$vars,
|
|
|
|
$vars,
|
|
|
|
$_SERVER['REMOTE_ADDR']));
|
|
|
|
$_SERVER['REMOTE_ADDR']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
return TRUE;
|
|
|
@ -98,16 +94,14 @@ function sess_destroy($key)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
global $DB;
|
|
|
|
global $DB;
|
|
|
|
|
|
|
|
|
|
|
|
$DB->query(sprintf("DELETE FROM %s
|
|
|
|
// delete session entries in cache table
|
|
|
|
WHERE sess_id='%s'",
|
|
|
|
$DB->query("DELETE FROM ".get_table_name('cache')."
|
|
|
|
get_table_name('session'),
|
|
|
|
WHERE session_id=?",
|
|
|
|
$key));
|
|
|
|
$key);
|
|
|
|
|
|
|
|
|
|
|
|
// also delete session entries in cache table
|
|
|
|
$DB->query("DELETE FROM ".get_table_name('session')."
|
|
|
|
$DB->query(sprintf("DELETE FROM %s
|
|
|
|
WHERE sess_id=?",
|
|
|
|
WHERE session_id='%s'",
|
|
|
|
$key);
|
|
|
|
get_table_name('cache'),
|
|
|
|
|
|
|
|
$key));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -119,11 +113,10 @@ function sess_gc($maxlifetime)
|
|
|
|
global $DB;
|
|
|
|
global $DB;
|
|
|
|
|
|
|
|
|
|
|
|
// get all expired sessions
|
|
|
|
// get all expired sessions
|
|
|
|
$sql_result = $DB->query(sprintf("SELECT sess_id
|
|
|
|
$sql_result = $DB->query("SELECT sess_id
|
|
|
|
FROM %s
|
|
|
|
FROM ".get_table_name('session')."
|
|
|
|
WHERE UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(created) > %d",
|
|
|
|
WHERE ".$DB->unixtimestamp('NOW()')."-".$DB->unixtimestamp('created')." > ?",
|
|
|
|
get_table_name('session'),
|
|
|
|
$maxlifetime);
|
|
|
|
$maxlifetime));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$a_exp_sessions = array();
|
|
|
|
$a_exp_sessions = array();
|
|
|
|
while ($sql_arr = $DB->fetch_assoc($sql_result))
|
|
|
|
while ($sql_arr = $DB->fetch_assoc($sql_result))
|
|
|
@ -132,17 +125,13 @@ function sess_gc($maxlifetime)
|
|
|
|
|
|
|
|
|
|
|
|
if (sizeof($a_exp_sessions))
|
|
|
|
if (sizeof($a_exp_sessions))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
// delete session cache records
|
|
|
|
|
|
|
|
$DB->query("DELETE FROM ".get_table_name('cache')."
|
|
|
|
|
|
|
|
WHERE session_id IN ('".join("','", $a_exp_sessions)."')");
|
|
|
|
|
|
|
|
|
|
|
|
// delete session records
|
|
|
|
// delete session records
|
|
|
|
$DB->query(sprintf("DELETE FROM %s
|
|
|
|
$DB->query("DELETE FROM ".get_table_name('session')."
|
|
|
|
WHERE sess_id IN ('%s')",
|
|
|
|
WHERE sess_id IN ('".join("','", $a_exp_sessions)."')");
|
|
|
|
get_table_name('session'),
|
|
|
|
|
|
|
|
join("','", $a_exp_sessions)));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// also delete session cache records
|
|
|
|
|
|
|
|
$DB->query(sprintf("DELETE FROM %s
|
|
|
|
|
|
|
|
WHERE session_id IN ('%s')",
|
|
|
|
|
|
|
|
get_table_name('cache'),
|
|
|
|
|
|
|
|
join("','", $a_exp_sessions)));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
return TRUE;
|
|
|
|