2 #################################################################################
4 # File: $RCSfile: detail.cgi,v $
5 # Revision: $Revision: 1.1 $
6 # Description: Displays list of email addresses based on report type.
7 # Author: Andrew@DeFaria.com
8 # Created: Fri Nov 29 14:17:21 2002
9 # Modified: $Date: 2013/06/12 14:05:47 $
12 # (c) Copyright 2000-2006, Andrew@DeFaria.com, all rights reserved.
14 ################################################################################
18 use MIME::Words qw(:all);
20 $0 = $FindBin::Script;
22 use lib $FindBin::Bin;
28 use CGI qw (:standard *table start_td end_td start_Tr end_Tr start_div end_div);
29 use CGI::Carp 'fatalsToBrowser';
31 my $type = param ('type');
32 my $next = param ('next');
33 my $lines = param ('lines');
34 my $date = param ('date');
43 my $table_name = 'detail';
48 'The following blacklisted users attempted to email you'
52 'Delivered email from the following users'
56 'Discarded messages from the following users'
64 'Automatically detected mail loops from the following users'
68 'The following users have recently registered'
72 'Sent Register reply to the following users'
79 my $prev_button = $prev >= 0 ?
80 a ({-href => "detail.cgi?type=$type;date=$date;next=$prev",
82 }, '<img src=/maps/images/previous.gif border=0 alt=Previous align=middle>') : '';
83 my $next_button = ($next + $lines) < $total ?
84 a {-href => "detail.cgi?type=$type;date=$date;next=" . ($next + $lines),
86 }, '<img src=/maps/images/next.gif border=0 alt=Next align=middle>' : '';
88 my $buttons = $prev_button;
90 if ($type eq 'whitelist') {
92 submit ({-name => 'action',
93 -value => 'Blacklist Marked',
94 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
95 submit ({-name => 'action',
96 -value => 'Nulllist Marked',
97 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
98 submit ({-name => 'action',
99 -value => 'Reset Marks',
100 -onClick => 'return ClearAll (document.detail);'});
101 } elsif ($type eq 'blacklist') {
102 $buttons = $buttons .
103 submit ({-name => 'action',
104 -value => 'Whitelist Marked',
105 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
106 submit ({-name => 'action',
107 -value => 'Nulllist Marked',
108 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
109 submit ({-name => 'action',
110 -value => 'Reset Marks',
111 -onClick => 'return ClearAll (document.detail);'});
112 } elsif ($type eq 'nulllist') {
113 $buttons = $buttons .
114 submit ({-name => 'action',
115 -value => 'Whitelist Marked',
116 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
117 submit ({-name => 'action',
118 -value => 'Blacklist Marked',
119 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
120 submit ({-name => 'action',
121 -value => 'Reset Marks',
122 -onClick => 'return ClearAll (document.detail);'});
124 $buttons = $buttons .
125 submit ({-name => 'action',
126 -value => 'Whitelist Marked',
127 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
128 submit ({-name => 'action',
129 -value => 'Blacklist Marked',
130 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
131 submit ({-name => 'action',
132 -value => 'Nulllist Marked',
133 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
134 submit ({-name => 'action',
135 -value => 'Reset Marks',
136 -onClick => 'return ClearAll (document.detail);'});
139 return $buttons . $next_button;
145 my $current = $next + 1;
147 print div {-align => 'center'}, b (
148 '(' . $current . '-' . $last . ' of ' . $total . ')');
151 -action => 'processaction.cgi',
154 print start_table ({-align => 'center',
159 -width => '100%'}) . "\n";
161 my $buttons = MakeButtons $type;
163 print start_div {-class => 'toolbar'};
166 td {-class => 'tablebordertopleft',
167 -valign => 'middle'},
168 td {-class => 'tablebordertopright',
170 -align => 'center'}, $buttons,
174 foreach my $sender (ReturnSenders $userid, $type, $next, $lines, $date) {
175 my @msgs = ReturnMessages $userid, $sender;
181 ($onlist, $rule) = OnWhitelist $sender, $userid, 0;
184 ($onlist, $rule) = OnBlacklist $sender, 0;
187 ($onlist, $rule) = OnNulllist $sender, 0;
192 $rule =~ s/Matching rule: \(//;
195 if ($rule =~ /(\w+):(\d+)/) {
197 my $sequence = $2 - 1;
198 my $link = "<a href=\"/maps/php/list.php?type=$list&next=$sequence\">$list:$2</a>";
200 $rule =~ s/\w+:\d+/$link/;
206 start_Tr {-valign => 'middle'};
208 td {-class => 'tableborder'}, small ($next,
209 checkbox {-name => "action$next",
211 hidden ({-name => "email$next",
212 -default => $sender});
214 start_td {-align => 'left'};
216 start_table {-class => 'tablerightdata',
221 -bgcolor => '#d4d0c8'};
223 td {-class => 'tablelabel',
225 -width => '40'}, 'Sender:',
226 td {-class => 'sender',
229 a {-href => "mailto:$sender?subject=$msgs2[0][0]"}, $sender,
231 -valign => 'middle'},
239 my $msg_date = pop @{$_};
240 my $subject = pop @{$_};
242 if ($date eq substr ($msg_date, 0, 10)) {
243 $msg_date = b font {-color => 'green'}, SQLDatetime2UnixDatetime $msg_date;
245 $msg_date = SQLDatetime2UnixDatetime $msg_date;
248 $subject = $subject eq '' ? '<Unspecified>' : $subject;
249 $subject = decode_mimewords ($subject);
250 $subject =~ s/\>/>/g;
251 $subject =~ s/\</</g;
254 start_table {-class => 'tablerightdata',
259 my $msg_nbr = $messages;
262 td {-class => 'msgnbr',
265 -width => '2%'}, $messages++,
266 td {-class => 'tablelabel',
268 -width => '45'}, 'Subject:',
269 td {-class => 'subject',
271 -bgcolor => '#ffffff'},
272 a {-href => "display.cgi?sender=$sender;msg_nbr=$msg_nbr"}, $subject,
273 td {-class => 'date',
275 -valign => 'middle'}, $msg_date
283 print start_div {-class => 'toolbar'};
286 td {-class => 'tableborderbottomleft',
287 -valign => 'middle'},
288 td {-class => 'tableborderbottomright',
289 -valign => 'middle'},
299 my @scripts = ('ListActions.js');
301 my $heading_date =$date ne '' ? ' on ' . FormatDate ($date) : '';
306 (ucfirst ($type) . ' Report'),
308 $types {$type} [1] . $heading_date,
313 $userid ||= $ENV{USER};
316 NavigationBar $userid;
319 my %options = GetUserOptions $userid;
320 $lines = $options{'Page'};
324 $condition .= "userid = '$userid' and type = '$type'";
326 my $sod = $date . ' 00:00:00';
327 my $eod = $date . ' 23:59:59';
329 $condition .= "userid = '$userid' and type = '$type' "
330 . "and timestamp > '$sod' and timestamp < '$eod' ";
333 $total = MAPSDB::count_distinct ('log', 'sender', $condition);
337 $last = $next + $lines < $total ? $next + $lines : $total;
339 if (($next - $lines) > 0) {
340 $prev = $next - $lines;
342 $prev = $next eq 0 ? -1 : 0;