]> code.citadel.org Git - citadel.git/blobdiff - webcit/messages.c
* ooooops
[citadel.git] / webcit / messages.c
index 07ebc2be4565a5ce6143ae1d43d10a6ba1db884c..f1779a19d74c2137ae4b8240f9308989f7204cab 100644 (file)
@@ -1,14 +1,33 @@
+
+
+
+
+#include <ctype.h>
 #include <stdlib.h>
 #include <unistd.h>
 #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 <time.h>
+#include <stdarg.h>
+#include <pthread.h>
+#include <signal.h>
 #include "webcit.h"
-#include "child.h"
 
-char reply_to[512];
+
+
+
+
+char reply_to[512];    /* FIX make these session-specific!!! */
 long msgarr[1024];
 
 /*
@@ -16,49 +35,60 @@ long msgarr[1024];
  * target window in order to keep the BBS session in its own window.
  */
 void url(buf)
-char buf[]; {
+char buf[];
+{
 
        int pos;
-       int start,end;
+       int start, end;
        char ench;
        char urlbuf[256];
-       char outbuf[256];
+       char outbuf[1024];
 
        start = (-1);
        end = strlen(buf);
        ench = 0;
 
-       for (pos=0; pos<strlen(buf); ++pos) {
-               if (!strncasecmp(&buf[pos],"http://",7)) start = pos;
-               if (!strncasecmp(&buf[pos],"ftp://",6)) start = pos;
-               }
-
-       if (start<0) return;
+       for (pos = 0; pos < strlen(buf); ++pos) {
+               if (!strncasecmp(&buf[pos], "http://", 7))
+                       start = pos;
+               if (!strncasecmp(&buf[pos], "ftp://", 6))
+                       start = pos;
+       }
 
-       if ((start>0)&&(buf[start-1]=='<')) ench = '>';
-       if ((start>0)&&(buf[start-1]=='[')) ench = ']';
-       if ((start>0)&&(buf[start-1]=='(')) ench = ')';
-       if ((start>0)&&(buf[start-1]=='{')) ench = '}';
+       if (start < 0)
+               return;
 
-       for (pos=strlen(buf); pos>start; --pos) {
-               if ((buf[pos]==' ')||(buf[pos]==ench)) end = pos;
-               }
+       if ((start > 0) && (buf[start - 1] == '<'))
+               ench = '>';
+       if ((start > 0) && (buf[start - 1] == '['))
+               ench = ']';
+       if ((start > 0) && (buf[start - 1] == '('))
+               ench = ')';
+       if ((start > 0) && (buf[start - 1] == '{'))
+               ench = '}';
+
+       for (pos = strlen(buf); pos > start; --pos) {
+               if ((buf[pos] == ' ') || (buf[pos] == ench))
+                       end = pos;
+       }
 
-       strncpy(urlbuf,&buf[start],end-start);
-       urlbuf[end-start] = 0;
+       strncpy(urlbuf, &buf[start], end - start);
+       urlbuf[end - start] = 0;
 
 
-       strncpy(outbuf,buf,start);
-       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);
-       }
+       strncpy(outbuf, buf, start);
+       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]);
+       if ( strlen(outbuf) < 250 )
+               strcpy(buf, outbuf);
+}
 
 
 void read_message(msgnum, oper)
 long msgnum;
