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");
239 wprintf("<SPAN CLASS=\"message_header\">");
240 strcpy(m_subject, "");
242 while (serv_gets(buf), strcasecmp(buf, "text")) {
243 if (!strcmp(buf, "000")) {
244 wprintf("<I>unexpected end of message</I><BR><BR>\n");
245 wprintf("</SPAN>\n");
248 if (!strncasecmp(buf, "nhdr=yes", 8))
252 if (!strncasecmp(buf, "type=", 5))
253 format_type = atoi(&buf[5]);
254 if (!strncasecmp(buf, "from=", 5)) {
255 strcpy(from, &buf[5]);
256 wprintf("from <A HREF=\"/showuser&who=");
262 if (!strncasecmp(buf, "subj=", 5))
263 strcpy(m_subject, &buf[5]);
264 if ((!strncasecmp(buf, "hnod=", 5))
265 && (strcasecmp(&buf[5], serv_info.serv_humannode)))
266 wprintf("(%s) ", &buf[5]);
267 if ((!strncasecmp(buf, "room=", 5))
268 && (strcasecmp(&buf[5], WC->wc_roomname))
269 && (strlen(&buf[5])>0) )
270 wprintf("in %s> ", &buf[5]);
271 if (!strncasecmp(buf, "rfca=", 5)) {
272 strcpy(rfca, &buf[5]);
278 if (!strncasecmp(buf, "node=", 5)) {
279 if ( ((WC->room_flags & QR_NETWORK)
280 || ((strcasecmp(&buf[5], serv_info.serv_nodename)
281 && (strcasecmp(&buf[5], serv_info.serv_fqdn)))))
284 wprintf("@%s ", &buf[5]);
287 if (!strncasecmp(buf, "rcpt=", 5))
288 wprintf("to %s ", &buf[5]);
289 if (!strncasecmp(buf, "time=", 5)) {
290 fmt_date(now, atol(&buf[5]));
294 if (!strncasecmp(buf, "part=", 5)) {
295 extract(mime_filename, &buf[5], 1);
296 extract(mime_partnum, &buf[5], 2);
297 extract(mime_disposition, &buf[5], 3);
298 extract(mime_content_type, &buf[5], 4);
299 mime_length = extract_int(&buf[5], 5);
301 if (!strcasecmp(mime_disposition, "attachment")) {
302 if (mime_http == NULL) {
303 mime_http = malloc(512);
304 strcpy(mime_http, "");
307 mime_http = realloc(mime_http,
308 strlen(mime_http) + 512);
310 sprintf(&mime_http[strlen(mime_http)],
311 "<A HREF=\"/output_mimepart?"
312 "msgnum=%ld&partnum=%s\" "
313 "TARGET=\"wc.%ld.%s\">"
314 "<IMG SRC=\"/static/attachment.gif\" "
315 "BORDER=0 ALIGN=MIDDLE>\n"
316 "Part %s: %s (%s, %d bytes)</A><BR>\n",
317 msgnum, mime_partnum,
318 msgnum, mime_partnum,
319 mime_partnum, mime_filename,
320 mime_content_type, mime_length);
323 if ((!strcasecmp(mime_disposition, "inline"))
324 && (!strncasecmp(mime_content_type, "image/", 6)) ){
325 if (mime_http == NULL) {
326 mime_http = malloc(512);
327 strcpy(mime_http, "");
330 mime_http = realloc(mime_http,
331 strlen(mime_http) + 512);
333 sprintf(&mime_http[strlen(mime_http)],
334 "<IMG SRC=\"/output_mimepart?"
335 "msgnum=%ld&partnum=%s\">",
336 msgnum, mime_partnum);
339 /*** begin handler prep ***/
340 if (!strcasecmp(mime_content_type, "text/x-vcard")) {
341 strcpy(vcard_partnum, mime_partnum);
344 if (!strcasecmp(mime_content_type, "text/calendar")) {
345 strcpy(cal_partnum, mime_partnum);
348 /*** end handler prep ***/
354 /* Generate a reply-to address */
355 if (strlen(rfca) > 0) {
356 strcpy(reply_to, rfca);
359 if (strlen(node) > 0) {
360 snprintf(reply_to, sizeof(reply_to), "%s @ %s",
364 snprintf(reply_to, sizeof(reply_to), "%s", from);
372 wprintf("</SPAN></TD>");
374 wprintf("<TD ALIGN=RIGHT>\n"
375 "<TABLE BORDER=0><TR>\n");
377 wprintf("<TD BGCOLOR=\"#AAAADD\">"
378 "<A HREF=\"/readfwd?startmsg=%ld", msgnum);
379 wprintf("&maxmsgs=1&summary=0\">Read</A>"
382 wprintf("<TD BGCOLOR=\"#AAAADD\">"
383 "<A HREF=\"/display_enter?recp=");
384 urlescputs(reply_to);
385 wprintf("\"><FONT SIZE=-1>Reply</FONT></A>"
388 if (WC->is_room_aide) {
389 wprintf("<TD BGCOLOR=\"#AAAADD\">"
390 "<A HREF=\"/confirm_move_msg"
392 "\"><FONT SIZE=-1>Move</FONT></A>"
395 wprintf("<TD BGCOLOR=\"#AAAADD\">"
396 "<A HREF=\"/delete_msg"
398 "onClick=\"return confirm('Delete this message?');\""
399 "><FONT SIZE=-1>Del</FONT></A>"
403 wprintf("</TR></TABLE>\n"
406 if (strlen(m_subject) > 0) {
408 "<SPAN CLASS=\"message_subject\">"
411 "</TD><TD> </TD></TR>\n", m_subject);
414 wprintf("</TR></TABLE>\n");
417 * Learn the content type
419 strcpy(mime_content_type, "text/plain");
420 while (serv_gets(buf), (strlen(buf) > 0)) {
421 if (!strcmp(buf, "000")) {
422 wprintf("<I>unexpected end of message</I><BR><BR>\n");
425 if (!strncasecmp(buf, "Content-type: ", 14)) {
426 safestrncpy(mime_content_type, &buf[14],
427 sizeof(mime_content_type));
431 /* Messages in legacy Citadel variformat get handled thusly... */
432 if (!strcasecmp(mime_content_type, "text/x-citadel-variformat")) {
436 /* Boring old 80-column fixed format text gets handled this way... */
437 else if (!strcasecmp(mime_content_type, "text/plain")) {
438 while (serv_gets(buf), strcmp(buf, "000")) {
439 if (buf[strlen(buf)-1] == '\n') buf[strlen(buf)-1] = 0;
440 if (buf[strlen(buf)-1] == '\r') buf[strlen(buf)-1] = 0;
441 while ((strlen(buf) > 0) && (isspace(buf[strlen(buf) - 1])))
442 buf[strlen(buf) - 1] = 0;
444 ((!strncmp(buf, ">", 1)) || (!strncmp(buf, " >", 2)) || (!strncmp(buf, " :-)", 4)))) {
445 wprintf("<SPAN CLASS=\"pull_quote\">");
447 } else if ((bq == 1) &&
448 (strncmp(buf, ">", 1)) && (strncmp(buf, " >", 2)) && (strncmp(buf, " :-)", 4))) {
455 wprintf("</TT><BR>\n");
460 else /* HTML is fun, but we've got to strip it first */
461 if (!strcasecmp(mime_content_type, "text/html")) {
465 /* Unknown weirdness */
467 wprintf("I don't know how to display %s<BR>\n",
469 while (serv_gets(buf), strcmp(buf, "000")) { }
473 /* Afterwards, offer links to download attachments 'n' such */
474 if (mime_http != NULL) {
475 wprintf("%s", mime_http);
479 /* Handler for vCard parts */
480 if (strlen(vcard_partnum) > 0) {
481 part_source = load_mimepart(msgnum, vcard_partnum);
482 if (part_source != NULL) {
484 /* If it's my vCard I can edit it */
485 if ( (!strcasecmp(WC->wc_roomname, USERCONFIGROOM))
486 || (!strcasecmp(&WC->wc_roomname[11], USERCONFIGROOM))) {
487 wprintf("<A HREF=\"/edit_vcard?"
488 "msgnum=%ld&partnum=%s\">",
489 msgnum, vcard_partnum);
490 wprintf("(edit)</A>");
493 /* In all cases, display the full card */
494 display_vcard(part_source, 0, 1);
498 /* Handler for calendar parts */
499 if (strlen(cal_partnum) > 0) {
500 part_source = load_mimepart(msgnum, cal_partnum);
501 if (part_source != NULL) {
502 cal_process_attachment(part_source,
503 msgnum, cal_partnum);
515 void summarize_message(long msgnum) {
526 memset(&summ, 0, sizeof(summ));
527 strcpy(summ.subj, "(no subject)");
529 sprintf(buf, "MSG0 %ld|1", msgnum); /* ask for headers only */
532 if (buf[0] != '1') return;
534 while (serv_gets(buf), strcmp(buf, "000")) {
535 if (!strncasecmp(buf, "from=", 5)) {
536 strcpy(summ.from, &buf[5]);
538 if (!strncasecmp(buf, "subj=", 5)) {
539 strcpy(summ.subj, &buf[5]);
541 if (!strncasecmp(buf, "rfca=", 5)) {
542 strcat(summ.from, " <");
543 strcat(summ.from, &buf[5]);
544 strcat(summ.from, ">");
547 if (!strncasecmp(buf, "node=", 5)) {
548 if ( ((WC->room_flags & QR_NETWORK)
549 || ((strcasecmp(&buf[5], serv_info.serv_nodename)
550 && (strcasecmp(&buf[5], serv_info.serv_fqdn)))))
552 strcat(summ.from, " @ ");
553 strcat(summ.from, &buf[5]);
557 if (!strncasecmp(buf, "rcpt=", 5)) {
558 strcpy(summ.to, &buf[5]);
561 if (!strncasecmp(buf, "time=", 5)) {
562 fmt_date(summ.date, atol(&buf[5]));
566 wprintf("<TD><A HREF=\"/readfwd?startmsg=%ld"
567 "&maxmsgs=1&summary=0\">",
570 wprintf("</A></TD><TD>");
572 wprintf(" </TD><TD>");
576 "<INPUT TYPE=\"checkbox\" NAME=\"msg_%ld\" VALUE=\"yes\">"
584 void display_addressbook(long msgnum, char alpha) {
586 char mime_partnum[SIZ];
587 char mime_filename[SIZ];
588 char mime_content_type[SIZ];
589 char mime_disposition[SIZ];
591 char vcard_partnum[SIZ];
592 char *vcard_source = NULL;
602 memset(&summ, 0, sizeof(summ));
603 strcpy(summ.subj, "(no subject)");
605 sprintf(buf, "MSG0 %ld|1", msgnum); /* ask for headers only */
608 if (buf[0] != '1') return;
610 while (serv_gets(buf), strcmp(buf, "000")) {
611 if (!strncasecmp(buf, "part=", 5)) {
612 extract(mime_filename, &buf[5], 1);
613 extract(mime_partnum, &buf[5], 2);
614 extract(mime_disposition, &buf[5], 3);
615 extract(mime_content_type, &buf[5], 4);
616 mime_length = extract_int(&buf[5], 5);
618 if (!strcasecmp(mime_content_type, "text/x-vcard")) {
619 strcpy(vcard_partnum, mime_partnum);
625 if (strlen(vcard_partnum) > 0) {
626 vcard_source = load_mimepart(msgnum, vcard_partnum);
627 if (vcard_source != NULL) {
629 /* Display the summary line */
630 display_vcard(vcard_source, alpha, 0);
632 /* If it's my vCard I can edit it */
633 if ( (!strcasecmp(WC->wc_roomname, USERCONFIGROOM))
634 || (!strcasecmp(&WC->wc_roomname[11], USERCONFIGROOM))) {
635 wprintf("<A HREF=\"/edit_vcard?"
636 "msgnum=%ld&partnum=%s\">",
637 msgnum, vcard_partnum);
638 wprintf("(edit)</A>");
650 * load message pointers from the server
652 int load_msg_ptrs(char *servcmd)
661 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
664 while (serv_gets(buf), strcmp(buf, "000")) {
665 WC->msgarr[nummsgs] = atol(buf);
666 /* FIXME check for overflow */
674 * command loop for reading messages
676 void readloop(char *oper)
684 int num_displayed = 0;
686 int is_addressbook = 0;
689 int remaining_messages;
691 int lowest_displayed = (-1);
692 int highest_displayed = 0;
693 long pn_previous = 0L;
694 long pn_current = 0L;
699 startmsg = atol(bstr("startmsg"));
700 maxmsgs = atoi(bstr("maxmsgs"));
701 is_summary = atoi(bstr("summary"));
702 if (maxmsgs == 0) maxmsgs = 20;
706 if (!strcmp(oper, "readnew")) {
707 strcpy(cmd, "MSGS NEW");
708 } else if (!strcmp(oper, "readold")) {
709 strcpy(cmd, "MSGS OLD");
711 strcpy(cmd, "MSGS ALL");
714 /* FIXME put in the correct constant #defs */
715 if ((WC->wc_view == 1) && (maxmsgs > 1)) {
717 strcpy(cmd, "MSGS ALL");
720 if ((WC->wc_view == 2) && (maxmsgs > 1)) {
722 strcpy(cmd, "MSGS ALL");
724 if (bstr("alpha") == NULL) {
728 strcpy(buf, bstr("alpha"));
732 for (i='A'; i<='Z'; ++i) {
733 if (i == alpha) wprintf("<FONT SIZE=+2>"
736 wprintf("<A HREF=\"/readfwd?alpha=%c\">"
741 if (!isalpha(alpha)) wprintf("<FONT SIZE=+2>(other)</FONT>\n");
742 else wprintf("<A HREF=\"/readfwd?alpha=1\">(other)</A>\n");
743 wprintf("<HR width=100%%>\n");
745 if (WC->wc_view == 3) { /* calendar */
747 strcpy(cmd, "MSGS ALL");
750 if (WC->wc_view == 4) { /* tasks */
752 strcpy(cmd, "MSGS ALL");
757 nummsgs = load_msg_ptrs(cmd);
760 if ((!is_tasks) && (!is_calendar)) {
761 if (!strcmp(oper, "readnew")) {
762 wprintf("<EM>No new messages in this room.</EM>\n");
763 } else if (!strcmp(oper, "readold")) {
764 wprintf("<EM>No old messages in this room.</EM>\n");
766 wprintf("<EM>This room is empty.</EM>\n");
773 if (startmsg == 0L) startmsg = WC->msgarr[0];
774 remaining_messages = 0;
776 for (a = 0; a < nummsgs; ++a) {
777 if (WC->msgarr[a] >= startmsg) {
778 ++remaining_messages;
783 wprintf("<FORM METHOD=\"POST\" ACTION=\"/do_stuff_to_msgs\">\n"
784 "<TABLE border=0 cellspacing=0 "
785 "cellpadding=0 width=100%%>\n"
787 "<TD><I>Subject</I></TD>"
788 "<TD><I>Sender</I></TD>"
789 "<TD><I>Date</I></TD>"
795 if (is_addressbook) {
796 wprintf("<TABLE border=0 cellspacing=0 "
797 "cellpadding=0 width=100%%>\n"
801 for (a = 0; a < nummsgs; ++a) {
802 if ((WC->msgarr[a] >= startmsg) && (num_displayed < maxmsgs)) {
804 /* Learn which msgs "Prev" & "Next" buttons go to */
805 pn_current = WC->msgarr[a];
806 if (a > 0) pn_previous = WC->msgarr[a-1];
807 if (a < (nummsgs-1)) pn_next = WC->msgarr[a+1];
809 /* If a tabular view, set up the line */
810 if ( (is_summary) || (is_addressbook) ) {
812 wprintf("<TR BGCOLOR=\"#%s\">",
813 (bg ? "DDDDDD" : "FFFFFF")
817 /* Display the message */
819 summarize_message(WC->msgarr[a]);
821 else if (is_addressbook) {
822 display_addressbook(WC->msgarr[a], alpha);
824 else if (is_calendar) {
825 display_calendar(WC->msgarr[a]);
828 display_task(WC->msgarr[a]);
831 read_message(WC->msgarr[a]);
834 /* If a tabular view, finish the line */
835 if ( (is_summary) || (is_addressbook) ) {
839 if (lowest_displayed < 0) lowest_displayed = a;
840 highest_displayed = a;
843 --remaining_messages;
848 wprintf("</TABLE>\n");
851 if (is_addressbook) {
852 wprintf("</TABLE>\n");
859 /* Bump these because although we're thinking in zero base, the user
860 * is a drooling idiot and is thinking in one base.
865 /* If we're only looking at one message, do a prev/next thing */
866 if (num_displayed == 1) {
867 if ((!is_tasks) && (!is_calendar)) {
870 "<TABLE BORDER=0 WIDTH=100%% BGCOLOR=\"#DDDDDD\"><TR><TD>"
871 "Reading #%d of %d messages.</TD>\n"
872 "<TD ALIGN=RIGHT><FONT SIZE=+1>",
873 lowest_displayed, nummsgs);
876 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" "
877 "VALUE=\"Delete selected\">\n");
880 if (pn_previous > 0L) {
881 wprintf("<A HREF=\"/%s"
891 wprintf("<A HREF=\"/%s"
900 wprintf("<A HREF=\"/%s?startmsg=%ld"
901 "&maxmsgs=999999&summary=1\">"
907 wprintf("</TD></TR></TABLE></CENTER>\n");
913 * If we're not currently looking at ALL requested
914 * messages, then display the selector bar
916 if (num_displayed > 1) {
917 if ((!is_tasks) && (!is_calendar)) {
919 "<TABLE BORDER=0 WIDTH=100%% BGCOLOR=\"#DDDDDD\"><TR><TD>"
920 "Reading #%d-%d of %d messages.</TD>\n"
921 "<TD ALIGN=RIGHT><FONT SIZE=+1>",
922 lowest_displayed, highest_displayed, nummsgs);
925 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" "
926 "VALUE=\"Delete selected\">\n");
930 for (b=0; b<nummsgs; b = b + maxmsgs) {
933 if (hi > nummsgs) hi = nummsgs;
934 if (WC->msgarr[b] != startmsg) {
935 wprintf("<A HREF=\"/%s"
947 wprintf("%d-%d \n", lo, hi);
951 wprintf("<A HREF=\"/%s?startmsg=%ld"
952 "&maxmsgs=999999&summary=%d\">"
956 WC->msgarr[0], is_summary);
958 wprintf("<A HREF=\"/%s?startmsg=%ld"
959 "&maxmsgs=999999&summary=1\">"
965 wprintf("</TD></TR></TABLE></CENTER>\n");
968 if (is_summary) wprintf("</FORM>\n");
972 wprintf("<A HREF=\"/display_edit_task?msgnum=0\">"
978 do_calendar_view(); /* Render the calendar */
988 * Post message (or don't post message)
990 * Note regarding the "dont_post" variable:
991 * A random value (actually, it's just a timestamp) is inserted as a hidden
992 * field called "postseq" when the display_enter page is generated. This
993 * value is checked when posting, using the static variable dont_post. If a
994 * user attempts to post twice using the same dont_post value, the message is
995 * discarded. This prevents the accidental double-saving of the same message
996 * if the user happens to click the browser "back" button.
998 void post_message(void)
1001 static long dont_post = (-1L);
1005 strcpy(buf, bstr("sc"));
1006 if (strcasecmp(buf, "Save message")) {
1007 wprintf("Cancelled. Message was not posted.<BR>\n");
1008 } else if (atol(bstr("postseq")) == dont_post) {
1009 wprintf("Automatically cancelled because you have already "
1010 "saved this message.<BR>\n");
1012 sprintf(buf, "ENT0 1|%s|0|4|%s",
1017 if (buf[0] == '4') {
1018 serv_puts("Content-type: text/html");
1020 text_to_server(bstr("msgtext"), 1);
1022 wprintf("Message has been posted.<BR>\n");
1023 dont_post = atol(bstr("postseq"));
1025 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
1036 * display the message entry screen
1038 void display_enter(void)
1046 sprintf(buf, "ENT0 0|%s|0|0", bstr("recp"));
1050 if (!strncmp(buf, "570", 3)) {
1051 if (strlen(bstr("recp")) > 0) {
1052 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
1054 do_template("prompt_for_recipient");
1057 if (buf[0] != '2') {
1058 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
1063 tm = (struct tm *) localtime(&now);
1064 strcpy(buf, (char *) asctime(tm));
1065 buf[strlen(buf) - 1] = 0;
1066 strcpy(&buf[16], &buf[19]);
1067 wprintf("</CENTER><FONT COLOR=\"#440000\">\n"
1068 "<IMG SRC=\"static/enter.gif\" ALIGN=MIDDLE ALT=\" \" "
1069 "onLoad=\"document.enterform.msgtext.focus();\" >");
1070 wprintf("<B> %s ", &buf[4]);
1071 wprintf("from %s ", WC->wc_username);
1072 if (strlen(bstr("recp")) > 0)
1073 wprintf("to %s ", bstr("recp"));
1074 wprintf("in %s> ", WC->wc_roomname);
1075 wprintf("</B></FONT><BR><CENTER>\n");
1077 wprintf("<FORM METHOD=\"POST\" ACTION=\"/post\" "
1078 "NAME=\"enterform\">\n");
1079 wprintf("<INPUT TYPE=\"hidden\" NAME=\"recp\" VALUE=\"%s\">\n",
1081 wprintf("<INPUT TYPE=\"hidden\" NAME=\"postseq\" VALUE=\"%ld\">\n",
1083 wprintf("<FONT SIZE=-1>Subject (optional):</FONT>"
1084 "<INPUT TYPE=\"text\" NAME=\"subject\" MAXLENGTH=70>"
1085 " "
1086 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Save message\">"
1087 "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\"><BR>\n");
1089 wprintf("<TEXTAREA NAME=\"msgtext\" wrap=soft ROWS=30 COLS=80 "
1090 "WIDTH=80></TEXTAREA><P>\n");
1092 wprintf("</FORM></CENTER>\n");
1093 DONE: wDumpContent(1);
1104 void delete_msg(void)
1109 msgid = atol(bstr("msgid"));
1113 sprintf(buf, "DELE %ld", msgid);
1116 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
1125 * Confirm move of a message
1127 void confirm_move_msg(void)
1133 msgid = atol(bstr("msgid"));
1137 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
1138 wprintf("<FONT SIZE=+1 COLOR=\"#FFFFFF\"");
1139 wprintf("<B>Confirm move of message</B>\n");
1140 wprintf("</FONT></TD></TR></TABLE>\n");
1142 wprintf("<CENTER>");
1144 wprintf("Please select the room to which you would like this message moved:<BR>\n");
1146 wprintf("<FORM METHOD=\"POST\" ACTION=\"/move_msg\">\n");
1147 wprintf("<INPUT TYPE=\"hidden\" NAME=\"msgid\" VALUE=\"%s\">\n",
1151 wprintf("<SELECT NAME=\"target_room\" SIZE=5>\n");
1154 if (buf[0] == '1') {
1155 while (serv_gets(buf), strcmp(buf, "000")) {
1156 extract(targ, buf, 0);
1157 wprintf("<OPTION>");
1162 wprintf("</SELECT>\n");
1165 wprintf("<INPUT TYPE=\"submit\" NAME=\"yesno\" VALUE=\"Move\">");
1166 wprintf("<INPUT TYPE=\"submit\" NAME=\"yesno\" VALUE=\"Cancel\">");
1167 wprintf("</FORM></CENTER>\n");
1169 wprintf("</CENTER>\n");
1180 msgid = atol(bstr("msgid"));
1184 if (!strcasecmp(bstr("yesno"), "Move")) {
1185 sprintf(buf, "MOVE %ld|%s", msgid, bstr("target_room"));
1188 wprintf("<EM>%s</EM><BR>\n", &buf[4]);
1190 wprintf("<EM>Message not moved.</EM><BR>\n");
1198 void do_stuff_to_msgs(void) {
1203 struct stuff_t *next;
1207 struct stuff_t *stuff = NULL;
1208 struct stuff_t *ptr;
1211 serv_puts("MSGS ALL");
1214 if (buf[0] == '1') while (serv_gets(buf), strcmp(buf, "000")) {
1215 ptr = malloc(sizeof(struct stuff_t));
1216 ptr->msgnum = atol(buf);
1221 strcpy(sc, bstr("sc"));
1223 while (stuff != NULL) {
1225 sprintf(buf, "msg_%ld", stuff->msgnum);
1226 if (!strcasecmp(bstr(buf), "yes")) {
1228 if (!strcasecmp(sc, "Delete selected")) {
1229 serv_printf("DELE %ld", stuff->msgnum);
1240 readloop("readfwd");