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