-char *oper; {
+char *oper;
+{
        char buf[256];
        char m_subject[256];
        char from[256];
@@ -68,72 +98,71 @@ char *oper; {
        int nhdr = 0;
        int bq = 0;
 
-       sprintf(buf,"MSG0 %ld",msgnum);
+       sprintf(buf, "MSG0 %ld", msgnum);
        serv_puts(buf);
        serv_gets(buf);
-       if (buf[0]!='1') {
-               wprintf("<STRONG>ERROR:</STRONG> %s<BR>\n",&buf[4]);
+       if (buf[0] != '1') {
+               wprintf("<STRONG>ERROR:</STRONG> %s<BR>\n", &buf[4]);
                return;
-               }
-
+       }
        wprintf("<TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=000077><TR><TD>\n");
-       wprintf("<FONT SIZE=+1 COLOR=\"FFFF00\"> ");
-       strcpy(m_subject,"");
-
-       strcpy(reply_to,"nobody...xxxxx");
-       while(serv_gets(buf), strncasecmp(buf,"text",4)) {
-               if (!strncasecmp(buf,"nhdr=yes",8)) nhdr=1;
-               if (nhdr==1) buf[0]='_';
-               if (!strncasecmp(buf,"type=",5))
-                       format_type=atoi(&buf[5]);
-               if (!strncasecmp(buf,"from=",5)) {
-                       wprintf("from %s ",&buf[5]);
-                       strcpy(from,&buf[5]);
-                       }
-               if (!strncasecmp(buf,"path=",5))
-                       strcpy(reply_to,&buf[5]);
-               if (!strncasecmp(buf,"subj=",5))
-                       strcpy(m_subject,&buf[5]);
-               if ((!strncasecmp(buf,"hnod=",5)) 
-                  && (strcasecmp(&buf[5],serv_info.serv_humannode)))
-                       wprintf("(%s) ",&buf[5]);
-               if ((!strncasecmp(buf,"room=",5))
-                  && (strcasecmp(&buf[5],wc_roomname)))
-                       wprintf("in %s> ",&buf[5]);
-
-               if (!strncasecmp(buf,"node=",5)) {
-                       if ( (room_flags&QR_NETWORK)
-                          || ((strcasecmp(&buf[5],serv_info.serv_nodename)
-                          &&(strcasecmp(&buf[5],serv_info.serv_fqdn)))))
-                               {
-                               wprintf("@%s ",&buf[5]);
-                               }
-                       if ((!strcasecmp(&buf[5],serv_info.serv_nodename))
-                          ||(!strcasecmp(&buf[5],serv_info.serv_fqdn)))
-                               {
-                               strcpy(reply_to,from);
-                               }
-                       else if (haschar(&buf[5],'.')==0) {
-                               sprintf(reply_to,"%s @ %s",from,&buf[5]);
-                               }
+       wprintf("<FONT FACE=\"Arial,Helvetica,sans-serif\" SIZE=+1 COLOR=\"FFFF00\"> ");
+       strcpy(m_subject, "");
+
+       strcpy(reply_to, "nobody...xxxxx");
+       while (serv_gets(buf), strncasecmp(buf, "text", 4)) {
+               if (!strncasecmp(buf, "nhdr=yes", 8))
+                       nhdr = 1;
+               if (nhdr == 1)
+                       buf[0] = '_';
+               if (!strncasecmp(buf, "type=", 5))
+                       format_type = atoi(&buf[5]);
+               if (!strncasecmp(buf, "from=", 5)) {
+                       wprintf("from %s ", &buf[5]);
+                       strcpy(from, &buf[5]);
+               }
+               if (!strncasecmp(buf, "path=", 5))
+                       strcpy(reply_to, &buf[5]);
+               if (!strncasecmp(buf, "subj=", 5))
+                       strcpy(m_subject, &buf[5]);
+               if ((!strncasecmp(buf, "hnod=", 5))
+                   && (strcasecmp(&buf[5], serv_info.serv_humannode)))
+                       wprintf("(%s) ", &buf[5]);
+               if ((!strncasecmp(buf, "room=", 5))
+                   && (strcasecmp(&buf[5], WC->wc_roomname)))
+                       wprintf("in %s> ", &buf[5]);
+
+               if (!strncasecmp(buf, "node=", 5)) {
+                       if ((WC->room_flags & QR_NETWORK)
+                       || ((strcasecmp(&buf[5], serv_info.serv_nodename)
+                       && (strcasecmp(&buf[5], serv_info.serv_fqdn))))) {
+                               wprintf("@%s ", &buf[5]);
                        }
-
-               if (!strncasecmp(buf,"rcpt=",5))
-                       wprintf("to %s ",&buf[5]);
-               if (!strncasecmp(buf,"time=",5)) {
-                       now=atol(&buf[5]);
-                       tm=(struct tm *)localtime(&now);
-                       strcpy(buf,(char *)asctime(tm)); buf[strlen(buf)-1]=0;
-                       strcpy(&buf[16],&buf[19]);
-                       wprintf("%s ",&buf[4]);
+                       if ((!strcasecmp(&buf[5], serv_info.serv_nodename))
+                       || (!strcasecmp(&buf[5], serv_info.serv_fqdn))) {
+                               strcpy(reply_to, from);
+                       } else if (haschar(&buf[5], '.') == 0) {
+                               sprintf(reply_to, "%s @ %s", from, &buf[5]);
                        }
                }
+               if (!strncasecmp(buf, "rcpt=", 5))
+                       wprintf("to %s ", &buf[5]);
+               if (!strncasecmp(buf, "time=", 5)) {
+                       now = atol(&buf[5]);
+                       tm = (struct tm *) localtime(&now);
+                       strcpy(buf, (char *) asctime(tm));
+                       buf[strlen(buf) - 1] = 0;
+                       strcpy(&buf[16], &buf[19]);
+                       wprintf("%s ", &buf[4]);
+               }
+       }
 
-       if (nhdr==1) wprintf("****");
+       if (nhdr == 1)
+               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);
@@ -146,39 +175,35 @@ char *oper; {
                wprintf("\">Del</A>");
 
                wprintf("</B></FONT></TD>");
-               }
-       
+       }
        wprintf("</TR></TABLE>\n");
 
-       if (strlen(m_subject)>0) {
-               wprintf("Subject: %s<BR>\n",m_subject);
-               }
-
+       if (strlen(m_subject) > 0) {
+               wprintf("Subject: %s<BR>\n", m_subject);
+       }
        if (format_type == 0) {
                fmout(NULL);
-               }
-       else {
-               while(serv_gets(buf), strcmp(buf,"000")) {
-                       while ((strlen(buf)>0)&&(isspace(buf[strlen(buf)-1])))
-                               buf[strlen(buf)-1] = 0;
-                       if ((bq==0)&&
-((!strncmp(buf,">",1))||(!strncmp(buf," >",2))||(!strncmp(buf," :-)",4)))) {
-                               wprintf("<FONT COLOR=\"000044\"><I>");
+       } else {
+               while (serv_gets(buf), strcmp(buf, "000")) {
+                       while ((strlen(buf) > 0) && (isspace(buf[strlen(buf) - 1])))
+                               buf[strlen(buf) - 1] = 0;
+                       if ((bq == 0) &&
+                           ((!strncmp(buf, ">", 1)) || (!strncmp(buf, " >", 2)) || (!strncmp(buf, " :-)", 4)))) {
+                               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))) {
+                       } else if ((bq == 1) &&
+                                  (strncmp(buf, ">", 1)) && (strncmp(buf, " >", 2)) && (strncmp(buf, " :-)", 4))) {
                                wprintf("</FONT></I>");
                                bq = 0;
-                               }
+                       }
                        wprintf("<TT>");
                        url(buf);
                        escputs(buf);
                        wprintf("</TT><BR>\n");
-                       }
                }
-               wprintf("<BR>");
        }
+       wprintf("</I><BR>");
+}
 
 
 
@@ -186,105 +211,112 @@ char *oper; {
  * load message pointers from the server
  */
 int load_msg_ptrs(servcmd)
-char *servcmd; {
+char *servcmd;
+{
        char buf[256];
        int nummsgs;
 
        nummsgs = 0;
        serv_puts(servcmd);
        serv_gets(buf);
-       if (buf[0]!='1') {
-               wprintf("<EM>%s</EM><BR>\n",&buf[4]);
-               return(nummsgs);
-               }
-       while (serv_gets(buf), strcmp(buf,"000")) {
+       if (buf[0] != '1') {
+               wprintf("<EM>%s</EM><BR>\n", &buf[4]);
+               return (nummsgs);
+       }
+       while (serv_gets(buf), strcmp(buf, "000")) {
                msgarr[nummsgs] = atol(buf);
                ++nummsgs;
-               }
-       return(nummsgs);
        }
+       return (nummsgs);
+}
 
 
 /*
  * command loop for reading messages
  */
-void readloop(char *oper) {
+void readloop(char *oper)
+{
        char cmd[256];
        int a;
        int nummsgs;
 
-       printf("HTTP/1.0 200 OK\n");
-       output_headers(1, "bottom");
+       output_headers(1);
 
-       wprintf("<CENTER><B>%s - ",wc_roomname);
-       if (!strcmp(oper,"readnew")) {
-               strcpy(cmd,"MSGS NEW");
+       wprintf("<FONT FACE=\"Arial,Helvetica,sans-serif\"><CENTER><B>%s - ", WC->wc_roomname);
+       if (!strcmp(oper, "readnew")) {
+               strcpy(cmd, "MSGS NEW");
                wprintf("new messages");
-               }
-       else if (!strcmp(oper,"readold")) {
-               strcpy(cmd,"MSGS OLD");
+       } else if (!strcmp(oper, "readold")) {
+               strcpy(cmd, "MSGS OLD");
                wprintf("old messages");
-               }
-       else {
-               strcpy(cmd,"MSGS ALL");
+       } else {
+               strcpy(cmd, "MSGS ALL");
                wprintf("all messages");
-               }
+       }
        wprintf("</B></CENTER><BR>\n");
 
        nummsgs = load_msg_ptrs(cmd);
        if (nummsgs == 0) {
-               if (!strcmp(oper,"readnew")) {
+               if (!strcmp(oper, "readnew")) {
                        wprintf("<EM>No new messages in this room.</EM>\n");
-                       }
-               else if (!strcmp(oper,"readold")) {
+               } else if (!strcmp(oper, "readold")) {
                        wprintf("<EM>No old messages in this room.</EM>\n");
-                       }
-               else {
+               } else {
                        wprintf("<EM>This room is empty.</EM>\n");
-                       }
-               goto DONE;
                }
-
-       for (a=0; a<nummsgs; ++a) {
+               goto DONE;
+       }
+       for (a = 0; a < nummsgs; ++a) {
                read_message(msgarr[a], oper);
-               }
-
-DONE:  wDumpContent(1);
        }
 
+      DONE:wDumpContent(1);
+}
+
 
 
 
 /*
- * 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) {
+void post_message(void)
+{
        char buf[256];
+       static long dont_post = (-1L);
 
-       printf("HTTP/1.0 200 OK\n");
-       output_headers(1, "bottom");
+       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 {
-               sprintf(buf,"ENT0 1|%s|0|0",bstr("recp"));
+       } 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);
                serv_gets(buf);
-               if (buf[0]=='4') {
+               if (buf[0] == '4') {
                        text_to_server(bstr("msgtext"));
                        serv_puts("000");
                        wprintf("Message has been posted.<BR>\n");
-                       }
-               else {
-                       wprintf("<EM>%s</EM><BR>\n",&buf[4]);
-                       }
+                       dont_post = atol(bstr("postseq"));
+               } else {
+                       wprintf("<EM>%s</EM><BR>\n", &buf[4]);
                }
+       }
 
        wDumpContent(1);
-       }       
+}
 
 
 
@@ -296,12 +328,13 @@ void post_message(void) {
 /*
  * prompt for a recipient (to be called from display_enter() only)
  */
-void prompt_for_recipient() {
+void prompt_for_recipient()
+{
 
-        wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=007700><TR><TD>");
-        wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
-        wprintf("<B>Send private e-mail</B>\n");
-        wprintf("</FONT></TD></TR></TABLE>\n");
+       wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=007700><TR><TD>");
+       wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
+       wprintf("<B>Send private e-mail</B>\n");
+       wprintf("</FONT></TD></TR></TABLE>\n");
 
        wprintf("<CENTER>");
        wprintf("<FORM METHOD=\"POST\" ACTION=\"/display_enter\">\n");
@@ -310,64 +343,70 @@ void prompt_for_recipient() {
        wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Enter message\">");
        wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
        wprintf("</FORM></CENTER>\n");
-       }
+}
 
 
 
 /*
  * display the message entry screen
  */
-void display_enter(void) {
+void display_enter(void)
+{
        char buf[256];
        long now;
        struct tm *tm;
 
-       printf("HTTP/1.0 200 OK\n");
-       output_headers(1, "bottom");
+       output_headers(1);
 
-       sprintf(buf,"ENT0 0|%s|0|0",bstr("recp"));
+       wprintf("<FACE=\"Arial,Helvetica,sans-serif\">");
+
+       sprintf(buf, "ENT0 0|%s|0|0", bstr("recp"));
        serv_puts(buf);
        serv_gets(buf);
 
-       if (!strncmp(buf,"570",3)) {
-               if (strlen(bstr("recp"))>0) {
-                       wprintf("<EM>%s</EM><BR>\n",&buf[4]);
-                       }
+       if (!strncmp(buf, "570", 3)) {
+               if (strlen(bstr("recp")) > 0) {
+                       wprintf("<EM>%s</EM><BR>\n", &buf[4]);
+               }
                prompt_for_recipient();
                goto DONE;
-               }
-
-       if (buf[0]!='2') {
-               wprintf("<EM>%s</EM><BR>\n",&buf[4]);
+       }
+       if (buf[0] != '2') {
+               wprintf("<EM>%s</EM><BR>\n", &buf[4]);
                goto DONE;
-               }
-
+       }
        wprintf("<CENTER>Enter message below.  Messages are formatted to\n");
        wprintf("the <EM>reader's</EM> screen width.  To defeat the\n");
        wprintf("formatting, indent a line at least one space.  \n");
        wprintf("<BR>");
 
-       time(&now);
-       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);
-       if (strlen(bstr("recp"))>0) wprintf("to %s ",bstr("recp"));
-       wprintf("in %s&gt; ",wc_roomname);
+       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->wc_username);
+       if (strlen(bstr("recp")) > 0)
+               wprintf("to %s ", bstr("recp"));
+       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);
-       }
+       wprintf("</FONT>");
+}
 
 
 
@@ -379,13 +418,13 @@ DONE:     wDumpContent(1);
 /*
  * Confirm deletion of a message
  */
-void confirm_delete_msg(void) {
+void confirm_delete_msg(void)
+{
        long msgid;
 
        msgid = atol(bstr("msgid"));
-       
-       printf("HTTP/1.0 200 OK\n");
-       output_headers(1, "bottom");
+
+       output_headers(1);
 
        wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
        wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
@@ -405,31 +444,30 @@ void confirm_delete_msg(void) {
 
        wprintf("</CENTER>\n");
        wDumpContent(1);
-       }
+}
 
 
 
-void delete_msg(void) {
+void delete_msg(void)
+{
        long msgid;
        char buf[256];
 
        msgid = atol(bstr("msgid"));
 
-       printf("HTTP/1.0 200 OK\n");
-       output_headers(1, "bottom");
+       output_headers(1);
 
        if (!strcasecmp(bstr("yesno"), "Yes")) {
                sprintf(buf, "DELE %ld", msgid);
                serv_puts(buf);
                serv_gets(buf);
                wprintf("<EM>%s</EM><BR>\n", &buf[4]);
-               }
-       else {
+       } else {
                wprintf("<EM>Message not deleted.</EM><BR>\n");
-               }
+       }
 
        wDumpContent(1);
-       }
+}
 
 
 
@@ -437,15 +475,15 @@ void delete_msg(void) {
 /*
  * Confirm move of a message
  */
-void confirm_move_msg(void) {
+void confirm_move_msg(void)
+{
        long msgid;
        char buf[256];
        char targ[256];
 
        msgid = atol(bstr("msgid"));
-       
-       printf("HTTP/1.0 200 OK\n");
-       output_headers(1, "bottom");
+
+       output_headers(1);
 
        wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=770000><TR><TD>");
        wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
@@ -461,19 +499,19 @@ void confirm_move_msg(void) {
                bstr("msgid"));
 
 
-       wprintf("<SELECT NAME=\"target_room\" SIZE=5>\n");
-        serv_puts("LKRA");
-        serv_gets(buf);
-        if (buf[0]=='1') {
-                while(serv_gets(buf), strcmp(buf,"000")) {
-                        extract(targ,buf,0);
-                        wprintf("<OPTION>");
-                        escputs(targ);
-                        wprintf("\n");
-                        }
-                }
-        wprintf("</SELECT>\n");
-        wprintf("<BR>\n");
+       wprintf("<SELECT NAME=\"target_room\" SIZE=5>\n");
+       serv_puts("LKRA");
+       serv_gets(buf);
+       if (buf[0] == '1') {
+               while (serv_gets(buf), strcmp(buf, "000")) {
+                       extract(targ, buf, 0);
+                       wprintf("<OPTION>");
+                       escputs(targ);
+                       wprintf("\n");
+               }
+       }
+       wprintf("</SELECT>\n");
+       wprintf("<BR>\n");
 
        wprintf("<INPUT TYPE=\"submit\" NAME=\"yesno\" VALUE=\"Move\">");
        wprintf("<INPUT TYPE=\"submit\" NAME=\"yesno\" VALUE=\"Cancel\">");
@@ -481,29 +519,27 @@ void confirm_move_msg(void) {
 
        wprintf("</CENTER>\n");
        wDumpContent(1);
-       }
+}
 
 
 
-void move_msg(void) {
+void move_msg(void)
+{
        long msgid;
        char buf[256];
 
        msgid = atol(bstr("msgid"));
 
-       printf("HTTP/1.0 200 OK\n");
-       output_headers(1, "bottom");
+       output_headers(1);
 
        if (!strcasecmp(bstr("yesno"), "Move")) {
                sprintf(buf, "MOVE %ld|%s", msgid, bstr("target_room"));
                serv_puts(buf);
                serv_gets(buf);
                wprintf("<EM>%s</EM><BR>\n", &buf[4]);
-               }
-       else {
+       } else {
                wprintf("<EM>Message not deleted.</EM><BR>\n");
-               }
-
-       wDumpContent(1);
        }
 
+       wDumpContent(1);
+}