4 * This file contains code which relates to authentication of users to Citadel.
32 * Display the login screen
34 void display_login(char *mesg)
38 printf("HTTP/1.0 200 OK\n");
39 output_headers(1, "_top");
42 wprintf("<CENTER><TABLE border=0 width=100%><TR><TD>\n");
43 wprintf("<IMG SRC=\"/image&name=hello\">");
44 wprintf("</TD><TD><CENTER>\n");
47 wprintf("<font size=+1><b>%s</b></font>", mesg);
49 serv_puts("MESG hello");
55 wprintf("</CENTER></TD></TR></TABLE></CENTER>\n");
59 wprintf("<CENTER><FORM ACTION=\"/login\" METHOD=\"POST\">\n");
60 wprintf("<TABLE border><TR>\n");
61 wprintf("<TD>User Name:</TD>\n");
62 wprintf("<TD><INPUT TYPE=\"text\" NAME=\"name\" MAXLENGTH=\"25\">\n");
63 wprintf("</TD></TR><TR>\n");
64 wprintf("<TD>Password:</TD>\n");
65 wprintf("<TD><INPUT TYPE=\"password\" NAME=\"pass\" MAXLENGTH=\"20\"></TD>\n");
66 wprintf("</TR></TABLE>\n");
67 wprintf("<INPUT type=\"submit\" NAME=\"action\" VALUE=\"Login\">\n");
68 wprintf("<INPUT type=\"submit\" NAME=\"action\" VALUE=\"New User\">\n");
69 wprintf("<INPUT type=\"submit\" NAME=\"action\" VALUE=\"Exit\">\n");
71 wprintf("<BR><INPUT TYPE=\"checkbox\" NAME=\"noframes\">");
72 wprintf("<FONT SIZE=-1> Check here to disable frames</FONT>\n");
73 wprintf("</FORM></CENTER>\n");
76 wprintf("<LI><EM>If you already have an account on %s,",
77 serv_info.serv_humannode);
78 wprintf("</EM> enter your user name\n");
79 wprintf("and password and click \"<TT>Login</TT>.\"<BR>\n");
80 wprintf("<LI><EM>If you are a new user,</EM>\n");
81 wprintf("enter the name and password you wish to use, and click\n");
82 wprintf("\"New User.\"<BR><LI>");
83 wprintf("<EM>Please log off properly when finished.</EM>");
84 wprintf("<LI>You must use a browser that supports <i>cookies</i>.<BR>\n");
85 wprintf("</EM></UL>\n");
94 * This function needs to get called whenever a PASS or NEWU succeeds.
96 void become_logged_in(char *user, char *pass, char *serv_response)
99 extract(wc_username, &serv_response[4], 0);
100 strcpy(wc_password, pass);
101 axlevel = extract_int(&serv_response[4], 1);
113 if (!strcasecmp(bstr("noframes"), "on"))
118 if (!strcasecmp(bstr("action"), "Exit")) {
121 if (!strcasecmp(bstr("action"), "Login")) {
122 serv_printf("USER %s", bstr("name"));
125 serv_printf("PASS %s", bstr("pass"));
128 become_logged_in(bstr("name"),
131 display_login(&buf[4]);
135 display_login(&buf[4]);
139 if (!strcasecmp(bstr("action"), "New User")) {
140 serv_printf("NEWU %s", bstr("name"));
143 become_logged_in(bstr("name"), bstr("pass"), buf);
144 serv_printf("SETP %s", bstr("pass"));
147 display_login(&buf[4]);
155 need_regi = extract_int(&buf[4], 1);
156 /* FIX also check for new mail etc. here */
164 display_login("Your password was not accepted.");
169 void do_welcome(void)
173 printf("HTTP/1.0 200 OK\n");
174 output_headers(1, "_top");
175 wprintf("<CENTER><H1>");
176 escputs(wc_username);
178 /* FIX add user stats here */
181 output_static("frameset.html");
190 strcpy(wc_username, "");
191 strcpy(wc_password, "");
192 strcpy(wc_roomname, "");
194 printf("HTTP/1.0 200 OK\n");
195 output_headers(2, "_top"); /* note "2" causes cookies to be unset */
198 serv_puts("MESG goodbye");
204 wprintf("Goodbye\n");
206 wprintf("<HR><A HREF=\"/\">Log in again</A></CENTER>\n");
226 printf("HTTP/1.0 200 OK\n");
227 output_headers(1, "bottom");
229 strcpy(buf, bstr("user"));
231 if (strlen(bstr("axlevel")) > 0) {
232 serv_printf("VALI %s|%s", buf, bstr("axlevel"));
235 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
242 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
246 strcpy(user, &buf[4]);
247 serv_printf("GREG %s", user);
255 wprintf("User #%s<BR><H1>%s</H1>",
258 wprintf("PW: %s<BR>\n", buf);
260 wprintf("%s<BR>\n", buf);
262 wprintf("%s<BR>\n", buf);
264 wprintf("%s, ", buf);
268 wprintf("%s<BR>\n", buf);
270 wprintf("%s<BR>\n", buf);
272 wprintf("Current access level: %d (%s)\n",
273 atoi(buf), axdefs[atoi(buf)]);
274 } while (strcmp(buf, "000"));
276 wprintf("<H1>%s</H1>%s<BR>\n", user, &cmd[4]);
279 wprintf("<CENTER><TABLE border><CAPTION>Select access level:");
280 wprintf("</CAPTION><TR>");
281 for (a = 0; a <= 6; ++a) {
283 "<TD><A HREF=\"/validate&user=%s&axlevel=%d\">%s</A></TD>\n",
284 urlesc(user), a, axdefs[a]);
286 wprintf("</TR></TABLE><CENTER><BR>\n");
296 * Display form for registration.
297 * (Set during_login to 1 if this registration is being performed during
298 * new user login and will require chaining to the proper screen.)
300 void display_reg(int during_login)
305 printf("HTTP/1.0 200 OK\n");
306 output_headers(1, "bottom");
308 wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=007700><TR><TD>");
309 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
310 wprintf("<B>Enter registration info</B>\n");
311 wprintf("</FONT></TD></TR></TABLE>\n");
314 serv_puts("MESG register");
319 wprintf("<FORM ACTION=\"/register\" METHOD=\"POST\">\n");
320 wprintf("<INPUT TYPE=\"hidden\" NAME=\"during_login\" VALUE=\"%d\">\n", during_login);
322 serv_puts("GREG _SELF_");
325 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
328 wprintf("<H1>%s</H1><TABLE border>\n", &buf[4]);
330 while (serv_gets(buf), strcmp(buf, "000")) {
335 wprintf("Real Name:</TD><TD><INPUT TYPE=\"text\" NAME=\"realname\" VALUE=\"%s\" MAXLENGTH=\"29\"><BR>\n", buf);
338 wprintf("Street Address:</TD><TD><INPUT TYPE=\"text\" NAME=\"address\" VALUE=\"%s\" MAXLENGTH=\"24\"><BR>\n", buf);
341 wprintf("City/town:</TD><TD><INPUT TYPE=\"text\" NAME=\"city\" VALUE=\"%s\" MAXLENGTH=\"14\"><BR>\n", buf);
344 wprintf("State/province:</TD><TD><INPUT TYPE=\"text\" NAME=\"state\" VALUE=\"%s\" MAXLENGTH=\"2\"><BR>\n", buf);
347 wprintf("ZIP code:</TD><TD><INPUT TYPE=\"text\" NAME=\"zip\" VALUE=\"%s\" MAXLENGTH=\"10\"><BR>\n", buf);
350 wprintf("Telephone:</TD><TD><INPUT TYPE=\"text\" NAME=\"phone\" VALUE=\"%s\" MAXLENGTH=\"14\"><BR>\n", buf);
353 wprintf("E-Mail:</TD><TD><INPUT TYPE=\"text\" NAME=\"email\" VALUE=\"%s\" MAXLENGTH=\"31\"><BR>\n", buf);
356 wprintf("</TD></TR>\n");
358 wprintf("</TABLE><P>");
360 wprintf("<INPUT type=\"submit\" NAME=\"action\" VALUE=\"Register\">\n");
361 wprintf("<INPUT type=\"submit\" NAME=\"action\" VALUE=\"Cancel\">\n");
362 wprintf("</CENTER>\n");
369 void register_user(void)
373 if (strcmp(bstr("action"), "Register")) {
374 display_error("Cancelled. Registration was not saved.");
380 display_error(&buf[4]);
382 serv_puts(bstr("realname"));
383 serv_puts(bstr("address"));
384 serv_puts(bstr("city"));
385 serv_puts(bstr("state"));
386 serv_puts(bstr("zip"));
387 serv_puts(bstr("phone"));
388 serv_puts(bstr("email"));
391 if (atoi(bstr("during_login"))) {
394 display_error("Registration information has been saved.");
403 * display form for changing your password
405 void display_changepw(void)
409 printf("HTTP/1.0 200 OK\n");
410 output_headers(1, "bottom");
412 wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
413 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
414 wprintf("<B>Change your password</B>\n");
415 wprintf("</FONT></TD></TR></TABLE>\n");
418 serv_puts("MESG changepw");
423 wprintf("<FORM ACTION=\"changepw\" METHOD=\"POST\">\n");
424 wprintf("<CENTER><TABLE border><TR><TD>Enter new password:</TD>\n");
425 wprintf("<TD><INPUT TYPE=\"password\" NAME=\"newpass1\" VALUE=\"\" MAXLENGTH=\"20\"></TD></TR>\n");
426 wprintf("<TR><TD>Enter it again to confirm:</TD>\n");
427 wprintf("<TD><INPUT TYPE=\"password\" NAME=\"newpass2\" VALUE=\"\" MAXLENGTH=\"20\"></TD></TR>\n");
428 wprintf("</TABLE>\n");
429 wprintf("<INPUT type=\"submit\" NAME=\"action\" VALUE=\"Change\">\n");
430 wprintf("<INPUT type=\"submit\" NAME=\"action\" VALUE=\"Cancel\">\n");
431 wprintf("</CENTER>\n");
441 char newpass1[32], newpass2[32];
443 if (strcmp(bstr("action"), "Change")) {
444 display_error("Cancelled. Password was not changed.");
447 strcpy(newpass1, bstr("newpass1"));
448 strcpy(newpass2, bstr("newpass2"));
450 if (strcasecmp(newpass1, newpass2)) {
451 display_error("They don't match. Password was not changed.");
454 serv_printf("SETP %s", newpass1);
457 display_success(&buf[4]);
459 display_error(&buf[4]);