]> code.citadel.org Git - citadel.git/blobdiff - webcit/mainmenu.c
* look and feel overhaul -- almost done!
[citadel.git] / webcit / mainmenu.c
index 8713620f46809bc4f9b270c6f9c48d69182f4aa8..8b34b46666e6c8fafa65b8149c152e5ac97b0b06 100644 (file)
@@ -1,25 +1,42 @@
 /* $Id$ */
 
+
+
+
+#include <ctype.h>
 #include <stdlib.h>
-#ifdef HAVE_UNISTD_H
 #include <unistd.h>
-#endif
 #include <stdio.h>
-#include <ctype.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <limits.h>
+#include <netinet/in.h>
+#include <netdb.h>
 #include <string.h>
+#include <pwd.h>
 #include <errno.h>
+#include <stdarg.h>
+#include <pthread.h>
+#include <signal.h>
 #include "webcit.h"
-#include "child.h"
 
 
-/* 
- * menu of commands (just the menu html itself)
- */
 
-void embed_main_menu(void)
+/*
+ * The Main Menu
+ */
+void display_main_menu(void)
 {
-       wprintf("<CENTER><TABLE border=0><TR>");
+       output_headers(1);
+
+       svprintf("BOXTITLE", WCS_STRING, "Basic commands");
+       do_template("beginbox");
 
+       wprintf("<TABLE border=0 align=center><TR>");
        wprintf("<TD>");        /* start of first column */
 
        wprintf("<UL>");
@@ -58,42 +75,28 @@ void embed_main_menu(void)
        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=\"/summary\">\n");
+       wprintf("Summary page</B></A><BR>Summary of my account</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("<LI><B><A HREF=\"/termquit\" TARGET=\"_top\">\n");
        wprintf("Log off</B></A><BR>Bye!</LI>\n");
        wprintf("</UL>\n");
 
        wprintf("</TR></TABLE>\n");
+       do_template("endbox");
 
