]> code.citadel.org Git - citadel.git/commitdiff
got login and frames working together
authorArt Cancro <ajc@citadel.org>
Thu, 26 Nov 1998 01:36:38 +0000 (01:36 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 26 Nov 1998 01:36:38 +0000 (01:36 +0000)
webcit/Makefile
webcit/auth.c
webcit/mainmenu.c [new file with mode: 0644]
webcit/webcit.c

index db05bcd8b935dfb03e43543e45852d95fc3f98da..55021beaf13448298d3bb6addcc8d3f0773425f0 100644 (file)
@@ -17,8 +17,8 @@ context_loop.o: context_loop.c webcit.h
 
 
 
-webcit: webcit.o auth.o tcp_sockets.o
-       cc webcit.o auth.o tcp_sockets.o -o webcit
+webcit: webcit.o auth.o tcp_sockets.o mainmenu.o
+       cc webcit.o auth.o tcp_sockets.o mainmenu.o -o webcit
 
 webcit.o: webcit.c webcit.h
        cc -c webcit.c
@@ -28,3 +28,6 @@ auth.o: auth.c webcit.h
 
 tcp_sockets.o: tcp_sockets.c webcit.h
        cc -c tcp_sockets.c
+
+mainmenu.o: mainmenu.c webcit.h
+       cc -c mainmenu.c
index ec685f2aab5ba47c56fc5022a2a4f01d5d551064..9b2cba50fc0e8ccaf458a08608751b86a0baf1a8 100644 (file)
@@ -53,15 +53,29 @@ void output_frameset() {
        wprintf("<HTML><HEAD><TITLE>FrameSet</TITLE></HEAD>\n");
        wprintf("<FRAMESET cols=\"20%, 80%\">\n");
        wprintf("    <FRAME name=\"left\" src=\"/static/velma.gif\">\n");
-       wprintf("    <FRAME name=\"right\" src=\"/nothing\">\n");
+       wprintf("    <FRAME name=\"right\" src=\"/display_main_menu\">\n");
        wprintf("<NOFRAMES>\n");
-       wprintf("ooo!  no frames!  too bad!\n");
+       wprintf("Your browser doesn't support frames.<BR>\n");
+       wprintf("This site uses frames.<BR>\n");
+       wprintf("Therefore, you cannot view this site.<BR>\n");
+       wprintf("Perhaps you should telnet instead?<BR>\n");
        wprintf("</NOFRAMES>\n");
        wprintf("</FRAMESET></HTML>\n");
        wDumpContent();
        }
 
 
+/*
+ * 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;
+       strcpy(wc_username, user);
+       strcpy(wc_password, pass);
+       
+       }
+
 
 void do_login() {
        char buf[256];
@@ -73,7 +87,7 @@ void do_login() {
                        serv_printf("PASS %s", bstr("pass"));
                        serv_gets(buf);
                        if (buf[0]=='2') {
-                               logged_in = 1;
+                               become_logged_in(bstr("name"), bstr("pass"), buf);
                                }
                        }
                }
@@ -88,7 +102,7 @@ void do_login() {
                wprintf("Your password was not accepted.\n");
                wprintf("<HR><A HREF=\"/\">Try again</A>\n");
                wprintf("</BODY></HTML>\n");
+               wDumpContent();
                }
 
-       wDumpContent();
        }
diff --git a/webcit/mainmenu.c b/webcit/mainmenu.c
new file mode 100644 (file)
index 0000000..60f654f
--- /dev/null
@@ -0,0 +1,86 @@
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+#include <errno.h>
+#include "webcit.h"
+
+
+/* 
+ * menu of commands (just the menu html itself)
+ */
+
+void embed_main_menu() {
+       wprintf("<CENTER><TABLE border=0><TR>");
+
+       wprintf("<TD>");        /* start of first column */
+
+       wprintf("<UL>");
+       wprintf("<LI><B><A HREF=\"/knrooms\">\n");
+       wprintf("List known rooms</B></A><BR>\n");
+       wprintf("Where can I go from here?</LI>\n");
+       
+       wprintf("<LI><B><A HREF=\"/gotonext\">\n");
+       wprintf("Goto next room</B></A><BR>\n");
+       wprintf("...with <EM>unread</EM> messages</LI>\n");
+       
+       wprintf("<LI><B><A HREF=\"/skip\">\n");
+       wprintf("Skip to next room</B></A><BR>\n");
+       wprintf("(come back here later)</LI>\n");
+       
+       /* ungoto not supported yet
+       if ( (strlen(ugname)>0) && (strucmp(ugname,room_name)) ) {
+               wprintf("<LI><B><A HREF=\"/ungoto\">\n");
+               wprintf("Ungoto</B></A><BR>\n");
+               wprintf("(oops! Back to %s)</LI>\n",ugname);
+               }
+       */
+       
+       wprintf("</UL>\n");
+       
+       wprintf("</TD><TD>\n"); /* start of second column */
+       
+       wprintf("<UL>");
+       wprintf("<LI><B><A HREF=\"/readnew\">\n");
+       wprintf("Read new messages</B></A><BR>...in this room</LI>\n");
+       
+       wprintf("<LI><B><A HREF=\"/readfwd\">\n");
+       wprintf("Read all messages</B></A><BR>...old <EM>and</EM> new</LI>\n");
+
+       wprintf("<LI><B><A HREF=\"/display_enter\">\n");
+       wprintf("Enter a message</B></A><BR>(post in this room)</LI>");
+       wprintf("</UL>\n");
+
+       wprintf("</TD><TD>"); /* start of third column */
+
+       wprintf("<UL>");
+       wprintf("<LI><B><A HREF=\"/whobbs\">\n");
+       wprintf("Who is online?</B></A><BR>(users <EM>currently</EM> logged on)</LI>\n");
+       
+       wprintf("<LI><B><A HREF=\"/userlist\">\n");
+       wprintf("User list</B></A><BR>(all registered users)</LI>\n");
+
+       wprintf("<LI><B><A HREF=\"/advanced\">\n");
+       wprintf("Advanced options</B></A><BR>...and maintenance</LI>\n");
+
+       wprintf("<LI><B><A HREF=\"/termquit\">\n");
+       wprintf("Log off</B></A><BR>Bye!</LI>\n");
+       wprintf("</UL>\n");
+
+       wprintf("</TR></TABLE>\n");
+
+       wprintf("</CENTER>\n");
+       }
+
+/*
+ * menu of commands (as a page)
+ */
+void display_main_menu() {
+       printf("HTTP/1.0 200 OK\n");
+       output_headers();
+       wprintf("<HTML><HEAD><TITLE>WebCit main menu</TITLE></HEAD><BODY>\n");
+       embed_main_menu();
+       printf("</BODY></HTML>\n");
+       wDumpContent();
+       }
index 16b0df7ec1b9f5ec45b70c8a525fa74ed12c8386..f856409000d01a9c0deb121a3191443f0a9be2db 100644 (file)
@@ -332,9 +332,7 @@ void session_loop() {
                        serv_printf("PASS %s", c_password);
                        serv_gets(buf);
                        if (buf[0]=='2') {
-                               logged_in = 1;
-                               strcpy(wc_username, c_username);
-                               strcpy(wc_password, c_password);
+                               become_logged_in(c_username, c_password, buf);
                                }
                        }
                }
