Filtering in the history: all | spam | innocent | whitelisted This is #34 in the feature request pool.
The author or authors of this submission hereby release any and all copyright interest in this code, documentation, or other materials included to the DSPAM project and its primary governors. We intend this relinquishment of copyright interest in perpetuity of all present and future rights to said submission under copyright law. --- dspam.cgi | 59 ++++++++++++++++++++++++++++++++++----- templates/nav_history.html | 4 +++ 2 files changed, 55 insertions(+), 8 deletions(-)
diff --git a/dspam.cgi b/dspam.cgi index 159fb27..b0161fc 100755 --- a/dspam.cgi +++ b/dspam.cgi @@ -214,6 +214,11 @@ sub DisplayHistory { $CONFIG{'HISTORY_PER_PAGE'} = 50; } + my($show) = $FORM{'show'}; + if ($show eq "") { + $show = "all"; + } + if ($FORM{'command'} eq "retrainChecked") { foreach my $i (0 .. $#{ $FORM{retrain_checked} }) { my ($retrain, $signature) = split(/:/, $FORM{retrain_checked}[$i]); @@ -225,7 +230,7 @@ sub DisplayHistory { system("$CONFIG{'DSPAM'} --source=error --class=" . quotemeta($retrain) . " --signature=" . quotemeta($signature) . " --user " . quotemeta("$CURRENT_USER")); } } - redirect("$MYURL&history_page=$history_page"); + redirect("$MYURL&show=$show&history_page=$history_page"); } else { if ($FORM{'retrain'} ne "") { if ($FORM{'retrain'} eq "innocent") { @@ -233,7 +238,7 @@ sub DisplayHistory { } else { system("$CONFIG{'DSPAM'} --source=error --class=" . quotemeta($FORM{'retrain'}) . " --signature=" . quotemeta($FORM{'signatureID'}) . " --user " . quotemeta("$CURRENT_USER")); } - redirect("$MYURL&history_page=$history_page"); + redirect("$MYURL&show=$show&history_page=$history_page"); } } @@ -249,6 +254,10 @@ sub DisplayHistory { my($time, $class, $from, $signature, $subject, $info, $messageid) = split(/\t/, $_); next if ($signature eq ""); + + # not good to check for messages to show here, we're skipping + # the retraining data so retrained messages won't show + if ($class eq "M" || $class eq "F" || $class eq "E") { if ($class eq "E") { $rec{$signature}->{'info'} = $info; @@ -263,6 +272,12 @@ sub DisplayHistory { } elsif ($messageid == '' || $rec{$signature}->{'messageid'} != $messageid || $CONFIG{'HISTORY_DUPLICATES'} ne "no") { + + # skip unwanted messages + next if ($class ne "S" && $show eq "spam"); + next if ($class ne "I" && $show eq "innocent"); + next if ($class ne "W" && $show eq "whitelisted"); + $rec{$signature}->{'time'} = $time; $rec{$signature}->{'class'} = $class; $rec{$signature}->{'from'} = $from; @@ -385,9 +400,9 @@ sub DisplayHistory { } if ($retrain eq "") { - $retrain = qq!<A HREF="$CONFIG{'ME'}?template=$FORM{'template'}&history_page=$history_page&user=$FORM{'user'}&retrain=$rclass&signatureID=$signature">As ! . ucfirst($rclass) . "</A>"; + $retrain = qq!<A HREF="$MYURL&show=$show&history_page=$history_page&retrain=$rclass&signatureID=$signature">As ! . ucfirst($rclass) . "</A>"; } else { - $retrain .= qq! (<A HREF="$CONFIG{'ME'}?template=$FORM{'template'}&history_page=$history_page&user=$FORM{'user'}&retrain=$rclass&signatureID=$signature">Undo</A>)!; + $retrain .= qq! (<A HREF="$MYURL&show=$show&history_page=$history_page&retrain=$rclass&signatureID=$signature">Undo</A>)!; } my($path) = "$USER.frag/$signature.frag"; @@ -441,22 +456,50 @@ _END $DATA{'HISTORY'} .= "<center>["; if (($history_pages > 1) && ($history_page > 1)) { my $i = $history_page-1; - $DATA{'HISTORY'} .= "<a href=\"$CONFIG{'DSPAM_CGI'}?user=$FORM{'user'}&template=$FORM{'template'}&history_page=$i\"> < </a>"; + $DATA{'HISTORY'} .= "<a href=\"$MYURL&show=$show&history_page=$i\"> < </a>"; } for(my $i = 1; $i <= $history_pages; $i++) { if ($i == $history_page) { - $DATA{'HISTORY'} .= "<a href=\"$CONFIG{'DSPAM_CGI'}?user=$FORM{'user'}&template=$FORM{'template'}&history_page=$i\"><big><strong> $i </strong></big></a>"; + $DATA{'HISTORY'} .= "<a href=\"$MYURL&show=$show&history_page=$i\"><big><strong> $i </strong></big></a>"; } else { - $DATA{'HISTORY'} .= "<a href=\"$CONFIG{'DSPAM_CGI'}?user=$FORM{'user'}&template=$FORM{'template'}&history_page=$i\"> $i </a>"; + $DATA{'HISTORY'} .= "<a href=\"$MYURL&show=$show&history_page=$i\"> $i </a>"; } } if (($history_pages > 1) && ($history_page < $history_pages)) { my $i = $history_page+1; - $DATA{'HISTORY'} .= "<a href=\"$CONFIG{'DSPAM_CGI'}?user=$FORM{'user'}&template=$FORM{'template'}&history_page=$i\"> > </a>"; + $DATA{'HISTORY'} .= "<a href=\"$MYURL&show=$show&history_page=$i\"> > </a>"; } $DATA{'HISTORY'} .= "]</center><BR>"; } + + $DATA{'SHOW'} = $show; + $DATA{'SHOW_SELECTOR'} .= "Show: <a href=\"$MYURL&show=all\">"; + if ($show eq "all") { + $DATA{'SHOW_SELECTOR'} .= "<strong>all</strong>"; + } else { + $DATA{'SHOW_SELECTOR'} .= "all"; + } + $DATA{'SHOW_SELECTOR'} .= "</a> | <a href=\"$MYURL&show=spam\">"; + if ($show eq "spam") { + $DATA{'SHOW_SELECTOR'} .= "<strong>spam</strong>"; + } else { + $DATA{'SHOW_SELECTOR'} .= "spam"; + } + $DATA{'SHOW_SELECTOR'} .= "</a> | <a href=\"$MYURL&show=innocent\">"; + if ($show eq "innocent") { + $DATA{'SHOW_SELECTOR'} .= "<strong>innocent</strong>"; + } else { + $DATA{'SHOW_SELECTOR'} .= "innocent"; + } + $DATA{'SHOW_SELECTOR'} .= "</a> | <a href=\"$MYURL&show=whitelisted\">"; + if ($show eq "whitelisted") { + $DATA{'SHOW_SELECTOR'} .= "<strong>whitelisted</strong>"; + } else { + $DATA{'SHOW_SELECTOR'} .= "whitelisted"; + } + $DATA{'SORT_SELECTOR'} .= "</a>"; + &output(%DATA); } diff --git a/templates/nav_history.html b/templates/nav_history.html index 99ab051..6595ca3 100644 --- a/templates/nav_history.html +++ b/templates/nav_history.html @@ -38,6 +38,10 @@ deliver any false positives that are still in your quarantine. <input type="hidden" name="template" value="history"> <input type="hidden" name="command" value="retrainChecked"> <input type="hidden" name="user" value="$REMOTE_USER$"> +<input type="hidden" name="show" value="$SHOW$" > + + $SHOW_SELECTOR$ + <table border="0" cellspacing="0" cellpadding="2" width="100%"> <tr> <th>Type</th>