-       wprintf("</CENTER>\n");
-}
-
-/*
- * advanced options
- */
-void embed_advanced_menu(void)
-{
-
-       wprintf("<TABLE WIDTH=100%><TR VALIGN=TOP><TD>");
+       wprintf("<TABLE WIDTH=100%%><TR VALIGN=TOP><TD>");
 
-
-       wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
-       wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
-       wprintf("<B>Interaction</B>\n");
-       wprintf("</FONT></TD></TR></TABLE>\n");
+       svprintf("BOXTITLE", WCS_STRING, "Interaction");
+       do_template("beginbox");
 
        wprintf("<UL>");
-       wprintf("<LI><A HREF=\"/display_page\">\n");
-       wprintf("Page another user</A>\n");
-
+       wprintf("<LI><A HREF=\"/whobbs\">\n");
+       wprintf("Who is online?</A><font size=-2> "
+               "(users <EM>currently</EM> logged on)</font>\n");
        wprintf("<LI><A HREF=\"/chat\">");
        wprintf("Chat with other online users</A>\n");
 
@@ -101,13 +104,12 @@ void embed_advanced_menu(void)
        wprintf("<FONT SIZE=-2>Generic server command</FONT></A>\n");
 
        wprintf("</UL>\n");
+       do_template("endbox");
 
        wprintf("</TD><TD>");
 
-       wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=007700><TR><TD>");
-       wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
-       wprintf("<B>Your info</B>\n");
-       wprintf("</FONT></TD></TR></TABLE>\n");
+       svprintf("BOXTITLE", WCS_STRING, "Your info");
+       do_template("beginbox");
 
        wprintf("<UL>");
        wprintf("<LI><A HREF=\"/display_editbio\">\n");
@@ -123,14 +125,12 @@ void embed_advanced_menu(void)
        wprintf("Change your password</A>\n");
 
        wprintf("</UL>\n");
-
+       do_template("endbox");
 
        wprintf("</TD></TR><TR VALIGN=TOP><TD>");
 
-       wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=000077><TR><TD>");
-       wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
-       wprintf("<B>Advanced room commands</B>\n");
-       wprintf("</FONT></TD></TR></TABLE>\n");
+       svprintf("BOXTITLE", WCS_STRING, "Advanced room commands");
+       do_template("beginbox");
 
        wprintf("<UL>");
        wprintf("<LI><A HREF=\"/display_private\">\n");
@@ -142,18 +142,20 @@ void embed_advanced_menu(void)
        wprintf("<LI><A HREF=\"/display_zap\">");
        wprintf("Zap (forget) this room (%s)</A>\n", WC->wc_roomname);
 
+        wprintf("<LI><A HREF=\"/display_whok\">\n");
+        wprintf("Access controls for this room</A>\n");
+
        wprintf("<LI><A HREF=\"/zapped_list\">");
        wprintf("List all forgotten rooms</A>\n");
 
        wprintf("</UL>\n");
+       do_template("endbox");
 
        wprintf("</TD><TD>");
 
        if ((WC->axlevel >= 6) || (WC->is_room_aide)) {
-               wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=007777><TR><TD>");
-               wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
-               wprintf("<B>Administrative functions</B>\n");
-               wprintf("</FONT></TD></TR></TABLE>\n");
+               svprintf("BOXTITLE", WCS_STRING, "Administrative functions");
+               do_template("beginbox");
 
                wprintf("<UL>");
                wprintf("<LI><A HREF=\"/display_editroom\">\n");
@@ -163,49 +165,27 @@ void embed_advanced_menu(void)
                wprintf("Edit site-wide configuration</A>\n");
 
                if (WC->axlevel >= 6) {
+                       wprintf("<LI><A HREF=\"/select_user_to_edit\">\n");
+                       wprintf("Add, change, delete user accounts</A>\n");
+
                        wprintf("<LI><A HREF=\"/validate\">\n");
                        wprintf("Validate new users</A>\n");
 
-                       wprintf("<LI><A HREF=\"/select_floor_to_edit_pic\">\n");
-                       wprintf("Set or change a floor label graphic</A>\n");
+                       wprintf("<LI><A HREF=\"/display_floorconfig\">\n");
+                       wprintf("Add, change, or delete floors</A>\n");
 
                        wprintf("<LI><A HREF=\"/display_netconf\">\n");
                        wprintf("Configure networking with other systems</A>\n");
                }
                wprintf("</UL>\n");
+               do_template("endbox");
        }
        wprintf("</TD></TR></TABLE>");
-
-       wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770077><TR><TD>");
-       wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
-       wprintf("<B>Basic commands</B>\n");
-       wprintf("</FONT></TD></TR></TABLE>\n");
-
-}
-
-
-
-
-/*
- * menu of commands (as a page)
- */
-void display_main_menu(void)
-{
-       printf("HTTP/1.0 200 OK\n");
-       output_headers(1);
-       embed_main_menu();
        wDumpContent(2);
 }
 
 
-void display_advanced_menu(void)
-{
-       printf("HTTP/1.0 200 OK\n");
-       output_headers(1);
-       embed_advanced_menu();
-       embed_main_menu();
-       wDumpContent(2);
-}
+
 
 
 /*
@@ -213,13 +193,10 @@ void display_advanced_menu(void)
  */
 void display_generic(void)
 {
-       printf("HTTP/1.0 200 OK\n");
-       output_headers(1);
+       output_headers(3);
 
-       wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770077><TR><TD>");
-       wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
-       wprintf("<B>Enter a server command</B>\n");
-       wprintf("</FONT></TD></TR></TABLE>\n");
+       svprintf("BOXTITLE", WCS_STRING, "Enter a server command");
+       do_template("beginbox");
 
        wprintf("<CENTER>");
        wprintf("This screen allows you to enter Citadel server commands which are\n");
@@ -232,19 +209,22 @@ void display_generic(void)
        wprintf("<INPUT TYPE=\"text\" NAME=\"g_cmd\" SIZE=80 MAXLENGTH=\"250\"><BR>\n");
 
        wprintf("Command input (if requesting SEND_LISTING transfer mode):<BR>\n");
-       wprintf("<TEXTAREA NAME=\"g_input\" ROWS=10 COLS=80 WIDTH=80></TEXTAREA>\n");
+       wprintf("<TEXTAREA NAME=\"g_input\" ROWS=10 COLS=80 WIDTH=80></TEXTAREA><BR>\n");
 
+       wprintf("<FONT SIZE=-2>Detected host header is http://%s</FONT>\n",
+               WC->http_host);
        wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Send command\">");
        wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\"><BR>\n");
 
        wprintf("</FORM></CENTER>\n");
