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"},
79 '<img src=/maps/images/previous.gif border=0 alt=Previous align=middle>') : '';
80 my $next_button = ($next + $lines) < $total ?
81 a {-href => "detail.cgi?type=$type;date=$date;next=" . ($next + $lines)},
82 '<img src=/maps/images/next.gif border=0 alt=Next align=middle>' : '';
84 my $buttons = $prev_button;
86 if ($type eq 'whitelist') {
88 submit ({-name => 'action',
89 -value => 'Blacklist Marked',
90 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
91 submit ({-name => 'action',
92 -value => 'Nulllist Marked',
93 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
94 submit ({-name => 'action',
95 -value => 'Reset Marks',
96 -onClick => 'return ClearAll (document.detail);'});
97 } elsif ($type eq 'blacklist') {
99 submit ({-name => 'action',
100 -value => 'Whitelist Marked',
101 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
102 submit ({-name => 'action',
103 -value => 'Nulllist Marked',
104 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
105 submit ({-name => 'action',
106 -value => 'Reset Marks',
107 -onClick => 'return ClearAll (document.detail);'});
108 } elsif ($type eq 'nulllist') {
109 $buttons = $buttons .
110 submit ({-name => 'action',
111 -value => 'Whitelist Marked',
112 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
113 submit ({-name => 'action',
114 -value => 'Blacklist Marked',
115 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
116 submit ({-name => 'action',
117 -value => 'Reset Marks',
118 -onClick => 'return ClearAll (document.detail);'});
120 $buttons = $buttons .
121 submit ({-name => 'action',
122 -value => 'Whitelist Marked',
123 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
124 submit ({-name => 'action',
125 -value => 'Blacklist Marked',
126 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
127 submit ({-name => 'action',
128 -value => 'Nulllist Marked',
129 -onClick => 'return CheckAtLeast1Checked (document.detail);'}) .
130 submit ({-name => 'action',
131 -value => 'Reset Marks',
132 -onClick => 'return ClearAll (document.detail);'});
135 return $buttons . $next_button;
141 my $current = $next + 1;
143 print div {-align => 'center'}, b (
144 '(' . $current . '-' . $last . ' of ' . $total . ')');
147 -action => 'processaction.cgi',
150 print start_table ({-align => 'center',
155 -width => '100%'}) . "\n";
157 my $buttons = MakeButtons $type;
159 print start_div {-class => 'toolbar'};
162 td {-class => 'tablebordertopleft',
163 -valign => 'middle'},
164 td {-class => 'tablebordertopright',
166 -align => 'center'}, $buttons,
170 foreach my $sender (ReturnSenders $userid, $type, $next, $lines, $date) {
171 my @msgs = ReturnMessages $userid, $sender;
175 start_Tr {-valign => 'middle'};
177 td {-class => 'tableborder'}, small ($next,
178 checkbox {-name => "action$next",
180 hidden ({-name => "email$next",
181 -default => $sender});
183 start_td {-align => 'left'};
185 start_table {-class => 'tablerightdata',
190 -bgcolor => '#d4d0c8'};
192 td {-class => 'tablelabel',
194 -width => '40'}, 'Sender:',
195 td {-class => 'sender',
196 -valign => 'middle'},
197 a {-href => "mailto:$sender"}, $sender;
204 my $msg_date = pop @{$_};
205 my $subject = pop @{$_};
207 if ($date eq substr ($msg_date, 0, 10)) {
208 $msg_date = b font {-color => 'green'}, SQLDatetime2UnixDatetime $msg_date;
210 $msg_date = SQLDatetime2UnixDatetime $msg_date;
213 $subject = $subject eq '' ? '<Unspecified>' : $subject;
214 $subject = decode_mimewords ($subject);
215 $subject =~ s/\>/>/g;
216 $subject =~ s/\</</g;
219 start_table {-class => 'tablerightdata',
224 my $msg_nbr = $messages;
227 td {-class => 'msgnbr',
230 -width => '2%'}, $messages++,
231 td {-class => 'tablelabel',
233 -width => '45'}, 'Subject:',
234 td {-class => 'subject',
236 -bgcolor => '#ffffff'},
237 a {-href => "display.cgi?sender=$sender;msg_nbr=$msg_nbr"}, $subject,
238 td {-class => 'date',
240 -valign => 'middle'}, $msg_date
248 print start_div {-class => 'toolbar'};
251 td {-class => 'tableborderbottomleft',
252 -valign => 'middle'},
253 td {-class => 'tableborderbottomright',
254 -valign => 'middle'},
263 my @scripts = ('ListActions.js');
265 my $heading_date =$date ne '' ? ' on ' . FormatDate ($date) : '';
270 (ucfirst ($type) . ' Report'),
272 $types {$type} [1] . $heading_date,
277 $userid ||= $ENV{USER};
280 NavigationBar $userid;
283 my %options = GetUserOptions $userid;
284 $lines = $options{'Page'};
288 $condition .= "userid = '$userid' and type = '$type'";
290 my $sod = $date . ' 00:00:00';
291 my $eod = $date . ' 23:59:59';
293 $condition .= "userid = '$userid' and type = '$type' "
294 . "and timestamp > '$sod' and timestamp < '$eod' ";
297 $total = MAPSDB::count_distinct ('log', 'sender', $condition);
301 $last = $next + $lines < $total ? $next + $lines : $total;
303 if (($next - $lines) > 0) {
304 $prev = $next - $lines;
306 $prev = $next eq 0 ? -1 : 0;