annotate edit.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\" VLINK=\"#55FF8B\" ALINK=\"#FFFF00\">";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
17 print "<META HTTP-EQUIV=\"Pragma\" content=\"no-cache\">\n";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
18 print "<TITLE>Edit the SCS Database</TITLE>";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
19 print "<H2>Edit the SCS Database</H2>";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
20
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
21 # print &HtmlTop ("Edit the SCS Database");
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
22
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
23 $id = $input{'id'};
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
24 $type = $input{'type'};
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
25
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
26 # Is this a query?
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
27 if ($type eq "edit") {
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
28
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
29 # Connect to the Database
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
30 $dbh = DBI->connect("dbi:Pg:dbname=$dbname", $user, $passwd) || bad_exit($sth->errstr);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
31
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
32 # Prepare the select statement
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
33 $sth = $dbh->prepare("SELECT * FROM members WHERE memberid = $id") || bad_exit($sth->errstr);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
34
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
35 # Execute it
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
36 $numrows = $sth->execute || bad_exit($sth->errstr);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
37
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
38 # Get one row. Only one.. if there is more than one, bad things have happened :)
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
39 if (@array = $sth->fetchrow_array) {
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
40
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
41 # Check their password
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
42 if (&dtrail(@array[4]) ne &dtrail($input{'passwd'})) {
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
43 print "Bad password for Member ID $id<P>\n";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
44 print "<A HREF=\"/scs/games/edit.html\">Try again</A>\n";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
45 } else {
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
46 # Print out a form which allows the user to change fields
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
47 $memberid = dtrail(@array[0]);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
48 $firstname = dtrail(@array[1]);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
49 $lastname = dtrail(@array[2]);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
50 $nickname = dtrail(@array[3]);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
51 $pin = dtrail(@array[4]);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
52 $age = dtrail(@array[5]);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
53 $phone1 = dtrail(@array[6]);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
54 $ph1_pub = dtrail(@array[7]);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
55 $phone2 = dtrail(@array[8]);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
56 $ph2_pub = dtrail(@array[9]);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
57 $email = dtrail(@array[10]);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
58 $email_pub = dtrail(@array[11]);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
59 $address1 = dtrail(@array[12]);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
60 $address2 = dtrail(@array[13]);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
61 $address3 = dtrail(@array[14]);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
62 $addy_pub = dtrail(@array[15]);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
63 $comments = dtrail(@array[16]);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
64 $joined = dtrail(@array[17]);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
65 $lstmemfee = dtrail(@array[18]);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
66 $lstpddate = dtrail(@array[19]);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
67
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
68 print "<FORM METHOD=GET ACTION=\"/cgi-bin/scs/edit.pl\">\n";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
69 print "<TABLE WIDTH=\"100%\">\n";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
70 print "<TR><TD ALIGN=RIGHT>First Name<TD>";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
71 printf("<INPUT TYPE=TEXT NAME=fname VALUE=\"%s\" SIZE=\"50%\"></TR>\n",
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
72 $firstname);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
73 print "<TR><TD ALIGN=RIGHT>Last Name<TD>";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
74 printf("<INPUT TYPE=TEXT NAME=lname VALUE=\"%s\" SIZE=\"50%\"></TR>\n",
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
75 $lastname);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
76 print "<TR><TD ALIGN=RIGHT>Member ID<TD>$id";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
77 printf("<INPUT TYPE=HIDDEN NAME=id VALUE=\"%d\"></TR>\n", $id);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
78 printf("<TR><TD ALIGN=RIGHT>Nickname<TD>");
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
79 printf("<INPUT TYPE=TEXT NAME=nick VALUE=\"%s\" SIZE=\"50%\"></TR>\n",
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
80 $nickname);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
81 print "<TR><TD ALIGN=RIGHT>Password<TD>";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
82 printf("<INPUT TYPE=PASSWORD NAME=pwd1 VALUE=\"%s\" SIZE=\"50%\">", $pin);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
83 printf("<INPUT TYPE=HIDDEN NAME=passwd VALUE=\"%s\"</TR>\n", $pin);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
84 print "<TR><TD ALIGN=RIGHT>And Again<TD>";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
85 printf("<INPUT TYPE=PASSWORD NAME=pwd2 VALUE=\"%s\" SIZE=\"50%\"></TR>\n",
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
86 $pin);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
87 print "<TR><TD ALIGN=RIGHT>Age<TD>";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
88 printf("<INPUT TYPE=TEXT NAME=age VALUE=\"%d\" SIZE=\"50%\"></TR>\n",
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
89 $age);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
90 print "<TR><TD ALIGN=RIGHT>Phone 1<TD>";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
91 printf("<INPUT TYPE=TEXT NAME=phone1 VALUE=\"%s\" SIZE=\"50%\"></TR>\n",
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
92 $phone1);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
93 print "<TR><TD ALIGN=RIGHT>Public number<TD>";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
94 printf("<INPUT TYPE=CHECKBOX NAME=ph1_pub %s SIZE=\"50%\"></TR>\n",
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
95 (($ph1_pub eq "0") ? '' : 'CHECKED'));
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
96 print "<TR><TD ALIGN=RIGHT>Phone 2<TD>";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
97 printf("<INPUT TYPE=TEXT NAME=phone2 VALUE=\"%s\" SIZE=\"50%\"></TR>\n",
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
98 $phone2);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
99 print "<TR><TD ALIGN=RIGHT>Public number<TD>";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
100 printf("<INPUT TYPE=CHECKBOX NAME=ph2_pub %s SIZE=\"50%\"></TR>\n",
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
101 (($ph2_pub eq "0") ? '' : 'CHECKED'));
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
102 print "<TR><TD ALIGN=RIGHT>Email<TD>";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
103 printf("<INPUT TYPE=TEXT NAME=email VALUE=\"%s\" SIZE=\"50%\"></TR>\n",
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
104 $email);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
105 print "<TR><TD ALIGN=RIGHT>Public Email<TD>";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
106 printf("<INPUT TYPE=CHECKBOX NAME=email_pub %s SIZE=\"50%\"></TR>\n",
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
107 (($email_pub eq "0") ? '' : 'CHECKED'));
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
108 print "<TR><TD ALIGN=RIGHT>Address 1<TD>";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
109 printf("<INPUT TYPE=TEXT NAME=addy1 VALUE=\"%s\" SIZE=\"50%\"></TR>\n",
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
110 $address1);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
111 print "<TR><TD ALIGN=RIGHT>Address 2<TD>";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
112 printf("<INPUT TYPE=TEXT NAME=addy2 VALUE=\"%s\" SIZE=\"50%\"></TR>\n",
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
113 $address2);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
114 print "<TR><TD ALIGN=RIGHT>Address 3<TD>";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
115 printf("<INPUT TYPE=TEXT NAME=addy3 VALUE=\"%s\" SIZE=\"50%\"></TR>\n",
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
116 $address3);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
117 print "<TR><TD ALIGN=RIGHT>Public Address<TD>";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
118 printf("<INPUT TYPE=CHECKBOX NAME=addy_pub %s SIZE=\"50%\"></TR>\n",
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
119 (($addy_pub eq "0") ? '' : 'CHECKED'));
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
120 print "<TR><TD ALIGN=RIGHT>Comments<TD>";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
121 printf("<INPUT TYPE=TEXT NAME=comments VALUE=\"%s\" SIZE=\"50%\"></TR>\n",
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
122 $comments);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
123 printf("<TR><TD ALIGN=RIGHT>Joined on<TD>@array[13]</TR>\n", $joined);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
124 printf("<TR><TD ALIGN=RIGHT>Last Membership paid<TD>%s</TR>\n", $lstmemfee);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
125 printf("<TR><TD ALIGN=RIGHT>Last Membership date<TD>%s</TR>\n", $lstpddate);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
126 print "</TABLE>\n";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
127 print "<INPUT TYPE=HIDDEN NAME=\"type\" VALUE=\"adjust\">\n";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
128 print "<INPUT TYPE=SUBMIT VALUE=\"Update information\"><P>\n";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
129 print "Or <A HREF=\"/scs/games/edit.html\">Go back to the Edit page</A>\n";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
130 print "<P>";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
131 }
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
132 } else {
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
133 # Couldn't find the member ID given
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
134 print "No such member ID $id<P>\n";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
135 print "<A HREF=\"/scs/games/edit.html\">Try again</A>\n";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
136 }
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
137
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
138 # Close down DB stuff
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
139 $sth->finish || bad_exit($sth->errstr);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
140
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
141 $dbh->disconnect || bad_exit($sth->errstr);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
142
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
143 # We are doing an adjust
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
144 } elsif ($type eq "adjust") {
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
145 # Connect to the Database
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
146 $dbh = DBI->connect("dbi:Pg:dbname=$dbname", $user, $passwd) || bad_exit($sth->errstr);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
147
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
148 # Prepare the select statement
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
149 $sth = $dbh->prepare("SELECT * FROM members WHERE memberid = $id") || bad_exit($sth->errstr);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
150
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
151 # Execute it
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
152 $numrows = $sth->execute || bad_exit($sth->errstr);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
153
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
154 # Get one row. Only one.. if there is more than one, bad things have happened :)
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
155 if (@array = $sth->fetchrow_array) {
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
156
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
157 # Check their password
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
158 if (&dtrail(@array[4]) ne &dtrail($input{'passwd'})) {
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
159 print "Bad password for Member ID $id<P>\n";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
160 print "Please report this error to <A HREF=\"mailto:darius\@dons.net.au\">\n";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
161 print "the administrator</A><P>\n";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
162 print "<A HREF=\"/scs/games/edit.html\">Try again</A>\n";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
163 } else {
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
164 $fname = san_str($input{'fname'});
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
165 $lname = san_str($input{'lname'});
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
166 $nick = san_str($input{'nick'});
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
167 $pwd1 = san_str($input{'pwd1'});
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
168 $pwd2 = san_str($input{'pwd2'});
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
169 $age = san_num($input{'age'});
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
170 $phone1 = san_str($input{'phone1'});
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
171 $ph1_pub = (san_str($input{'ph1_pub'}) eq 'on') ? 't' : 'f';
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
172 $phone2 = san_str($input{'phone2'});
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
173 $ph2_pub = (san_str($input{'ph2_pub'}) eq 'on') ? 't' : 'f';
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
174 $email = san_str($input{'email'});
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
175 $email_pub = (san_str($input{'email_pub'}) eq 'on') ? 't' : 'f';
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
176 $address1 = san_str($input{'addy1'});
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
177 $address2 = san_str($input{'addy2'});
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
178 $address3 = san_str($input{'addy3'});
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
179 $addy_pub = (san_str($input{'addy_pub'}) eq 'on') ? 't' : 'f';
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
180 $comments = san_str($input{'comments'});
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
181
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
182 if ($pwd1 ne $pwd2) {
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
183 print "New password mismatch\n";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
184 print "<A HREF=\"/scs/games/edit.html\">Try again</A>\n";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
185 } else {
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
186 $dbh->do("UPDATE members SET firstname=\'$fname\', lastname=\'$lname\', nickname=\'$nick\', pin=\'$pwd1\', age=\'$age\', phone1=\'$phone1\', ph1_pub=\'$ph1_pub', phone2=\'$phone2\', ph2_pub=\'$ph2_pub\', email=\'$email\', email_pub=\'$email_pub\', address1=\'$address1\', address2=\'$address2\', address3=\'$address3\', addy_pub=\'$addy_pub\', comments=\'$comments\' WHERE memberid=$id;") || bad_exit($sth->errstr);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
187 print "Update finished!<P>\n";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
188 print "Go back to the <A HREF=\"/games/scs/edit.html\">Edit Page</A>";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
189 }
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
190 }
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
191 } else {
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
192 # Couldn't find the member ID given
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
193 print "No such member ID $id<P>\n";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
194 print "<A HREF=\"/scs/games/edit.html\">Try again</A>\n";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
195 }
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
196
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
197 # Close down DB stuff
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
198 $sth->finish || bad_exit($sth->errstr);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
199
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
200 $dbh->disconnect || bad_exit($sth->errstr);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
201
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
202 # Something weird happened here
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
203 } else {
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
204 print "Unsupported action!<P>\n";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
205 print "Please email <A HREF=\"mailto:darius\@dons.net.au\">The Administrator</A> and<BR>\n";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
206 print "give a problem report. Thanks!<P>";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
207 }
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
208
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
209 print &HtmlBot;
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
210 }
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
211
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
212 sub bad_exit
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
213 {
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
214 print "<H2>An internal error has occurred</H2><BR>";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
215 print "Please mail <A HREF=\"mailto:darius\@dons.net.au\">The Administrator</A> and\n";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
216 print "say the following error occured - $_[0]<P>";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
217 print "<A HREF=\"/scs/games/edit.html\">Back to the Edit Page</A>\n";
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
218
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
219 print &HtmlBot;
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
220
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
221 exit(0);
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
222 }
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
223
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
224 sub dtrail
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
225 {
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
226 $_[0] =~ s/(\ *)$//g;
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
227 return $_[0];
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
228 }
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
229
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
230 sub san_str
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
231 {
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
232 $_[0] =~ s/\\/\\\\/g;
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
233 $_[0] =~ s/'/\\'/g;
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
234 $_[0] =~ s/"/\\"/g;
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
235 return $_[0];
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
236 }
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
237
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
238 sub san_num
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
239 {
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
240 # $_[0] =~ s/'/\\'/g;
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
241 return $_[0];
d95e74cd12f4 Initial commit
darius
parents:
diff changeset
242 }