From 609f855217afba087210f13aae12f08c589823ba Mon Sep 17 00:00:00 2001 From: jengo Date: Sat, 31 Mar 2001 08:11:41 +0000 Subject: [PATCH] Added session_dla field to phpgw_app_sessions to make sure things get cleaned up --- phpgwapi/inc/class.sessions.inc.php | 24 +++++++++++++++++------- setup/sql/mysql_newtables.inc.php | 5 +++-- setup/sql/mysql_upgrade_beta.inc.php | 26 ++++++++++++++++++-------- setup/sql/pgsql_newtables.inc.php | 5 +++-- setup/sql/pgsql_upgrade_beta.inc.php | 11 +++++++++++ version.inc.php | 24 ++++++++++++------------ 6 files changed, 64 insertions(+), 31 deletions(-) diff --git a/phpgwapi/inc/class.sessions.inc.php b/phpgwapi/inc/class.sessions.inc.php index 7496f3fa44..dbefd55c51 100644 --- a/phpgwapi/inc/class.sessions.inc.php +++ b/phpgwapi/inc/class.sessions.inc.php @@ -185,11 +185,18 @@ { global $phpgw_info, $phpgw; - if (!isset($phpgw_info['server']['cron_apps']) || ! $phpgw_info['server']['cron_apps']) - { + // If you plan on using the cron apps, please remove the following lines. + // I am going to make this a config option durring 0.9.11, instead of an application (jengo) + +// if (! isset($phpgw_info['server']['cron_apps']) || ! $phpgw_info['server']['cron_apps']) +// { $phpgw->db->query("delete from phpgw_sessions where session_dla <= '" . (time() - 7200) . "' and session_flags !='A'",__LINE__,__FILE__); - } + + // This is set a little higher, we don't want to kill session data for anonymous sessions. + $phpgw->db->query("delete from phpgw_app_sessions where session_dla <= '" . (time() - 86400) + . "'",__LINE__,__FILE__); +// } } function create($login,$passwd) @@ -298,8 +305,11 @@ { global $phpgw_info, $phpgw, $PHP_SELF; - $phpgw->db->query("update phpgw_sessions set session_dla='" . time() . "', session_action='$PHP_SELF'" - . " where session_id='" . $this->sessionid."'",__LINE__,__FILE__); + $phpgw->db->query("update phpgw_sessions set session_dla='" . time() . "', session_action='$PHP_SELF' " + . "where session_id='" . $this->sessionid."'",__LINE__,__FILE__); + + $phpgw->db->query("update phpgw_app_sessions set session_dla='" . time() . "' " + . "where sessionid='" . $this->sessionid."'",__LINE__,__FILE__); } function destroy() @@ -409,9 +419,9 @@ $data = serialize($data); $data = $phpgw->crypto->encrypt($data); - $phpgw->db->query("INSERT INTO phpgw_app_sessions (sessionid,loginid,app,location,content) " + $phpgw->db->query("INSERT INTO phpgw_app_sessions (sessionid,loginid,app,location,content,session_dla) " . "VALUES ('".$this->sessionid."','".$this->account_id."','".$appname - . "','".$location."','".$data."')",__LINE__,__FILE__); + . "','".$location."','".$data."','" . time() . "')",__LINE__,__FILE__); } else { $data = $phpgw->crypto->encrypt(serialize($data)); $phpgw->db->query("update phpgw_app_sessions set content = '".$data."'" diff --git a/setup/sql/mysql_newtables.inc.php b/setup/sql/mysql_newtables.inc.php index aa94f68538..09cbf4fc48 100644 --- a/setup/sql/mysql_newtables.inc.php +++ b/setup/sql/mysql_newtables.inc.php @@ -78,7 +78,8 @@ loginid varchar(20), location varchar(255), app varchar(20), - content text + content text, + session_dla int )"; $phpgw_setup->db->query($sql); @@ -346,7 +347,7 @@ )"; $phpgw_setup->db->query($sql); - $phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre25'; + $phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre26'; $phpgw_info['setup']['oldver']['phpgwapi'] = $phpgw_info['setup']['currentver']['phpgwapi']; update_version_table(); // $phpgw_setup->update_version_table(); diff --git a/setup/sql/mysql_upgrade_beta.inc.php b/setup/sql/mysql_upgrade_beta.inc.php index 1c5b0e07ed..6a0e901bf8 100644 --- a/setup/sql/mysql_upgrade_beta.inc.php +++ b/setup/sql/mysql_upgrade_beta.inc.php @@ -1396,17 +1396,27 @@ $phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre24'; } - $test[] = '0.9.10pre24'; - function upgrade0_9_10pre24() - { - global $phpgw_info, $phpgw_setup; + $test[] = '0.9.10pre24'; + function upgrade0_9_10pre24() + { + global $phpgw_info, $phpgw_setup; - $sql = "alter table phpgw_categories add column cat_access char(7) after cat_owner"; + $sql = "alter table phpgw_categories add column cat_access char(7) after cat_owner"; + $phpgw_setup->db->query($sql,__LINE__,__FILE__); - $phpgw_setup->db->query($sql,__LINE__,__FILE__); + $phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre25'; + } - $phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre25'; - } + $test[] = '0.9.10pre25'; + function upgrade0_9_10pre25() + { + global $phpgw_info, $phpgw_setup; + + $phpgw_setup->db->query("alter table phpgw_app_sessions add column session_dla int",__LINE__,__FILE__); + + $phpgw_setup->db->query($sql); + $phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre26'; + } reset ($test); while (list ($key, $value) = each ($test)){ diff --git a/setup/sql/pgsql_newtables.inc.php b/setup/sql/pgsql_newtables.inc.php index f66432480b..2f19b2739e 100644 --- a/setup/sql/pgsql_newtables.inc.php +++ b/setup/sql/pgsql_newtables.inc.php @@ -77,7 +77,8 @@ loginid varchar(20), location varchar(255), app varchar(20), - content text + content text, + session_dla int )"; $phpgw_setup->db->query($sql); @@ -314,7 +315,7 @@ )"; $phpgw_setup->db->query($sql); - $phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre25'; + $phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre26'; $phpgw_info['setup']['oldver']['phpgwapi'] = $phpgw_info['setup']['currentver']['phpgwapi']; update_version_table(); ?> diff --git a/setup/sql/pgsql_upgrade_beta.inc.php b/setup/sql/pgsql_upgrade_beta.inc.php index 266e6626dd..28d818d782 100644 --- a/setup/sql/pgsql_upgrade_beta.inc.php +++ b/setup/sql/pgsql_upgrade_beta.inc.php @@ -1785,6 +1785,17 @@ $phpgw_info["setup"]["currentver"]["phpgwapi"] = "0.9.10pre25"; } + $test[] = '0.9.10pre25'; + function upgrade0_9_10pre25() + { + global $phpgw_info, $phpgw_setup; + + $phpgw_setup->db->query("alter table phpgw_app_sessions add column session_dla int",__LINE__,__FILE__); + + $phpgw_setup->db->query($sql); + $phpgw_info['setup']['currentver']['phpgwapi'] = '0.9.10pre26'; + } + reset ($test); while (list ($key, $value) = each ($test)){ if ($phpgw_info["setup"]["currentver"]["phpgwapi"] == $value) { diff --git a/version.inc.php b/version.inc.php index d01f8f953d..9c1954a265 100644 --- a/version.inc.php +++ b/version.inc.php @@ -1,15 +1,15 @@