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