]> code.citadel.org Git - citadel.git/blob - webcit/messages.c
e5a1b2a0173ecfbb1e29172de2b0ffa04ef6c0b7
[citadel.git] / webcit / messages.c
1 /*
2  * $Id$
3  *
4  * Functions which deal with the fetching and displaying of messages.
5  *
6  */
7
8 #include <ctype.h>
9 #include <stdlib.h>
10 #include <unistd.h>
11 #include <stdio.h>
12 #include <fcntl.h>
13 #include <signal.h>
14 #include <sys/types.h>
15 #include <sys/wait.h>
16 #include <sys/socket.h>
17 #include <limits.h>
18 #include <netinet/in.h>
19 #include <netdb.h>
20 #include <string.h>
21 #include <pwd.h>
22 #include <errno.h>
23 #include <stdarg.h>
24 #include <pthread.h>
25 #include <signal.h>
26 #include "webcit.h"
27 #include "vcard.h"
28
29
30 /*
31  * Look for URL's embedded in a buffer and make them linkable.  We use a
32  * target window in order to keep the BBS session in its own window.
33  */
34 void url(buf)
35 char buf[];
36 {
37
38         int pos;
39         int start, end;
40         char ench;
41         char urlbuf[SIZ];
42         char outbuf[1024];
43
44         start = (-1);
45         end = strlen(buf);
46         ench = 0;
47
48         for (pos = 0; pos < strlen(buf); ++pos) {
49                 if (!strncasecmp(&buf[pos], "http://", 7))
50                         start = pos;
51                 if (!strncasecmp(&buf[pos], "ftp://", 6))
52                         start = pos;
53         }
54
55         if (start < 0)
56                 return;
57
58         if ((start > 0) && (buf[start - 1] == '<'))
59                 ench = '>';
60         if ((start > 0) && (buf[start - 1] == '['))
61                 ench = ']';
62         if ((start > 0) && (buf[start - 1] == '('))
63                 ench = ')';
64         if ((start > 0) && (buf[start - 1] == '{'))
65                 ench = '}';
66
67         for (pos = strlen(buf); pos > start; --pos) {
68                 if ((buf[pos] == ' ') || (buf[pos] == ench))
69                         end = pos;
70         }
71
72         strncpy(urlbuf, &buf[start], end - start);
73         urlbuf[end - start] = 0;
74
75
76         strncpy(outbuf, buf, start);
77         sprintf(&outbuf[start], "%cA HREF=%c%s%c TARGET=%c%s%c%c%s%c/A%c",
78                 LB, QU, urlbuf, QU, QU, TARGET, QU, RB, urlbuf, LB, RB);
79         strcat(outbuf, &buf[end]);
80         if ( strlen(outbuf) < 250 )
81                 strcpy(buf, outbuf);
82 }
83
84
85
86
87 /*
88  * Experimental output type of thing
89  */
90 void display_vcard(char *vcard_source) {
91         int i, j;
92         struct vCard *v;
93         char buf[SIZ];
94
95         v = vcard_load(vcard_source);
96         if (v == NULL) return;
97
98         wprintf("<TABLE bgcolor=#888888>");
99         if (v->numprops) for (i=0; i<(v->numprops); ++i) {
100                 if (!strcasecmp(v->prop[i].name, "n")) {
101                         wprintf("<TR BGCOLOR=#AAAAAA><TD><FONT SIZE=+1><B>");
102                         escputs(v->prop[i].value);
103                         wprintf("</B></FONT></TD></TR>\n");
104                 }
105                 else if (!strcasecmp(v->prop[i].name, "email;internet")) {
106                         wprintf("<TR><TD>Internet e-mail:</TD>"
107                                 "<TD><A HREF=\"mailto:");
108                         urlescputs(v->prop[i].value);
109                         wprintf("\">");
110                         escputs(v->prop[i].value);
111                         wprintf("</A></TD></TR>\n");
112                 }
113                 else if (!strcasecmp(v->prop[i].name, "adr")) {
114                         wprintf("<TR><TD>Address:</TD><TD>");
115                         for (j=0; j<num_tokens(v->prop[i].value, ';'); ++j) {
116                                 extract_token(buf, v->prop[i].value, j, ';');
117                                 if (strlen(buf) > 0) {
118                                         escputs(buf);
119                                         wprintf("<BR>");
120                                 }
121                         }
122                         wprintf("</TD></TR>\n");
123                 }
124                 else if (!strncasecmp(v->prop[i].name, "tel;", 4)) {
125                         wprintf("<TR><TD>%s telephone:</TD><TD>",
126                                 &v->prop[i].name[4]);
127                         for (j=0; j<num_tokens(v->prop[i].value, ';'); ++j) {
128                                 extract_token(buf, v->prop[i].value, j, ';');
129                                 if (strlen(buf) > 0) {
130                                         escputs(buf);
131                                         wprintf("<BR>");
132                                 }
133                         }
134                         wprintf("</TD></TR>\n");
135                 }
136                 else {
137                         wprintf("<TR><TD>");
138                         escputs(v->prop[i].name);
139                         wprintf("</TD><TD>");
140                         escputs(v->prop[i].value);
141                         wprintf("</TD></TR>\n");
142                 }
143         }
144
145         wprintf("</TABLE>\n");
146
147         vcard_free(v);
148 }
149
150
151
152
153
154
155 void read_message(long msgnum, int is_summary) {
156         char buf[SIZ];
157         char mime_partnum[SIZ];
158         char mime_filename[SIZ];
159         char mime_content_type[SIZ];
160         char mime_disposition[SIZ];
161         int mime_length;
162         char *mime_http = NULL;
163         char m_subject[SIZ];
164         char from[SIZ];
165         char node[SIZ];
166         char rfca[SIZ];
167         char reply_to[512];
168         char now[SIZ];
169         int format_type = 0;
170         int nhdr = 0;
171         int bq = 0;
172         char vcard_partnum[SIZ];
173         char *vcard_source = NULL;
174
175         strcpy(from, "");
176         strcpy(node, "");
177         strcpy(rfca, "");
178         strcpy(reply_to, "");
179         strcpy(vcard_partnum, "");
180
181         sprintf(buf, "MSG0 %ld", msgnum);
182         serv_puts(buf);
183         serv_gets(buf);
184         if (buf[0] != '1') {
185                 wprintf("<STRONG>ERROR:</STRONG> %s<BR>\n", &buf[4]);
186                 return;
187         }
188         wprintf("<TABLE WIDTH=100%% BORDER=0 CELLSPACING=0 CELLPADDING=1 BGCOLOR=CCCCCC><TR><TD>\n");
189         wprintf("<FONT ");
190         if (!is_summary) wprintf("SIZE=+1 ");
191         wprintf("COLOR=\"000000\"> ");
192         strcpy(m_subject, "");
193
194         while (serv_gets(buf), strncasecmp(buf, "text", 4)) {
195                 if (!strncasecmp(buf, "nhdr=yes", 8))
196                         nhdr = 1;
197                 if (nhdr == 1)
198                         buf[0] = '_';
199                 if (!strncasecmp(buf, "type=", 5))
200                         format_type = atoi(&buf[5]);
201                 if (!strncasecmp(buf, "from=", 5)) {
202                         strcpy(from, &buf[5]);
203                         wprintf("from <A HREF=\"/showuser&who=");
204                         urlescputs(from);
205                         wprintf("\">");
206                         escputs(from);
207                         wprintf("</A> ");
208                 }
209                 if (!strncasecmp(buf, "subj=", 5))
210                         strcpy(m_subject, &buf[5]);
211                 if ((!strncasecmp(buf, "hnod=", 5))
212                     && (strcasecmp(&buf[5], serv_info.serv_humannode)))
213                         wprintf("(%s) ", &buf[5]);
214                 if ((!strncasecmp(buf, "room=", 5))
215                     && (strcasecmp(&buf[5], WC->wc_roomname)))
216                         wprintf("in %s> ", &buf[5]);
217                 if (!strncasecmp(buf, "rfca=", 5)) {
218                         strcpy(rfca, &buf[5]);
219                         wprintf("&lt;");
220                         escputs(rfca);
221                         wprintf("&gt; ");
222                 }
223
224                 if (!strncasecmp(buf, "node=", 5)) {
225                         if ( ((WC->room_flags & QR_NETWORK)
226                         || ((strcasecmp(&buf[5], serv_info.serv_nodename)
227                         && (strcasecmp(&buf[5], serv_info.serv_fqdn)))))
228                         && (strlen(rfca)==0)
229                         ) {
230                                 wprintf("@%s ", &buf[5]);
231                         }
232                 }
233                 if (!strncasecmp(buf, "rcpt=", 5))
234                         wprintf("to %s ", &buf[5]);
235                 if (!strncasecmp(buf, "time=", 5)) {
236                         fmt_date(now, atol(&buf[5]));
237                         wprintf("%s ", now);
238                 }
239
240                 if (!strncasecmp(buf, "part=", 5)) {
241                         extract(mime_filename, &buf[5], 1);
242                         extract(mime_partnum, &buf[5], 2);
243                         extract(mime_disposition, &buf[5], 3);
244                         extract(mime_content_type, &buf[5], 4);
245                         mime_length = extract_int(&buf[5], 5);
246
247                         if (!strcasecmp(mime_disposition, "attachment")) {
248                                 if (mime_http == NULL) {
249                                         mime_http = malloc(512);
250                                         strcpy(mime_http, "");
251                                 }
252                                 else {
253                                         mime_http = realloc(mime_http,
254                                                 strlen(mime_http) + 512);
255                                 }
256                                 sprintf(&mime_http[strlen(mime_http)],
257                                         "<A HREF=\"/output_mimepart?"
258                                         "msgnum=%ld&partnum=%s\" "
259                                         "TARGET=\"wc.%ld.%s\">"
260                                         "<IMG SRC=\"/static/attachment.gif\" "
261                                         "BORDER=0 ALIGN=MIDDLE>\n"
262                                         "Part %s: %s (%s, %d bytes)</A><BR>\n",
263                                         msgnum, mime_partnum,
264                                         msgnum, mime_partnum,
265                                         mime_partnum, mime_filename,
266                                         mime_content_type, mime_length);
267                         }
268
269                         if ((!strcasecmp(mime_disposition, "inline"))
270                            && (!strncasecmp(mime_content_type, "image/", 6)) ){
271                                 if (mime_http == NULL) {
272                                         mime_http = malloc(512);
273                                         strcpy(mime_http, "");
274                                 }
275                                 else {
276                                         mime_http = realloc(mime_http,
277                                                 strlen(mime_http) + 512);
278                                 }
279                                 sprintf(&mime_http[strlen(mime_http)],
280                                         "<IMG SRC=\"/output_mimepart?"
281                                         "msgnum=%ld&partnum=%s\">",
282                                         msgnum, mime_partnum);
283                         }
284
285                         if (!strcasecmp(mime_content_type, "text/x-vcard")) {
286                                 strcpy(vcard_partnum, mime_partnum);
287                         }
288
289                 }
290
291         }
292
293
294         /* Generate a reply-to address */
295         if (strlen(rfca) > 0) {
296                 strcpy(reply_to, rfca);
297         }
298         else {
299                 if (strlen(node) > 0) {
300                         snprintf(reply_to, sizeof(reply_to), "%s @ %s",
301                                 from, node);
302                 }
303                 else {
304                         snprintf(reply_to, sizeof(reply_to), "%s", from);
305                 }
306         }
307
308         if (nhdr == 1)
309                 wprintf("****");
310         wprintf("</FONT></TD>");
311
312         /* begin right-hand toolbar */
313         wprintf("<TD ALIGN=RIGHT>\n"
314                 "<TABLE BORDER=0><TR>\n");
315
316         if (is_summary) {
317                 wprintf("<TD BGCOLOR=\"AAAADD\">"
318                         "<A HREF=\"/readfwd?startmsg=%ld", msgnum);
319                 wprintf("&maxmsgs=1&summary=0\">Read</A>"
320                         "</TD>\n", msgnum);
321         }
322
323         wprintf("<TD BGCOLOR=\"AAAADD\">"
324                 "<A HREF=\"/display_enter?recp=");
325         urlescputs(reply_to);
326         wprintf("\"><FONT SIZE=-1>Reply</FONT></A>"
327                 "</TD>\n", msgnum);
328
329         if (WC->is_room_aide) {
330                 wprintf("<TD BGCOLOR=\"AAAADD\">"
331                         "<A HREF=\"/confirm_move_msg"
332                         "&msgid=%ld"
333                         "\"><FONT SIZE=-1>Move</FONT></A>"
334                         "</TD>\n", msgnum);
335
336                 wprintf("<TD BGCOLOR=\"AAAADD\">"
337                         "<A HREF=\"/delete_msg"
338                         "&msgid=%ld\""
339                         "onClick=\"return confirm('Delete this message?');\""
340                         "><FONT SIZE=-1>Del</FONT></A>"
341                         "</TD>\n", msgnum);
342         }
343
344         wprintf("</TR></TABLE>\n"
345                 "</TD>\n");
346
347         /* end right-hand toolbar */
348
349
350         if (strlen(m_subject) > 0) {
351                 wprintf("<TR><TD><FONT COLOR=\"0000FF\">"
352                         "Subject: %s</FONT>"
353                         "</TD><TD>&nbsp;</TD></TR>\n", m_subject);
354         }
355
356         wprintf("</TR></TABLE>\n");
357
358         if (is_summary) {
359                 while (serv_gets(buf), strcmp(buf, "000")) ;
360                 return;
361         }
362
363         if (format_type == 0) {
364                 fmout(NULL);
365         } else {
366                 while (serv_gets(buf), strcmp(buf, "000")) {
367                         while ((strlen(buf) > 0) && (isspace(buf[strlen(buf) - 1])))
368                                 buf[strlen(buf) - 1] = 0;
369                         if ((bq == 0) &&
370                             ((!strncmp(buf, ">", 1)) || (!strncmp(buf, " >", 2)) || (!strncmp(buf, " :-)", 4)))) {
371                                 wprintf("<FONT COLOR=\"000044\"><I>");
372                                 bq = 1;
373                         } else if ((bq == 1) &&
374                                    (strncmp(buf, ">", 1)) && (strncmp(buf, " >", 2)) && (strncmp(buf, " :-)", 4))) {
375                                 wprintf("</FONT></I>");
376                                 bq = 0;
377                         }
378                         wprintf("<TT>");
379                         url(buf);
380                         escputs(buf);
381                         wprintf("</TT><BR>\n");
382                 }
383         }
384         wprintf("</I><BR>");
385
386         if (mime_http != NULL) {
387                 wprintf("%s", mime_http);
388                 free(mime_http);
389         }
390
391         if (strlen(vcard_partnum) > 0) {
392                 vcard_source = load_mimepart(msgnum, vcard_partnum);
393                 if (vcard_source != NULL) {
394                         display_vcard(vcard_source);
395                         free(vcard_source);
396                 }
397         }
398
399 }
400
401
402
403 /* 
404  * load message pointers from the server
405  */
406 int load_msg_ptrs(servcmd)
407 char *servcmd;
408 {
409         char buf[SIZ];
410         int nummsgs;
411
412         nummsgs = 0;
413         serv_puts(servcmd);
414         serv_gets(buf);
415         if (buf[0] != '1') {
416                 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
417                 return (nummsgs);
418         }
419         while (serv_gets(buf), strcmp(buf, "000")) {
420                 WC->msgarr[nummsgs] = atol(buf);
421                 ++nummsgs;
422         }
423         return (nummsgs);
424 }
425
426
427 /*
428  * command loop for reading messages
429  */
430 void readloop(char *oper)
431 {
432         char cmd[SIZ];
433         int a, b;
434         int nummsgs;
435         long startmsg;
436         int maxmsgs;
437         int num_displayed = 0;
438         int is_summary = 0;
439         int remaining_messages;
440         int lo, hi;
441         int lowest_displayed = 0;
442         int highest_displayed = 0;
443
444         startmsg = atol(bstr("startmsg"));
445         maxmsgs = atoi(bstr("maxmsgs"));
446         is_summary = atoi(bstr("summary"));
447         if (maxmsgs == 0) maxmsgs = 20;
448
449         output_headers(1);
450
451         if (!strcmp(oper, "readnew")) {
452                 strcpy(cmd, "MSGS NEW");
453         } else if (!strcmp(oper, "readold")) {
454                 strcpy(cmd, "MSGS OLD");
455         } else {
456                 strcpy(cmd, "MSGS ALL");
457         }
458
459         nummsgs = load_msg_ptrs(cmd);
460         if (nummsgs == 0) {
461                 if (!strcmp(oper, "readnew")) {
462                         wprintf("<EM>No new messages in this room.</EM>\n");
463                 } else if (!strcmp(oper, "readold")) {
464                         wprintf("<EM>No old messages in this room.</EM>\n");
465                 } else {
466                         wprintf("<EM>This room is empty.</EM>\n");
467                 }
468                 goto DONE;
469         }
470
471         if (startmsg == 0L) startmsg = WC->msgarr[0];
472         remaining_messages = 0;
473
474         for (a = 0; a < nummsgs; ++a) {
475                 if (WC->msgarr[a] >= startmsg) {
476                         ++remaining_messages;
477                 }
478         }
479
480         for (a = 0; ( (a < nummsgs) && (num_displayed < maxmsgs) ) ; ++a) {
481                 if (WC->msgarr[a] >= startmsg) {
482
483                         read_message(WC->msgarr[a], is_summary);
484                         if (lowest_displayed == 0) lowest_displayed = a;
485                         highest_displayed = a;
486                         if (is_summary) wprintf("<BR>");
487
488                         ++num_displayed;
489                         --remaining_messages;
490                 }
491         }
492
493         /* Bump these because although we're thinking in zero base, the user
494          * is a drooling idiot and is thinking in one base.
495          */
496         ++lowest_displayed;
497         ++highest_displayed;
498
499         /*
500          * If we're not currently looking at ALL requested
501          * messages, then display the selector bar
502          */
503         if (num_displayed < nummsgs) {
504
505                 wprintf("<CENTER>"
506                         "<TABLE BORDER=0 WIDTH=100%% BGCOLOR=DDDDDD><TR><TD>"
507                         "You are reading #%d-%d of %d messages.</TD>\n"
508                         "<TD ALIGN=RIGHT><FONT SIZE=+1>",
509                         lowest_displayed, highest_displayed, nummsgs);
510
511                 for (b=0; b<nummsgs; b = b + maxmsgs) {
512                 lo = b+1;
513                 hi = b+maxmsgs+1;
514                 if (hi > nummsgs) hi = nummsgs;
515                         if (WC->msgarr[b] != startmsg) {
516                                 wprintf("<A HREF=\"/%s"
517                                         "?startmsg=%ld"
518                                         "&maxmsgs=%d"
519                                         "&summary=%d\">"
520                                         "%d-%d</A> \n",
521                                                 oper,
522                                                 WC->msgarr[b],
523                                                 maxmsgs,
524                                                 is_summary,
525                                                 lo, hi);
526                         }
527                         else {
528                                 wprintf("%d-%d \n", lo, hi);
529                         }
530
531                 }
532                 wprintf("<A HREF=\"/%s?startmsg=%ld"
533                         "&maxmsgs=999999&summary=%d\">"
534                         "ALL"
535                         "</A>&nbsp;&nbsp;&nbsp;",
536                         oper,
537                         WC->msgarr[0], is_summary);
538                 wprintf("</TD></TR></TABLE></CENTER><HR>\n");
539         }
540
541 DONE:   wDumpContent(1);
542 }
543
544
545
546
547 /*
548  * Post message (or don't post message)
549  *
550  * Note regarding the "dont_post" variable:
551  * A random value (actually, it's just a timestamp) is inserted as a hidden
552  * field called "postseq" when the display_enter page is generated.  This
553  * value is checked when posting, using the static variable dont_post.  If a
554  * user attempts to post twice using the same dont_post value, the message is
555  * discarded.  This prevents the accidental double-saving of the same message
556  * if the user happens to click the browser "back" button.
557  */
558 void post_message(void)
559 {
560         char buf[SIZ];
561         static long dont_post = (-1L);
562
563         output_headers(1);
564
565         wprintf("<FONT FACE=\"Arial,Helvetica,sans-serif\">");
566         strcpy(buf, bstr("sc"));
567         if (strcasecmp(buf, "Save message")) {
568                 wprintf("Cancelled.  Message was not posted.<BR>\n");
569         } else if (atol(bstr("postseq")) == dont_post) {
570                 wprintf("Automatically cancelled because you have already "
571                         "saved this message.<BR>\n");
572         } else {
573                 sprintf(buf, "ENT0 1|%s|0|0|%s",
574                         bstr("recp"),
575                         bstr("subject") );
576                 serv_puts(buf);
577                 serv_gets(buf);
578                 if (buf[0] == '4') {
579                         text_to_server(bstr("msgtext"));
580                         serv_puts("000");
581                         wprintf("Message has been posted.<BR>\n");
582                         dont_post = atol(bstr("postseq"));
583                 } else {
584                         wprintf("<EM>%s</EM><BR>\n", &buf[4]);
585                 }
586         }
587
588         wDumpContent(1);
589 }
590
591
592
593
594 /*
595  * display the message entry screen
596  */
597 void display_enter(void)
598 {
599         char buf[SIZ];
600         long now;
601         struct tm *tm;
602
603         output_headers(1);
604
605         wprintf("<FONT FACE=\"Arial,Helvetica,sans-serif\">");
606
607         sprintf(buf, "ENT0 0|%s|0|0", bstr("recp"));
608         serv_puts(buf);
609         serv_gets(buf);
610
611         if (!strncmp(buf, "570", 3)) {
612                 if (strlen(bstr("recp")) > 0) {
613                         wprintf("<EM>%s</EM><BR>\n", &buf[4]);
614                 }
615                 do_template("prompt_for_recipient.html");
616                 goto DONE;
617         }
618         if (buf[0] != '2') {
619                 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
620                 goto DONE;
621         }
622
623         now = time(NULL);
624         tm = (struct tm *) localtime(&now);
625         strcpy(buf, (char *) asctime(tm));
626         buf[strlen(buf) - 1] = 0;
627         strcpy(&buf[16], &buf[19]);
628         wprintf("</CENTER><FONT COLOR=\"440000\">\n"
629                 "<IMG SRC=\"static/enter.gif\" ALIGN=MIDDLE ALT=\" \" "
630                 "onLoad=\"document.enterform.msgtext.focus();\" >");
631         wprintf("<B> %s ", &buf[4]);
632         wprintf("from %s ", WC->wc_username);
633         if (strlen(bstr("recp")) > 0)
634                 wprintf("to %s ", bstr("recp"));
635         wprintf("in %s&gt; ", WC->wc_roomname);
636         wprintf("</B></FONT><BR><CENTER>\n");
637
638         wprintf("<FORM METHOD=\"POST\" ACTION=\"/post\" "
639                 "NAME=\"enterform\">\n");
640         wprintf("<INPUT TYPE=\"hidden\" NAME=\"recp\" VALUE=\"%s\">\n",
641                 bstr("recp"));
642         wprintf("<INPUT TYPE=\"hidden\" NAME=\"postseq\" VALUE=\"%ld\">\n",
643                 now);
644         wprintf("<FONT SIZE=-1>Subject (optional):</FONT>"
645                 "<INPUT TYPE=\"text\" NAME=\"subject\" MAXLENGTH=70>"
646                 "&nbsp;&nbsp;&nbsp;"
647                 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Save message\">"
648                 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\"><BR>\n");
649
650         wprintf("<TEXTAREA NAME=\"msgtext\" wrap=soft ROWS=30 COLS=80 "
651                 "WIDTH=80></TEXTAREA><P>\n");
652
653         wprintf("</FORM></CENTER>\n");
654 DONE:   wDumpContent(1);
655         wprintf("</FONT>");
656 }
657
658
659
660
661
662
663
664
665 void delete_msg(void)
666 {
667         long msgid;
668         char buf[SIZ];
669
670         msgid = atol(bstr("msgid"));
671
672         output_headers(1);
673
674         sprintf(buf, "DELE %ld", msgid);
675         serv_puts(buf);
676         serv_gets(buf);
677         wprintf("<EM>%s</EM><BR>\n", &buf[4]);
678
679         wDumpContent(1);
680 }
681
682
683
684
685 /*
686  * Confirm move of a message
687  */
688 void confirm_move_msg(void)
689 {
690         long msgid;
691         char buf[SIZ];
692         char targ[SIZ];
693
694         msgid = atol(bstr("msgid"));
695
696         output_headers(1);
697
698         wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=770000><TR><TD>");
699         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
700         wprintf("<B>Confirm move of message</B>\n");
701         wprintf("</FONT></TD></TR></TABLE>\n");
702
703         wprintf("<CENTER>");
704
705         wprintf("Please select the room to which you would like this message moved:<BR>\n");
706
707         wprintf("<FORM METHOD=\"POST\" ACTION=\"/move_msg\">\n");
708         wprintf("<INPUT TYPE=\"hidden\" NAME=\"msgid\" VALUE=\"%s\">\n",
709                 bstr("msgid"));
710
711
712         wprintf("<SELECT NAME=\"target_room\" SIZE=5>\n");
713         serv_puts("LKRA");
714         serv_gets(buf);
715         if (buf[0] == '1') {
716                 while (serv_gets(buf), strcmp(buf, "000")) {
717                         extract(targ, buf, 0);
718                         wprintf("<OPTION>");
719                         escputs(targ);
720                         wprintf("\n");
721                 }
722         }
723         wprintf("</SELECT>\n");
724         wprintf("<BR>\n");
725
726         wprintf("<INPUT TYPE=\"submit\" NAME=\"yesno\" VALUE=\"Move\">");
727         wprintf("<INPUT TYPE=\"submit\" NAME=\"yesno\" VALUE=\"Cancel\">");
728         wprintf("</FORM></CENTER>\n");
729
730         wprintf("</CENTER>\n");
731         wDumpContent(1);
732 }
733
734
735
736 void move_msg(void)
737 {
738         long msgid;
739         char buf[SIZ];
740
741         msgid = atol(bstr("msgid"));
742
743         output_headers(1);
744
745         if (!strcasecmp(bstr("yesno"), "Move")) {
746                 sprintf(buf, "MOVE %ld|%s", msgid, bstr("target_room"));
747                 serv_puts(buf);
748                 serv_gets(buf);
749                 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
750         } else {
751                 wprintf("<EM>Message not deleted.</EM><BR>\n");
752         }
753
754         wDumpContent(1);
755 }
756
757
758