update-mirrors.pl
532901be
 #!/usr/bin/perl -w
 use warnings;
 use strict;
 use LWP::Simple;
 use LWP;
 use Date::Parse;
759dd463
 use Date::Format;
532901be
 
238e706b
 #
 # A quick hack by Jacob Appelbaum <jacob@appelbaum.net>
940ab031
 # LWP suggestions by Leigh Honeywell
238e706b
 # This is Free Software (GPLv3)
 # http://www.gnu.org/licenses/gpl-3.0.txt
 #
838938ca
 # CHANGELOG
 # 20091003 Code changes to elimiate the need for a trailing slash in addresses for script runtime
 # 20091004 Code changes to increase out of date tolerance to 48 hours
 # 20091028 Code changes to increase timout to 30 seconds (attempting to # resolve "unknown" status')
 # 20091028 Code changes to change user agent of script
 # 20100807 Remove dead mirrors.
238e706b
 
532901be
 print "Creating LWP agent ($LWP::VERSION)...\n";
 my $lua = LWP::UserAgent->new(
     keep_alive => 1,
55e27233
     timeout => 30,
69c4ddc9
     agent => "Tor MirrorCheck Agent"
532901be
 );
 
 sub sanitize {
     my $taintedData = shift;
     my $cleanedData;
     my $whitelist = '-a-zA-Z0-9: +';
 
     # clean the data, return cleaned data
     $taintedData =~ s/[^$whitelist]//go;
     $cleanedData = $taintedData;
 
     return $cleanedData;
 }
 
 sub FetchDate {
     my $url = shift; # Base url for mirror
db2f9456
     my $trace = "/project/trace/www-master.torproject.org"; # Location of recent update info
532901be
     $url = "$url$trace";
 
     print "Fetching possible date from: $url\n";
 
     my $request = new HTTP::Request GET => "$url";
     my $result = $lua->request($request);
a86b52c5
     my $code = $result->code();
     print "Result code $code\n";
532901be
 
a86b52c5
     if ($result->is_success && $code eq "200"){
532901be
        my $taint = $result->content;
        my $content = sanitize($taint);
        if ($content) {
940ab031
 
532901be
             my $date = str2time($content);
 
             if ($date) {
                 print "We've fetched a date $date.\n";
                 return $date;
             } else {
                 print "We've haven't fetched a date.\n";
                 return "Unknown";
             }
 
         } else {
             print "Unable to fetch date, empty content returned.\n";
             return "Unknown";
         }
940ab031
 
532901be
     } else {
        print "Our request failed, we had no result.\n";
        return "Unknown";
     }
a86b52c5
 
     return "Unknown";
532901be
 }
 
 # This is the list of all known Tor mirrors
 # Add new mirrors to the bottom!
