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 ALIGN=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 (!strcmp(buf, "000")) {
246 wprintf("<I>unexpected end of message</I><BR><BR>\n");
249 if (!strncasecmp(buf, "nhdr=yes", 8))
253 if (!strncasecmp(buf, "type=", 5))
254 format_type = atoi(&buf[5]);
255 if (!strncasecmp(buf, "from=", 5)) {
256 strcpy(from, &buf[5]);
257 wprintf("from <A HREF=\"/showuser&who=");
263 if (!strncasecmp(buf, "subj=", 5))
264 strcpy(m_subject, &buf[5]);
265 if ((!strncasecmp(buf, "hnod=", 5))
266 && (strcasecmp(&buf[5], serv_info.serv_humannode)))
267 wprintf("(%s) ", &buf[5]);
268 if ((!strncasecmp(buf, "room=", 5))
269 && (strcasecmp(&buf[5], WC->wc_roomname))
270 && (strlen(&buf[5])>0) )
271 wprintf("in %s> ", &buf[5]);
272 if (!strncasecmp(buf, "rfca=", 5)) {
273 strcpy(rfca, &buf[5]);
279 if (!strncasecmp(buf, "node=", 5)) {
280 if ( ((WC->room_flags & QR_NETWORK)
281 || ((strcasecmp(&buf[5], serv_info.serv_nodename)
282 && (strcasecmp(&buf[5], serv_info.serv_fqdn)))))
285 wprintf("@%s ", &buf[5]);
288 if (!strncasecmp(buf, "rcpt=", 5))
289 wprintf("to %s ", &buf[5]);
290 if (!strncasecmp(buf, "time=", 5)) {
291 fmt_date(now, atol(&buf[5]));
295 if (!strncasecmp(buf, "part=", 5)) {
296 extract(mime_filename, &buf[5], 1);
297 extract(mime_partnum, &buf[5], 2);
298 extract(mime_disposition, &buf[5], 3);
299 extract(mime_content_type, &buf[5], 4);
300 mime_length = extract_int(&buf[5], 5);
302 if (!strcasecmp(mime_disposition, "attachment")) {
303 if (mime_http == NULL) {
304 mime_http = malloc(512);
305 strcpy(mime_http, "");
308 mime_http = realloc(mime_http,
309 strlen(mime_http) + 512);
311 sprintf(&mime_http[strlen(mime_http)],
312 "<A HREF=\"/output_mimepart?"
313 "msgnum=%ld&partnum=%s\" "
314 "TARGET=\"wc.%ld.%s\">"
315 "<IMG SRC=\"/static/attachment.gif\" "
316 "BORDER=0 ALIGN=MIDDLE>\n"
317 "Part %s: %s (%s, %d bytes)</A><BR>\n",
318 msgnum, mime_partnum,
319 msgnum, mime_partnum,
320 mime_partnum, mime_filename,
321 mime_content_type, mime_length);
324 if ((!strcasecmp(mime_disposition, "inline"))
325 && (!strncasecmp(mime_content_type, "image/", 6)) ){
326 if (mime_http == NULL) {
327 mime_http = malloc(512);
328 strcpy(mime_http, "");
331 mime_http = realloc(mime_http,
332 strlen(mime_http) + 512);
334 sprintf(&mime_http[strlen(mime_http)],
335 "<IMG SRC=\"/output_mimepart?"
336 "msgnum=%ld&partnum=%s\">",
337 msgnum, mime_partnum);
340 /*** begin handler prep ***/
341 if (!strcasecmp(mime_content_type, "text/x-vcard")) {
342 strcpy(vcard_partnum, mime_partnum);
345 if (!strcasecmp(mime_content_type, "text/calendar")) {
346 strcpy(cal_partnum, mime_partnum);
349 /*** end handler prep ***/
355 /* Generate a reply-to address */
356 if (strlen(rfca) > 0) {
357 strcpy(reply_to, rfca);
360 if (strlen(node) > 0) {
361 snprintf(reply_to, sizeof(reply_to), "%s @ %s",
365 snprintf(reply_to, sizeof(reply_to), "%s", from);
373 wprintf("</FONT></TD>");
375 wprintf("<TD ALIGN=RIGHT>\n"
376 "<TABLE BORDER=0><TR>\n");
378 wprintf("<TD BGCOLOR=\"AAAADD\">"
379 "<A HREF=\"/readfwd?startmsg=%ld", msgnum);
380 wprintf("&maxmsgs=1&summary=0\">Read</A>"
383 wprintf("<TD BGCOLOR=\"AAAADD\">"
384 "<A HREF=\"/display_enter?recp=");
385 urlescputs(reply_to);
386 wprintf("\"><FONT SIZE=-1>Reply</FONT></A>"
389 if (WC->is_room_aide) {
390 wprintf("<TD BGCOLOR=\"AAAADD\">"
391 "<A HREF=\"/confirm_move_msg"
393 "\"><FONT SIZE=-1>Move</FONT></A>"
396 wprintf("<TD BGCOLOR=\"AAAADD\">"
397 "<A HREF=\"/delete_msg"
399 "onClick=\"return confirm('Delete this message?');\""
400 "><FONT SIZE=-1>Del</FONT></A>"
404 wprintf("</TR></TABLE>\n"
407 if (strlen(m_subject) > 0) {
408 wprintf("<TR><TD><FONT COLOR=\"0000FF\">"
410 "</TD><TD> </TD></TR>\n", m_subject);
413 wprintf("</TR></TABLE>\n");
416 * Learn the content type
418 strcpy(mime_content_type, "text/plain");
419 while (serv_gets(buf), (strlen(buf) > 0)) {
420 if (!strcmp(buf, "000")) {
421 wprintf("<I>unexpected end of message</I><BR><BR>\n");
424 if (!strncasecmp(buf, "Content-type: ", 14)) {
425 safestrncpy(mime_content_type, &buf[14],
426 sizeof(mime_content_type));
430 /* Messages in legacy Citadel variformat get handled thusly... */
431 if (!strcasecmp(mime_content_type, "text/x-citadel-variformat")) {
435 /* Boring old 80-column fixed format text gets handled this way... */
436 else if (!strcasecmp(mime_content_type, "text/plain")) {
437 while (serv_gets(buf), strcmp(buf, "000")) {
438 if (buf[strlen(buf)-1] == '\n') buf[strlen(buf)-1] = 0;
439 if (buf[strlen(buf)-1] == '\r') buf[strlen(buf)-1] = 0;
440 while ((strlen(buf) > 0) && (isspace(buf[strlen(buf) - 1])))
441 buf[strlen(buf) - 1] = 0;
443 ((!strncmp(buf, ">", 1)) || (!strncmp(buf, " >", 2)) || (!strncmp(buf, " :-)", 4)))) {
444 wprintf("<FONT COLOR=\"000044\"><I>");
446 } else if ((bq == 1) &&
447 (strncmp(buf, ">", 1)) && (strncmp(buf, " >", 2)) && (strncmp(buf, " :-)", 4))) {
448 wprintf("</FONT></I>");
454 wprintf("</TT><BR>\n");
459 else /* HTML is fun, but we've got to strip it first */
460 if (!strcasecmp(mime_content_type, "text/html")) {
464 /* Unknown weirdness */
466 wprintf("I don't know how to display %s<BR>\n",
468 while (serv_gets(buf), strcmp(buf, "000")) { }
472 /* Afterwards, offer links to download attachments 'n' such */
473 if (mime_http != NULL) {
474 wprintf("%s", mime_http);
478 /* Handler for vCard parts */
479 if (strlen(vcard_partnum) > 0) {
480 part_source = load_mimepart(msgnum, vcard_partnum);
481 if (part_source != NULL) {
483 /* If it's my vCard I can edit it */
484 if ( (!strcasecmp(WC->wc_roomname, USERCONFIGROOM))
485 || (!strcasecmp(&WC->wc_roomname[11], USERCONFIGROOM))) {
486 wprintf("<A HREF=\"/edit_vcard?"
487 "msgnum=%ld&partnum=%s\">",
488 msgnum, vcard_partnum);
489 wprintf("(edit)</A>");
492 /* In all cases, display the full card */
493 display_vcard(part_source, 0, 1);
497 /* Handler for calendar parts */
498 if (strlen(cal_partnum) > 0) {
499 part_source = load_mimepart(msgnum, cal_partnum);
500 if (part_source != NULL) {
501 cal_process_attachment(part_source,
502 msgnum, cal_partnum);
514 void summarize_message(long msgnum) {
525 memset(&summ, 0, sizeof(summ));
526 strcpy(summ.subj, "(no subject)");
528 sprintf(buf, "MSG0 %ld|1", msgnum); /* ask for headers only */
531 if (buf[0] != '1') return;
533 while (serv_gets(buf), strcmp(buf, "000")) {
534 if (!strncasecmp(buf, "from=", 5)) {
535 strcpy(summ.from, &buf[5]);
537 if (!strncasecmp(buf, "subj=", 5)) {
538 strcpy(summ.subj, &buf[5]);
540 if (!strncasecmp(buf, "rfca=", 5)) {
541 strcat(summ.from, " <");
542 strcat(summ.from, &buf[5]);
543 strcat(summ.from, ">");
546 if (!strncasecmp(buf, "node=", 5)) {
547 if ( ((WC->room_flags & QR_NETWORK)
548 || ((strcasecmp(&buf[5], serv_info.serv_nodename)
549 && (strcasecmp(&buf[5], serv_info.serv_fqdn)))))
551 strcat(summ.from, " @ ");
552 strcat(summ.from, &buf[5]);
556 if (!strncasecmp(buf, "rcpt=", 5)) {
557 strcpy(summ.to, &buf[5]);
560 if (!strncasecmp(buf, "time=", 5)) {
561 fmt_date(summ.date, atol(&buf[5]));
565 wprintf("<TD><A HREF=\"/readfwd?startmsg=%ld"
566 "&maxmsgs=1&summary=0\">",
569 wprintf("</A></TD><TD>");
571 wprintf(" </TD><TD>");
575 "<INPUT TYPE=\"checkbox\" NAME=\"msg_%ld\" VALUE=\"yes\">"
583 void display_addressbook(long msgnum, char alpha) {
585 char mime_partnum[SIZ];
586 char mime_filename[SIZ];
587 char mime_content_type[SIZ];
588 char mime_disposition[SIZ];
590 char vcard_partnum[SIZ];
591 char *vcard_source = NULL;
601 memset(&summ, 0, sizeof(summ));
602 strcpy(summ.subj, "(no subject)");
604 sprintf(buf, "MSG0 %ld|1", msgnum); /* ask for headers only */
607 if (buf[0] != '1') return;
609 while (serv_gets(buf), strcmp(buf, "000")) {
610 if (!strncasecmp(buf, "part=", 5)) {
611 extract(mime_filename, &buf[5], 1);
612 extract(mime_partnum, &buf[5], 2);
613 extract(mime_disposition, &buf[5], 3);
614 extract(mime_content_type, &buf[5], 4);
615 mime_length = extract_int(&buf[5], 5);
617 if (!strcasecmp(mime_content_type, "text/x-vcard")) {
618 strcpy(vcard_partnum, mime_partnum);
624 if (strlen(vcard_partnum) > 0) {
625 vcard_source = load_mimepart(msgnum, vcard_partnum);
626 if (vcard_source != NULL) {
628 /* Display the summary line */
629 display_vcard(vcard_source, alpha, 0);
631 /* If it's my vCard I can edit it */
632 if ( (!strcasecmp(WC->wc_roomname, USERCONFIGROOM))
633 || (!strcasecmp(&WC->wc_roomname[11], USERCONFIGROOM))) {
634 wprintf("<A HREF=\"/edit_vcard?"
635 "msgnum=%ld&partnum=%s\">",
636 msgnum, vcard_partnum);
637 wprintf("(edit)</A>");
649 * load message pointers from the server
651 int load_msg_ptrs(char *servcmd)
660 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
663 while (serv_gets(buf), strcmp(buf, "000")) {
664 WC->msgarr[nummsgs] = atol(buf);
665 /* FIXME check for overflow */
673 * command loop for reading messages
675 void readloop(char *oper)
683 int num_displayed = 0;
685 int is_addressbook = 0;
688 int remaining_messages;
690 int lowest_displayed = (-1);
691 int highest_displayed = 0;
692 long pn_previous = 0L;
693 long pn_current = 0L;
698 startmsg = atol(bstr("startmsg"));
699 maxmsgs = atoi(bstr("maxmsgs"));
700 is_summary = atoi(bstr("summary"));
701 if (maxmsgs == 0) maxmsgs = 20;
705 if (!strcmp(oper, "readnew")) {
706 strcpy(cmd, "MSGS NEW");
707 } else if (!strcmp(oper, "readold")) {
708 strcpy(cmd, "MSGS OLD");
710 strcpy(cmd, "MSGS ALL");
713 /* FIXME put in the correct constant #defs */
714 if ((WC->wc_view == 1) && (maxmsgs > 1)) {
716 strcpy(cmd, "MSGS ALL");
719 if ((WC->wc_view == 2) && (maxmsgs > 1)) {
721 strcpy(cmd, "MSGS ALL");
723 if (bstr("alpha") == NULL) {
727 strcpy(buf, bstr("alpha"));
731 for (i='A'; i<='Z'; ++i) {
732 if (i == alpha) wprintf("<FONT SIZE=+2>"
735 wprintf("<A HREF=\"/readfwd?alpha=%c\">"
740 if (!isalpha(alpha)) wprintf("<FONT SIZE=+2>(other)</FONT>\n");
741 else wprintf("<A HREF=\"/readfwd?alpha=1\">(other)</A>\n");
742 wprintf("<HR width=100%%>\n");
744 if (WC->wc_view == 3) { /* calendar */
746 strcpy(cmd, "MSGS ALL");
749 if (WC->wc_view == 4) { /* tasks */
751 strcpy(cmd, "MSGS ALL");
756 nummsgs = load_msg_ptrs(cmd);
759 if ((!is_tasks) && (!is_calendar)) {
760 if (!strcmp(oper, "readnew")) {
761 wprintf("<EM>No new messages in this room.</EM>\n");
762 } else if (!strcmp(oper, "readold")) {
763 wprintf("<EM>No old messages in this room.</EM>\n");
765 wprintf("<EM>This room is empty.</EM>\n");
772 if (startmsg == 0L) startmsg = WC->msgarr[0];
773 remaining_messages = 0;
775 for (a = 0; a < nummsgs; ++a) {
776 if (WC->msgarr[a] >= startmsg) {
777 ++remaining_messages;
782 wprintf("<FORM METHOD=\"POST\" ACTION=\"/do_stuff_to_msgs\">\n"
783 "<TABLE border=0 cellspacing=0 "
784 "cellpadding=0 width=100%%>\n"
786 "<TD><I>Subject</I></TD>"
787 "<TD><I>Sender</I></TD>"
788 "<TD><I>Date</I></TD>"
794 if (is_addressbook) {
795 wprintf("<TABLE border=0 cellspacing=0 "
796 "cellpadding=0 width=100%%>\n"
800 for (a = 0; a < nummsgs; ++a) {
801 if ((WC->msgarr[a] >= startmsg) && (num_displayed < maxmsgs)) {
803 /* Learn which msgs "Prev" & "Next" buttons go to */
804 pn_current = WC->msgarr[a];
805 if (a > 0) pn_previous = WC->msgarr[a-1];
806 if (a < (nummsgs-1)) pn_next = WC->msgarr[a+1];
808 /* If a tabular view, set up the line */
809 if ( (is_summary) || (is_addressbook) ) {
811 wprintf("<TR BGCOLOR=%s>",
812 (bg ? "DDDDDD" : "FFFFFF")
816 /* Display the message */
818 summarize_message(WC->msgarr[a]);
820 else if (is_addressbook) {
821 display_addressbook(WC->msgarr[a], alpha);
823 else if (is_calendar) {
824 display_calendar(WC->msgarr[a]);
827 display_task(WC->msgarr[a]);
830 read_message(WC->msgarr[a]);
833 /* If a tabular view, finish the line */
834 if ( (is_summary) || (is_addressbook) ) {
838 if (lowest_displayed < 0) lowest_displayed = a;
839 highest_displayed = a;
842 --remaining_messages;
847 wprintf("</TABLE>\n");
850 if (is_addressbook) {
851 wprintf("</TABLE>\n");
858 /* Bump these because although we're thinking in zero base, the user
859 * is a drooling idiot and is thinking in one base.
864 /* If we're only looking at one message, do a prev/next thing */
865 if (num_displayed == 1) {
866 if ((!is_tasks) && (!is_calendar)) {
869 "<TABLE BORDER=0 WIDTH=100%% BGCOLOR=DDDDDD><TR><TD>"
870 "Reading #%d of %d messages.</TD>\n"
871 "<TD ALIGN=RIGHT><FONT SIZE=+1>",
872 lowest_displayed, nummsgs);
875 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" "
876 "VALUE=\"Delete selected\">\n");
879 if (pn_previous > 0L) {
880 wprintf("<A HREF=\"/%s"
890 wprintf("<A HREF=\"/%s"
899 wprintf("<A HREF=\"/%s?startmsg=%ld"
900 "&maxmsgs=999999&summary=1\">"
906 wprintf("</TD></TR></TABLE></CENTER>\n");
912 * If we're not currently looking at ALL requested
913 * messages, then display the selector bar
915 if (num_displayed > 1) {
916 if ((!is_tasks) && (!is_calendar)) {
918 "<TABLE BORDER=0 WIDTH=100%% BGCOLOR=DDDDDD><TR><TD>"
919 "Reading #%d-%d of %d messages.</TD>\n"
920 "<TD ALIGN=RIGHT><FONT SIZE=+1>",
921 lowest_displayed, highest_displayed, nummsgs);
924 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" "
925 "VALUE=\"Delete selected\">\n");
929 for (b=0; b<nummsgs; b = b + maxmsgs) {
932 if (hi > nummsgs) hi = nummsgs;
933 if (WC->msgarr[b] != startmsg) {
934 wprintf("<A HREF=\"/%s"
946 wprintf("%d-%d \n", lo, hi);
950 wprintf("<A HREF=\"/%s?startmsg=%ld"
951 "&maxmsgs=999999&summary=%d\">"
955 WC->msgarr[0], is_summary);
957 wprintf("<A HREF=\"/%s?startmsg=%ld"
958 "&maxmsgs=999999&summary=1\">"
964 wprintf("</TD></TR></TABLE></CENTER>\n");
967 if (is_summary) wprintf("</FORM>\n");
971 wprintf("<A HREF=\"/display_edit_task?msgnum=0\">"
977 do_calendar_view(); /* Render the calendar */
987 * Post message (or don't post message)
989 * Note regarding the "dont_post" variable:
990 * A random value (actually, it's just a timestamp) is inserted as a hidden
991 * field called "postseq" when the display_enter page is generated. This
992 * value is checked when posting, using the static variable dont_post. If a
993 * user attempts to post twice using the same dont_post value, the message is
994 * discarded. This prevents the accidental double-saving of the same message
995 * if the user happens to click the browser "back" button.
997 void post_message(void)
1000 static long dont_post = (-1L);
1004 strcpy(buf, bstr("sc"));
1005 if (strcasecmp(buf, "Save message")) {
1006 wprintf("Cancelled. Message was not posted.<BR>\n");
1007 } else if (atol(bstr("postseq")) == dont_post) {
1008 wprintf("Automatically cancelled because you have already "
1009 "saved this message.<BR>\n");
1011 sprintf(buf, "ENT0 1|%s|0|4|%s",
1016 if (buf[0] == '4') {
1017 serv_puts("Content-type: text/html");
1019 text_to_server(bstr("msgtext"), 1);
1021 wprintf("Message has been posted.<BR>\n");
1022 dont_post = atol(bstr("postseq"));
1024 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
1035 * display the message entry screen
1037 void display_enter(void)
1045 sprintf(buf, "ENT0 0|%s|0|0", bstr("recp"));
1049 if (!strncmp(buf, "570", 3)) {
1050 if (strlen(bstr("recp")) > 0) {
1051 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
1053 do_template("prompt_for_recipient");
1056 if (buf[0] != '2') {
1057 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
1062 tm = (struct tm *) localtime(&now);
1063 strcpy(buf, (char *) asctime(tm));
1064 buf[strlen(buf) - 1] = 0;
1065 strcpy(&buf[16], &buf[19]);
1066 wprintf("</CENTER><FONT COLOR=\"440000\">\n"
1067 "<IMG SRC=\"static/enter.gif\" ALIGN=MIDDLE ALT=\" \" "
1068 "onLoad=\"document.enterform.msgtext.focus();\" >");
1069 wprintf("<B> %s ", &buf[4]);
1070 wprintf("from %s ", WC->wc_username);
1071 if (strlen(bstr("recp")) > 0)
1072 wprintf("to %s ", bstr("recp"));
1073 wprintf("in %s> ", WC->wc_roomname);
1074 wprintf("</B></FONT><BR><CENTER>\n");
1076 wprintf("<FORM METHOD=\"POST\" ACTION=\"/post\" "
1077 "NAME=\"enterform\">\n");
1078 wprintf("<INPUT TYPE=\"hidden\" NAME=\"recp\" VALUE=\"%s\">\n",
1080 wprintf("<INPUT TYPE=\"hidden\" NAME=\"postseq\" VALUE=\"%ld\">\n",
1082 wprintf("<FONT SIZE=-1>Subject (optional):</FONT>"
1083 "<INPUT TYPE=\"text\" NAME=\"subject\" MAXLENGTH=70>"
1084 " "
1085 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Save message\">"
1086 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\"><BR>\n");
1088 wprintf("<TEXTAREA NAME=\"msgtext\" wrap=soft ROWS=30 COLS=80 "
1089 "WIDTH=80></TEXTAREA><P>\n");
1091 wprintf("</FORM></CENTER>\n");
1092 DONE: wDumpContent(1);
1103 void delete_msg(void)
1108 msgid = atol(bstr("msgid"));
1112 sprintf(buf, "DELE %ld", msgid);
1115 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
1124 * Confirm move of a message
1126 void confirm_move_msg(void)
1132 msgid = atol(bstr("msgid"));
1136 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=770000><TR><TD>");
1137 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
1138 wprintf("<B>Confirm move of message</B>\n");
1139 wprintf("</FONT></TD></TR></TABLE>\n");
1141 wprintf("<CENTER>");
1143 wprintf("Please select the room to which you would like this message moved:<BR>\n");
1145 wprintf("<FORM METHOD=\"POST\" ACTION=\"/move_msg\">\n");
1146 wprintf("<INPUT TYPE=\"hidden\" NAME=\"msgid\" VALUE=\"%s\">\n",
1150 wprintf("<SELECT NAME=\"target_room\" SIZE=5>\n");
1153 if (buf[0] == '1') {
1154 while (serv_gets(buf), strcmp(buf, "000")) {
1155 extract(targ, buf, 0);
1156 wprintf("<OPTION>");
1161 wprintf("</SELECT>\n");
1164 wprintf("<INPUT TYPE=\"submit\" NAME=\"yesno\" VALUE=\"Move\">");
1165 wprintf("<INPUT TYPE=\"submit\" NAME=\"yesno\" VALUE=\"Cancel\">");
1166 wprintf("</FORM></CENTER>\n");
1168 wprintf("</CENTER>\n");
1179 msgid = atol(bstr("msgid"));
1183 if (!strcasecmp(bstr("yesno"), "Move")) {
1184 sprintf(buf, "MOVE %ld|%s", msgid, bstr("target_room"));
1187 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
1189 wprintf("<EM>Message not moved.</EM><BR>\n");
1197 void do_stuff_to_msgs(void) {
1202 struct stuff_t *next;
1206 struct stuff_t *stuff = NULL;
1207 struct stuff_t *ptr;
1210 serv_puts("MSGS ALL");
1213 if (buf[0] == '1') while (serv_gets(buf), strcmp(buf, "000")) {
1214 ptr = malloc(sizeof(struct stuff_t));
1215 ptr->msgnum = atol(buf);
1220 strcpy(sc, bstr("sc"));
1222 while (stuff != NULL) {
1224 sprintf(buf, "msg_%ld", stuff->msgnum);
1225 if (!strcasecmp(bstr(buf), "yes")) {
1227 if (!strcasecmp(sc, "Delete selected")) {
1228 serv_printf("DELE %ld", stuff->msgnum);
1239 readloop("readfwd");