X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=Util.pm;h=08a5f070ae891700ea52a7e6636ba3eeae9df852;hb=6565c4df864eaf8ebf23c1cb26cd5a3ac67ee585;hp=0ec02cddf526bdd3e8f6942495c56b65988579f5;hpb=84df47b464fcf0d1c1871445c19300a47efce79a;p=mirror%2Fuserdir-ldap-cgi.git diff --git a/Util.pm b/Util.pm index 0ec02cd..08a5f07 100644 --- a/Util.pm +++ b/Util.pm @@ -190,7 +190,7 @@ sub FetchKey { $fingerprint = "0x".$fingerprint; $/ = undef; # just suck it up .... - open(FP, "$config{gpg} --no-options --no-default-keyring $keyringparam --list-sigs --fingerprint $fingerprint|"); + open(FP, "$config{gpg} --no-options --no-default-keyring $keyringparam --check-sigs --fingerprint $fingerprint|"); $out = ; close FP; open(FP, "$config{gpg} --no-options --no-default-keyring $keyringparam --export -a $fingerprint|"); @@ -225,7 +225,7 @@ sub FormatLastSeen { $lastseen = (($d1 gt $d2) ? $lastseenpgp : $lastseenfrom); } - my ($date,$user,$list,$msgid) = ($lastseen =~ /^\[(.+?)\]\s+"(.+?)"\s+"(?:<(.+?)>.+?|\-)"\s+"<(.+?)>"/); + my ($date,$user,$list,$msgid) = ($lastseen =~ /^\[(.+?)\]\s+"(.+?)"\s+"(?:<(.+?)>.*?|\-)"\s+"<(.+?)>"/); $list = "on $list" if ($list); return "$date $list
 Message ID: $msgid"; } @@ -278,6 +278,38 @@ sub CheckLatLong { } } +sub FixParams { + my $query = shift; + my $key; + my @names = $query->param; + + foreach $key (@names) { # web security is a joke ... + $_ = $query->param($key); + s/&/&/g; + s/[<\x8B]/</g; + s/[>\x9B]/>/g; + + $query->param($key, $_); + } +} + + +sub LDAPUpdate { + my $ldap = shift; + my $dn = shift; + my $attr = shift; + my $val = shift; + my $mesg; + + if (!$val) { + $mesg = $ldap->modify($dn, delete => { $attr => [] }); + } else { + $val = [ $val ] if (!ref($val)); + $mesg = $ldap->modify($dn, replace => { $attr => $val }); + $mesg->code && &Util::HTMLError("error updating $attr: ".$mesg->error); + } +} + ################### # Config file stuff sub ReadConfigFile {