From c83dcc52c32482cc0b24e14611bd305a4198eddb Mon Sep 17 00:00:00 2001 From: Metabox Date: Mon, 22 Apr 2019 19:37:48 +1000 Subject: [PATCH] init --- htdocs/cgi-bin/time_zones.cgi | 84 +++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100755 htdocs/cgi-bin/time_zones.cgi diff --git a/htdocs/cgi-bin/time_zones.cgi b/htdocs/cgi-bin/time_zones.cgi new file mode 100755 index 0000000..1758d5c --- /dev/null +++ b/htdocs/cgi-bin/time_zones.cgi @@ -0,0 +1,84 @@ +#!/usr/bin/perl +# +# Programed in vim by: Will Budic +# Open Source License -> https://choosealicense.com/licenses/isc/ +# + +use Try::Tiny; +use Switch; + +use CGI; +use CGI::Session '-ip_match'; +use Text::CSV; + +my @zones; +my $zone; +open my $fh, '<', '/home/will/dev/LifeLog/dbLifeLog/zone.csv' or die "Cannot open: $!"; +while (my $line = <$fh>) { + $line =~ s/\s*\z//; + my @a = split /,/, $line; + my $z = $a[2]; + push @zones, $z; +} +close $fh; + + +my $cgi = CGI->new; +print $cgi->header(-expires=>"+6s", -charset=>"UTF-8"); +print $cgi->start_html(-title => "Personal Log", -BGCOLOR=>"#c8fff8", + -script=>{-type => 'text/javascript', -src => 'wsrc/main.js'}, + -style =>{-type => 'text/css', -src => 'wsrc/main.css'}, + ); + + +#TODO +my %countries = {}; +my @states; +foreach $zone (sort @zones){ + $zone =~ s/\"//g; + my @p = split /\//, $zone; + my $country = $p[0]; + my $city = $p[1]; + my $region = $p[2]; + + if(length($country)==0){next;} + + if($region){ + $city = "$region/$city"; + } + my $def = "$country/$city"; + + if(exists($countries{$country})){ + $states = $countries{$country}; + }else{ + $states = (); + push (@{$countries{$country}}, $states); + # print "[$country] created list!\n"; + } + push @{$states}, "$country/$city"; + #print "$zone
\n"; +} + +print "
"; +print "

World Time Zone Strings

\n"; +foreach $key (sort keys %countries){ + $states = $countries{$key}; + if( length($states)>0 ){ + print "
$key
\n"; + print "
    \n"; + foreach $entry (sort @{$states}){ + if(!$entry){next} + foreach $city ($entry){ + if($city){ + print "
  • $city
  • "; + } + } + } + print "
\n"; + print "
\n"; + + } +} + +print "
"; +print $cgi->end_html; \ No newline at end of file -- 2.34.1