0
|
1 <?
|
|
2 $mode = stGetRequestItem("mode", "start");
|
|
3
|
|
4 $botCheckIDs = "aBcdefghIjklmnopqrsTuvxyz0123456";
|
|
5 $botCheckOPs = "bit";
|
|
6 $botCheckROPs = "+-*";
|
|
7
|
|
8
|
|
9 function stPrintFormData($button, $mode = "start")
|
|
10 {
|
|
11 echo
|
|
12 "<form name=\"register\" action=\"register\" method=\"post\">\n".
|
|
13 " <input type=\"submit\" value=\"".chentities($button)."\" />\n";
|
|
14
|
|
15 stPrintFormHiddenInput("mode", $mode);
|
|
16
|
|
17 foreach (array("name", "groups", "email", "oneliner", "hash", "botcheck") as $name)
|
|
18 stPrintFormHiddenInput($name, stGetRequestItem($name));
|
|
19
|
|
20 echo "</form>\n";
|
|
21 }
|
|
22
|
|
23
|
|
24 function intValueToHash($val)
|
|
25 {
|
|
26 global $botCheckIDs;
|
|
27 $str = "";
|
|
28 do
|
|
29 {
|
|
30 $str = $botCheckIDs[$val & 31].$str;
|
|
31 $val >>= 5;
|
|
32 }
|
|
33 while ($val > 0);
|
|
34 return $str;
|
|
35 }
|
|
36
|
|
37
|
|
38 function intHashToValue($hash)
|
|
39 {
|
|
40 global $botCheckIDs;
|
|
41 for ($val = 0, $i = 0; $i < strlen($hash); $i++)
|
|
42 {
|
|
43 $val *= 32;
|
|
44 $n = strpos($botCheckIDs, $hash[$i]);
|
|
45 if ($n !== FALSE)
|
|
46 $val += $n;
|
|
47 else
|
|
48 return -2;
|
|
49 }
|
|
50 return $val;
|
|
51 }
|
|
52
|
|
53
|
|
54 function splitHash($hash)
|
|
55 {
|
|
56 global $botCheckOPs;
|
|
57 return preg_split("/([".$botCheckOPs."])/", $hash, -1, PREG_SPLIT_DELIM_CAPTURE);
|
|
58 }
|
|
59
|
|
60
|
|
61 function hashToCheckStr($hash)
|
|
62 {
|
|
63 global $botCheckOPs, $botCheckROPs;
|
|
64 $out = "";
|
|
65
|
|
66 foreach (splitHash($hash) as $val)
|
|
67 {
|
|
68 $i = strpos($botCheckOPs, $val);
|
|
69 if ($i !== FALSE)
|
|
70 $out .= " ".$botCheckROPs[$i]." ";
|
|
71 else
|
|
72 $out .= intHashToValue($val);
|
|
73 }
|
|
74 return $out;
|
|
75 }
|
|
76
|
|
77
|
|
78 function hashToAnswer($hash)
|
|
79 {
|
|
80 eval("\$res = ".hashToCheckStr($hash).";");
|
|
81 return $res;
|
|
82 }
|
|
83
|
|
84 // Check if registration is enabled
|
|
85 if (!stChkSetting("allowRegister"))
|
|
86 {
|
|
87 ?>
|
|
88 <h1>Sorry, registration disabled!</h1>
|
|
89 <p>
|
|
90 Registration to the event is not available at this time.
|
|
91 </p>
|
|
92 <?
|
|
93 }
|
|
94 else
|
|
95 if ($mode == "start")
|
|
96 {
|
|
97 $botCheckHash =
|
|
98 intValueToHash(rand(1,5)).
|
|
99 $botCheckOPs[rand(0,2)].
|
|
100 intValueToHash(rand(1,5)).
|
|
101 $botCheckOPs[rand(0,2)].
|
|
102 intValueToHash(5 * rand(1,5));
|
|
103
|
|
104 ?>
|
|
105 <h1>Registration</h1>
|
|
106
|
|
107 <form name="register" action="register" method="post">
|
|
108 <input type="hidden" name="mode" value="check">
|
|
109 <input type="hidden" name="hash" value="<? echo $botCheckHash ?>">
|
|
110 <table>
|
|
111 <?
|
|
112 stPrintFormTextInput("Handle:", "(elite)", 30, 30, "name");
|
|
113 stPrintFormTextInput("Group(s):", "(elite crew^supahmen)", 40, 64, "groups");
|
|
114 stPrintFormTextInput("E-mail:", "(to be informed of location etc)", 40, 64, "email");
|
|
115 stPrintFormTextInput("Oneliner:", "(whatever)", 64, 64, "oneliner");
|
|
116 stPrintFormTextInput(hashToCheckStr($botCheckHash)." = ", "(I.Q. / robot check".
|
|
117 //" [".hashToAnswer($botCheckHash)."]".
|
16
|
118 ")", 20, 20, "botcheck", "autocomplete=\"off\"");
|
0
|
119 ?>
|
|
120 <tr><td colspan="2"></td><td><input type="submit" value="Register" /></td></tr>
|
|
121 </table>
|
|
122 </form>
|
|
123 <?
|
16
|
124 echo stGetSetting("registerInfoText");
|
0
|
125 }
|
|
126 else
|
|
127 if ($mode == "check")
|
|
128 {
|
|
129 if (stChkDataItem("name") || strlen(stGetRequestItem("name")) < 3)
|
|
130 stError("Handle / name not given, or too short.");
|
|
131
|
|
132 if (stChkDataItem("hash"))
|
|
133 stError("Invalid data.");
|
|
134
|
16
|
135 $email = stGetRequestItem("email");
|
|
136 if (stGetSetting("requireEMail"))
|
|
137 {
|
|
138 if (stChkDataItem("email") || strlen($email) < 4)
|
|
139 stError("E-mail address not given, or it is too short.");
|
|
140 }
|
|
141
|
|
142 if (strlen($email >= 4) && (strpos($email, "@") === FALSE || strpos($email, ".") === FALSE))
|
|
143 stError("E-mail address not in proper format.");
|
|
144
|
0
|
145 $hash = stGetRequestItem("hash");
|
|
146 $answer = stGetRequestItem("botcheck");
|
|
147 if (hashToAnswer($hash) != intval($answer))
|
|
148 stError("Incorrect answer to I.Q. / bot check.");
|
|
149
|
|
150 if ($errorSet)
|
|
151 {
|
|
152 echo "<p>Following errors occured:</p>\n".
|
|
153 "<ul>\n".$errorMsg."</ul>\n";
|
|
154 stPrintFormData("Go back");
|
|
155 }
|
|
156 else
|
|
157 {
|
|
158 $sql = stPrepareSQL(
|
|
159 "INSERT INTO attendees (regtime,name,groups,oneliner,email) VALUES (%d,%S,%S,%S,%S)",
|
|
160 time(), "name", "groups", "oneliner", "email");
|
|
161
|
|
162 if (stExecSQL($sql) !== FALSE)
|
|
163 {
|
16
|
164 echo "<h1>Registration successful</h1>\n".
|
|
165 stGetSetting("registerPostText");
|
|
166
|
0
|
167 if (stChkDataItem("email"))
|
16
|
168 echo stGetSetting("registerPostNoEmail");
|
0
|
169 }
|
|
170 else
|
|
171 {
|
|
172 echo "<h1>An error occured.</h1>\n";
|
|
173 echo "<p>Oh noes! SQL error happenstance!</p>";
|
|
174 }
|
|
175 }
|
|
176 }
|
|
177 ?> |