51ec2c117aee04c375790118fcb4805c0782ae5a
[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 local $0 = $FindBin::Script;
20
21 use lib "$FindBin::Bin/../lib";
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 $userid //= $ENV{USER};
37
38 my $sender = param("sender");
39
40 sub Heading() {
41   print
42     header     (-title  => "MAPS: Check Address"),
43     start_html (-title  => "MAPS: Check Address",
44                 -author => "Andrew\@DeFaria.com");
45     print h3 {-align => "center",
46               -class => "header"},
47     "MAPS: Checking address $sender";
48
49   return;
50 } # Heading
51
52 sub Body() {
53   my ($onlist, $rule);
54
55   # Algorithm change: We now first check to see if the sender is not found
56   # in the message and skip it if so. Then we handle if we are the sender
57   # and that the from address is formatted properly. Spammers often use 
58   # the senders email address (i.e. andrew@defaria.com) as their from address
59   # so we check "Andrew DeFaria <Andrew@DeFaria.com>", which they have never
60   # forged. This catches a lot of spam actually.
61   #
62   # Next we check to see if the sender is on our whitelist. If so then we let
63   # them in. This allows us to say whitelist josephrosenberg@hotmail.com while
64   # still nulllisting all of the other hotmail.com spammers.
65   #
66   # Next we process blacklisted people as they are also of high priority.
67   #
68   # Then we process nulllist people.
69   #
70   # Finally, we handle return processing
71   ($onlist, $rule) = OnWhitelist($sender, $userid, 0);
72
73   if ($onlist) {
74     print div {-align => "center"},
75       font {-color => "green"},
76         "Messages from", b ($sender), "will be", b ("delivered"), br, hr;
77     print $rule;
78   } else {
79     ($onlist, $rule) = OnBlacklist($sender, 0);
80
81     if ($onlist) {
82       print div {-align => "center"},
83            font {-color => "black"},
84             "Messages from", b ($sender), "will be", b ("blacklisted"), br, hr;
85       print $rule;
86     } else {
87       ($onlist, $rule) = OnNulllist($sender, 0);
88
89       if ($onlist) {
90         print div {-align => "center"},
91              font {-color => "grey"},
92             "Messages from", b ($sender), "will be", b ("discarded"), br, hr;
93         print $rule;
94       } else {
95         print div {-align => "center"},
96              font {-color => "red"},
97             "Messages from", b ($sender), "will be", b ("returned");
98       } # if
99     } # if
100   } # if
101
102   print br div {-align => "center"},
103     submit(-name      => "submit",
104            -value     => "Close",
105            -onClick   => "window.close (self)");
106
107   return;
108 } # Body
109
110 sub Footing() {
111   print end_html;
112
113   return;
114 } # Footing
115
116 # Main
117 SetContext($userid);
118 Heading;
119 Body;
120 Footing;
121
122 exit;
123