3b28cce9b6acae442b05a7756a60232c220446c2
[clearscm.git] / maps / bin / checkaddress.cgi
1 #!/usr/bin/perl
2 ################################################################################
3 #
4 # File:         $RCSfile: checkaddress.cgi,v $
5 # Revision:     $Revision: 1.1 $
6 # Description:  Check an email address
7 # Author:       Andrew@DeFaria.com
8 # Created:      Mon Jan 16 20:25:32 PST 2006
9 # Modified:     $Date: 2013/06/12 14:05:47 $
10 # Language:     perl
11 #
12 # (c) Copyright 2000-2006, Andrew@DeFaria.com, all rights reserved.
13 #
14 ################################################################################
15 use strict;
16 use warnings;
17
18 use FindBin;
19 $0 = $FindBin::Script;
20
21 use lib $FindBin::Bin;
22
23 use MAPS;
24
25 use CGI qw (:standard);
26
27 # Get MAPSUser from cookie
28 my $userid;
29
30 if (param "user") {
31   $userid = param "user";
32 } else {
33   $userid = cookie ("MAPSUser");
34 } # if
35
36 my $sender = param ("sender");
37
38 sub Heading {
39   print
40     header     (-title  => "MAPS: Check Address"),
41     start_html (-title  => "MAPS: Check Address",
42                 -author => "Andrew\@DeFaria.com");
43     print h3 {-align => "center",
44               -class => "header"},
45     "MAPS: Checking address $sender";
46 } # Heading
47
48 sub Body {
49   my ($onlist, $rule);
50
51   # Algorithm change: We now first check to see if the sender is not found
52   # in the message and skip it if so. Then we handle if we are the sender
53   # and that the from address is formatted properly. Spammers often use 
54   # the senders email address (i.e. andrew@defaria.com) as their from address
55   # so we check "Andrew DeFaria <Andrew@DeFaria.com>", which they have never
56   # forged. This catches a lot of spam actually.
57   #
58   # Next we check to see if the sender is on our whitelist. If so then we let
59   # them in. This allows us to say whitelist josephrosenberg@hotmail.com while
60   # still nulllisting all of the other hotmail.com spammers.
61   #
62   # Next we process blacklisted people as they are also of high priority.
63   #
64   # Then we process nulllist people.
65   #
66   # Finally, we handle return processing
67   ($onlist, $rule) = OnWhitelist $sender, $userid, 0;
68
69   if ($onlist) {
70     print div {-align => "center"},
71       font {-color => "green"},
72         "Messages from", b ($sender), "will be", b ("delivered"), br, hr;
73     print $rule;
74   } else {
75     ($onlist, $rule) = OnBlacklist $sender, 0;
76
77     if ($onlist) {
78       print div {-align => "center"},
79            font {-color => "black"},
80             "Messages from", b ($sender), "will be", b ("blacklisted"), br, hr;
81       print $rule;
82     } else {
83       ($onlist, $rule) = OnNulllist $sender, 0;
84
85       if ($onlist) {
86         print div {-align       => "center"},
87           font {-color  => "grey"},
88             "Messages from", b ($sender), "will be", b ("discarded"), br, hr;
89         print $rule;
90       } else {
91         print div {-align       => "center"},
92           font {-color  => "red"},
93             "Messages from", b ($sender), "will be", b ("returned");
94       } # if
95     } # if
96   } # if
97
98   print br div {-align => "center"},
99     submit (-name      => "submit",
100             -value     => "Close",
101             -onClick   => "window.close (self)");
102 } # Body
103
104 sub Footing {
105   print end_html;
106 } # Footing
107
108 # Main
109 SetContext $userid;
110 Heading;
111 Body;
112 Footing;
113
114 exit;
115