annotate register.inc.php @ 188:a49c5f15a273

Less strict username check.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 08 Nov 2013 20:39:35 +0200
parents 1fcdc6e752f6
children 988e0ab2b77e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 <?
136
aeebfedb5709 Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
2 //
aeebfedb5709 Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
3 // FAPWeb Simple Demoparty System
aeebfedb5709 Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
4 // Attendee registration page
aeebfedb5709 Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
5 // (C) Copyright 2012-2013 Tecnic Software productions (TNSP)
aeebfedb5709 Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
6 //
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 $mode = stGetRequestItem("mode", "start");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8
138
e04f6e3c04f7 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
9 // Settings for robot check hash generator
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 $botCheckIDs = "aBcdefghIjklmnopqrsTuvxyz0123456";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 $botCheckOPs = "bit";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 $botCheckROPs = "+-*";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 function stPrintFormData($button, $mode = "start")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 echo
26
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
18 stGetFormStart("register").
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
19 " ".stGetFormSubmitInput("continue", $button)."\n";
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 stPrintFormHiddenInput("mode", $mode);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23 foreach (array("name", "groups", "email", "oneliner", "hash", "botcheck") as $name)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24 stPrintFormHiddenInput($name, stGetRequestItem($name));
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26 echo "</form>\n";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29
138
e04f6e3c04f7 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
30 // Convert integer value to hash code
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 function intValueToHash($val)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 global $botCheckIDs;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 $str = "";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 do
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37 $str = $botCheckIDs[$val & 31].$str;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 $val >>= 5;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 while ($val > 0);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 return $str;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44
138
e04f6e3c04f7 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
45 // Convert integer hash to integer value
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 function intHashToValue($hash)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48 global $botCheckIDs;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49 for ($val = 0, $i = 0; $i < strlen($hash); $i++)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51 $val *= 32;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52 $n = strpos($botCheckIDs, $hash[$i]);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53 if ($n !== FALSE)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54 $val += $n;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56 return -2;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58 return $val;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61
138
e04f6e3c04f7 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
62 // Split hash into parts
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63 function splitHash($hash)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65 global $botCheckOPs;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66 return preg_split("/([".$botCheckOPs."])/", $hash, -1, PREG_SPLIT_DELIM_CAPTURE);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
68
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
69
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70 function hashToCheckStr($hash)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
71 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72 global $botCheckOPs, $botCheckROPs;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73 $out = "";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
74
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
75 foreach (splitHash($hash) as $val)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
76 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
77 $i = strpos($botCheckOPs, $val);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78 if ($i !== FALSE)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
79 $out .= " ".$botCheckROPs[$i]." ";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81 $out .= intHashToValue($val);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
82 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83 return $out;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
85
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
87 function hashToAnswer($hash)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
88 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
89 eval("\$res = ".hashToCheckStr($hash).";");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90 return $res;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92
138
e04f6e3c04f7 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
93 // Check if user registration is available
103
c6b9041078ec Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
94 stCheckRegistrationAvailable();
c6b9041078ec Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
95
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
96 // Check if registration is enabled
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
97 if (!stChkSetting("allowRegister"))
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98 {
182
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
99 echo stGetSetting("registerNotEnabled");
103
c6b9041078ec Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
100 }
c6b9041078ec Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
101 else
c6b9041078ec Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
102 if ($maxAttendeesHard > 0 && $numAttendees >= $maxAttendeesHard)
c6b9041078ec Add hard limit option for attendees, and add feature of using "0" to disable
Matti Hamalainen <ccr@tnsp.org>
parents: 48
diff changeset
103 {
182
e227e6a3d46b Move some texts to settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
104 echo stGetSetting("registerLimitExceeded");
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
105 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
106 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
107 if ($mode == "start")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
108 {
138
e04f6e3c04f7 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
109 //
e04f6e3c04f7 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
110 // Show registration form
e04f6e3c04f7 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
111 //
e04f6e3c04f7 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
112 // Generate bot-check
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
113 $botCheckHash =
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
114 intValueToHash(rand(1,5)).
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
115 $botCheckOPs[rand(0,2)].
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
116 intValueToHash(rand(1,5)).
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
117 $botCheckOPs[rand(0,2)].
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
118 intValueToHash(5 * rand(1,5));
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
119
26
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
120 echo
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
121 "<h1>Registration</h1>\n".
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
122 stGetFormStart("register").
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
123 " ".stGetFormHiddenInput("mode", "check")."\n".
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
124 " ".stGetFormHiddenInput("hash", $botCheckHash)."\n".
184
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
125 " <table class=\"register\">\n";
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
126 stPrintFormTextInput("Handle:", "(elite)", 20, SET_LEN_USERNAME, "name");
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
127 stPrintFormTextInput("Group(s):", "(elite crew^supahmen)", 30, SET_LEN_GROUPS, "groups");
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
128 stPrintFormTextInput("E-mail:", "(to be informed of location etc)", 30, SET_LEN_EMAIL, "email");
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
129 stPrintFormTextInput("Oneliner:", "(whatever)", 30, SET_LEN_ONELINER, "oneliner");
26
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
130 stPrintFormTextInput(hashToCheckStr($botCheckHash)." = ", "(I.Q. / robot check".
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
131 //" [".hashToAnswer($botCheckHash)."]".
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
132 ")", 20, 20, "botcheck", "autocomplete=\"off\"");
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
133 echo
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
134 " <tr><td colspan=\"2\"></td><td>".stGetFormSubmitInput("register", "Register")."</td></tr>\n".
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
135 " </table>\n".
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
136 "</form>\n";
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
137
26
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 16
diff changeset
138 echo stGetSetting("registerInfoText");
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
139 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
140 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
141 if ($mode == "check")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
142 {
138
e04f6e3c04f7 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
143 //
e04f6e3c04f7 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
144 // Check the registrant's details
e04f6e3c04f7 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
145 //
187
1fcdc6e752f6 Some fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
146 stChkRequestItem("name", $fake,
184
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
147 array(CHK_ISGT, VT_STR, 0, "Handle / name not given."),
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
148 array(CHK_ISLT, VT_STR, SET_LEN_USERNAME, "Handle / name is too long, should be less than ".SET_LEN_USERNAME." characters."));
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
149
187
1fcdc6e752f6 Some fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
150 stChkRequestItem("groups", $fake,
184
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
151 array(CHK_ISLT, VT_STR, SET_LEN_GROUPS, "Groups are too long, should be less than ".SET_LEN_GROUPS." characters."));
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
152
187
1fcdc6e752f6 Some fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
153 stChkRequestItem("oneliner", $fake,
184
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
154 array(CHK_ISLT, VT_STR, SET_LEN_ONELINER, "Oneliner is too long, should be less than ".SET_LEN_ONELINER." characters."));
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
155
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
156 stChkRequestItem("hash", $hash,
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
157 array(CHK_GTEQ, VT_STR, 0, "Invalid data."));
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
158
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
159
16
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
160 $email = stGetRequestItem("email");
184
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
161 if (stGetSetting("requireEMail") && strlen($email) < 4)
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
162 stError("E-mail address not given, or it is too short.");
16
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
163
48
1fccb8f031ed Fix e-mail check.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
164 if (strlen($email) > 0 && (strpos($email, "@") === FALSE || strpos($email, ".") === FALSE))
16
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
165 stError("E-mail address not in proper format.");
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
166
184
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
167 if (strlen($email) > SET_LEN_EMAIL)
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
168 stError("E-mail address too long, max ".SET_LEN_EMAIL." characters.");
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
169
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
170 $answer = stGetRequestItem("botcheck");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
171 if (hashToAnswer($hash) != intval($answer))
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
172 stError("Incorrect answer to I.Q. / bot check.");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
173
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
174 if ($errorSet)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
175 {
183
320d6b68062b Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 182
diff changeset
176 echo
320d6b68062b Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 182
diff changeset
177 "<p>Following errors occured:</p>\n".
320d6b68062b Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 182
diff changeset
178 "<ul>\n".$errorMsg."</ul>\n";
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
179 stPrintFormData("Go back");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
180 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
181 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
182 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
183 $sql = stPrepareSQL(
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
184 "INSERT INTO attendees (regtime,name,groups,oneliner,email) VALUES (%d,%S,%S,%S,%S)",
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
185 time(), "name", "groups", "oneliner", "email");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
186
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
187 if (stExecSQL($sql) !== FALSE)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
188 {
183
320d6b68062b Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 182
diff changeset
189 echo stGetSetting("registerPostText");
16
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
190
184
1b30c2107e5b Add function for validating input with different definable conditions. Use
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
191 if (strlen($email) < 4)
16
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
192 echo stGetSetting("registerPostNoEmail");
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
193 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
194 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
195 {
183
320d6b68062b Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 182
diff changeset
196 echo
320d6b68062b Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 182
diff changeset
197 "<h1>An error occured.</h1>\n".
320d6b68062b Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 182
diff changeset
198 "<p>Oh noes! SQL error happenstance!</p>";
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
199 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
200 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
201 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
202 ?>