@@ -364,16 +362,6 @@ void session_loop() {
                output_static(buf);
                }
 
-       if (!strncasecmp(cmd, "GET /nothing", 12)) {
-               printf("HTTP/1.0 200 OK\n");
-               output_headers();
-       
-               wprintf("<HTML><HEAD><TITLE>WebCit</TITLE></HEAD><BODY>\n");
-               wprintf("TransactionCount is %d<HR>\n", TransactionCount);
-               wprintf("You're in session %d<BR>\n", wc_session);
-               wprintf("</BODY></HTML>\n");
-               wDumpContent();
-               }
 
        else if ((!logged_in)&&(!strncasecmp(cmd, "POST /login", 11))) {
                do_login();
@@ -384,10 +372,21 @@ void session_loop() {
                }
 
        /* Various commands... */
+       
+       else if (!strncasecmp(cmd, "GET /display_main_menu", 22)) {
+               display_main_menu();
+               }
 
-       /* When all else fails, display the login page. */
+       /* When all else fails, display the oops page. */
        else {
-               display_login_page();
+               printf("HTTP/1.0 200 OK\n");
+               output_headers();
+       
+               wprintf("<HTML><HEAD><TITLE>WebCit</TITLE></HEAD><BODY>\n");
+               wprintf("TransactionCount is %d<HR>\n", TransactionCount);
+               wprintf("You're in session %d<BR>\n", wc_session);
+               wprintf("</BODY></HTML>\n");
+               wDumpContent();
                }
 
        fflush(stdout);