]> code.citadel.org Git - citadel.git/blobdiff - webcit/messages.c
* Started moving all of the global variables into a struct, to facilitate
[citadel.git] / webcit / messages.c
index 4007bd2e962efbed8240314972b4300244f585b3..0af37486a4b4669a5fdb1da3407819107825fcda 100644 (file)
@@ -23,7 +23,7 @@ char buf[];
        int start, end;
        char ench;
        char urlbuf[256];
-       char outbuf[256];
+       char outbuf[1024];
 
        start = (-1);
        end = strlen(buf);
@@ -61,7 +61,8 @@ char buf[];
        sprintf(&outbuf[start], "%cA HREF=%c%s%c TARGET=%c%s%c%c%s%c/A%c",
                LB, QU, urlbuf, QU, QU, TARGET, QU, RB, urlbuf, LB, RB);
        strcat(outbuf, &buf[end]);
-       strcpy(buf, outbuf);
+       if ( strlen(outbuf) < 250 )
+               strcpy(buf, outbuf);
 }
 
 
@@ -86,7 +87,7 @@ char *oper;
                return;
        }
        wprintf("<TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=000077><TR><TD>\n");
-       wprintf("<FONT SIZE=+1 COLOR=\"FFFF00\"> ");
+       wprintf("<FONT FACE=\"Arial,Helvetica,sans-serif\" SIZE=+1 COLOR=\"FFFF00\"> ");
        strcpy(m_subject, "");
 
        strcpy(reply_to, "nobody...xxxxx");
