63975b4253cf976ff02bc0af2633ddd2b13f2b83
[clearscm.git] / maps / bin / register.cgi
1 #!/usr/bin/perl
2 ################################################################################
3 #
4 # File:         $RCSfile: register.cgi,v $
5 # Revision:     $Revision: 1.1 $
6 # Description:  Register a MAPS user
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 use MAPSLog;
25 use MAPSWeb;
26
27 use CGI qw/:standard/;
28
29 my $fullname    = param ("fullname");
30 my $sender      = lc (param ("sender"));
31 my $userid      = param ("userid");
32
33 sub MyFooting {
34   print div ({-align    => "center"},
35     button (-name       => "close",
36             -value      => "Close Window",
37             -onClick    => "window.close ()"));
38   print end_html;
39 } # MyFooting
40
41 sub MyError {
42   my $errmsg = shift;
43
44   print h3 ({-class => "error",
45              -align => "center"}, "ERROR: " . $errmsg);
46
47   MyFooting;
48
49   exit 1;
50 } # MyError
51
52 sub MyHeading {
53   print
54     header     (-title  => "MAPS Registration"),
55     start_html (-title  => "MAPS Registration",
56                 -author => "Andrew\@DeFaria.com",
57                 -style  => {-src        => "/maps/css/MAPSPlain.css"});
58   print
59     h2 ({-class => "header",
60          -align => "center"},
61       font ({-class => "standout"}, 
62             "MAPS"), "Registration Results");
63 } # MyHeading
64
65 # Main
66 MyHeading;
67
68 if ($sender eq "") {
69   MyError "Sender not specified!";
70 }
71
72 my $rule;
73
74 if (OnWhitelist $sender, $userid) {
75   MyError "The email address $sender is already on ${userid}'s list"
76 } # if
77
78 my $messages = Add2Whitelist $sender, $userid, $fullname;
79
80 print p "$fullname, your email address, $sender, has been added to ${userid}'s white list.";
81
82 if ($messages > 0) {
83   if ($messages == 1) {
84     print p "Your previous message has been delivered\n";
85   } else {
86     print p "Your previous $messages messages have been delivered\n";
87   } # if
88 } elsif ($messages == -1) {
89   MyError "Unable to deliver message";
90 } else {
91   print p "Unable to find any old messages but future messages will now be delivered.";
92 } # if
93
94 MyFooting;