fafbb604
 my %m = (
 
76ebe69b
         
         mirror000 => {
             adminContact => "coralcdn.org",
             orgName => "CoralCDN",
             isoCC => "INT",
             subRegion => "",
             region => "INT",
             ipv4 => "True",
             ipv6 => "False",
             loadBalanced => "Yes",
             httpWebsiteMirror => "http://www.torproject.org.nyud.net/",
             httpsWebsiteMirror => "",
             rsyncWebsiteMirror => "",
             ftpWebsiteMirror => "",
             httpDistMirror => "http://www.torproject.org.nyud.net/dist/",
             httpsDistMirror => "",
             rsyncDistMirror => "",
             hiddenServiceMirror => "",
             updateDate => "Unknown",
 
         },
 
fe0b5ab8
         mirror001 => {
             adminContact => "BarkerJr AT barkerjr DOT net",
             orgName => "BarkerJr",
             isoCC => "FR",
             subRegion => "",
             region => "FR",
             ipv4 => "True",
             ipv6 => "False",
             loadBalanced => "No",
a0226d94
             httpWebsiteMirror => "http://www.oignon.net/",
4a46cda9
             httpsWebsiteMirror => "https://www.oignon.net/",
fe0b5ab8
             rsyncWebsiteMirror => "",
             ftpWebsiteMirror => "",
72c3928b
             httpDistMirror => "http://www.oignon.net/dist/",
4a46cda9
             httpsDistMirror => "https://www.oignon.net/dist/",
fe0b5ab8
             rsyncDistMirror => "",
             hiddenServiceMirror => "",
             updateDate => "Unknown",
         },
 
532901be
        mirror002 => {
940ab031
             adminContact => "",
d6db243b
             orgName => "Boinc",
532901be
             isoCC => "CH",
             subRegion => "",
             region => "Europe",
             ipv4 => "True",
             ipv6 => "False",
             loadBalanced => "Unknown",
             httpWebsiteMirror => "http://tor.boinc.ch/",
             ftpWebsiteMirror => "",
             rsyncWebsiteMirror => "",
             httpDistMirror => "http://tor.boinc.ch/dist/",
             rsyncDistMirror => "",
a86b52c5
             updateDate => "Unknown",
532901be
         },
 
838938ca
        mirror003 => {
ab4b6992
             adminContact => "citizen428 AT gmail DOT com",
79e6ad8b
             orgName => "[[:bbs:]]",
532901be
             isoCC => "DE",
             subRegion => "",
             region => "Europe",
             ipv4 => "True",
             ipv6 => "False",
             loadBalanced => "Unknown",
             httpWebsiteMirror => "http://tor.blingblingsquad.net/",
e44f4a70
             httpsWebsiteMirror => "https://tor.blingblingsquad.net/",
532901be
             ftpWebsiteMirror => "",
             rsyncWebsiteMirror => "",
79e6ad8b
             httpDistMirror => "http://tor.blingblingsquad.net/dist",
e44f4a70
             httpsDistMirror => "https://tor.blingblingsquad.net/dist",
532901be
             rsyncDistMirror => "",
a86b52c5
             updateDate => "Unknown",
532901be
         },
 
838938ca
        mirror005 => {
ab4b6992
             adminContact => "contact AT algorithmus DOT com",
532901be
             orgName => "Spline",
             isoCC => "DE",
             subRegion => "FU",
             region => "Europe",
             ipv4 => "True",
             ipv6 => "False",
             loadBalanced => "Unknown",
8c5bd823
             httpWebsiteMirror => "",
532901be
             ftpWebsiteMirror => "",
             rsyncWebsiteMirror => "",
8c5bd823
             httpDistMirror => "http://rem.spline.de/tor/",
532901be
             rsyncDistMirror => "",
a86b52c5
             updateDate => "Unknown",
532901be
         },
 
838938ca
 	    mirror006 => {
44a792e5
             adminContact => "BarkerJr AT barkerjr DOT net",
             orgName => "BarkerJr",
             isoCC => "US",
             subRegion => "",
             region => "US",
             ipv4 => "True",
             ipv6 => "False",
             loadBalanced => "No",
e2724479
             httpWebsiteMirror => "http://www.torproject.us/",
             httpsWebsiteMirror => "https://www.torproject.us/",
567072db
             rsyncWebsiteMirror => "rsync://rsync.torproject.us/tor",
44a792e5
             ftpWebsiteMirror => "",
e2724479
             httpDistMirror => "http://www.torproject.us/dist/",
             httpsDistMirror => "https://www.torproject.us/dist/",
567072db
             rsyncDistMirror => "rsync://rsync.torproject.us/tor/dist",
44a792e5
             hiddenServiceMirror => "",
             updateDate => "Unknown",
         },
 
838938ca
        mirror007 => {
ab4b6992
             adminContact => "info AT zentrum-der-gesundheit DOT de",
d6db243b
             orgName => "Zentrum der Gesundheit",
532901be
             isoCC => "DK",
             subRegion => "",
             region => "Europe",
             ipv4 => "True",
             ipv6 => "False",
             loadBalanced => "Unknown",
ef0bc85c
             httpWebsiteMirror => "http://tor.idnr.ws/",
532901be
             ftpWebsiteMirror => "",
940ab031
             rsyncWebsiteMirror => "",
ef0bc85c
             httpDistMirror => "http://tor.idnr.ws/dist/",
532901be
             rsyncDistMirror => "",
a86b52c5
             updateDate => "Unknown",
532901be
         },
 
838938ca
        mirror008 => {
ab4b6992
             adminContact => "root AT amorphis DOT eu",
d6db243b
             orgName => "Amorphis",
532901be
             isoCC => "NL",
             subRegion => "",
             region => "Europe",
             ipv4 => "True",
             ipv6 => "False",
             loadBalanced => "Unknown",
             httpWebsiteMirror => "http://tor.amorphis.eu/",
940ab031
             rsyncWebsiteMirror => "",
532901be
             ftpWebsiteMirror => "",
             httpDistMirror => "http://tor.amorphis.eu/dist/",
             rsyncDistMirror => "",
a86b52c5
             updateDate => "Unknown",
532901be
         },
 
838938ca
        mirror009 => {
ab4b6992
             adminContact => "mirror AT bit DOT nl",
532901be
             orgName => "BIT BV",
             isoCC => "NL",
             subRegion => "",
             region => "Europe",
             ipv4 => "True",
             ipv6 => "False",
             loadBalanced => "Unknown",
8c5bd823
             httpWebsiteMirror => "",
940ab031
             rsyncWebsiteMirror => "",
532901be
             ftpWebsiteMirror => "ftp://ftp.bit.nl/mirror/tor/",
8c5bd823
             httpDistMirror => "http://ftp.bit.nl/mirror/tor/",
532901be
             rsyncDistMirror => "",
a86b52c5
             updateDate => "Unknown",
532901be
         },
 
838938ca
        mirror010 => {
ab4b6992
             adminContact => "webmaster AT ccc DOT de",
532901be
             orgName => "CCC",
             isoCC => "NL",
             subRegion => "",
             region => "Europe",
             ipv4 => "True",
             ipv6 => "False",
             loadBalanced => "Unknown",
             httpWebsiteMirror => "http://tor.ccc.de/",
940ab031
             rsyncWebsiteMirror => "",
532901be
             ftpWebsiteMirror => "",
             httpDistMirror => "http://tor.ccc.de/dist/",
             rsyncDistMirror => "",
a86b52c5
             updateDate => "Unknown",
532901be
         },
 
838938ca
        mirror011 => {
ab4b6992
             adminContact => "root AT kamagurka DOT org",
d6db243b
             orgName => "Kamagurka",
532901be
             isoCC => "NL",
             subRegion => "Haarlem",
             region => "Europe",
             ipv4 => "True",
             ipv6 => "False",
             loadBalanced => "Unknown",
             httpWebsiteMirror => "http://tor.kamagurka.org/",
940ab031
             rsyncWebsiteMirror => "",
532901be
             ftpWebsiteMirror => "",
             httpDistMirror => "http://tor.kamagurka.org/dist/",
             rsyncDistMirror => "",
a86b52c5
             updateDate => "Unknown",
532901be
         },
 
838938ca
        mirror012 => {
ab4b6992
             adminContact => "evert AT meulie DOT net",
d6db243b
             orgName => "Meulie",
532901be
             isoCC => "NO",
             subRegion => "",
             region => "Europe",
             ipv4 => "True",
             ipv6 => "False",
             loadBalanced => "Unknown",
8c5bd823
             httpWebsiteMirror => "",
940ab031
             rsyncWebsiteMirror => "",
532901be
             ftpWebsiteMirror => "",
8c5bd823
             httpDistMirror => "http://tor.meulie.net/",
532901be
             rsyncDistMirror => "",
a86b52c5
             updateDate => "Unknown",
532901be
         },
 
838938ca
        mirror013 => {
ab4b6992
 	    adminContact => "hostmaster AT zombiewerks DOT com",
cfa2b38c
             orgName => "TheOnionRouter",
532901be
             isoCC => "US",
ece98df7
             subRegion => "New Jersey",
532901be
             region => "North America",
             ipv4 => "True",
             ipv6 => "False",
             loadBalanced => "Unknown",
5e891d10
             httpWebsiteMirror => "",
940ab031
             rsyncWebsiteMirror => "",
532901be
             ftpWebsiteMirror => "",
5e891d10
             httpDistMirror => "http://theonionrouter.com/dist/",
532901be
             rsyncDistMirror => "",
a86b52c5
             updateDate => "Unknown",
532901be
         },
 
838938ca
         mirror014 => {
fc3928ac
             adminContact => "tormaster AT xpdm DOT us",
cfa2b38c
             orgName => "Xpdm",
4c0fefd4
             isoCC => "US",
             subRegion => "",
             region => "North America",
             ipv4 => "True",
             ipv6 => "False",
             loadBalanced => "Unknown",
             httpWebsiteMirror => "http://torproj.xpdm.us/",
7237e767
             httpsWebsiteMirror => "https://torproj.xpdm.us/",
940ab031
             rsyncWebsiteMirror => "",
4c0fefd4
             ftpWebsiteMirror => "",
7237e767
             httpDistMirror => "http://torproj.xpdm.us/dist/",
             httpsDistMirror => "https://torproj.xpdm.us/dist/",
4c0fefd4
             rsyncDistMirror => "",
             hiddenServiceMirror => "http://h3prhz46uktgm4tt.onion/",
             updateDate => "Unknown",
940ab031
         },
4c0fefd4
 
838938ca
         mirror016 => {
ab4b6992
             adminContact => "security AT hostoffice DOT hu",
87080eec
             orgName => "Unknown",
             isoCC => "HU",
             subRegion => "Hungary",
             region => "Europe",
             ipv4 => "True",
             ipv6 => "False",
             loadBalanced => "No",
ed6938ba
             httpWebsiteMirror => "http://tor.hu/",
87080eec
             httpsWebsiteMirror => "",
940ab031
             rsyncWebsiteMirror => "",
87080eec
             ftpWebsiteMirror => "",
ed6938ba
             httpDistMirror => "",
87080eec
             httpsDistMirror => "",
             rsyncDistMirror => "",
             hiddenServiceMirror => "",
             updateDate => "Unknown",
940ab031
         },
6f73b9b1
 
838938ca
         mirror017 => {
ece98df7
             adminContact => "",
b2daa681
             orgName => "Technica-03",
518a040b
             isoCC => "UA",
ece98df7
             subRegion => "Ukraine",
             region => "Eastern Europe",
             ipv4 => "True",
             ipv6 => "False",
             loadBalanced => "No",
             httpWebsiteMirror => "http://torua.reactor-xg.kiev.ua/",
             httpsWebsiteMirror => "",
940ab031
             rsyncWebsiteMirror => "",
ece98df7
             ftpWebsiteMirror => "",
a0226d94
             httpDistMirror => "http://tordistua.reactor-xg.kiev.ua/",
ece98df7
             httpsDistMirror => "",
             rsyncDistMirror => "",
             hiddenServiceMirror => "",
             updateDate => "Unknown",
940ab031
         },
6f73b9b1
 
838938ca
 	    mirror018 => {
940ab031
             adminContact => "",
             orgName => "chaos darmstadt",
             isoCC => "DE",
             subRegion => "Germany",
             region => "Europe",
             ipv4 => "True",
             ipv6 => "False",
             loadBalanced => "No",
             httpWebsiteMirror => "http://mirrors.chaos-darmstadt.de/tor-mirror/",
             httpsWebsiteMirror => "",
             rsyncWebsiteMirror => "",
             ftpWebsiteMirror => "",
             httpDistMirror => "http://mirrors.chaos-darmstadt.de/tor-mirror/dist/",
             httpsDistMirror => "",
             rsyncDistMirror => "",
             hiddenServiceMirror => "",
             updateDate => "Unknown",
c7112e94
         },
6f73b9b1
 
838938ca
 	mirror019 => {
da69ab61
             adminContact => "webmaster AT askapache DOT com",
             orgName => "AskApache",
c7112e94
             isoCC => "US",
             subRegion => "California",
             region => "US",
             ipv4 => "True",
             ipv6 => "False",
             loadBalanced => "No",
             httpWebsiteMirror => "http://tor.askapache.com/",
             httpsWebsiteMirror => "",
             rsyncWebsiteMirror => "",
             ftpWebsiteMirror => "",
da69ab61
             httpDistMirror => "http://tor.askapache.com/dist/",
c7112e94
             httpsDistMirror => "",
             rsyncDistMirror => "",
             hiddenServiceMirror => "",
             updateDate => "Unknown",
c819dd8d
         },
6f73b9b1
 
838938ca
 	mirror020 => {
ddfe7fb7
             adminContact => " mail AT benjamin-meier DOT info ",
             orgName => "beme it",
6355d769
             isoCC => "DE",
54ef3364
             subRegion => "",
ddfe7fb7
             region => "DE",
54ef3364
             ipv4 => "True",
             ipv6 => "False",
             loadBalanced => "No",
ddfe7fb7
             httpWebsiteMirror => "http://tor.beme-it.de/",
2412008c
             httpsWebsiteMirror => "https://tor.beme-it.de/",
6355d769
             rsyncWebsiteMirror => "rsync://tor.beme-it.de/tor",
54ef3364
             ftpWebsiteMirror => "",
ddfe7fb7
             httpDistMirror => "http://tor.beme-it.de/dist/",
2412008c
             httpsDistMirror => "https://tor.beme-it.de/dist/",
6355d769
             rsyncDistMirror => "rsync://tor.beme-it.de/tor/dist",
54ef3364
             hiddenServiceMirror => "",
             updateDate => "Unknown",
c819dd8d
         },
6f73b9b1
 
838938ca
         mirror021 => {
56e53786
             adminContact => "",
65d4c20f
             orgName => "India Tor Fans",
56e53786
             isoCC => "IN",
             subRegion => "",
             region => "IN",
             ipv4 => "True",
             ipv6 => "False",
             loadBalanced => "No",
df83e179
             httpWebsiteMirror => "http://www.torproject.org.in/",
56e53786
             httpsWebsiteMirror => "",
             rsyncWebsiteMirror => "",
             ftpWebsiteMirror => "",
             httpDistMirror => "http://www.torproject.org.in/dist/",
             httpsDistMirror => "",
             rsyncDistMirror => "",
             hiddenServiceMirror => "",
             updateDate => "Unknown",
         },
 
838938ca
         mirror023 => {
962a1385
             adminContact => "sina at accessnow.org",
             orgName => "Access",
             isoCC => "IR",
             subRegion => "",
             region => "IR",
             ipv4 => "True",
             ipv6 => "False",
             loadBalanced => "Yes",
             httpWebsiteMirror => "http://irani-tor.ath.cx/",
             httpsWebsiteMirror => "",
             rsyncWebsiteMirror => "",
             ftpWebsiteMirror => "",
             httpDistMirror => "http://irani-tor.ath.cx/dist/",
             httpsDistMirror => "",
             rsyncDistMirror => "",
e6221169
             hiddenServiceMirror => "",
         },
 
838938ca
         mirror024 => {
bf3c67eb
             adminContact => "",
65d4c20f
             orgName => "homosu",
b55e8536
             isoCC => "SE",
bf3c67eb
             subRegion => "",
b55e8536
             region => "SE",
bf3c67eb
             ipv4 => "True",
             ipv6 => "False",
             loadBalanced => "No",
             httpWebsiteMirror => "http://tor.homosu.net/",
             httpsWebsiteMirror => "",
             rsyncWebsiteMirror => "",
             ftpWebsiteMirror => "",
             httpDistMirror => "http://tor.homosu.net/dist",
             httpsDistMirror => "",
             rsyncDistMirror => "",
e2a7cfa7
             hiddenServiceMirror => "",
86771c7f
         },
e2a7cfa7
 
838938ca
         mirror025 => {
e2a7cfa7
             adminContact => "margus.random at mail.ee",
             orgName => "CyberSIDE",
65fa2bbd
             isoCC => "EE",
e2a7cfa7
             subRegion => "",
             region => "EE",
             ipv4 => "True",
             ipv6 => "False",
             loadBalanced => "No",
             httpWebsiteMirror => "http://cyberside.planet.ee/tor/",
             httpsWebsiteMirror => "",
             rsyncWebsiteMirror => "",
             ftpWebsiteMirror => "",
dcf4e3fd
             httpDistMirror => "http://cyberside.net.ee/tor/",
e2a7cfa7
             httpsDistMirror => "",
             rsyncDistMirror => "",
962a1385
             hiddenServiceMirror => "",
9133d82f
         },
962a1385
 
838938ca
         mirror026 => {
9133d82f
             adminContact => "me_ at tomyn dot com",
             orgName => "tomyn",
             isoCC => "UK",
             subRegion => "",
             region => "UK",
             ipv4 => "True",
             ipv6 => "False",
             loadBalanced => "No",
             httpWebsiteMirror => "http://tor.tomyn.com",
             httpsWebsiteMirror => "https://tor.tomyn.com",
             rsyncWebsiteMirror => "",
             ftpWebsiteMirror => "ftp://tor.tomyn.com",
             httpDistMirror => "http://tor.tomyn.com/dist",
             httpsDistMirror => "https://tor.tomyn.com/dist",
             rsyncDistMirror => "",
5093a6da
             hiddenServiceMirror => "",
         },
 
         mirror027 => {
             adminContact => "",
             orgName => "mirrors.sykotik.org",
             isoCC => "RO",
             subRegion => "",
             region => "RO",
             ipv4 => "True",
             ipv6 => "False",
             loadBalanced => "No",
             httpWebsiteMirror => "",
             httpsWebsiteMirror => "",
             rsyncWebsiteMirror => "",
             ftpWebsiteMirror => "ftp://mirrors.sykotik.org/pub/tor/",
             httpDistMirror => "http://mirrors.sykotik.org/pub/tor/",
             httpsDistMirror => "",
             rsyncDistMirror => "",
08265341
             hiddenServiceMirror => "",
684500ce
         },
08265341
 
         mirror028 => {
             adminContact => "gouki",
3a2b140d
             orgName => "5ยช Coluna",
08265341
             isoCC => "PT",
             subRegion => "",
             region => "PT",
             ipv4 => "True",
             ipv6 => "False",
             loadBalanced => "No",
             httpWebsiteMirror => "http://tor-www.5coluna.com",
             httpsWebsiteMirror => "https://tor-www.5coluna.com",
             rsyncWebsiteMirror => "",
             ftpWebsiteMirror => "",
             httpDistMirror => "http://tor-www.5coluna.com/dist/",
             httpsDistMirror => "https://tor-www.5coluna.com/dist/",
             rsyncDistMirror => "",
b5630580
             hiddenServiceMirror => "",
         },
 
         mirror029 => {
             adminContact => "",
             orgName => "",
             isoCC => "US",
             subRegion => "WA",
             region => "US",
             ipv4 => "True",
             ipv6 => "False",
             loadBalanced => "No",
             httpWebsiteMirror => "http://torproject.nwlinux.us",
             httpsWebsiteMirror => "",
             rsyncWebsiteMirror => "",
             ftpWebsiteMirror => "",
             httpDistMirror => "http://torproject.nwlinux.us/dist",
             httpsDistMirror => "",
             rsyncDistMirror => "",
1042f856
             hiddenServiceMirror => "",
         },
         mirror030 => {
             adminContact => "",
             orgName => "LazyTiger",
             isoCC => "FR",
             subRegion => "",
             region => "FR",
             ipv4 => "True",
             ipv6 => "False",
             loadBalanced => "No",
             httpWebsiteMirror => "http://tor.taiga-san.net/",
             httpsWebsiteMirror => "",
             rsyncWebsiteMirror => "",
             ftpWebsiteMirror => "",
             httpDistMirror => "http://tor.taiga-san.net/dist",
             httpsDistMirror => "",
             rsyncDistMirror => "",
b4cd62c2
             hiddenServiceMirror => "",
         },
         mirror031 => {
             adminContact => "",
             orgName => "searchprivate",
             isoCC => "US",
             subRegion => "TX",
             region => "US",
             ipv4 => "True",
             ipv6 => "False",
             loadBalanced => "No",
             httpWebsiteMirror => "http://tor.searchprivate.com",
             httpsWebsiteMirror => "",
             rsyncWebsiteMirror => "",
             ftpWebsiteMirror => "",
             httpDistMirror => "http://tor.searchprivate.com/dist",
             httpsDistMirror => "",
             rsyncDistMirror => "",
9133d82f
             hiddenServiceMirror => "",
         }
532901be
 );
 
 my $count = values %m;
 print "We have a total of $count mirrors\n";
 print "Fetching the last updated date for each mirror.\n";
 
