diff options
| author | Guilhem Moulin <guilhem@fripost.org> | 2018-09-02 04:57:06 +0200 | 
|---|---|---|
| committer | Guilhem Moulin <guilhem@fripost.org> | 2018-09-02 04:57:06 +0200 | 
| commit | c3af385908866291109afb8cf8779da555a9922a (patch) | |
| tree | 026c391d83c32e99af4332ab99ca91541ee56717 /purge | |
| parent | a0d7989835c98e9f0cb30a732e434d6b180afae4 (diff) | |
Simple login screen.
Diffstat (limited to 'purge')
| -rwxr-xr-x | purge | 58 | 
1 files changed, 58 insertions, 0 deletions
| @@ -0,0 +1,58 @@ +#!/usr/bin/perl -T + +#---------------------------------------------------------------------- +# Fripost's admin panel - session prune job +# Copyright © 2018 Fripost +# Copyright © 2018 Guilhem Moulin <guilhem@fripost.org> +# +# 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 <http://www.gnu.org/licenses/>. +#---------------------------------------------------------------------- + +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"; +} | 
