From 8f2cd6ce3d1372d471002e0a98a7ade0151b1973 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Mon, 4 Jan 1999 01:07:54 +0000 Subject: [PATCH] * Added "enter registration" * Set up automatic trigger of Enter Registration when the server says it's needed * Established that a one-to-one WebCit/Citadel correspondence will be required. No big deal due to shared code segments. --- webcit/ChangeLog | 7 +++ webcit/Makefile.in | 2 +- webcit/auth.c | 119 ++++++++++++++++++++++++++++++++++++++++-- webcit/child.h | 4 +- webcit/context_loop.c | 4 +- webcit/start-webcit | 5 -- webcit/webcit.c | 25 ++++++--- webcit/webserver.c | 2 + 8 files changed, 149 insertions(+), 19 deletions(-) delete mode 100755 webcit/start-webcit diff --git a/webcit/ChangeLog b/webcit/ChangeLog index a37ff7649..144347380 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -1,3 +1,10 @@ +Sun Jan 3 20:05:31 EST 1999 Art Cancro + * Added "enter registration" + * Set up automatic trigger of Enter Registration when the server + says it's needed + * Established that a one-to-one WebCit/Citadel correspondence will + be required. No big deal due to shared code segments. + Thu Dec 31 21:53:20 EST 1998 Art Cancro * Final cvs commit for 1998 (an awful year, I'm glad to see it over). * "Finished" the MIME parser. diff --git a/webcit/Makefile.in b/webcit/Makefile.in index 72f57cf1c..9a9008c9a 100644 --- a/webcit/Makefile.in +++ b/webcit/Makefile.in @@ -24,7 +24,7 @@ webserver: webserver.o context_loop.o $(LIBOBJS) $(CC) webserver.o context_loop.o $(LIBOBJS) $(LIBS) -o webserver webserver.o: webserver.c webcit.h - $(CC) $(CFLAGS) $(DEFS) -c -D_REENTRANT webserver.c + $(CC) $(CFLAGS) $(DEFS) -c -D_REENTRANT -DWEBCITDIR=\"`pwd`\" webserver.c context_loop.o: context_loop.c webcit.h webserver.h $(CC) $(CFLAGS) $(DEFS) -c -D_REENTRANT context_loop.c diff --git a/webcit/auth.c b/webcit/auth.c index 9f66fb8f9..b865ab7cf 100644 --- a/webcit/auth.c +++ b/webcit/auth.c @@ -88,7 +88,7 @@ void display_login(char *mesg) { /* - * This function needs to get called whenever a PASS or NEWU succeeds + * This function needs to get called whenever a PASS or NEWU succeeds. */ void become_logged_in(char *user, char *pass, char *serv_response) { logged_in = 1; @@ -101,6 +101,7 @@ void become_logged_in(char *user, char *pass, char *serv_response) { void do_login(void) { char buf[256]; + int need_regi = 0; if (!strcasecmp(bstr("action"), "Exit")) { do_logout(); @@ -142,7 +143,18 @@ void do_login(void) { } if (logged_in) { - output_static("frameset.html"); + serv_puts("CHEK"); + serv_gets(buf); + if (buf[0]=='2') { + need_regi = extract_int(&buf[4], 1); + /* FIX also check for new mail etc. here */ + } + if (need_regi) { + display_reg(1); + } + else { + output_static("frameset.html"); + } } else { display_login("Your password was not accepted."); @@ -190,7 +202,6 @@ void do_logout(void) { else wprintf("Goodbye\n"); wprintf("
Log in again\n"); - wprintf("\n"); wDumpContent(); serv_puts("QUIT"); @@ -266,3 +277,105 @@ void validate(void) { wprintf("

\n"); wDumpContent(); } + + + + + + +/* + * Display form for registration. + * (Set during_login to 1 if this registration is being performed during + * new user login and will require chaining to the proper screen.) + */ +void display_reg(int during_login) { + char buf[256]; + int a; + + printf("HTTP/1.0 200 OK\n"); + output_headers(1); + + wprintf("
"); + wprintf("Enter registration info\n"); + wprintf("
\n"); + + wprintf("
"); + serv_puts("MESG register"); + serv_gets(buf); + if (buf[0]=='1') fmout(NULL); + + wprintf("
\n"); + wprintf("\n", during_login); + + serv_puts("GREG _SELF_"); + serv_gets(buf); + if (buf[0]!='1') { + wprintf("%s
\n",&buf[4]); + } + else { + + wprintf("

%s

\n",&buf[4]); + a = 0; + while (serv_gets(buf), strcmp(buf,"000")) { + ++a; + wprintf("\n"); + } + wprintf("
"); + switch(a) { + case 3: wprintf("Real Name:
\n",buf); + break; + case 4: wprintf("Street Address:

\n",buf); + break; + case 5: wprintf("City/town:

\n",buf); + break; + case 6: wprintf("State/province:

\n",buf); + break; + case 7: wprintf("ZIP code:

\n",buf); + break; + case 8: wprintf("Telephone:

\n",buf); + break; + case 9: wprintf("E-Mail:

\n",buf); + break; + } + wprintf("

"); + } + wprintf("\n"); + wprintf("\n"); + wprintf("

\n"); + wDumpContent(); + } + +/* + * register + */ +void register_user(void) { + char buf[256]; + + if (strcmp(bstr("action"),"Register")) { + display_error("Cancelled. Registration was not saved."); + return; + } + + serv_puts("REGI"); + serv_gets(buf); + if (buf[0]!='4') { + display_error(&buf[4]); + } + + serv_puts(bstr("realname")); + serv_puts(bstr("address")); + serv_puts(bstr("city")); + serv_puts(bstr("state")); + serv_puts(bstr("zip")); + serv_puts(bstr("phone")); + serv_puts(bstr("email")); + serv_puts("000"); + + if (atoi(bstr("during_login"))) { + output_static("frameset.html"); + } + else { + display_error("Registration information has been saved."); + } + } diff --git a/webcit/child.h b/webcit/child.h index ac063593f..99ec7cc19 100644 --- a/webcit/child.h +++ b/webcit/child.h @@ -4,7 +4,7 @@ * $Id$ */ -void become_logged_in(char *user, char *pass, char *serv_response); +void become_logged_in(char *, char *, char *); void do_login(void); void display_login(char *mesg); void do_welcome(void); @@ -81,3 +81,5 @@ void serv_puts(char *string); void serv_printf(const char *format, ...); void load_floorlist(void); void select_floor_to_edit_pic(void); +void display_reg(int); +void register_user(void); diff --git a/webcit/context_loop.c b/webcit/context_loop.c index 1cb45ed2f..818067bf0 100644 --- a/webcit/context_loop.c +++ b/webcit/context_loop.c @@ -336,8 +336,8 @@ void *context_loop(int sock) { printf("Content-type: text/html\n"); printf("Content-length: 76\n"); printf("\n"); - printf("Error\n"); - printf("execlp() failed\n"); + printf("Error\n"); + printf("execlp() failed: %s\n", strerror(errno)); exit(0); } else { diff --git a/webcit/start-webcit b/webcit/start-webcit deleted file mode 100755 index f201478b3..000000000 --- a/webcit/start-webcit +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -# nathan - please don't autoconf-ize this; it's a temporary hack -cd /appl/develcit/velma -exec ./webserver >/dev/null 2>&1 diff --git a/webcit/webcit.c b/webcit/webcit.c index 34e97a88a..749dcb7a6 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -531,12 +531,21 @@ void session_loop(void) { content = NULL; } + /* If there are variables in the URL, we must grab them now */ + for (a=0; a0) strcpy(c_host, bstr("host")); + if (strlen(bstr("port"))>0) strcpy(c_port, bstr("port")); serv_sock = connectsock(c_host, c_port, "tcp"); connected = 1; serv_gets(buf); /* get the server welcome message */ @@ -575,13 +584,7 @@ void session_loop(void) { } } - /* If there are variables in the URL, we must grab them now */ - for (a=0; a