Added support for base64 encodings
[clearscm.git] / maps / bin / MAPSWeb.pm
index dc3d881..f167aae 100644 (file)
@@ -1,7 +1,7 @@
 #################################################################################
 #
 # File:         $RCSfile: MAPSWeb.pm,v $
-# Revision:    $Revision: 1.1 $
+# Revision:     $Revision: 1.1 $
 # Description:  Routines for generating portions of MAPSWeb
 # Author:       Andrew@DeFaria.com
 # Created:      Fri Nov 29 14:17:21  2002
@@ -43,7 +43,7 @@ sub getquickstats {
 
   my %dates = GetStats (1, $date);
 
-  foreach (@MAPSLog::Types) {
+  for (@MAPSLog::Types) {
     $dates{$date}{processed} += $dates{$date}{$_};
   } # foreach
 
@@ -58,32 +58,32 @@ sub displayquickstats {
   my %dates = getquickstats $date;
 
   print start_div {-class => 'quickstats'};
-  print h4 {-class     => 'header',
-           -align      => 'center'},
+  print h4 {-class    => 'header',
+            -align    => 'center'},
     'Today\'s Activity';
-  print p {-align      => 'center'},
+  print p {-align     => 'center'},
     b ('as of ' . FormatTime ($time));
   print start_table {
-    -align             => 'center',
-    -border            => 0,
-    -cellspacing       => 0,
-    -cellpadding       => 2};
+    -align       => 'center',
+    -border      => 0,
+    -cellspacing => 0,
+    -cellpadding => 2};
   print start_Tr {-align => 'right'};
   print
-    td {-class => 'smalllabel',
-       -align  => 'right'},
+    td {-class => 'smalllabel',
+        -align => 'right'},
       'Processed';
   print
-    td {-class => 'smallnumber',
-       -align  => 'right'},
+    td {-class => 'smallnumber',
+        -align => 'right'},
       $dates{$date}{'processed'};
   print
-    td {-class => 'smallnumber',
-       -align  => 'right'},
+    td {-class => 'smallnumber',
+        -align => 'right'},
       'n/a';
   print end_Tr;
 
-  foreach (@MAPSLog::Types) {
+  for (@MAPSLog::Types) {
     print start_Tr {-align => 'right'};
 
     my $value = $dates{$date}{$_};
@@ -92,17 +92,17 @@ sub displayquickstats {
       $percent = 'n/a';
     } else {
       $percent = $dates{$date}{processed} == 0 ?
-       0 : $dates{$date}{$_} / $dates{$date}{processed} * 100;
+        0 : $dates{$date}{$_} / $dates{$date}{processed} * 100;
       $percent = sprintf '%5.1f%s', $percent, '%';
     } # if
     my $stat = $value == 0 ?
       0 : a {-href => "detail.cgi?type=$_;date=$date"}, $value;
     print
-      td {-class       => 'smalllabel'}, ucfirst ($_);
+      td {-class => 'smalllabel'}, ucfirst ($_);
     print
-      td {-class       => 'smallnumber'}, $stat;
+      td {-class => 'smallnumber'}, $stat;
     print
-      td {-class       => 'smallnumber'}, $percent;
+      td {-class => 'smallnumber'}, $percent;
     print end_Tr;
   } # foreach
   print end_table;
@@ -151,13 +151,13 @@ sub DisplayError ($) {
 # This subroutine puts out the header for web pages. It is called by
 # various cgi scripts thus has a few parameters.
 sub Heading ($$$$;$$@) {
-  my ($action,         # One of getcookie, setcookie, unsetcookie
-      $userid,         # User id (if setting a cookie)
-      $title,          # Title string
-      $h1,             # H1 header
-      $h2,             # H2 header (optional)
-      $table_name,     # Name of table in page, if any
-      @scripts)        = @_;   # Array of JavaScript scripts to include
+  my ($action,             # One of getcookie, setcookie, unsetcookie
+      $userid,             # User id (if setting a cookie)
+      $title,              # Title string
+      $h1,                 # H1 header
+      $h2,                 # H2 header (optional)
+      $table_name,         # Name of table in page, if any
+      @scripts)    = @_;   # Array of JavaScript scripts to include
 
   my @java_scripts;
   my $cookie;
@@ -165,19 +165,19 @@ sub Heading ($$$$;$$@) {
   # Since CheckAddress appears on all pages (well except for the login
   # page) include it by default along with MAPSUtils.js
   push @java_scripts, [
-    {-language => 'JavaScript1.2',
-     -src      => '/maps/JavaScript/MAPSUtils.js'},
-    {-language => 'JavaScript1.2',
-     -src      => '/maps/JavaScript/CheckAddress.js'}
+    {-language => 'JavaScript1.2',
+     -src      => '/maps/JavaScript/MAPSUtils.js'},
+    {-language => 'JavaScript1.2',
+     -src      => '/maps/JavaScript/CheckAddress.js'}
   ];
 
   # Add on any additional JavaScripts that the caller wants. Note the
   # odd single element array of hashes but that's what CGI requires!
   # Build up scripts from array
-  foreach (@scripts) {
+  for (@scripts) {
     push @{$java_scripts[0]},
-      {-language       => 'JavaScript1.2',
-       -src            => "/maps/JavaScript/$_"}
+      {-language => 'JavaScript1.2',
+       -src      => "/maps/JavaScript/$_"}
   } # foreach
 
   # Since Heading is called from various scripts we sometimes need to
@@ -188,61 +188,61 @@ sub Heading ($$$$;$$@) {
     $userid = cookie ('MAPSUser');
   } elsif ($action eq 'setcookie') {
     $cookie = cookie (
-       -name   => 'MAPSUser',
-       -value  => $userid,
-       -expires        => '+1y',
-       -path   => '/maps'
+       -name    => 'MAPSUser',
+       -value   => $userid,
+       -expires => '+1y',
+       -path    => '/maps'
     );
   } elsif ($action eq 'unsetcookie') {
     $cookie = cookie (
-       -name   => 'MAPSUser',
-       -value  => '',
-       -expires        => '-1d',
-       -path   => '/maps'
+       -name    => 'MAPSUser',
+       -value   => '',
+       -expires => '-1d',
+       -path    => '/maps'
     );
   } # if
 
   print
-    header     (-title => "MAPS: $title",
-               -cookie => $cookie);
+    header (-title  => "MAPS: $title",
+            -cookie => $cookie);
 
   if (defined $table_name) {
     print
-      start_html (-title       => "MAPS: $title",
-                 -author       => 'Andrew\@DeFaria.com',
-                 -style        => {-src        => '/maps/css/MAPSStyle.css'},
-                 -onResize     => "AdjustTableWidth (\"$table_name\");",
-                 -head         => [
-                   Link ({-rel  => 'icon',
-                          -href => '/maps/MAPS.png',
-                          -type => 'image/png'}),
-                   Link ({-rel  => 'shortcut icon',
-                          -href => '/maps/favicon.ico'})
+      start_html (-title    => "MAPS: $title",
+                  -author   => 'Andrew\@DeFaria.com',
+                  -style    => {-src    => '/maps/css/MAPSStyle.css'},
+                  -onResize => "AdjustTableWidth (\"$table_name\");",
+                  -head     => [
+            Link ({-rel  => 'icon',
+                   -href => '/maps/MAPS.png',
+                   -type => 'image/png'}),
+            Link ({-rel  => 'shortcut icon',
+                   -href => '/maps/favicon.ico'})
                   ],
-                 -script       => @java_scripts);
+          -script    => @java_scripts);
   } else {
     print
-      start_html (-title       => "MAPS: $title",
-                 -author       => 'Andrew\@DeFaria.com',
-                 -style        => {-src        => '/maps/css/MAPSStyle.css'},
-                 -head         => [
-                    Link ({-rel  => 'icon',
-                           -href => '/maps/MAPS.png',
-                           -type => 'image/png'}),
-                    Link ({-rel  => 'shortcut icon',
-                           -href => '/maps/favicon.ico'})],
-                 -script       => @java_scripts);
+      start_html (-title  => "MAPS: $title",
+                  -author => 'Andrew\@DeFaria.com',
+                  -style  => {-src    => '/maps/css/MAPSStyle.css'},
+                  -head   => [
+             Link ({-rel  => 'icon',
+                    -href => '/maps/MAPS.png',
+                    -type => 'image/png'}),
+             Link ({-rel  => 'shortcut icon',
+                    -href => '/maps/favicon.ico'})],
+                   -script    => @java_scripts);
   } # if
 
   print start_div {class => 'heading'};
-  print h2 {-align     => 'center',
-           -class      => 'header'},
-    font ({-class      => 'standout'}, 'MAPS'),
+  print h2 {-align => 'center',
+            -class => 'header'},
+    font ({-class  => 'standout'}, 'MAPS'),
       $h1;
 
   if (defined $h2 && $h2 ne '') {
-    print h3 {-align   => 'center',
-             -class    => 'header'},
+    print h3 {-align => 'center',
+              -class => 'header'},
       $h2;
   } # if
   print end_div;
@@ -259,75 +259,75 @@ sub NavigationBar {
   print start_div {-id => 'leftbar'};
 
   if (!defined $userid) {
-    print div ({-class => 'username'}, 'Welcome to MAPS');
-    print div ({-class => 'menu'},
-      (a {-href        => '/maps/doc/'},
+    print div ({-class => 'username'}, 'Welcome to MAPS');
+    print div ({-class => 'menu'},
+      (a {-href => '/maps/doc/'},
         'What is MAPS?<br>'),
-      (a {-href        => '/maps/doc/SPAM.html'},
+      (a {-href => '/maps/doc/SPAM.html'},
         'What is SPAM?<br>'),
-      (a {-href        => '/maps/doc/Requirements.html'},
+      (a {-href => '/maps/doc/Requirements.html'},
         'Requirements<br>'),
-      (a {-href        => '/maps/SignupForm.html'},
+      (a {-href => '/maps/SignupForm.html'},
         'Signup<br>'),
-      (a {-href        => '/maps/doc/Using.html'},
+      (a {-href => '/maps/doc/Using.html'},
         'Using MAPS<br>'),
-      (a {-href        => '/maps/doc/'},
+      (a {-href => '/maps/doc/'},
         'Help<br>'),
     );
   } else {
-    print div ({-class => 'username'}, 'Welcome '. ucfirst $userid);
-    print div ({-class => 'menu'},
-      (a {-href        => '/maps/'},
+    print div ({-class => 'username'}, 'Welcome '. ucfirst $userid);
+    print div ({-class => 'menu'},
+      (a {-href => '/maps/'},
         'MAPS Home<br>'),
-      (a {-href        => '/maps/bin/stats.cgi'},
+      (a {-href => '/maps/bin/stats.cgi'},
         'Statistics<br>'),
-      (a {-href        => '/maps/bin/editprofile.cgi'},
+      (a {-href => '/maps/bin/editprofile.cgi'},
         'Edit Profile<br>'),
-      (a {-href        => '/maps/php/Reports.php'},
+      (a {-href => '/maps/php/Reports.php'},
         'Reports<br>'),
-      (a {-href        => '/maps/php/list.php?type=white'},
+      (a {-href => '/maps/php/list.php?type=white'},
         'White List<br>'),
-      (a {-href        => '/maps/php/list.php?type=black'},
+      (a {-href => '/maps/php/list.php?type=black'},
         'Black List<br>'),
-      (a {-href        => '/maps/php/list.php?type=null'},
+      (a {-href => '/maps/php/list.php?type=null'},
         'Null List<br>'),
-      (a {-href        => '/maps/doc/'},
+      (a {-href => '/maps/doc/'},
         'Help<br>'),
-      (a {-href        => '/maps/adm/'},
+      (a {-href => '/maps/adm/'},
         'MAPS Admin<br>'),
-      (a {-href        => '/maps/?logout=yes'},
+      (a {-href => '/maps/?logout=yes'},
         'Logout'),
     );
     print start_div {-class => 'search'};
-    print start_form {-method  => 'get',
-                     -action   => '/maps/bin/search.cgi',
-                     -name     => 'search'};
+    print start_form {-method => 'get',
+                      -action => '/maps/bin/search.cgi',
+                      -name   => 'search'};
     print 'Search Sender/Subject',
-      textfield {-class                => 'searchfield',
-                -id            => 'searchfield',
-                -name          => 'str',
-                -size          => 20,
-                -maxlength     => 255,
-                -value         => '',
-                -onclick       => "document.search.str.value = '';"};
+      textfield {-class     => 'searchfield',
+                 -id        => 'searchfield',
+                 -name      => 'str',
+                 -size      => 20,
+                 -maxlength => 255,
+                 -value     => '',
+                 -onclick   => "document.search.str.value = '';"};
     print end_form;
     print end_div;
 
     displayquickstats;
 
     print start_div {-class => 'search'};
-    print start_form {-method  => 'post',
-                     -action   => 'javascript://',
-                     -name     => 'address',
-                     -onsubmit => 'checkaddress(this);'};
+    print start_form {-method => 'post',
+                -action   => 'javascript://',
+                -name     => 'address',
+                -onsubmit => 'checkaddress(this);'};
     print 'Check Email Address',
-      textfield {-class                => 'searchfield',
-                -id            => 'searchfield',
-                -name          => 'email',
-                -size          => 20,
-                -maxlength     => 255,
-                -value         => '',
-                -onclick       => "document.address.email.value = '';"};
+      textfield {-class     => 'searchfield',
+                 -id        => 'searchfield',
+                 -name      => 'email',
+                 -size      => 20,
+                 -maxlength => 255,
+                 -value     => '',
+                 -onclick   => "document.address.email.value = '';"};
     print end_form;
     print end_div;
   } # if