2 $CALL_ME_FUNCTIONS["register"] = "gwvpmini_RegisterCallMe";
4 global $can_register, $reg_reqs_confirm, $confirm_from_address;
\r
6 $reg = gwvpmini_getConfigVal("canregister");
\r
7 $reg2 = gwvpmini_getConfigVal("registerrequiresconfirm");
8 $reg3 = gwvpmini_getConfigVal("eamilfromaddress");
\r
11 gwvpmini_setConfigVal("canregister", "1");
\r
12 } else if($reg == 1) {
\r
13 $can_register = true;
\r
15 $can_register = false;
\r
19 gwvpmini_setConfigVal("registerrequiresconfirm", "0");
\r
20 } else if($reg2 == 1) {
\r
21 $reg_reqs_confirm = true;
\r
23 $reg_reqs_confirm = false;
\r
27 gwvpmini_setConfigVal("eamilfromaddress", "admin@localhost");
28 $confirm_from_address = "admin@localhost";
\r
30 $confirm_from_address = $reg3;
\r
34 function gwvpmini_RegisterCallMe()
38 error_log("in admin callme");
39 if(isset($_REQUEST["q"])) {
40 $query = $_REQUEST["q"];
41 $qspl = explode("/", $query);
43 if($qspl[0] == "register") {
45 if($qspl[1] == "sendinfo") {
46 return "gwvpmini_RegisterUser";
48 if($qspl[1] == "confirmreg") {
49 return "gwvpmini_ConfirmRegistration";
51 } else return "gwvpmini_RegisterPage";
62 function gwvpmini_RegisterPage()
64 global $user_view_call, $MENU_ITEMS, $BASE_URL;
66 $MENU_ITEMS["40thisuser"]["text"] = "Register";
67 $MENU_ITEMS["40thisuser"]["link"] = "$BASE_URL/register";
69 gwvpmini_goMainPage("gwvpmini_RegisterPageBody");
72 function gwvpmini_RegisterPageBody()
74 global $user_view_call, $can_register, $BASE_URL, $reg_reqs_confirm;
76 echo "<h2>Registration</h2>";
77 echo "Complete the following form for registration<br>";
78 if($reg_reqs_confirm) {
79 echo "Email address will be confirmed after this form is completed, so make sure its available and viewable<br>";
81 echo "<form method=\"post\" action=\"$BASE_URL/register/sendinfo\">";
82 echo "<table border=\"1\">";
83 echo "<tr><th>Name to go by (full name/nickname/etc)</th><td><input type=\"text\" name=\"fullname\"></td></tr>";
84 echo "<tr><th>Username (desired username for login)</th><td><input type=\"text\" name=\"username\"></td></tr>";
85 echo "<tr><th>Password</th><td><input type=\"password\" name=\"password\"></td></tr>";
\r
86 echo "<tr><th>Confirm Password</th><td><input type=\"password\" name=\"confpassword\"></td></tr>";
\r
87 echo "<tr><th>Description of yourself</th><td><input type=\"text\" name=\"desc\"></td></tr>";
\r
88 echo "<tr><th>Email</th><td><input type=\"text\" name=\"email\"></td></tr>";
\r
89 echo "<tr><th>Confirm Email</th><td><input type=\"text\" name=\"confemail\"></td></tr>";
90 echo "<tr><td colspan=\"2\"><input type=\"submit\" name=\"Add\" value=\"Add\"></td></tr>";
\r
96 function gwvpmini_RegisterUser()
98 global $can_register, $BASE_URL, $reg_reqs_confirm;
100 $reg_succeeded = true;
101 $failed_error = "oops";
\r
103 $uname = $_REQUEST["username"];
104 $fname = $_REQUEST["fullname"];
105 $pass1 = $_REQUEST["password"];
106 $pass2 = $_REQUEST["confpassword"];
107 $email1 = $_REQUEST["email"];
108 $email2 = $_REQUEST["confemail"];
109 $desc = $_REQUEST["desc"];
111 if($pass1 != $pass2) {
112 $failed_error = "Password and confirmation password differ (hit back to try again)";
113 $reg_succeeded = false;
116 if($email1 != $email2) {
117 $failed_error = "email and confirmation email differ (hit back to try again)";
118 $reg_succeeded = false;
121 if(gwvpmini_GetUserId($uname) !== false) {
122 $failed_error = "Username already in use (hit back and try a new one)";
123 $reg_succeeded = false;
126 if(!$reg_succeeded) {
127 gwvpmini_SendMessage("error", $failed_error);
129 //function gwvpmini_AddUser($username, $password, $fullname, $email, $desc, $level, $status)
130 if($reg_reqs_confirm) {
131 $hash = gwvpmini_GenerateHash();
133 gwvpmini_SendMessage("info", "An email has been sent to the registered email address with details to continue the registration process $hash");
135 gwvpmini_SendMessage("info", "Congratulations, you are now registered, login to continue");
139 gwvpmini_AddUser($uname, $pass1, $fname, $email1, $desc, 0, $s);
143 header("Location: $BASE_URL");
146 function gwvpmini_GenerateHash()
149 $hashchars = "abcdefghijlkmnopqrstuvwxyz01234567890";
152 for($i=0; $i<$hashlen; $i++) {
153 $hash .= $hashchars[rand(0,strlen($hashchars)-1)];
159 function gwvpmini_ConfirmRegistration()
161 global $can_register, $BASE_URL, $reg_reqs_confirm;
164 if(isset($_REQUEST["q"])) {
\r
165 $query = $_REQUEST["q"];
\r
166 $qspl = explode("/", $query);
167 if(isset($qspl[2])) {
173 gwvpmini_SendMessage("error", "Confirmation failed, Confirm the url you used and try again");
174 } else if(gwvpmini_UpdateStatusFromConfirm($hash)) {
175 gwvpmini_SendMessage("info", "Confirmation succeeded, you may now login with your username and password");
177 gwvpmini_SendMessage("error", "Confirmation failed, Confirm the url you used and try again");
180 header("Location: $BASE_URL");