X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;ds=sidebyside;f=web%2FUtil.pm;h=6117a4e6b9b60515dc462df53678ac30e2177b72;hb=e9fb8e4029022dfae6792f8dcc680792bc431c2e;hp=1127c63d9f1f32e8f7ab7368779b159fe8219227;hpb=3745d115c3acf579e60479dd27efcf7871718294;p=mirror%2Fuserdir-ldap.git diff --git a/web/Util.pm b/web/Util.pm index 1127c63..6117a4e 100644 --- a/web/Util.pm +++ b/web/Util.pm @@ -2,6 +2,7 @@ package Util; use strict; +use Date::Manip qw(ParseDate); my $blocksize = 8; # A blowfish block is 8 bytes my $configfile = "/etc/userdir-ldap/userdir-ldap.conf"; @@ -203,6 +204,28 @@ sub FormatTimestamp { return sprintf("%04d/%02d/%02d %02d:%02d:%02d UTC", $1,$2,$3,$4,$5,$6); } +sub FormatLastSeen { +# Format: +# [Tue, 11 Jan 2000 02:37:18] "Joey Hess " " archive/latest/7130" "<20000110181924.H19910@kitenet.net>" +# [Mon, 10 Jan 2000 21:48:19] "9E1E 1052 F8BB A351 0606 5527 50BB 2974 2D59 A7D2" " archive/latest/58632" "<20000110200506.13257.qmail@master.debian.org>" + my $lastseenpgp = shift; + my $lastseenfrom = shift; + my ($d1, $d2, $lastseen); + + return "No activity detected" if (!$lastseenpgp && !$lastseenfrom); + $lastseen = $lastseenfrom if (!$lastseenpgp); + + if ($lastseenfrom && $lastseenpgp) { + ($d1) = ($lastseenpgp =~ /^\[(.+?)\]/); $d1 = ParseDate($d1); + ($d2) = ($lastseenfrom =~ /^\[(.+?)\]/); $d2 = ParseDate($d2); + $lastseen = (($d1 gt $d2) ? $lastseenpgp : $lastseenfrom); + } + + my ($date,$user,$list,$msgid) = ($lastseen =~ /^\[(.+?)\]\s+"(.+?)"\s+"(?:<(.+?)>.+?|\-)"\s+"<(.+?)>"/); + $list = "on $list" if ($list); + return "$date $list
 Message ID: $msgid"; +} + sub LookupCountry { my $in = shift; my ($abbrev, $country);