From c3af385908866291109afb8cf8779da555a9922a Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Sun, 2 Sep 2018 04:57:06 +0200 Subject: Simple login screen. --- purge | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100755 purge (limited to 'purge') diff --git a/purge b/purge new file mode 100755 index 0000000..32f178c --- /dev/null +++ b/purge @@ -0,0 +1,58 @@ +#!/usr/bin/perl -T + +#---------------------------------------------------------------------- +# Fripost's admin panel - session prune job +# Copyright © 2018 Fripost +# Copyright © 2018 Guilhem Moulin +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +#---------------------------------------------------------------------- + +use strict; +use warnings; + +use lib "lib"; +use Fripost::Util "read_config"; + +my %CONFIG = read_config(); +$CONFIG{www} //= {}; + +my $cache = Fripost::Util::session_cache(%{$CONFIG{www}}); + +if (-t \*STDOUT) { + my $count = 0; + my $count_expired = 0; + require "POSIX.pm"; + + foreach my $k ($cache->get_keys()) { + $count++; + my $obj = $cache->get_object($k) // next; + if ($obj->is_expired) { + $count_expired++; + my $date = POSIX::strftime("%Y-%m-%d %T %z", + localtime($obj->expires_at())); + printf " - %-32s expired on %s\n", $k, $date; + } + } + print "$count keys founds (incl. $count_expired expired keys)\n"; + print "Purging...\n" +} + +$cache->purge(); + +if (-t \*STDOUT) { + my $count = 0; + $count++ foreach $cache->get_keys(); + print "$count keys left after purge()\n"; +} -- cgit v1.2.3