00001
00002
00003
00009 #include "webcit.h"
00010
00014 void display_queue_msg(long msgnum)
00015 {
00016 char buf[1024];
00017 char keyword[32];
00018 int in_body = 0;
00019 int is_delivery_list = 0;
00020 time_t submitted = 0;
00021 time_t attempted = 0;
00022 time_t last_attempt = 0;
00023 int number_of_attempts = 0;
00024 char sender[256];
00025 char recipients[65536];
00026 char thisrecp[256];
00027 char thisdsn[256];
00028 long msgid = 0;
00029
00030 strcpy(sender, "");
00031 strcpy(recipients, "");
00032
00033 serv_printf("MSG2 %ld", msgnum);
00034 serv_getln(buf, sizeof buf);
00035 if (buf[0] != '1') return;
00036
00037 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
00038
00039 if (strlen(buf) > 0) {
00040 if (buf[strlen(buf)-1] == 13) {
00041 buf[strlen(buf)-1] = 0;
00042 }
00043 }
00044
00045 if ( (strlen(buf) == 0) && (in_body == 0) ) {
00046 in_body = 1;
00047 }
00048
00049 if ( (!in_body)
00050 && (!strncasecmp(buf, "Content-type: application/x-citadel-delivery-list", 49))
00051 ) {
00052 is_delivery_list = 1;
00053 }
00054
00055 if ( (in_body) && (!is_delivery_list) ) {
00056 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
00057
00058 }
00059 return;
00060 }
00061
00062 if ( (in_body) && (is_delivery_list) ) {
00063 extract_token(keyword, buf, 0, '|', sizeof keyword);
00064
00065 if (!strcasecmp(keyword, "msgid")) {
00066 msgid = extract_long(buf, 1);
00067 }
00068
00069 if (!strcasecmp(keyword, "submitted")) {
00070 submitted = extract_long(buf, 1);
00071 }
00072
00073 if (!strcasecmp(keyword, "attempted")) {
00074 attempted = extract_long(buf, 1);
00075 ++number_of_attempts;
00076 if (attempted > last_attempt) {
00077 last_attempt = attempted;
00078 }
00079 }
00080
00081 if (!strcasecmp(keyword, "bounceto")) {
00082 extract_token(sender, buf, 1, '|', sizeof sender);
00083
00084
00085 char *atsign;
00086 atsign = strchr(sender, '@');
00087 if (atsign != NULL) {
00088 ++atsign;
00089 if (!strcasecmp(atsign, serv_info.serv_nodename)) {
00090 --atsign;
00091 *atsign = 0;
00092 }
00093 }
00094 }
00095
00096 if (!strcasecmp(keyword, "remote")) {
00097 extract_token(thisrecp, buf, 1, '|', sizeof thisrecp);
00098 extract_token(thisdsn, buf, 3, '|', sizeof thisdsn);
00099
00100 if (strlen(recipients) + strlen(thisrecp) + strlen(thisdsn) + 100
00101 < sizeof recipients) {
00102 if (strlen(recipients) > 0) {
00103 strcat(recipients, "<br />");
00104 }
00105 stresc(&recipients[strlen(recipients)], thisrecp, 1, 1);
00106 strcat(recipients, "<br /> <i>");
00107 stresc(&recipients[strlen(recipients)], thisdsn, 1, 1);
00108 strcat(recipients, "</i>");
00109 }
00110
00111 }
00112
00113 }
00114
00115 }
00116
00117 wprintf("<tr><td>");
00118 wprintf("%ld<br />", msgnum);
00119 wprintf(" <a href=\"javascript:DeleteQueueMsg(%ld,%ld);\">%s</a>",
00120 msgnum, msgid, _("(Delete)")
00121 );
00122
00123 wprintf("</td><td>");
00124 if (submitted > 0) {
00125 fmt_date(buf, submitted, 1);
00126 wprintf("%s", buf);
00127 }
00128 else {
00129 wprintf(" ");
00130 }
00131
00132 wprintf("</td><td>");
00133 if (last_attempt > 0) {
00134 fmt_date(buf, last_attempt, 1);
00135 wprintf("%s", buf);
00136 }
00137 else {
00138 wprintf(" ");
00139 }
00140
00141 wprintf("</td><td>");
00142 escputs(sender);
00143
00144 wprintf("</td><td>");
00145 wprintf("%s", recipients);
00146 wprintf("</td></tr>\n");
00147
00148 }
00149
00150
00151 void display_smtpqueue_inner_div(void) {
00152 int i;
00153 int num_msgs;
00154
00155
00156
00157
00158 gotoroom("__CitadelSMTPspoolout__");
00159 if (!strcasecmp(WC->wc_roomname, "__CitadelSMTPspoolout__")) {
00160
00161 num_msgs = load_msg_ptrs("MSGS ALL", 0);
00162 if (num_msgs > 0) {
00163 wprintf("<table class=\"mailbox_summary\" rules=rows "
00164 "cellpadding=2 style=\"width:100%%;-moz-user-select:none;\">"
00165 );
00166
00167 wprintf("<tr><td><b><i>");
00168 wprintf(_("Message ID"));
00169 wprintf("</i></b></td><td><b><i>");
00170 wprintf(_("Date/time submitted"));
00171 wprintf("</i></b></td><td><b><i>");
00172 wprintf(_("Last attempt"));
00173 wprintf("</i></b></td><td><b><i>");
00174 wprintf(_("Sender"));
00175 wprintf("</i></b></td><td><b><i>");
00176 wprintf(_("Recipients"));
00177 wprintf("</i></b></td></tr>\n");
00178
00179 for (i=0; i<num_msgs; ++i) {
00180 display_queue_msg(WC->msgarr[i]);
00181 }
00182
00183 wprintf("</table>");
00184
00185 }
00186 else {
00187 wprintf("<br /><br /><div align=\"center\">");
00188 wprintf(_("The queue is empty."));
00189 wprintf("</div><br /><br />");
00190 }
00191 }
00192 else {
00193 wprintf("<br /><br /><div align=\"center\">");
00194 wprintf(_("You do not have permission to view this resource."));
00195 wprintf("</div><br /><br />");
00196 }
00197
00198 }
00199
00203 void display_smtpqueue(void)
00204 {
00205 output_headers(1, 1, 2, 0, 0, 0);
00206
00207 wprintf("<script type=\"text/javascript\"> \n"
00208 "function RefreshQueueDisplay() { \n"
00209 " new Ajax.Updater('smtpqueue_inner_div', \n"
00210 " 'display_smtpqueue_inner_div', { method: 'get', \n"
00211 " parameters: Math.random() } ); \n"
00212 "} \n"
00213 " \n"
00214 "function DeleteQueueMsg(msgnum1, msgnum2) { \n"
00215 " new Ajax.Request( \n"
00216 " 'ajax_servcmd', { \n"
00217 " method: 'post', \n"
00218 " parameters: 'g_cmd=DELE ' + msgnum1 + ',' + msgnum2, \n"
00219 " onComplete: RefreshQueueDisplay() \n"
00220 " } \n"
00221 " ); \n"
00222 "} \n"
00223 " \n"
00224 "</script> \n"
00225 );
00226
00227 wprintf("<div id=\"banner\">\n");
00228 wprintf("<TABLE class=\"smtpqueue_banner\"><TR><TD>");
00229 wprintf("<SPAN CLASS=\"titlebar\">");
00230 wprintf(_("View the outbound SMTP queue"));
00231 wprintf("</SPAN>\n");
00232 wprintf("</TD></TR></TABLE>\n");
00233 wprintf("</div>\n<div id=\"content\">\n");
00234
00235 wprintf("<div class=\"fix_scrollbar_bug\">"
00236 "<table class=\"smtpqueue_background\">"
00237 "<tr><td valign=top>\n");
00238
00239 wprintf("<div id=\"smtpqueue_inner_div\">");
00240
00241 display_smtpqueue_inner_div();
00242
00243 wprintf("</div>"
00244 "<div align=\"center\">"
00245 "<a href=\"javascript:RefreshQueueDisplay();\">%s</a>"
00246 "</div>"
00247 "</td></tr></table></div>\n", _("Refresh this page")
00248 );
00249 wDumpContent(1);
00250
00251 }
00252
00253
00254
00255