* Added "enter registration"
authorArt Cancro <ajc@citadel.org>
Mon, 4 Jan 1999 01:07:54 +0000 (01:07 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 4 Jan 1999 01:07:54 +0000 (01:07 +0000)
        * 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
webcit/Makefile.in
webcit/auth.c
webcit/child.h
webcit/context_loop.c
webcit/start-webcit [deleted file]
webcit/webcit.c
webcit/webserver.c

index a37ff76495ebf7bef7b257767a2655dbb16172f2..144347380e56afbb2a9ca933fbdc8459cf0df727 100644 (file)
@@ -1,3 +1,10 @@
+Sun Jan  3 20:05:31 EST 1999 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
+       * 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 <ajc@uncnsrd.mt-kisco.ny.us>
        * Final cvs commit for 1998 (an awful year, I'm glad to see it over).
        * "Finished" the MIME parser.
index 72f57cf1c31a234b420d27300dfa65606582f517..9a9008c9a84261ccb67c65e2e01ebc0b74c2de1f 100644 (file)
@@ -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
index 9f66fb8f9c3d8e78e6fc73331d2c3ce866320a7e..b865ab7cf019a7783af7f0e9feb58d03cbbc0450 100644 (file)
@@ -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("<HR><A HREF=\"/\">Log in again</A>\n");
-
        wprintf("</CENTER></BODY></HTML>\n");
        wDumpContent();
        serv_puts("QUIT");
@@ -266,3 +277,105 @@ void validate(void) {
        wprintf("</TR></TABLE><CENTER><BR>\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("<TABLE WIDTH=100% BORDER=0 BGCOLOR=007700><TR><TD>");
+        wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
+        wprintf("<B>Enter registration info</B>\n");
+        wprintf("</FONT></TD></TR></TABLE>\n");
+
+       wprintf("<CENTER>");
+       serv_puts("MESG register");
+       serv_gets(buf);
+       if (buf[0]=='1') fmout(NULL);
+
+       wprintf("<FORM ACTION=\"/register\" METHOD=\"POST\">\n");
+       wprintf("<INPUT TYPE=\"hidden\" NAME=\"during_login\" VALUE=\"%d\">\n", during_login);
+
+       serv_puts("GREG _SELF_");
+       serv_gets(buf);
+       if (buf[0]!='1') {
+               wprintf("<EM>%s</EM><BR>\n",&buf[4]);
+               }
+       else {
+       
+               wprintf("<H1>%s</H1><TABLE border>\n",&buf[4]);
+               a = 0;
+               while (serv_gets(buf), strcmp(buf,"000")) {
+                       ++a;
+                       wprintf("<TR><TD>");
+                       switch(a) {
+                               case 3: wprintf("Real Name:</TD><TD><INPUT TYPE=\"text\" NAME=\"realname\" VALUE=\"%s\" MAXLENGTH=\"29\"><BR>\n",buf);
+                                       break;
+                               case 4: wprintf("Street Address:</TD><TD><INPUT TYPE=\"text\" NAME=\"address\" VALUE=\"%s\" MAXLENGTH=\"24\"><BR>\n",buf);
+                                       break;
+                               case 5: wprintf("City/town:</TD><TD><INPUT TYPE=\"text\" NAME=\"city\" VALUE=\"%s\" MAXLENGTH=\"14\"><BR>\n",buf);
+                                       break;
+                               case 6: wprintf("State/province:</TD><TD><INPUT TYPE=\"text\" NAME=\"state\" VALUE=\"%s\" MAXLENGTH=\"2\"><BR>\n",buf);
+                                       break;
+                               case 7: wprintf("ZIP code:</TD><TD><INPUT TYPE=\"text\" NAME=\"zip\" VALUE=\"%s\" MAXLENGTH=\"10\"><BR>\n",buf);
+                                       break;
+                               case 8: wprintf("Telephone:</TD><TD><INPUT TYPE=\"text\" NAME=\"phone\" VALUE=\"%s\" MAXLENGTH=\"14\"><BR>\n",buf);
+                                       break;
+                               case 9: wprintf("E-Mail:</TD><TD><INPUT TYPE=\"text\" NAME=\"email\" VALUE=\"%s\" MAXLENGTH=\"31\"><BR>\n",buf);
+                                       break;
+                               }
+                       wprintf("</TD></TR>\n");
+                       }
+               wprintf("</TABLE><P>");
+               }
+       wprintf("<INPUT type=\"submit\" NAME=\"action\" VALUE=\"Register\">\n");
+       wprintf("<INPUT type=\"submit\" NAME=\"action\" VALUE=\"Cancel\">\n");
+       wprintf("</CENTER></BODY></HTML>\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.");
+               }
+       }
index ac063593fe48c261720bc6971f85b835f85b23cb..99ec7cc192cca0888db022535f7243bf8218f24c 100644 (file)
@@ -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);
index 1cb45ed2ff667c6bbe736a99d219047b82af64d3..818067bf0eb3cd91a31b03981458560ab5e6613d 100644 (file)
@@ -336,8 +336,8 @@ void *context_loop(int sock) {
                        printf("Content-type: text/html\n");
                        printf("Content-length: 76\n");
                        printf("\n");
-                       printf("<HTML><HEAD><TITLE>Error</TITLE></HEAD>\n");
-                       printf("<BODY BACKGROUND=\"/image&name=background\" TEXT=\"#000000\" LINK=\"#004400\">execlp() failed</BODY></HTML>\n");
+                       printf("<HTML><HEAD><TITLE>Error</TITLE></HEAD><BODY>\n");
+                       printf("execlp() failed: %s</BODY></HTML>\n", strerror(errno));
                        exit(0);
                        }
                else {
diff --git a/webcit/start-webcit b/webcit/start-webcit
deleted file mode 100755 (executable)
index f201478..0000000
+++ /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
index 34e97a88a6f2a6f39a031e7f57012059e513413c..749dcb7a69de31aefa399e3dd12dab0ab3fff060 100644 (file)
@@ -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; a<strlen(cmd); ++a) if ((cmd[a]=='?')||(cmd[a]=='&')) {
+               for (b=a; b<strlen(cmd); ++b) if (isspace(cmd[b])) cmd[b]=0;
+               addurls(&cmd[a+1]);
+               cmd[a] = 0;
+               }
+
        /*
         * If we're not connected to a Citadel server, try to hook up the
         * connection now.  Preference is given to the host and port specified
         * by browser cookies, if cookies have been supplied.
         */
        if (!connected) {
+               if (strlen(bstr("host"))>0) 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<strlen(cmd); ++a) if ((cmd[a]=='?')||(cmd[a]=='&')) {
-               for (b=a; b<strlen(cmd); ++b) if (isspace(cmd[b])) cmd[b]=0;
-               addurls(&cmd[a+1]);
-               cmd[a] = 0;
-               }
-
+       /* FIX unfix etc. here's where the addurls() WAS... */
        if (!strcasecmp(action, "static")) {
                strcpy(buf, &cmd[12]);
                for (a=0; a<strlen(buf); ++a) if (isspace(buf[a])) buf[a]=0;
@@ -803,6 +806,14 @@ void session_loop(void) {
                do_graphics_upload(buf);
                }
 
+       else if (!strcasecmp(action, "display_reg")) {
+               display_reg(0);
+               }
+
+       else if (!strcasecmp(action, "register")) {
+               register_user();
+               }
+
        /* When all else fails... */
        else {
                printf("HTTP/1.0 200 OK\n");
index 089ea2cf024b8a5b32b10e43c2af38ac256233ce..efa0dbaa6ad357a901b98d5a06de4905420a100c 100644 (file)
@@ -273,6 +273,8 @@ int main(int argc, char **argv)
        printf("Copyright (C) 1996-1998 by Art Cancro.  ");
        printf("All rights reserved.\n\n");
 
+       if (chdir(WEBCITDIR)!=0) perror("chdir");
+
        /*
         * Bind the server to our favourite port.
         * There is no need to check for errors, because ig_tcp_server()