]> code.citadel.org Git - citadel.git/blob - webcit/messages.c
* Some work on email summary screen
[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                            || (!strcasecmp(&WC->wc_roomname[11], USERCONFIGROOM))) {
401                                 wprintf("<A HREF=\"/edit_vcard?"
402                                         "msgnum=%ld&partnum=%s\">",
403                                         msgnum, vcard_partnum);
404                                 wprintf("(edit)</A>");
405                         }
406
407                         /* In all cases, display it */
408                         display_vcard(vcard_source);
409                         free(vcard_source);
410                 }
411         }
412
413 }
414
415
416
417 /* 
418  * load message pointers from the server
419  */
420 int load_msg_ptrs(servcmd)
421 char *servcmd;
422 {
423         char buf[SIZ];
424         int nummsgs;
425
426         nummsgs = 0;
427         serv_puts(servcmd);
428         serv_gets(buf);
429         if (buf[0] != '1') {
430                 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
431                 return (nummsgs);
432         }
433         while (serv_gets(buf), strcmp(buf, "000")) {
434                 WC->msgarr[nummsgs] = atol(buf);
435                 ++nummsgs;
436         }
437         return (nummsgs);
438 }
439
440
441 /*
442  * command loop for reading messages
443  */
444 void readloop(char *oper)
445 {
446         char cmd[SIZ];
447         int a, b;
448         int nummsgs;
449         long startmsg;
450         int maxmsgs;
451         int num_displayed = 0;
452         int is_summary = 0;
453         int remaining_messages;
454         int lo, hi;
455         int lowest_displayed = 0;
456         int highest_displayed = 0;
457         long pn_previous = 0L;
458         long pn_current = 0L;
459         long pn_next = 0L;
460
461         startmsg = atol(bstr("startmsg"));
462         maxmsgs = atoi(bstr("maxmsgs"));
463         is_summary = atoi(bstr("summary"));
464         if (maxmsgs == 0) maxmsgs = 20;
465
466         output_headers(1);
467
468         if (!strcmp(oper, "readnew")) {
469                 strcpy(cmd, "MSGS NEW");
470         } else if (!strcmp(oper, "readold")) {
471                 strcpy(cmd, "MSGS OLD");
472         } else {
473                 strcpy(cmd, "MSGS ALL");
474         }
475
476         nummsgs = load_msg_ptrs(cmd);
477         if (nummsgs == 0) {
478                 if (!strcmp(oper, "readnew")) {
479                         wprintf("<EM>No new messages in this room.</EM>\n");
480                 } else if (!strcmp(oper, "readold")) {
481                         wprintf("<EM>No old messages in this room.</EM>\n");
482                 } else {
483                         wprintf("<EM>This room is empty.</EM>\n");
484                 }
485                 goto DONE;
486         }
487
488         if (startmsg == 0L) startmsg = WC->msgarr[0];
489         remaining_messages = 0;
490
491         for (a = 0; a < nummsgs; ++a) {
492                 if (WC->msgarr[a] >= startmsg) {
493                         ++remaining_messages;
494                 }
495         }
496
497         for (a = 0; a < nummsgs; ++a) {
498                 if ((WC->msgarr[a] >= startmsg) && (num_displayed < maxmsgs)) {
499
500                         /* Learn which msgs "Prev" & "Next" buttons go to */
501                         pn_current = WC->msgarr[a];
502                         if (a > 0) pn_previous = WC->msgarr[a-1];
503                         if (a < (nummsgs-1)) pn_next = WC->msgarr[a+1];
504
505                         /* Display the message */
506                         read_message(WC->msgarr[a], is_summary);
507                         if (lowest_displayed == 0) lowest_displayed = a;
508                         highest_displayed = a;
509                         if (is_summary) wprintf("<BR>");
510
511                         ++num_displayed;
512                         --remaining_messages;
513                 }
514         }
515
516         /* Bump these because although we're thinking in zero base, the user
517          * is a drooling idiot and is thinking in one base.
518          */
519         ++lowest_displayed;
520         ++highest_displayed;
521
522         /* If we're only looking at one message, do a prev/next thing */
523         if (num_displayed == 1) {
524
525                 wprintf("<CENTER>"
526                         "<TABLE BORDER=0 WIDTH=100%% BGCOLOR=DDDDDD><TR><TD>"
527                         "Reading #%d of %d messages.</TD>\n"
528                         "<TD ALIGN=RIGHT><FONT SIZE=+1>",
529                         lowest_displayed, nummsgs);
530
531                         if (pn_previous > 0L) {
532                                 wprintf("<A HREF=\"/%s"
533                                         "?startmsg=%ld"
534                                         "&maxmsgs=1"
535                                         "&summary=0\">"
536                                         "Previous</A> \n",
537                                                 oper,
538                                                 pn_previous );
539                         }
540
541                         if (pn_next > 0L) {
542                                 wprintf("<A HREF=\"/%s"
543                                         "?startmsg=%ld"
544                                         "&maxmsgs=1"
545                                         "&summary=0\">"
546                                         "Next</A> \n",
547                                                 oper,
548                                                 pn_next );
549                         }
550
551                 wprintf("<A HREF=\"/%s?startmsg=%ld"
552                         "&maxmsgs=999999&summary=1\">"
553                         "Summary"
554                         "</A>",
555                         oper,
556                         WC->msgarr[0]);
557
558                 wprintf("</TD></TR></TABLE></CENTER><HR>\n");
559         }
560
561
562         /*
563          * If we're not currently looking at ALL requested
564          * messages, then display the selector bar
565          */
566         /* if (num_displayed < nummsgs) { */
567         if (num_displayed > 1) {
568
569                 wprintf("<CENTER>"
570                         "<TABLE BORDER=0 WIDTH=100%% BGCOLOR=DDDDDD><TR><TD>"
571                         "Reading #%d-%d of %d messages.</TD>\n"
572                         "<TD ALIGN=RIGHT><FONT SIZE=+1>",
573                         lowest_displayed, highest_displayed, nummsgs);
574
575                 for (b=0; b<nummsgs; b = b + maxmsgs) {
576                 lo = b+1;
577                 hi = b+maxmsgs+1;
578                 if (hi > nummsgs) hi = nummsgs;
579                         if (WC->msgarr[b] != startmsg) {
580                                 wprintf("<A HREF=\"/%s"
581                                         "?startmsg=%ld"
582                                         "&maxmsgs=%d"
583                                         "&summary=%d\">"
584                                         "%d-%d</A> \n",
585                                                 oper,
586                                                 WC->msgarr[b],
587                                                 maxmsgs,
588                                                 is_summary,
589                                                 lo, hi);
590                         }
591                         else {
592                                 wprintf("%d-%d \n", lo, hi);
593                         }
594
595                 }
596                 wprintf("<A HREF=\"/%s?startmsg=%ld"
597                         "&maxmsgs=999999&summary=%d\">"
598                         "ALL"
599                         "</A> ",
600                         oper,
601                         WC->msgarr[0], is_summary);
602
603                 wprintf("<A HREF=\"/%s?startmsg=%ld"
604                         "&maxmsgs=999999&summary=1\">"
605                         "Summary"
606                         "</A>",
607                         oper,
608                         WC->msgarr[0]);
609
610                 wprintf("</TD></TR></TABLE></CENTER><HR>\n");
611         }
612
613 DONE:   wDumpContent(1);
614 }
615
616
617
618
619 /*
620  * Post message (or don't post message)
621  *
622  * Note regarding the "dont_post" variable:
623  * A random value (actually, it's just a timestamp) is inserted as a hidden
624  * field called "postseq" when the display_enter page is generated.  This
625  * value is checked when posting, using the static variable dont_post.  If a
626  * user attempts to post twice using the same dont_post value, the message is
627  * discarded.  This prevents the accidental double-saving of the same message
628  * if the user happens to click the browser "back" button.
629  */
630 void post_message(void)
631 {
632         char buf[SIZ];
633         static long dont_post = (-1L);
634
635         output_headers(1);
636
637         wprintf("<FONT FACE=\"Arial,Helvetica,sans-serif\">");
638         strcpy(buf, bstr("sc"));
639         if (strcasecmp(buf, "Save message")) {
640                 wprintf("Cancelled.  Message was not posted.<BR>\n");
641         } else if (atol(bstr("postseq")) == dont_post) {
642                 wprintf("Automatically cancelled because you have already "
643                         "saved this message.<BR>\n");
644         } else {
645                 sprintf(buf, "ENT0 1|%s|0|0|%s",
646                         bstr("recp"),
647                         bstr("subject") );
648                 serv_puts(buf);
649                 serv_gets(buf);
650                 if (buf[0] == '4') {
651                         text_to_server(bstr("msgtext"));
652                         serv_puts("000");
653                         wprintf("Message has been posted.<BR>\n");
654                         dont_post = atol(bstr("postseq"));
655                 } else {
656                         wprintf("<EM>%s</EM><BR>\n", &buf[4]);
657                 }
658         }
659
660         wDumpContent(1);
661 }
662
663
664
665
666 /*
667  * display the message entry screen
668  */
669 void display_enter(void)
670 {
671         char buf[SIZ];
672         long now;
673         struct tm *tm;
674
675         output_headers(1);
676
677         wprintf("<FONT FACE=\"Arial,Helvetica,sans-serif\">");
678
679         sprintf(buf, "ENT0 0|%s|0|0", bstr("recp"));
680         serv_puts(buf);
681         serv_gets(buf);
682
683         if (!strncmp(buf, "570", 3)) {
684                 if (strlen(bstr("recp")) > 0) {
685                         wprintf("<EM>%s</EM><BR>\n", &buf[4]);
686                 }
687                 do_template("prompt_for_recipient.html");
688                 goto DONE;
689         }
690         if (buf[0] != '2') {
691                 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
692                 goto DONE;
693         }
694
695         now = time(NULL);
696         tm = (struct tm *) localtime(&now);
697         strcpy(buf, (char *) asctime(tm));
698         buf[strlen(buf) - 1] = 0;
699         strcpy(&buf[16], &buf[19]);
700         wprintf("</CENTER><FONT COLOR=\"440000\">\n"
701                 "<IMG SRC=\"static/enter.gif\" ALIGN=MIDDLE ALT=\" \" "
702                 "onLoad=\"document.enterform.msgtext.focus();\" >");
703         wprintf("<B> %s ", &buf[4]);
704         wprintf("from %s ", WC->wc_username);
705         if (strlen(bstr("recp")) > 0)
706                 wprintf("to %s ", bstr("recp"));
707         wprintf("in %s&gt; ", WC->wc_roomname);
708         wprintf("</B></FONT><BR><CENTER>\n");
709
710         wprintf("<FORM METHOD=\"POST\" ACTION=\"/post\" "
711                 "NAME=\"enterform\">\n");
712         wprintf("<INPUT TYPE=\"hidden\" NAME=\"recp\" VALUE=\"%s\">\n",
713                 bstr("recp"));
714         wprintf("<INPUT TYPE=\"hidden\" NAME=\"postseq\" VALUE=\"%ld\">\n",
715                 now);
716         wprintf("<FONT SIZE=-1>Subject (optional):</FONT>"
717                 "<INPUT TYPE=\"text\" NAME=\"subject\" MAXLENGTH=70>"
718                 "&nbsp;&nbsp;&nbsp;"
719                 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Save message\">"
720                 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\"><BR>\n");
721
722         wprintf("<TEXTAREA NAME=\"msgtext\" wrap=soft ROWS=30 COLS=80 "
723                 "WIDTH=80></TEXTAREA><P>\n");
724
725         wprintf("</FORM></CENTER>\n");
726 DONE:   wDumpContent(1);
727         wprintf("</FONT>");
728 }
729
730
731
732
733
734
735
736
737 void delete_msg(void)
738 {
739         long msgid;
740         char buf[SIZ];
741
742         msgid = atol(bstr("msgid"));
743
744         output_headers(1);
745
746         sprintf(buf, "DELE %ld", msgid);
747         serv_puts(buf);
748         serv_gets(buf);
749         wprintf("<EM>%s</EM><BR>\n", &buf[4]);
750
751         wDumpContent(1);
752 }
753
754
755
756
757 /*
758  * Confirm move of a message
759  */
760 void confirm_move_msg(void)
761 {
762         long msgid;
763         char buf[SIZ];
764         char targ[SIZ];
765
766         msgid = atol(bstr("msgid"));
767
768         output_headers(1);
769
770         wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=770000><TR><TD>");
771         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
772         wprintf("<B>Confirm move of message</B>\n");
773         wprintf("</FONT></TD></TR></TABLE>\n");
774
775         wprintf("<CENTER>");
776
777         wprintf("Please select the room to which you would like this message moved:<BR>\n");
778
779         wprintf("<FORM METHOD=\"POST\" ACTION=\"/move_msg\">\n");
780         wprintf("<INPUT TYPE=\"hidden\" NAME=\"msgid\" VALUE=\"%s\">\n",
781                 bstr("msgid"));
782
783
784         wprintf("<SELECT NAME=\"target_room\" SIZE=5>\n");
785         serv_puts("LKRA");
786         serv_gets(buf);
787         if (buf[0] == '1') {
788                 while (serv_gets(buf), strcmp(buf, "000")) {
789                         extract(targ, buf, 0);
790                         wprintf("<OPTION>");
791                         escputs(targ);
792                         wprintf("\n");
793                 }
794         }
795         wprintf("</SELECT>\n");
796         wprintf("<BR>\n");
797
798         wprintf("<INPUT TYPE=\"submit\" NAME=\"yesno\" VALUE=\"Move\">");
799         wprintf("<INPUT TYPE=\"submit\" NAME=\"yesno\" VALUE=\"Cancel\">");
800         wprintf("</FORM></CENTER>\n");
801
802         wprintf("</CENTER>\n");
803         wDumpContent(1);
804 }
805
806
807
808 void move_msg(void)
809 {
810         long msgid;
811         char buf[SIZ];
812
813         msgid = atol(bstr("msgid"));
814
815         output_headers(1);
816
817         if (!strcasecmp(bstr("yesno"), "Move")) {
818                 sprintf(buf, "MOVE %ld|%s", msgid, bstr("target_room"));
819                 serv_puts(buf);
820                 serv_gets(buf);
821                 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
822         } else {
823                 wprintf("<EM>Message not deleted.</EM><BR>\n");
824         }
825
826         wDumpContent(1);
827 }
828
829
830