-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
tcp_sockets.o: tcp_sockets.c webcit.h
cc -c tcp_sockets.c
+
+mainmenu.o: mainmenu.c webcit.h
+ cc -c mainmenu.c
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];
serv_printf("PASS %s", bstr("pass"));
serv_gets(buf);
if (buf[0]=='2') {
- logged_in = 1;
+ become_logged_in(bstr("name"), bstr("pass"), buf);
}
}
}
wprintf("Your password was not accepted.\n");
wprintf("<HR><A HREF=\"/\">Try again</A>\n");
wprintf("</BODY></HTML>\n");
+ wDumpContent();
}
- wDumpContent();
}
--- /dev/null
+#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();
+ }
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);
}
}
}
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();
}
/* 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);