3d7f7acd
 my $tortime;
 $tortime = FetchDate("http://www.torproject.org/");
8c8f898f
 # Adjust offical Tor time by out-of-date offset: number of days * seconds per day 
fa36305b
 $tortime -= 1 * 172800; 
3d7f7acd
 print "The official time for Tor is $tortime. \n";
 
532901be
 foreach my $server ( keys %m ) {
 
     print "Attempting to fetch from $m{$server}{'orgName'}\n";
 
     if ($m{$server}{'httpWebsiteMirror'}) {
         print "Attempt to fetch via HTTP.\n";
         $m{$server}{"updateDate"} = FetchDate("$m{$server}{'httpWebsiteMirror'}");
     } elsif ($m{$server}{'httpsWebsiteMirror'}) {
         print "Attempt to fetch via HTTPS.\n";
         $m{$server}{"updateDate"} = FetchDate("$m{$server}{'httpsWebsiteMirror'}");
     } elsif ($m{$server}{'ftpWebsiteMirror'}) {
         print "Attempt to fetch via FTP.\n";
         $m{$server}{"updateDate"} = FetchDate("$m{$server}{'ftpWebsiteMirror'}");
     } else {
         print "We were unable to fetch or store anything. We still have the following: $m{$server}{'updateDate'}\n";
     }
 
     print "We fetched and stored the following: $m{$server}{'updateDate'}\n";
 
  }
 
 
 print "We sorted the following mirrors by their date of last update: \n";
 foreach my $server ( sort { $m{$b}{'updateDate'} <=> $m{$a}{'updateDate'}} keys %m ) {
 
      print "\n";
      print "Mirror $m{$server}{'orgName'}: \n";
 
      foreach my $attrib ( sort keys %{$m{$server}} ) {
         print "$attrib = $m{$server}{$attrib}";
         print "\n";
      };
 }
 
 my $outFile = "include/mirrors-table.wmi";
 my $html;
 open(OUT, "> $outFile") or die "Can't open $outFile: $!";
 
