diff options
author | Loui Chang <louipc.ist@gmail.com> | 2008-11-13 21:18:48 +0100 |
---|---|---|
committer | Loui Chang <louipc.ist@gmail.com> | 2008-11-13 21:18:48 +0100 |
commit | cf2a82fe8578bd10187157bd884b3f109f0b5201 (patch) | |
tree | c0ddb531431b66d1538b1493ed909f425e0f9f64 | |
parent | 53bb32a15a7b34ebe95c52b6e31d4cd9666d4ae6 (diff) | |
download | aur-cf2a82fe8578bd10187157bd884b3f109f0b5201.tar.gz aur-cf2a82fe8578bd10187157bd884b3f109f0b5201.tar.xz |
Clear out old expired sessions on log out.
Signed-off-by: Loui Chang <louipc.ist@gmail.com>
-rw-r--r-- | web/html/logout.php | 7 | ||||
-rw-r--r-- | web/lib/acctfuncs.inc | 14 |
2 files changed, 15 insertions, 6 deletions
diff --git a/web/html/logout.php b/web/html/logout.php index c1c376c6..41dedc37 100644 --- a/web/html/logout.php +++ b/web/html/logout.php @@ -3,7 +3,7 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR . '../lang'); include("aur.inc"); # access AUR common functions -include("pkgfuncs_po.inc"); # Add to handle the i18n of My Packages +include_once("acctfuncs.inc"); # access AUR common functions include("logout_po.inc"); # use some form of this for i18n support set_lang(); # this sets up the visitor's language @@ -19,8 +19,7 @@ if (isset($_COOKIE["AURSID"])) { setcookie("AURLANG", "", time() - (60*60*24*30), "/"); } +clear_expired_sessions(); + header('Location: index.php'); -exit; -html_footer(AUR_VERSION); -?> diff --git a/web/lib/acctfuncs.inc b/web/lib/acctfuncs.inc index 73db2708..d0b6b0ac 100644 --- a/web/lib/acctfuncs.inc +++ b/web/lib/acctfuncs.inc @@ -625,7 +625,6 @@ function try_login() { $num_tries = 0; # Account looks good. Generate a SID and store it. - # $dbh = db_connect(); while (!$logged_in && $num_tries < 5) { @@ -790,4 +789,15 @@ function user_is_privileged( $id ) } -?> +# Clear out old expired sessions. +function clear_expired_sessions($dbh) { + global $LOGIN_TIMEOUT; + + if (empty($dbh)) + $dbh = db_connect(); + + $q = "DELETE FROM Sessions WHERE LastUpdateTS < (UNIX_TIMESTAMP() - $LOGIN_TIMEOUT)"; + db_query($q, $dbh); + + return; +} |