From 2c15a5ecbc6628727ba1db09b71dd61a857b8f0a Mon Sep 17 00:00:00 2001 From: Will Budic Date: Wed, 8 Jan 2020 10:14:13 +1100 Subject: [PATCH] added removeOldSessions subrotine. --- htdocs/cgi-bin/system/modules/Settings.pm | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/htdocs/cgi-bin/system/modules/Settings.pm b/htdocs/cgi-bin/system/modules/Settings.pm index ee87226..ec4b6c5 100644 --- a/htdocs/cgi-bin/system/modules/Settings.pm +++ b/htdocs/cgi-bin/system/modules/Settings.pm @@ -170,4 +170,17 @@ sub toLog { # } } +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"; + } + } +} + 1; \ No newline at end of file -- 2.34.1