X-Git-Url: https://git.sthu.org/?p=pgp-tools.git;a=blobdiff_plain;f=keyanalyze%2Fscripts%2Ftop50.pl;h=5a30de65b00e93539f1397e824dbb0ef1138d7b7;hp=0bfe47f47d11095052248de9987afdc0075a845a;hb=399de2651b9ae515825eb9a261fe87a213274de1;hpb=9827f766ec8dacf50e3bca40b27c0c45a21de970 diff --git a/keyanalyze/scripts/top50.pl b/keyanalyze/scripts/top50.pl index 0bfe47f..5a30de6 100755 --- a/keyanalyze/scripts/top50.pl +++ b/keyanalyze/scripts/top50.pl @@ -1,33 +1,72 @@ -#!/usr/bin/perl +#!/usr/bin/perl -w # this short script is for making the HTML for the top50 report monthly # Copyright (c)2001 M. Drew Streib # This code is released under the GPL version 2 or later. -# NOTE: this is designed to be run one directory up, from analyze.sh - -while ($line = ) { - $line =~ /\s+(\d+)\s+((\w|\d)+)\s+((\w|\d)+)\s+((\d|\.)+)/; - $rank = $1; - $key0 = $2; - $key = $4; - $msd = $6; - $command = 'wget -O - -q "http://pgp.dtype.org:11371/pks/lookup?search=0x' - .$key.'&op=index"'; - $wget = `$command`; - $command = 'grep "'.$key.'" scripts/top50comments.txt'; - $rawcomments = `$command`; - if (!($wget =~ /\d\d\d\d\/\d\d\/\d\d (.*)( \<.*)\n/)) { - $wget =~ /\d\d\d\d\/\d\d\/\d\d (.*)/; - $name = $1; - } - else { - $name = $1; +# 2004-09-14: modifications by Christoph Berg : +# * use perl to read top50comments.txt +# * use gpg --list-key instead of wget +# * use strict & warnings + +# 2008-07-18: modifications by Christoph Berg : +# * directly read msd.txt instead of a -sorted variant + +use strict; +use Getopt::Std; + +#my $keyserver = "http://pks.gpg.cz:11371/pks/lookup?op=vindex&fingerprint=on&search=0x"; +#my $keyserver = "http://keyserver.noreply.org/pks/lookup?op=index&fingerprint=on&search=0x"; +my $keyserver = "http://subkeys.pgp.net:11371/pks/lookup?op=index&fingerprint=on&search=0x"; +my %options; +getopts('c:k:n:', \%options); +my $comments = $options{c} || "top50comments.txt"; +my $keyring = $options{k} ? "--no-default-keyring --keyring=$options{k}" : ""; +my $top = $options{n} || 50; + +my %comment; +if (open F, $comments) { + while() { + die "$comments.$.: syntax error" unless /([\dA-F]+)\b ?(.*)/; + $comment{$1} = $2; } - if ($rawcomments) { - $rawcomments =~ /(\w|\d)+\s(.*)/; - $comments = $2; - } else { - $comments = ''; + close F; +} + +my %msd; +while (my $line = <>) { + $line =~ /^\w+\s+(\w+)\s+([\d\.]+)/ or die "cannot parse line $.: $_"; + $msd{$1} = $2; +} + +print "\n"; +print "\n"; + +my $oldmsd = 0; +my $i = 1; +foreach my $key (sort { $msd{$a} <=> $msd{$b} } keys %msd) { + my $rank = ""; + if($oldmsd != $msd{$key}) { + $rank = $i++; } - print "\n"; + last if $rank and $rank > $top; + $oldmsd = $msd{$key}; + my $name = ""; + open G, "gpg --list-key --fixed-list-mode --with-colon --trust-model always $keyring $key |" or die "gpg: $!"; + while() { + #uid:u::::1082202576::1DC0BEA2AC64671CC902D50B8121F6E4E6336E15::Christoph Berg : + next unless /^uid:[-qmfue]::::\d*::[\dA-F]*::(.+):$/; + $name = $1; + $name =~ s//>/g; + $name =~ s/\@/@/g; + last; + } + close G; + my $comment = $comment{$key} || ""; + $key =~ /^([\dA-F]{2})/; + #my $prefix = $1; + #print "\n"; + print "\n"; } + +print "
#IdNameMSD
$rank$key$name$comments$msd
$rank$key keyserver$name$comment$msd
$rank$keykeyserver$name $comment$msd{$key}
\n";