From 8369ae020e71731705c76400ef7ba0f6281a15b6 Mon Sep 17 00:00:00 2001 From: Metabox Date: Tue, 23 Apr 2019 05:27:32 +1000 Subject: [PATCH] Added removeOldSessions --- htdocs/cgi-bin/login_ctr.cgi | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/htdocs/cgi-bin/login_ctr.cgi b/htdocs/cgi-bin/login_ctr.cgi index 41c0523..359e7ef 100755 --- a/htdocs/cgi-bin/login_ctr.cgi +++ b/htdocs/cgi-bin/login_ctr.cgi @@ -97,6 +97,9 @@ try{ print $cgi->header(-expires=>"0s", -charset=>"UTF-8", -cookie=>$cookie, -location=>"main.cgi"); return 1; } + else{ + &removeOldSessions; + } return 0; } catch{ @@ -222,4 +225,18 @@ sub populateConfig{ $st->execute(8,"SESSN_EXPR", $SESSN_EXPR); } + +sub removeOldSessions{ + opendir(DIR, $LOG_PATH); + my @files = grep(/cgisess_*/,readdir(DIR)); + closedir(DIR); + my $now = time - (24 * 60 * 60); + foreach my $file (@files) { + my $mod = (stat("$LOG_PATH/$file"))[9]; + if($mod<$now){ + unlink "$LOG_PATH/$file"; + } + } +} + ### CGI END \ No newline at end of file -- 2.34.1