1 #################################################################################
3 # File: $RCSfile: MAPSWeb.pm,v $
4 # Revision: $Revision: 1.1 $
5 # Description: Routines for generating portions of MAPSWeb
6 # Author: Andrew@DeFaria.com
7 # Created: Fri Nov 29 14:17:21 2002
8 # Modified: $Date: 2013/06/12 14:05:47 $
11 # (c) Copyright 2000-2006, Andrew@DeFaria.com, all rights reserved.
13 ################################################################################
23 use CGI qw (:standard *table start_Tr end_Tr start_div end_div);
24 use vars qw (@ISA @EXPORT);
38 sub getquickstats($) {
41 my %dates = GetStats (1, $date);
43 for (@MAPSLog::Types) {
44 $dates{$date}{processed} += $dates{$date}{$_};
50 sub displayquickstats() {
51 # Quick stats are today only.
52 my $today = Today2SQLDatetime;
53 my $time = substr $today, 11;
54 my $date = substr $today, 0, 10;
55 my %dates = getquickstats $date;
57 print start_div {-class => 'quickstats'};
58 print h4 {-class => 'header',
61 print p {-align => 'center'},
62 b ('as of ' . FormatTime ($time));
68 print start_Tr {-align => 'right'};
70 td {-class => 'smalllabel',
74 td {-class => 'smallnumber',
76 $dates{$date}{'processed'};
78 td {-class => 'smallnumber',
83 for (@MAPSLog::Types) {
84 print start_Tr {-align => 'right'};
86 my $value = $dates{$date}{$_};
88 if ($_ eq 'mailloop' || $_ eq 'registered') {
91 $percent = $dates{$date}{processed} == 0 ?
92 0 : $dates{$date}{$_} / $dates{$date}{processed} * 100;
93 $percent = sprintf '%5.1f%s', $percent, '%';
95 my $stat = $value == 0 ?
96 0 : a {-href => "detail.cgi?type=$_;date=$date"}, $value;
98 td {-class => 'smalllabel'}, ucfirst ($_);
100 td {-class => 'smallnumber'}, $stat;
102 td {-class => 'smallnumber'}, $percent;
109 } # displayquickstats
112 my ($table_name) = @_;
114 # General footing (copyright). Note we calculate the current year
115 # so that the copyright automatically extends itself.
116 my $year = substr((scalar (localtime)), 20, 4);
118 print start_div {-class => "copyright"};
119 print "Copyright © 2001-$year - All rights reserved";
121 a ({-href => 'https://defaria.com'},
123 a ({-href => 'mailto:Andrew@DeFaria.com'},
124 '<Andrew@DeFaria.com>'));
127 print end_div; # This div ends "content" which was started in Heading
128 print "<script language='JavaScript1.2'>AdjustTableWidth (\"$table_name\");</script>"
138 print br, font ({ -class => 'error' }, 'DEBUG: '), $msg;
143 sub DisplayError($) {
146 print h3 ({-class => 'error',
147 -align => 'center'}, 'ERROR: ' . $errmsg);
154 # This subroutine puts out the header for web pages. It is called by
155 # various cgi scripts thus has a few parameters.
156 sub Heading($$$$;$$@) {
157 my ($action, # One of getcookie, setcookie, unsetcookie
158 $userid, # User id (if setting a cookie)
159 $title, # Title string
161 $h2, # H2 header (optional)
162 $table_name, # Name of table in page, if any
163 @scripts) = @_; # Array of JavaScript scripts to include
168 # Since CheckAddress appears on all pages (well except for the login
169 # page) include it by default along with MAPSUtils.js
170 push @java_scripts, [
171 {-language => 'JavaScript1.2',
172 -src => '/maps/JavaScript/MAPSUtils.js'},
173 {-language => 'JavaScript1.2',
174 -src => '/maps/JavaScript/CheckAddress.js'}
177 # Add on any additional JavaScripts that the caller wants. Note the
178 # odd single element array of hashes but that's what CGI requires!
179 # Build up scripts from array
181 push @{$java_scripts[0]},
182 {-language => 'JavaScript1.2',
183 -src => "/maps/JavaScript/$_"}
186 # Since Heading is called from various scripts we sometimes need to
187 # set a cookie, other times delete a cookie but most times return the
189 if ($action eq 'getcookie') {
190 # Get userid from cookie
191 $userid = cookie ('MAPSUser');
192 } elsif ($action eq 'setcookie') {
199 } elsif ($action eq 'unsetcookie') {
209 header (-title => "MAPS: $title",
212 if (defined $table_name) {
214 start_html (-title => "MAPS: $title",
215 -author => 'Andrew\@DeFaria.com',
216 -style => {-src => '/maps/css/MAPSStyle.css'},
217 -onResize => "AdjustTableWidth (\"$table_name\");",
219 Link ({-rel => 'icon',
220 -href => '/maps/MAPS.png',
221 -type => 'image/png'}),
222 Link ({-rel => 'shortcut icon',
223 -href => '/maps/favicon.ico'})
225 -script => @java_scripts);
228 start_html (-title => "MAPS: $title",
229 -author => 'Andrew\@DeFaria.com',
230 -style => {-src => '/maps/css/MAPSStyle.css'},
232 Link ({-rel => 'icon',
233 -href => '/maps/MAPS.png',
234 -type => 'image/png'}),
235 Link ({-rel => 'shortcut icon',
236 -href => '/maps/favicon.ico'})],
237 -script => @java_scripts);
240 print start_div {class => 'heading'};
241 print h2 {-align => 'center',
243 font ({-class => 'standout'}, 'MAPS'),
246 if (defined $h2 && $h2 ne '') {
247 print h3 {-align => 'center',
254 print start_div {-class => 'content'};
259 sub NavigationBar($) {
262 print start_div {-id => 'leftbar'};
264 if (!defined $userid) {
265 print div ({-class => 'username'}, 'Welcome to MAPS');
266 print div ({-class => 'menu'},
267 (a {-href => '/maps/doc/'},
268 'What is MAPS?<br>'),
269 (a {-href => '/maps/doc/SPAM.html'},
270 'What is SPAM?<br>'),
271 (a {-href => '/maps/doc/Requirements.html'},
273 (a {-href => '/maps/SignupForm.html'},
275 (a {-href => '/maps/doc/Using.html'},
277 (a {-href => '/maps/doc/'},
281 print div ({-class => 'username'}, 'Welcome '. ucfirst $userid);
282 print div ({-class => 'menu'},
283 (a {-href => '/maps/'},
285 (a {-href => '/maps/bin/stats.cgi'},
287 (a {-href => '/maps/bin/editprofile.cgi'},
289 (a {-href => '/maps/php/Reports.php'},
291 (a {-href => '/maps/php/list.php?type=white'},
293 (a {-href => '/maps/php/list.php?type=black'},
295 (a {-href => '/maps/php/list.php?type=null'},
297 (a {-href => '/maps/doc/'},
299 (a {-href => '/maps/adm/'},
301 (a {-href => '/maps/?logout=yes'},
304 print start_div {-class => 'search'};
305 print start_form {-method => 'get',
306 -action => '/maps/bin/search.cgi',
308 print 'Search Sender/Subject',
309 textfield {-class => 'searchfield',
310 -id => 'searchfield',
315 -onclick => "document.search.str.value = '';"};
321 print start_div {-class => 'search'};
322 print start_form {-method => 'post',
323 -action => 'javascript://',
325 -onsubmit => 'checkaddress(this);'};
326 print 'Check Email Address',
327 textfield {-class => 'searchfield',
328 -id => 'searchfield',
333 -onclick => "document.address.email.value = '';"};