4 * Functions which deal with the fetching and displaying of messages.
14 #include <sys/types.h>
16 #include <sys/socket.h>
18 #include <netinet/in.h>
28 #include "webserver.h"
32 * Look for URL's embedded in a buffer and make them linkable. We use a
33 * target window in order to keep the BBS session in its own window.
49 for (pos = 0; pos < strlen(buf); ++pos) {
50 if (!strncasecmp(&buf[pos], "http://", 7))
52 if (!strncasecmp(&buf[pos], "ftp://", 6))
59 if ((start > 0) && (buf[start - 1] == '<'))
61 if ((start > 0) && (buf[start - 1] == '['))
63 if ((start > 0) && (buf[start - 1] == '('))
65 if ((start > 0) && (buf[start - 1] == '{'))
68 for (pos = strlen(buf); pos > start; --pos) {
69 if ((buf[pos] == ' ') || (buf[pos] == ench))
73 strncpy(urlbuf, &buf[start], end - start);
74 urlbuf[end - start] = 0;
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 )
85 /* display_vcard() calls this after parsing the textual vCard into
86 * our 'struct vCard' data object.
88 * Set 'full' to nonzero to display the full card, otherwise it will only
89 * show a summary line.
91 void display_parsed_vcard(struct vCard *v, int full) {
98 name = vcard_get_prop(v, "n", 1, 0, 0);
110 wprintf("<TABLE bgcolor=#888888>");
111 if (v->numprops) for (i=0; i<(v->numprops); ++i) {
112 if (!strcasecmp(v->prop[i].name, "n")) {
113 wprintf("<TR BGCOLOR=#AAAAAA>"
114 "<TD BGCOLOR=#FFFFFF>"
115 "<IMG VALIGN=CENTER SRC=\"/static/vcard.gif\"></TD>"
116 "<TD><FONT SIZE=+1><B>");
117 escputs(v->prop[i].value);
118 wprintf("</B></FONT></TD></TR>\n");
120 else if (!strcasecmp(v->prop[i].name, "email;internet")) {
121 wprintf("<TR><TD>Internet e-mail:</TD>"
122 "<TD><A HREF=\"mailto:");
123 urlescputs(v->prop[i].value);
125 escputs(v->prop[i].value);
126 wprintf("</A></TD></TR>\n");
128 else if (!strcasecmp(v->prop[i].name, "adr")) {
129 wprintf("<TR><TD>Address:</TD><TD>");
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) {
137 wprintf("</TD></TR>\n");
139 else if (!strncasecmp(v->prop[i].name, "tel;", 4)) {
140 wprintf("<TR><TD>%s telephone:</TD><TD>",
141 &v->prop[i].name[4]);
142 for (j=0; j<num_tokens(v->prop[i].value, ';'); ++j) {
143 extract_token(buf, v->prop[i].value, j, ';');
144 if (strlen(buf) > 0) {
149 wprintf("</TD></TR>\n");
153 escputs(v->prop[i].name);
154 wprintf("</TD><TD>");
155 escputs(v->prop[i].value);
156 wprintf("</TD></TR>\n");
159 wprintf("</TABLE>\n");
165 * Display a textual vCard
166 * (Converts to a vCard object and then calls the actual display function)
167 * Set 'full' to nonzero to display the whole card instead of a one-liner
169 void display_vcard(char *vcard_source, char alpha, int full) {
175 v = vcard_load(vcard_source);
176 if (v == NULL) return;
178 name = vcard_get_prop(v, "n", 1, 0, 0);
185 || ((isalpha(alpha)) && (tolower(alpha) == tolower(this_alpha)) )
186 || ((!isalpha(alpha)) && (!isalpha(this_alpha))) ) {
188 display_parsed_vcard(v, full);
199 * I wanna SEE that message!
201 void read_message(long msgnum) {
203 char mime_partnum[SIZ];
204 char mime_filename[SIZ];
205 char mime_content_type[SIZ];
206 char mime_disposition[SIZ];
208 char *mime_http = NULL;
218 char vcard_partnum[SIZ];
219 char cal_partnum[SIZ];
220 char *part_source = NULL;
225 strcpy(reply_to, "");
226 strcpy(vcard_partnum, "");
227 strcpy(cal_partnum, "");
229 serv_printf("MSG4 %ld", msgnum);
232 wprintf("<STRONG>ERROR:</STRONG> %s<BR>\n", &buf[4]);
236 wprintf("<TABLE WIDTH=100%% BORDER=0 CELLSPACING=0 "
237 "CELLPADDING=1 BGCOLOR=CCCCCC><TR><TD>\n");
241 wprintf("COLOR=\"000000\"> ");
242 strcpy(m_subject, "");
244 while (serv_gets(buf), strcasecmp(buf, "text")) {
245 if (!strncasecmp(buf, "nhdr=yes", 8))
249 if (!strncasecmp(buf, "type=", 5))
250 format_type = atoi(&buf[5]);
251 if (!strncasecmp(buf, "from=", 5)) {
252 strcpy(from, &buf[5]);
253 wprintf("from <A HREF=\"/showuser&who=");
259 if (!strncasecmp(buf, "subj=", 5))
260 strcpy(m_subject, &buf[5]);
261 if ((!strncasecmp(buf, "hnod=", 5))
262 && (strcasecmp(&buf[5], serv_info.serv_humannode)))
263 wprintf("(%s) ", &buf[5]);
264 if ((!strncasecmp(buf, "room=", 5))
265 && (strcasecmp(&buf[5], WC->wc_roomname)))
266 wprintf("in %s> ", &buf[5]);
267 if (!strncasecmp(buf, "rfca=", 5)) {
268 strcpy(rfca, &buf[5]);
274 if (!strncasecmp(buf, "node=", 5)) {
275 if ( ((WC->room_flags & QR_NETWORK)
276 || ((strcasecmp(&buf[5], serv_info.serv_nodename)
277 && (strcasecmp(&buf[5], serv_info.serv_fqdn)))))
280 wprintf("@%s ", &buf[5]);
283 if (!strncasecmp(buf, "rcpt=", 5))
284 wprintf("to %s ", &buf[5]);
285 if (!strncasecmp(buf, "time=", 5)) {
286 fmt_date(now, atol(&buf[5]));
290 if (!strncasecmp(buf, "part=", 5)) {
291 extract(mime_filename, &buf[5], 1);
292 extract(mime_partnum, &buf[5], 2);
293 extract(mime_disposition, &buf[5], 3);
294 extract(mime_content_type, &buf[5], 4);
295 mime_length = extract_int(&buf[5], 5);
297 if (!strcasecmp(mime_disposition, "attachment")) {
298 if (mime_http == NULL) {
299 mime_http = malloc(512);
300 strcpy(mime_http, "");
303 mime_http = realloc(mime_http,
304 strlen(mime_http) + 512);
306 sprintf(&mime_http[strlen(mime_http)],
307 "<A HREF=\"/output_mimepart?"
308 "msgnum=%ld&partnum=%s\" "
309 "TARGET=\"wc.%ld.%s\">"
310 "<IMG SRC=\"/static/attachment.gif\" "
311 "BORDER=0 ALIGN=MIDDLE>\n"
312 "Part %s: %s (%s, %d bytes)</A><BR>\n",
313 msgnum, mime_partnum,
314 msgnum, mime_partnum,
315 mime_partnum, mime_filename,
316 mime_content_type, mime_length);
319 if ((!strcasecmp(mime_disposition, "inline"))
320 && (!strncasecmp(mime_content_type, "image/", 6)) ){
321 if (mime_http == NULL) {
322 mime_http = malloc(512);
323 strcpy(mime_http, "");
326 mime_http = realloc(mime_http,
327 strlen(mime_http) + 512);
329 sprintf(&mime_http[strlen(mime_http)],
330 "<IMG SRC=\"/output_mimepart?"
331 "msgnum=%ld&partnum=%s\">",
332 msgnum, mime_partnum);
335 /*** begin handler prep ***/
336 if (!strcasecmp(mime_content_type, "text/x-vcard")) {
337 strcpy(vcard_partnum, mime_partnum);
340 if (!strcasecmp(mime_content_type, "text/calendar")) {
341 strcpy(cal_partnum, mime_partnum);
344 /*** end handler prep ***/
351 /* Generate a reply-to address */
352 if (strlen(rfca) > 0) {
353 strcpy(reply_to, rfca);
356 if (strlen(node) > 0) {
357 snprintf(reply_to, sizeof(reply_to), "%s @ %s",
361 snprintf(reply_to, sizeof(reply_to), "%s", from);
369 wprintf("</FONT></TD>");
371 wprintf("<TD ALIGN=RIGHT>\n"
372 "<TABLE BORDER=0><TR>\n");
374 wprintf("<TD BGCOLOR=\"AAAADD\">"
375 "<A HREF=\"/readfwd?startmsg=%ld", msgnum);
376 wprintf("&maxmsgs=1&summary=0\">Read</A>"
379 wprintf("<TD BGCOLOR=\"AAAADD\">"
380 "<A HREF=\"/display_enter?recp=");
381 urlescputs(reply_to);
382 wprintf("\"><FONT SIZE=-1>Reply</FONT></A>"
385 if (WC->is_room_aide) {
386 wprintf("<TD BGCOLOR=\"AAAADD\">"
387 "<A HREF=\"/confirm_move_msg"
389 "\"><FONT SIZE=-1>Move</FONT></A>"
392 wprintf("<TD BGCOLOR=\"AAAADD\">"
393 "<A HREF=\"/delete_msg"
395 "onClick=\"return confirm('Delete this message?');\""
396 "><FONT SIZE=-1>Del</FONT></A>"
400 wprintf("</TR></TABLE>\n"
403 if (strlen(m_subject) > 0) {
404 wprintf("<TR><TD><FONT COLOR=\"0000FF\">"
406 "</TD><TD> </TD></TR>\n", m_subject);
409 wprintf("</TR></TABLE>\n");
412 * Learn the content type
414 strcpy(mime_content_type, "text/plain");
415 while (serv_gets(buf), (strlen(buf) > 0)) {
416 if (!strncasecmp(buf, "Content-type: ", 14)) {
417 safestrncpy(mime_content_type, &buf[14],
418 sizeof(mime_content_type));
422 /* Messages in legacy Citadel variformat get handled thusly... */
423 if (!strcasecmp(mime_content_type, "text/x-citadel-variformat")) {
427 /* Boring old 80-column fixed format text gets handled this way... */
428 else if (!strcasecmp(mime_content_type, "text/plain")) {
429 while (serv_gets(buf), strcmp(buf, "000")) {
430 while ((strlen(buf) > 0) && (isspace(buf[strlen(buf) - 1])))
431 buf[strlen(buf) - 1] = 0;
433 ((!strncmp(buf, ">", 1)) || (!strncmp(buf, " >", 2)) || (!strncmp(buf, " :-)", 4)))) {
434 wprintf("<FONT COLOR=\"000044\"><I>");
436 } else if ((bq == 1) &&
437 (strncmp(buf, ">", 1)) && (strncmp(buf, " >", 2)) && (strncmp(buf, " :-)", 4))) {
438 wprintf("</FONT></I>");
444 wprintf("</TT><BR>\n");
449 else /* HTML is fun, but we've got to strip it first */
450 if (!strcasecmp(mime_content_type, "text/html")) {
454 /* Unknown weirdness */
456 wprintf("I don't know how to display %s<BR>\n",
458 while (serv_gets(buf), strcmp(buf, "000")) { }
462 /* Afterwards, offer links to download attachments 'n' such */
463 if (mime_http != NULL) {
464 wprintf("%s", mime_http);
468 /* Handler for vCard parts */
469 if (strlen(vcard_partnum) > 0) {
470 part_source = load_mimepart(msgnum, vcard_partnum);
471 if (part_source != NULL) {
473 /* If it's my vCard I can edit it */
474 if ( (!strcasecmp(WC->wc_roomname, USERCONFIGROOM))
475 || (!strcasecmp(&WC->wc_roomname[11], USERCONFIGROOM))) {
476 wprintf("<A HREF=\"/edit_vcard?"
477 "msgnum=%ld&partnum=%s\">",
478 msgnum, vcard_partnum);
479 wprintf("(edit)</A>");
482 /* In all cases, display the full card */
483 display_vcard(part_source, 0, 1);
487 /* Handler for calendar parts */
488 if (strlen(cal_partnum) > 0) {
489 part_source = load_mimepart(msgnum, cal_partnum);
490 if (part_source != NULL) {
491 cal_process_attachment(part_source);
503 void summarize_message(long msgnum) {
514 memset(&summ, 0, sizeof(summ));
515 strcpy(summ.subj, "(no subject)");
517 sprintf(buf, "MSG0 %ld|1", msgnum); /* ask for headers only */
520 if (buf[0] != '1') return;
522 while (serv_gets(buf), strcmp(buf, "000")) {
523 if (!strncasecmp(buf, "from=", 5)) {
524 strcpy(summ.from, &buf[5]);
526 if (!strncasecmp(buf, "subj=", 5)) {
527 strcpy(summ.subj, &buf[5]);
529 if (!strncasecmp(buf, "rfca=", 5)) {
530 strcat(summ.from, " <");
531 strcat(summ.from, &buf[5]);
532 strcat(summ.from, ">");
535 if (!strncasecmp(buf, "node=", 5)) {
536 if ( ((WC->room_flags & QR_NETWORK)
537 || ((strcasecmp(&buf[5], serv_info.serv_nodename)
538 && (strcasecmp(&buf[5], serv_info.serv_fqdn)))))
540 strcat(summ.from, " @ ");
541 strcat(summ.from, &buf[5]);
545 if (!strncasecmp(buf, "rcpt=", 5)) {
546 strcpy(summ.to, &buf[5]);
549 if (!strncasecmp(buf, "time=", 5)) {
550 fmt_date(summ.date, atol(&buf[5]));
554 wprintf("<TD><A HREF=\"/readfwd?startmsg=%ld"
555 "&maxmsgs=1&summary=0\">",
558 wprintf("</A></TD><TD>");
560 wprintf(" </TD><TD>");
564 "<INPUT TYPE=\"checkbox\" NAME=\"msg_%ld\" VALUE=\"yes\">"
572 void display_addressbook(long msgnum, char alpha) {
574 char mime_partnum[SIZ];
575 char mime_filename[SIZ];
576 char mime_content_type[SIZ];
577 char mime_disposition[SIZ];
579 char vcard_partnum[SIZ];
580 char *vcard_source = NULL;
590 memset(&summ, 0, sizeof(summ));
591 strcpy(summ.subj, "(no subject)");
593 sprintf(buf, "MSG0 %ld|1", msgnum); /* ask for headers only */
596 if (buf[0] != '1') return;
598 while (serv_gets(buf), strcmp(buf, "000")) {
599 if (!strncasecmp(buf, "part=", 5)) {
600 extract(mime_filename, &buf[5], 1);
601 extract(mime_partnum, &buf[5], 2);
602 extract(mime_disposition, &buf[5], 3);
603 extract(mime_content_type, &buf[5], 4);
604 mime_length = extract_int(&buf[5], 5);
606 if (!strcasecmp(mime_content_type, "text/x-vcard")) {
607 strcpy(vcard_partnum, mime_partnum);
613 if (strlen(vcard_partnum) > 0) {
614 vcard_source = load_mimepart(msgnum, vcard_partnum);
615 if (vcard_source != NULL) {
617 /* Display the summary line */
618 display_vcard(vcard_source, alpha, 0);
620 /* If it's my vCard I can edit it */
621 if ( (!strcasecmp(WC->wc_roomname, USERCONFIGROOM))
622 || (!strcasecmp(&WC->wc_roomname[11], USERCONFIGROOM))) {
623 wprintf("<A HREF=\"/edit_vcard?"
624 "msgnum=%ld&partnum=%s\">",
625 msgnum, vcard_partnum);
626 wprintf("(edit)</A>");
638 * load message pointers from the server
640 int load_msg_ptrs(servcmd)
650 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
653 while (serv_gets(buf), strcmp(buf, "000")) {
654 WC->msgarr[nummsgs] = atol(buf);
662 * command loop for reading messages
664 void readloop(char *oper)
672 int num_displayed = 0;
674 int is_addressbook = 0;
677 int remaining_messages;
679 int lowest_displayed = (-1);
680 int highest_displayed = 0;
681 long pn_previous = 0L;
682 long pn_current = 0L;
687 startmsg = atol(bstr("startmsg"));
688 maxmsgs = atoi(bstr("maxmsgs"));
689 is_summary = atoi(bstr("summary"));
690 if (maxmsgs == 0) maxmsgs = 20;
694 if (!strcmp(oper, "readnew")) {
695 strcpy(cmd, "MSGS NEW");
696 } else if (!strcmp(oper, "readold")) {
697 strcpy(cmd, "MSGS OLD");
699 strcpy(cmd, "MSGS ALL");
702 /* FIXME put in the correct constant #defs */
703 if ((WC->wc_view == 1) && (maxmsgs > 1)) {
705 strcpy(cmd, "MSGS ALL");
708 if ((WC->wc_view == 2) && (maxmsgs > 1)) {
710 strcpy(cmd, "MSGS ALL");
712 if (bstr("alpha") == NULL) {
716 strcpy(buf, bstr("alpha"));
720 for (i='A'; i<='Z'; ++i) {
721 if (i == alpha) wprintf("<FONT SIZE=+2>"
724 wprintf("<A HREF=\"/readfwd?alpha=%c\">"
729 if (!isalpha(alpha)) wprintf("<FONT SIZE=+2>(other)</FONT>\n");
730 else wprintf("<A HREF=\"/readfwd?alpha=1\">(other)</A>\n");
731 wprintf("<HR width=100%%>\n");
733 if (WC->wc_view == 3) { /* calendar */
735 strcpy(cmd, "MSGS ALL");
738 if (WC->wc_view == 4) { /* tasks */
740 strcpy(cmd, "MSGS ALL");
745 nummsgs = load_msg_ptrs(cmd);
747 if (!strcmp(oper, "readnew")) {
748 wprintf("<EM>No new messages in this room.</EM>\n");
749 } else if (!strcmp(oper, "readold")) {
750 wprintf("<EM>No old messages in this room.</EM>\n");
752 wprintf("<EM>This room is empty.</EM>\n");
757 if (startmsg == 0L) startmsg = WC->msgarr[0];
758 remaining_messages = 0;
760 for (a = 0; a < nummsgs; ++a) {
761 if (WC->msgarr[a] >= startmsg) {
762 ++remaining_messages;
767 wprintf("<FORM METHOD=\"POST\" ACTION=\"/do_stuff_to_msgs\">\n"
768 "<TABLE border=0 cellspacing=0 "
769 "cellpadding=0 width=100%%>\n"
771 "<TD><I>Subject</I></TD>"
772 "<TD><I>Sender</I></TD>"
773 "<TD><I>Date</I></TD>"
779 if (is_addressbook) {
780 wprintf("<TABLE border=0 cellspacing=0 "
781 "cellpadding=0 width=100%%>\n"
785 for (a = 0; a < nummsgs; ++a) {
786 if ((WC->msgarr[a] >= startmsg) && (num_displayed < maxmsgs)) {
788 /* Learn which msgs "Prev" & "Next" buttons go to */
789 pn_current = WC->msgarr[a];
790 if (a > 0) pn_previous = WC->msgarr[a-1];
791 if (a < (nummsgs-1)) pn_next = WC->msgarr[a+1];
793 /* If a tabular view, set up the line */
794 if ( (is_summary) || (is_addressbook) ) {
796 wprintf("<TR BGCOLOR=%s>",
797 (bg ? "DDDDDD" : "FFFFFF")
801 /* Display the message */
803 summarize_message(WC->msgarr[a]);
805 else if (is_addressbook) {
806 display_addressbook(WC->msgarr[a], alpha);
808 else if (is_calendar) {
809 display_calendar(WC->msgarr[a]);
812 display_task(WC->msgarr[a]);
815 read_message(WC->msgarr[a]);
818 /* If a tabular view, finish the line */
819 if ( (is_summary) || (is_addressbook) ) {
823 if (lowest_displayed < 0) lowest_displayed = a;
824 highest_displayed = a;
827 --remaining_messages;
832 wprintf("</TABLE>\n");
835 if (is_addressbook) {
836 wprintf("</TABLE>\n");
841 "<A HREF=\"/display_edit_task?msgnum=0\">"
846 /* Bump these because although we're thinking in zero base, the user
847 * is a drooling idiot and is thinking in one base.
852 /* If we're only looking at one message, do a prev/next thing */
853 if (num_displayed == 1) {
856 "<TABLE BORDER=0 WIDTH=100%% BGCOLOR=DDDDDD><TR><TD>"
857 "Reading #%d of %d messages.</TD>\n"
858 "<TD ALIGN=RIGHT><FONT SIZE=+1>",
859 lowest_displayed, nummsgs);
862 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" "
863 "VALUE=\"Delete selected\">\n");
866 if (pn_previous > 0L) {
867 wprintf("<A HREF=\"/%s"
877 wprintf("<A HREF=\"/%s"
886 wprintf("<A HREF=\"/%s?startmsg=%ld"
887 "&maxmsgs=999999&summary=1\">"
893 wprintf("</TD></TR></TABLE></CENTER>\n");
898 * If we're not currently looking at ALL requested
899 * messages, then display the selector bar
901 if (num_displayed > 1) {
903 "<TABLE BORDER=0 WIDTH=100%% BGCOLOR=DDDDDD><TR><TD>"
904 "Reading #%d-%d of %d messages.</TD>\n"
905 "<TD ALIGN=RIGHT><FONT SIZE=+1>",
906 lowest_displayed, highest_displayed, nummsgs);
909 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" "
910 "VALUE=\"Delete selected\">\n");
914 for (b=0; b<nummsgs; b = b + maxmsgs) {
917 if (hi > nummsgs) hi = nummsgs;
918 if (WC->msgarr[b] != startmsg) {
919 wprintf("<A HREF=\"/%s"
931 wprintf("%d-%d \n", lo, hi);
935 wprintf("<A HREF=\"/%s?startmsg=%ld"
936 "&maxmsgs=999999&summary=%d\">"
940 WC->msgarr[0], is_summary);
942 wprintf("<A HREF=\"/%s?startmsg=%ld"
943 "&maxmsgs=999999&summary=1\">"
949 wprintf("</TD></TR></TABLE></CENTER>\n");
951 if (is_summary) wprintf("</FORM>\n");
953 DONE: wDumpContent(1);
960 * Post message (or don't post message)
962 * Note regarding the "dont_post" variable:
963 * A random value (actually, it's just a timestamp) is inserted as a hidden
964 * field called "postseq" when the display_enter page is generated. This
965 * value is checked when posting, using the static variable dont_post. If a
966 * user attempts to post twice using the same dont_post value, the message is
967 * discarded. This prevents the accidental double-saving of the same message
968 * if the user happens to click the browser "back" button.
970 void post_message(void)
973 static long dont_post = (-1L);
977 wprintf("<FONT FACE=\"Arial,Helvetica,sans-serif\">");
978 strcpy(buf, bstr("sc"));
979 if (strcasecmp(buf, "Save message")) {
980 wprintf("Cancelled. Message was not posted.<BR>\n");
981 } else if (atol(bstr("postseq")) == dont_post) {
982 wprintf("Automatically cancelled because you have already "
983 "saved this message.<BR>\n");
985 sprintf(buf, "ENT0 1|%s|0|4|%s",
991 serv_puts("Content-type: text/html");
993 text_to_server(bstr("msgtext"), 1);
995 wprintf("Message has been posted.<BR>\n");
996 dont_post = atol(bstr("postseq"));
998 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
1009 * display the message entry screen
1011 void display_enter(void)
1019 wprintf("<FONT FACE=\"Arial,Helvetica,sans-serif\">");
1021 sprintf(buf, "ENT0 0|%s|0|0", bstr("recp"));
1025 if (!strncmp(buf, "570", 3)) {
1026 if (strlen(bstr("recp")) > 0) {
1027 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
1029 do_template("prompt_for_recipient");
1032 if (buf[0] != '2') {
1033 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
1038 tm = (struct tm *) localtime(&now);
1039 strcpy(buf, (char *) asctime(tm));
1040 buf[strlen(buf) - 1] = 0;
1041 strcpy(&buf[16], &buf[19]);
1042 wprintf("</CENTER><FONT COLOR=\"440000\">\n"
1043 "<IMG SRC=\"static/enter.gif\" ALIGN=MIDDLE ALT=\" \" "
1044 "onLoad=\"document.enterform.msgtext.focus();\" >");
1045 wprintf("<B> %s ", &buf[4]);
1046 wprintf("from %s ", WC->wc_username);
1047 if (strlen(bstr("recp")) > 0)
1048 wprintf("to %s ", bstr("recp"));
1049 wprintf("in %s> ", WC->wc_roomname);
1050 wprintf("</B></FONT><BR><CENTER>\n");
1052 wprintf("<FORM METHOD=\"POST\" ACTION=\"/post\" "
1053 "NAME=\"enterform\">\n");
1054 wprintf("<INPUT TYPE=\"hidden\" NAME=\"recp\" VALUE=\"%s\">\n",
1056 wprintf("<INPUT TYPE=\"hidden\" NAME=\"postseq\" VALUE=\"%ld\">\n",
1058 wprintf("<FONT SIZE=-1>Subject (optional):</FONT>"
1059 "<INPUT TYPE=\"text\" NAME=\"subject\" MAXLENGTH=70>"
1060 " "
1061 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Save message\">"
1062 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\"><BR>\n");
1064 wprintf("<TEXTAREA NAME=\"msgtext\" wrap=soft ROWS=30 COLS=80 "
1065 "WIDTH=80></TEXTAREA><P>\n");
1067 wprintf("</FORM></CENTER>\n");
1068 DONE: wDumpContent(1);
1079 void delete_msg(void)
1084 msgid = atol(bstr("msgid"));
1088 sprintf(buf, "DELE %ld", msgid);
1091 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
1100 * Confirm move of a message
1102 void confirm_move_msg(void)
1108 msgid = atol(bstr("msgid"));
1112 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=770000><TR><TD>");
1113 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
1114 wprintf("<B>Confirm move of message</B>\n");
1115 wprintf("</FONT></TD></TR></TABLE>\n");
1117 wprintf("<CENTER>");
1119 wprintf("Please select the room to which you would like this message moved:<BR>\n");
1121 wprintf("<FORM METHOD=\"POST\" ACTION=\"/move_msg\">\n");
1122 wprintf("<INPUT TYPE=\"hidden\" NAME=\"msgid\" VALUE=\"%s\">\n",
1126 wprintf("<SELECT NAME=\"target_room\" SIZE=5>\n");
1129 if (buf[0] == '1') {
1130 while (serv_gets(buf), strcmp(buf, "000")) {
1131 extract(targ, buf, 0);
1132 wprintf("<OPTION>");
1137 wprintf("</SELECT>\n");
1140 wprintf("<INPUT TYPE=\"submit\" NAME=\"yesno\" VALUE=\"Move\">");
1141 wprintf("<INPUT TYPE=\"submit\" NAME=\"yesno\" VALUE=\"Cancel\">");
1142 wprintf("</FORM></CENTER>\n");
1144 wprintf("</CENTER>\n");
1155 msgid = atol(bstr("msgid"));
1159 if (!strcasecmp(bstr("yesno"), "Move")) {
1160 sprintf(buf, "MOVE %ld|%s", msgid, bstr("target_room"));
1163 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
1165 wprintf("<EM>Message not moved.</EM><BR>\n");
1173 void do_stuff_to_msgs(void) {
1178 struct stuff_t *next;
1182 struct stuff_t *stuff = NULL;
1183 struct stuff_t *ptr;
1186 serv_puts("MSGS ALL");
1189 if (buf[0] == '1') while (serv_gets(buf), strcmp(buf, "000")) {
1190 ptr = malloc(sizeof(struct stuff_t));
1191 ptr->msgnum = atol(buf);
1196 strcpy(sc, bstr("sc"));
1198 while (stuff != NULL) {
1200 sprintf(buf, "msg_%ld", stuff->msgnum);
1201 if (!strcasecmp(bstr(buf), "yes")) {
1203 if (!strcasecmp(sc, "Delete selected")) {
1204 serv_printf("DELE %ld", stuff->msgnum);
1215 readloop("readfwd");