@@ -109,11 +110,11 @@ char *oper;
                    && (strcasecmp(&buf[5], serv_info.serv_humannode)))
                        wprintf("(%s) ", &buf[5]);
                if ((!strncasecmp(buf, "room=", 5))
-                   && (strcasecmp(&buf[5], wc_roomname)))
+                   && (strcasecmp(&buf[5], WC->wc_roomname)))
                        wprintf("in %s> ", &buf[5]);
 
                if (!strncasecmp(buf, "node=", 5)) {
-                       if ((room_flags & QR_NETWORK)
+                       if ((WC->room_flags & QR_NETWORK)
                        || ((strcasecmp(&buf[5], serv_info.serv_nodename)
                        && (strcasecmp(&buf[5], serv_info.serv_fqdn))))) {
                                wprintf("@%s ", &buf[5]);
@@ -141,8 +142,8 @@ char *oper;
                wprintf("****");
        wprintf("</FONT></TD>");
 
-       if (is_room_aide) {
-               wprintf("<TD ALIGN=RIGHT NOWRAP><FONT COLOR=\"FFFF00\"><B>");
+       if (WC->is_room_aide) {
+               wprintf("<TD ALIGN=RIGHT NOWRAP><FONT FACE=\"Arial,Helvetica,sans-serif\" COLOR=\"FFFF00\"><B>");
 
                wprintf("<A HREF=\"/confirm_move_msg");
                wprintf("&msgid=%ld", msgnum);
@@ -169,7 +170,7 @@ char *oper;
                                buf[strlen(buf) - 1] = 0;
                        if ((bq == 0) &&
                            ((!strncmp(buf, ">", 1)) || (!strncmp(buf, " >", 2)) || (!strncmp(buf, " :-)", 4)))) {
-                               wprintf("<FONT COLOR=\"000044\"><I>");
+                               wprintf("<FONT FACE=\"Arial,Helvetica,sans-serif\" COLOR=\"000044\"><I>");
                                bq = 1;
                        } else if ((bq == 1) &&
                                   (strncmp(buf, ">", 1)) && (strncmp(buf, " >", 2)) && (strncmp(buf, " :-)", 4))) {
@@ -182,7 +183,7 @@ char *oper;
                        wprintf("</TT><BR>\n");
                }
        }
-       wprintf("<BR>");
+       wprintf("</I><BR>");
 }
 
 
@@ -223,7 +224,7 @@ void readloop(char *oper)
        printf("HTTP/1.0 200 OK\n");
        output_headers(1);
 
-       wprintf("<CENTER><B>%s - ", wc_roomname);
+       wprintf("<FONT FACE=\"Arial,Helvetica,sans-serif\"><CENTER><B>%s - ", WC->wc_roomname);
        if (!strcmp(oper, "readnew")) {
                strcpy(cmd, "MSGS NEW");
                wprintf("new messages");
@@ -258,18 +259,31 @@ void readloop(char *oper)
 
 
 /*
- * post message (or don't post message)
+ * Post message (or don't post message)
+ *
+ * Note regarding the "dont_post" variable:
+ * A random value (actually, it's just a timestamp) is inserted as a hidden
+ * field called "postseq" when the display_enter page is generated.  This
+ * value is checked when posting, using the static variable dont_post.  If a
+ * user attempts to post twice using the same dont_post value, the message is
+ * discarded.  This prevents the accidental double-saving of the same message
+ * if the user happens to click the browser "back" button.
  */
 void post_message(void)
 {
        char buf[256];
+       static long dont_post = (-1L);
 
        printf("HTTP/1.0 200 OK\n");
        output_headers(1);
 
+       wprintf("<FONT FACE=\"Arial,Helvetica,sans-serif\">");
        strcpy(buf, bstr("sc"));
        if (strcasecmp(buf, "Save message")) {
                wprintf("Cancelled.  Message was not posted.<BR>\n");
+       } else if (atol(bstr("postseq")) == dont_post) {
+               wprintf("Automatically cancelled because you have already "
+                       "saved this message.<BR>\n");
        } else {
                sprintf(buf, "ENT0 1|%s|0|0", bstr("recp"));
                serv_puts(buf);
@@ -278,6 +292,7 @@ void post_message(void)
                        text_to_server(bstr("msgtext"));
                        serv_puts("000");
                        wprintf("Message has been posted.<BR>\n");
+                       dont_post = atol(bstr("postseq"));
                } else {
                        wprintf("<EM>%s</EM><BR>\n", &buf[4]);
                }
@@ -327,6 +342,8 @@ void display_enter(void)
        printf("HTTP/1.0 200 OK\n");
        output_headers(1);
 
+       wprintf("<FACE=\"Arial,Helvetica,sans-serif\">");
+
        sprintf(buf, "ENT0 0|%s|0|0", bstr("recp"));
        serv_puts(buf);
        serv_gets(buf);
@@ -347,28 +364,32 @@ void display_enter(void)
        wprintf("formatting, indent a line at least one space.  \n");
        wprintf("<BR>");
 
-       time(&now);
+       now = time(NULL);
        tm = (struct tm *) localtime(&now);
        strcpy(buf, (char *) asctime(tm));
        buf[strlen(buf) - 1] = 0;
        strcpy(&buf[16], &buf[19]);
        wprintf("</CENTER><FONT COLOR=\"440000\"><B> %s ", &buf[4]);
-       wprintf("from %s ", wc_username);
+       wprintf("from %s ", WC->wc_username);
        if (strlen(bstr("recp")) > 0)
                wprintf("to %s ", bstr("recp"));
-       wprintf("in %s&gt; ", wc_roomname);
+       wprintf("in %s&gt; ", WC->wc_roomname);
        wprintf("</B></FONT><BR><CENTER>\n");
 
        wprintf("<FORM METHOD=\"POST\" ACTION=\"/post\">\n");
        wprintf("<INPUT TYPE=\"hidden\" NAME=\"recp\" VALUE=\"%s\">\n",
                bstr("recp"));
-       wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Save message\">");
-       wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\"><BR>\n");
+       wprintf("<INPUT TYPE=\"hidden\" NAME=\"postseq\" VALUE=\"%ld\">\n",
+               now);
+       wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Save message\">"
+               "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\"><BR>\n");
 
-       wprintf("<TEXTAREA NAME=\"msgtext\" wrap=soft ROWS=30 COLS=80 WIDTH=80></TEXTAREA><P>\n");
+       wprintf("<TEXTAREA NAME=\"msgtext\" wrap=soft ROWS=30 COLS=80 "
+               "WIDTH=80></TEXTAREA><P>\n");
 
        wprintf("</FORM></CENTER>\n");
-      DONE:wDumpContent(1);
+DONE:  wDumpContent(1);
+       wprintf("</FONT>");
 }