940ab031
 # Here's where we open a file and print some wml include goodness
532901be
 # This is storted from last known recent update to unknown update times
 foreach my $server ( sort { $m{$b}{'updateDate'} <=> $m{$a}{'updateDate'}} keys %m ) {
 
bf099ff9
      my $time;
b57d3dbe
      if ( "$m{$server}{'updateDate'}" ne "Unknown") {
8c8f898f
 	  if ( $m{$server}{'updateDate'} > $tortime ) {
eafdc12d
 	    $time = "Up to date";
 	  } else { $time = "Out of date"; }
33d46751
      } else { $time = "Unknown"; }
759dd463
 print OUT <<"END";
      \n<tr>\n
          <td>$m{$server}{'isoCC'}</td>\n
          <td>$m{$server}{'orgName'}</td>\n
          <td>$time</td>\n
 END
 
      my %prettyNames = (
                         httpWebsiteMirror => "http",
                         httpsWebsiteMirror => "https",
                         ftpWebsiteMirror => "ftp",
                         rsyncWebsiteMirror => "rsync",
                         httpDistMirror => "http",
                         httpsDistMirror => "https",
                         rsyncDistMirrors => "rsync", );
 
      foreach my $precious ( sort keys %prettyNames )
532901be
      {
         if ($m{$server}{"$precious"}) {
             print OUT "    <td><a href=\"" . $m{$server}{$precious} . "\">" .
759dd463
                       "$prettyNames{$precious}</a></td>\n";
532901be
         } else { print OUT "    <td> - </td>\n"; }
      }
 
      print OUT "</tr>\n";
 }
 
 close(OUT);