2 #################################################################################
3 # File: $RCSfile: detail.cgi,v $
4 # Revision: $Revision: 1.1 $
5 # Description: Displays list of email addresses based on report type.
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 ################################################################################use strict;
16 use MIME::Words qw(:all);
18 $0 = $FindBin::Script;
20 use lib $FindBin::Bin;
26 use CGI qw (:standard *table start_td end_td start_Tr end_Tr start_div end_div);
27 use CGI::Carp 'fatalsToBrowser';
29 my $type = param ('type');
30 my $next = param ('next');
31 my $lines = param ('lines');
32 my $date = param ('date');
41 my $table_name = 'detail';
46 'The following blacklisted users attempted to email you'
50 'Delivered email from the following users'
54 'Discarded messages from the following users'
62 'Automatically detected mail loops from the following users'
66 'The following users have recently registered'
70 'Sent Register reply to the following users'
77 my $prev_button = $prev >= 0 ?
78 a ({-href => "detail.cgi?type=$type;date=$date;next=$prev",
80 }, '<img src=/maps/images/previous.gif border=0 alt=Previous align=middle>') : '';
81 my $next_button = ($next + $lines) < $total ?
82 a {-href => "detail.cgi?type=$type;date=$date;next=" . ($next + $lines),
84 }, '<img src=/maps/images/next.gif border=0 alt=Next align=middle>' : '';
86 my $buttons = $prev_button;
88 if ($type eq 'whitelist') {
90 submit ({-name => 'action',
91 -value => 'Blacklist Marked',
92 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
93 submit ({-name => 'action',
94 -value => 'Nulllist Marked',
95 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
96 submit ({-name => 'action',
97 -value => 'Reset Marks',
98 -onClick => 'return ClearAll (document.detail);'});
99 } elsif ($type eq 'blacklist') {
100 $buttons = $buttons .
101 submit ({-name => 'action',
102 -value => 'Whitelist Marked',
103 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
104 submit ({-name => 'action',
105 -value => 'Nulllist Marked',
106 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
107 submit ({-name => 'action',
108 -value => 'Reset Marks',
109 -onClick => 'return ClearAll (document.detail);'});
110 } elsif ($type eq 'nulllist') {
111 $buttons = $buttons .
112 submit ({-name => 'action',
113 -value => 'Whitelist Marked',
114 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
115 submit ({-name => 'action',
116 -value => 'Blacklist Marked',
117 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
118 submit ({-name => 'action',
119 -value => 'Reset Marks',
120 -onClick => 'return ClearAll (document.detail);'});
122 $buttons = $buttons .
123 submit ({-name => 'action',
124 -value => 'Whitelist Marked',
125 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
126 submit ({-name => 'action',
127 -value => 'Blacklist Marked',
128 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
129 submit ({-name => 'action',
130 -value => 'Nulllist Marked',
131 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
132 submit ({-name => 'action',
133 -value => 'Reset Marks',
134 -onClick => 'return ClearAll (document.detail);'});
137 return $buttons . $next_button;
143 my $current = $next + 1;
145 print div {-align => 'center'}, b (
146 '(' . $current . '-' . $last . ' of ' . $total . ')');
149 -action => 'processaction.cgi',
152 print start_table ({-align => 'center',
157 -width => '100%'}) . "\n";
159 my $buttons = MakeButtons $type;
161 print start_div {-class => 'toolbar'};
164 td {-class => 'tablebordertopleft',
165 -valign => 'middle'},
166 td {-class => 'tablebordertopright',
168 -align => 'center'}, $buttons,
172 foreach my $sender (ReturnSenders $userid, $type, $next, $lines, $date) {
173 my @msgs = ReturnMessages $userid, $sender;
179 ($onlist, $rule) = OnNulllist $sender;
182 ($onlist, $rule) = OnBlacklist $sender;
185 ($onlist, $rule) = OnWhitelist $sender;
191 start_Tr {-valign => 'middle'};
193 td {-class => 'tableborder'}, small ($next,
194 checkbox {-name => "action$next",
196 hidden ({-name => "email$next",
197 -default => $sender});
199 start_td {-align => 'left'};
201 start_table {-class => 'tablerightdata',
206 -bgcolor => '#d4d0c8'};
208 td {-class => 'tablelabel',
210 -width => '40'}, 'Sender:',
211 td {-class => 'sender',
214 a {-href => "mailto:$sender?subject=$msgs2[0][0]"}, $sender,
216 -valign => 'middle'},
224 my $msg_date = pop @{$_};
225 my $subject = pop @{$_};
227 if ($date eq substr ($msg_date, 0, 10)) {
228 $msg_date = b font {-color => 'green'}, SQLDatetime2UnixDatetime $msg_date;
230 $msg_date = SQLDatetime2UnixDatetime $msg_date;
233 $subject = $subject eq '' ? '<Unspecified>' : $subject;
234 $subject = decode_mimewords ($subject);
235 $subject =~ s/\>/>/g;
236 $subject =~ s/\</</g;
239 start_table {-class => 'tablerightdata',
244 my $msg_nbr = $messages;
247 td {-class => 'msgnbr',
250 -width => '2%'}, $messages++,
251 td {-class => 'tablelabel',
253 -width => '45'}, 'Subject:',
254 td {-class => 'subject',
256 -bgcolor => '#ffffff'},
257 a {-href => "display.cgi?sender=$sender;msg_nbr=$msg_nbr"}, $subject,
258 td {-class => 'date',
260 -valign => 'middle'}, $msg_date
268 print start_div {-class => 'toolbar'};
271 td {-class => 'tableborderbottomleft',
272 -valign => 'middle'},
273 td {-class => 'tableborderbottomright',
274 -valign => 'middle'},
283 my @scripts = ('ListActions.js');
285 my $heading_date =$date ne '' ? ' on ' . FormatDate ($date) : '';
290 (ucfirst ($type) . ' Report'),
292 $types {$type} [1] . $heading_date,
297 $userid ||= $ENV{USER};
300 NavigationBar $userid;
303 my %options = GetUserOptions $userid;
304 $lines = $options{'Page'};
308 $condition .= "userid = '$userid' and type = '$type'";
310 my $sod = $date . ' 00:00:00';
311 my $eod = $date . ' 23:59:59';
313 $condition .= "userid = '$userid' and type = '$type' "
314 . "and timestamp > '$sod' and timestamp < '$eod' ";
317 $total = MAPSDB::count_distinct ('log', 'sender', $condition);
321 $last = $next + $lines < $total ? $next + $lines : $total;
323 if (($next - $lines) > 0) {
324 $prev = $next - $lines;
326 $prev = $next eq 0 ? -1 : 0;