annotate adduser.pl @ 2:791e87929f83 default tip

Added tag RELENG_1_0 for changeset d95e74cd12f4
author darius@midget.dons.net.au
date Tue, 23 Oct 2007 10:07:21 +0930
parents d95e74cd12f4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
1 #!/usr/local/bin/perl
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
2
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
3 require "cgi-lib.pl";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
4 use DBI;
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
5
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
6 $user = "";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
7 $passwd = "";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
8 $dbname = "scs";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
9
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
10 MAIN:
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
11 {
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
12 # Read in all the variables set by the form
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
13 &ReadParse(*input);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
14
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
15 print &PrintHeader;
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
16 print "<BODY BGCOLOR=\"#00000\" TEXT=\"#CCCCCC\" LINK=\"#00EE20\"";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
17 print " VLINK=\"#55FF8B\" ALINK=\"#FFFF00\">";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
18 print "<META HTTP-EQUIV=\"Pragma\" content=\"no-cache\">\n";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
19 print "<TITLE>Add a user to the SCS Database</TITLE>";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
20 print "<H2>Add a user to the SCS Database</H2>";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
21
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
22 # Connect to the Database
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
23 $dbh = DBI->connect("dbi:Pg:dbname=$dbname", $user, $passwd) || bad_exit($sth->errstr);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
24
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
25 $fname = san_str($input{'fname'});
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
26 $lname = san_str($input{'lname'});
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
27 $nick = san_str($input{'nick'});
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
28 $pwd1 = san_str($input{'pwd1'});
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
29 $pwd2 = san_str($input{'pwd2'});
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
30 $age = san_num($input{'age'});
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
31 $phone1 = san_str($input{'phone1'});
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
32 $ph1_pub = (san_str($input{'ph1_pub'}) eq 'on') ? 't' : 'f';
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
33 $phone2 = san_str($input{'phone2'});
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
34 $ph2_pub = (san_str($input{'ph2_pub'}) eq 'on') ? 't' : 'f';
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
35 $email = san_str($input{'email'});
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
36 $email_pub = (san_str($input{'email_pub'}) eq 'on') ? 't' : 'f';
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
37 $address1 = san_str($input{'addy1'});
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
38 $address2 = san_str($input{'addy2'});
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
39 $address3 = san_str($input{'addy3'});
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
40 $addy_pub = (san_str($input{'addy_pub'}) eq 'on') ? 't' : 'f';
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
41 $comments = san_str($input{'comments'});
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
42 }
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
43
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
44 sub bad_exit
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
45 {
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
46 print "<H2>An internal error has occurred</H2><BR>";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
47 print "Please mail <A HREF=\"mailto:darius\@dons.net.au\">The Administrator</A> and\n";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
48 print "say the following error occured - $_[0]<P>\n";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
49 print "<A HREF=\"/scs/games/adduser.html\">Back to the Add User Page</A>\n";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
50
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
51 print &HtmlBot;
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
52
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
53 exit(0);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
54 }
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
55
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
56 sub dtrail
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
57 {
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
58 $_[0] =~ s/(\ *)$//g;
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
59 return $_[0];
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
60 }
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
61
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
62 sub san_str
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
63 {
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
64 $_[0] =~ s/\\/\\\\/g;
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
65 $_[0] =~ s/'/\\'/g;
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
66 $_[0] =~ s/"/\\"/g;
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
67 return $_[0];
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
68 }
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
69
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
70 sub san_num
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
71 {
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
72 # $_[0] =~ s/'/\\'/g;
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
73 return $_[0];
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
74 }