+       do_template("endbox");
        wDumpContent(1);
 }
 
 void do_generic(void)
 {
-       char buf[256];
-       char gcontent[256];
+       char buf[SIZ];
+       char gcontent[SIZ];
        char *junk;
        size_t len;
 
@@ -253,16 +233,13 @@ void do_generic(void)
                return;
        }
 
-       printf("HTTP/1.0 200 OK\n");
-       output_headers(1);
+       output_headers(3);
 
        serv_printf("%s", bstr("g_cmd"));
        serv_gets(buf);
 
-       wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770077><TR><TD>");
-       wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
-       wprintf("<B>Server command results</B>\n");
-       wprintf("</FONT></TD></TR></TABLE>\n");
+       svprintf("BOXTITLE", WCS_STRING, "Server command results");
+       do_template("beginbox");
 
        wprintf("<TABLE border=0><TR><TD>Command:</TD><TD><TT>");
        escputs(bstr("g_cmd"));
@@ -281,7 +258,7 @@ void do_generic(void)
                wprintf("000");
        }
        if (buf[0] == '4') {
-               text_to_server(bstr("g_input"));
+               text_to_server(bstr("g_input"), 0);
                serv_puts("000");
        }
        if (buf[0] == '6') {
@@ -293,13 +270,14 @@ void do_generic(void)
        if (buf[0] == '7') {
                len = atol(&buf[4]);
                junk = malloc(len);
-               bzero(junk, len);
+               memset(junk, 0, len);
                serv_write(junk, len);
                free(junk);
        }
        wprintf("<HR>");
        wprintf("<A HREF=\"/display_generic\">Enter another command</A><BR>\n");
        wprintf("<A HREF=\"/display_advanced\">Return to menu</A>\n");
+       do_template("endbox");
        wDumpContent(1);
 }
 
@@ -312,11 +290,8 @@ void do_generic(void)
  * that the menubar is being embedded in another page.
  */
 void display_menubar(int as_single_page) {
-       FILE *menubar_body;
-       char buf[256];
 
        if (as_single_page) {
-               printf("HTTP/1.0 200 OK\n");
                output_headers(0);
                wprintf("<HTML>\n"
                        "<HEAD>\n"
@@ -324,22 +299,11 @@ void display_menubar(int as_single_page) {
                        "<STYLE TYPE=\"text/css\">\n"
                        "BODY   { text-decoration: none; }\n"
                        "</STYLE>\n"
-                       "</HEAD>\n"
-                       "<BODY BACKGROUND=\"/image&name=background\" "
-                       "TEXT=\"#000000\" LINK=\"#FFFFFF\" "
-                       "ALINK=\"#FFFFFF\" VLINK=\"#FFFFFF\">\n");
+                       "</HEAD>\n");
+               do_template("background");
        }
 
-       menubar_body = fopen("static/menubar.html", "r");
-       if (menubar_body == NULL) {
-               wprintf("menubar<BR>%s", strerror(errno));
-       } else {
-               while (fgets(buf, sizeof(buf), menubar_body) != NULL) {
-                       wprintf("%s", buf);
-               }
-               fclose(menubar_body);
-       }
-               
+       do_template("menubar");
 
        if (as_single_page) {
                wDumpContent(2);
@@ -347,3 +311,5 @@ void display_menubar(int as_single_page) {
 
 
 }
+
+