Clean up some of the page generation logic in www_msgs.c.
More application of stralloc. Needs to be tested. :-) Signed-off-by: Dan Cross <patchdev@fat-dragon.org>
This commit is contained in:
parent
0a91165b07
commit
37bcd31ff2
802
src/www_msgs.c
802
src/www_msgs.c
@ -91,9 +91,7 @@ char *www_msgs_arealist(struct user_record *user) {
|
|||||||
|
|
||||||
char *www_msgs_messagelist(struct user_record *user, int conference, int area, int skip) {
|
char *www_msgs_messagelist(struct user_record *user, int conference, int area, int skip) {
|
||||||
struct msg_headers *mhrs;
|
struct msg_headers *mhrs;
|
||||||
char *page;
|
stralloc page = EMPTY_STRALLOC;
|
||||||
int max_len;
|
|
||||||
int len;
|
|
||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
int i;
|
int i;
|
||||||
struct tm msg_date;
|
struct tm msg_date;
|
||||||
@ -109,51 +107,32 @@ char *www_msgs_messagelist(struct user_record *user, int conference, int area, i
|
|||||||
if (conference < 0 || conference >= conf.mail_conference_count || area < 0 || area >= conf.mail_conferences[conference]->mail_area_count) {
|
if (conference < 0 || conference >= conf.mail_conference_count || area < 0 || area >= conf.mail_conferences[conference]->mail_area_count) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
page = (char *)malloz(4096);
|
stralloc_copys(&page, "<div class=\"content-header\"><h2>");
|
||||||
max_len = 4096;
|
stralloc_cats(&page, conf.mail_conferences[conference]->name);
|
||||||
len = 0;
|
stralloc_cats(&page, " - ");
|
||||||
|
stralloc_cats(&page, conf.mail_conferences[conference]->mail_areas[area]->name);
|
||||||
sprintf(buffer, "<div class=\"content-header\"><h2>%s - %s</h2></div>\n", conf.mail_conferences[conference]->name, conf.mail_conferences[conference]->mail_areas[area]->name);
|
stralloc_cats(&page, "</h2></div>\n");
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
|
||||||
max_len += 4096;
|
|
||||||
page = (char *)realloc(page, max_len);
|
|
||||||
}
|
|
||||||
strcat(page, buffer);
|
|
||||||
len += strlen(buffer);
|
|
||||||
|
|
||||||
if (conf.mail_conferences[conference]->mail_areas[area]->type != TYPE_NETMAIL_AREA) {
|
if (conf.mail_conferences[conference]->mail_areas[area]->type != TYPE_NETMAIL_AREA) {
|
||||||
sprintf(buffer, "<div class=\"button\"><a href=\"%smsgs/new/%d/%d\">New Message</a></div>\n", conf.www_url, conference, area);
|
stralloc_cats(&page, "<div class=\"button\"><a href=\"");
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
stralloc_cats(&page, conf.www_url);
|
||||||
max_len += 4096;
|
stralloc_cats(&page, "msgs/new/");
|
||||||
page = (char *)realloc(page, max_len);
|
stralloc_cat_long(&page, conference);
|
||||||
}
|
stralloc_append1(&page, '/');
|
||||||
strcat(page, buffer);
|
stralloc_cat_long(&page, area);
|
||||||
len += strlen(buffer);
|
stralloc_cats(&page, "\">New Message</a></div>\n");
|
||||||
}
|
}
|
||||||
mhrs = read_message_headers(conference, area, user, 0);
|
mhrs = read_message_headers(conference, area, user, 0);
|
||||||
|
|
||||||
if (mhrs == NULL) {
|
if (mhrs == NULL) {
|
||||||
sprintf(buffer, "<h3>No Messages</h3>\n");
|
stralloc_cats(&page, "<h3>No Messages</h3>\n");
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
|
||||||
max_len += 4096;
|
|
||||||
page = (char *)realloc(page, max_len);
|
|
||||||
}
|
|
||||||
strcat(page, buffer);
|
|
||||||
len += strlen(buffer);
|
|
||||||
return page;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(buffer, "<div class=\"div-table\">\n");
|
stralloc_cats(&page, "<div class=\"div-table\">\n");
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
|
||||||
max_len += 4096;
|
|
||||||
page = (char *)realloc(page, max_len);
|
|
||||||
}
|
|
||||||
strcat(page, buffer);
|
|
||||||
len += strlen(buffer);
|
|
||||||
|
|
||||||
jb = open_jam_base(conf.mail_conferences[conference]->mail_areas[area]->path);
|
jb = open_jam_base(conf.mail_conferences[conference]->mail_areas[area]->path);
|
||||||
if (!jb) {
|
if (!jb) {
|
||||||
free(page);
|
free(page.s);
|
||||||
free_message_headers(mhrs);
|
free_message_headers(mhrs);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -177,21 +156,21 @@ char *www_msgs_messagelist(struct user_record *user, int conference, int area, i
|
|||||||
subject = www_sanitize(mhrs->msgs[i]->subject);
|
subject = www_sanitize(mhrs->msgs[i]->subject);
|
||||||
if (msgbase_is_flagged(user, conference, area, mhrs->msgs[i]->msg_h->MsgNum)) {
|
if (msgbase_is_flagged(user, conference, area, mhrs->msgs[i]->msg_h->MsgNum)) {
|
||||||
if (conf.date_style == 1) {
|
if (conf.date_style == 1) {
|
||||||
sprintf(buffer, "<div class=\"msg-summary-flag\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mon + 1, msg_date.tm_mday, msg_date.tm_year - 100);
|
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary-flag\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mon + 1, msg_date.tm_mday, msg_date.tm_year - 100);
|
||||||
} else {
|
} else {
|
||||||
sprintf(buffer, "<div class=\"msg-summary-flag\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
|
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary-flag\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
|
||||||
}
|
}
|
||||||
} else if (mhrs->msgs[i]->msg_h->MsgNum > jlr.HighReadMsg) {
|
} else if (mhrs->msgs[i]->msg_h->MsgNum > jlr.HighReadMsg) {
|
||||||
if (conf.date_style == 1) {
|
if (conf.date_style == 1) {
|
||||||
sprintf(buffer, "<div class=\"msg-summary\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mon + 1, msg_date.tm_mday, msg_date.tm_year - 100);
|
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mon + 1, msg_date.tm_mday, msg_date.tm_year - 100);
|
||||||
} else {
|
} else {
|
||||||
sprintf(buffer, "<div class=\"msg-summary\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
|
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (conf.date_style == 1) {
|
if (conf.date_style == 1) {
|
||||||
sprintf(buffer, "<div class=\"msg-summary-seen\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mon + 1, msg_date.tm_mday, msg_date.tm_year - 100);
|
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary-seen\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mon + 1, msg_date.tm_mday, msg_date.tm_year - 100);
|
||||||
} else {
|
} else {
|
||||||
sprintf(buffer, "<div class=\"msg-summary-seen\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
|
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary-seen\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,46 +178,28 @@ char *www_msgs_messagelist(struct user_record *user, int conference, int area, i
|
|||||||
free(from);
|
free(from);
|
||||||
free(subject);
|
free(subject);
|
||||||
|
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
stralloc_cats(&page, buffer);
|
||||||
max_len += 4096;
|
|
||||||
page = (char *)realloc(page, max_len);
|
|
||||||
}
|
|
||||||
strcat(page, buffer);
|
|
||||||
len += strlen(buffer);
|
|
||||||
}
|
}
|
||||||
sprintf(buffer, "</div>\n");
|
stralloc_cats(&page, "</div>\n");
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
|
||||||
max_len += 4096;
|
|
||||||
page = (char *)realloc(page, max_len);
|
|
||||||
}
|
|
||||||
strcat(page, buffer);
|
|
||||||
len += strlen(buffer);
|
|
||||||
if (skip + 50 <= mhrs->msg_count) {
|
if (skip + 50 <= mhrs->msg_count) {
|
||||||
sprintf(buffer, "<div class=\"msg-summary-next\"><a href=\"%smsgs/%d/%d/?skip=%d\">Next</a></div>\n", conf.www_url, conference, area, skip + 50);
|
snprintf(buffer, sizeof buffer,
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
"<div class=\"msg-summary-next\"><a href=\"%smsgs/%d/%d/?skip=%d\">Next</a></div>\n",
|
||||||
max_len += 4096;
|
conf.www_url, conference, area, skip + 50);
|
||||||
page = (char *)realloc(page, max_len);
|
stralloc_cats(&page, buffer);
|
||||||
}
|
|
||||||
strcat(page, buffer);
|
|
||||||
len += strlen(buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skip > 0) {
|
if (skip > 0) {
|
||||||
if (skip - 50 < 0) {
|
if (skip - 50 < 0) {
|
||||||
sprintf(buffer, "<div class=\"msg-summary-prev\"><a href=\"%smsgs/%d/%d/\">Prev</a></div>\n", conf.www_url, conference, area);
|
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary-prev\"><a href=\"%smsgs/%d/%d/\">Prev</a></div>\n", conf.www_url, conference, area);
|
||||||
} else {
|
} else {
|
||||||
sprintf(buffer, "<div class=\"msg-summary-prev\"><a href=\"%smsgs/%d/%d/?skip=%d\">Prev</a></div>\n", conf.www_url, conference, area, skip - 50);
|
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary-prev\"><a href=\"%smsgs/%d/%d/?skip=%d\">Prev</a></div>\n", conf.www_url, conference, area, skip - 50);
|
||||||
}
|
}
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
stralloc_cats(&page, buffer);
|
||||||
max_len += 4096;
|
|
||||||
page = (char *)realloc(page, max_len);
|
|
||||||
}
|
|
||||||
strcat(page, buffer);
|
|
||||||
len += strlen(buffer);
|
|
||||||
}
|
}
|
||||||
|
stralloc_0(&page);
|
||||||
|
|
||||||
free_message_headers(mhrs);
|
free_message_headers(mhrs);
|
||||||
return page;
|
return page.s;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *www_msgs_messageview(struct user_record *user, int conference, int area, int msg) {
|
char *www_msgs_messageview(struct user_record *user, int conference, int area, int msg) {
|
||||||
@ -262,9 +223,7 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i
|
|||||||
int z;
|
int z;
|
||||||
struct tm msg_date;
|
struct tm msg_date;
|
||||||
time_t date;
|
time_t date;
|
||||||
char *page;
|
stralloc page = EMPTY_STRALLOC;
|
||||||
int max_len;
|
|
||||||
int len;
|
|
||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
int chars;
|
int chars;
|
||||||
int i;
|
int i;
|
||||||
@ -281,428 +240,270 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conf.mail_conferences[conference]->sec_level <= user->sec_level && conf.mail_conferences[conference]->mail_areas[area]->read_sec_level <= user->sec_level) {
|
if (!(conf.mail_conferences[conference]->sec_level <= user->sec_level && conf.mail_conferences[conference]->mail_areas[area]->read_sec_level <= user->sec_level)) {
|
||||||
jb = open_jam_base(conf.mail_conferences[conference]->mail_areas[area]->path);
|
|
||||||
if (!jb) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
JAM_ReadMBHeader(jb, &jbh);
|
|
||||||
|
|
||||||
memset(&jmh, 0, sizeof(s_JamMsgHeader));
|
|
||||||
z = JAM_ReadMsgHeader(jb, msg - 1, &jmh, &jsp);
|
|
||||||
if (z != 0) {
|
|
||||||
JAM_CloseMB(jb);
|
|
||||||
free(jb);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if (jmh.Attribute & JAM_MSG_DELETED) {
|
|
||||||
JAM_DelSubPacket(jsp);
|
|
||||||
JAM_CloseMB(jb);
|
|
||||||
free(jb);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (z = 0; z < jsp->NumFields; z++) {
|
|
||||||
if (jsp->Fields[z]->LoID == JAMSFLD_SUBJECT) {
|
|
||||||
subject = strndup(jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
|
||||||
} else if (jsp->Fields[z]->LoID == JAMSFLD_SENDERNAME) {
|
|
||||||
from = strndup(jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
|
||||||
} else if (jsp->Fields[z]->LoID == JAMSFLD_RECVRNAME) {
|
|
||||||
to = strndup(jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
|
||||||
} else if (jsp->Fields[z]->LoID == JAMSFLD_DADDRESS) {
|
|
||||||
daddress = strndup(jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
|
||||||
} else if (jsp->Fields[z]->LoID == JAMSFLD_OADDRESS) {
|
|
||||||
oaddress = strndup(jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
|
||||||
} else if (jsp->Fields[z]->LoID == JAMSFLD_MSGID) {
|
|
||||||
msgid = strndup(jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
|
||||||
} else if (jsp->Fields[z]->LoID == JAMSFLD_REPLYID) {
|
|
||||||
replyid = strndup(jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
JAM_DelSubPacket(jsp);
|
|
||||||
|
|
||||||
if (subject == NULL) {
|
|
||||||
subject = strdup("(No Subject)");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (from == NULL) {
|
|
||||||
from = strdup("(No Sender)");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (to == NULL) {
|
|
||||||
to = strdup("(No Recipient)");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (jmh.Attribute & JAM_MSG_PRIVATE) {
|
|
||||||
if (!msg_is_to(user, to, daddress, conf.mail_conferences[conference]->nettype, conf.mail_conferences[conference]->realnames, conference) &&
|
|
||||||
!msg_is_from(user, from, oaddress, conf.mail_conferences[conference]->nettype, conf.mail_conferences[conference]->realnames, conference) &&
|
|
||||||
!msg_is_to(user, to, daddress, conf.mail_conferences[conference]->nettype, !conf.mail_conferences[conference]->realnames, conference) &&
|
|
||||||
!msg_is_from(user, from, oaddress, conf.mail_conferences[conference]->nettype, !conf.mail_conferences[conference]->realnames, conference)) {
|
|
||||||
|
|
||||||
if (subject != NULL) {
|
|
||||||
free(subject);
|
|
||||||
}
|
|
||||||
if (from != NULL) {
|
|
||||||
free(from);
|
|
||||||
}
|
|
||||||
if (to != NULL) {
|
|
||||||
free(to);
|
|
||||||
}
|
|
||||||
if (oaddress != NULL) {
|
|
||||||
free(oaddress);
|
|
||||||
}
|
|
||||||
if (daddress != NULL) {
|
|
||||||
free(daddress);
|
|
||||||
}
|
|
||||||
if (msgid != NULL) {
|
|
||||||
free(msgid);
|
|
||||||
}
|
|
||||||
if (replyid != NULL) {
|
|
||||||
free(replyid);
|
|
||||||
}
|
|
||||||
JAM_CloseMB(jb);
|
|
||||||
free(jb);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
body = (char *)malloz(jmh.TxtLen + 1);
|
|
||||||
|
|
||||||
JAM_ReadMsgText(jb, jmh.TxtOffset, jmh.TxtLen, (char *)body);
|
|
||||||
|
|
||||||
if (JAM_ReadLastRead(jb, user->id, &jlr) == JAM_NO_USER) {
|
|
||||||
jlr.UserCRC = JAM_Crc32(user->loginname, strlen(user->loginname));
|
|
||||||
jlr.UserID = user->id;
|
|
||||||
jlr.HighReadMsg = msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
jlr.LastReadMsg = msg;
|
|
||||||
if (jlr.HighReadMsg < msg) {
|
|
||||||
jlr.HighReadMsg = msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
JAM_WriteLastRead(jb, user->id, &jlr);
|
|
||||||
JAM_CloseMB(jb);
|
|
||||||
free(jb);
|
|
||||||
|
|
||||||
page = (char *)malloz(4096);
|
|
||||||
max_len = 4096;
|
|
||||||
len = 0;
|
|
||||||
|
|
||||||
sprintf(buffer, "<div class=\"content-header\"><a href=\"%smsgs/%d/%d\"><h2>%s - %s</h2></a></div>\n", conf.www_url, conference, area, conf.mail_conferences[conference]->name, conf.mail_conferences[conference]->mail_areas[area]->name);
|
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
|
||||||
max_len += 4096;
|
|
||||||
page = (char *)realloc(page, max_len);
|
|
||||||
}
|
|
||||||
strcat(page, buffer);
|
|
||||||
len += strlen(buffer);
|
|
||||||
|
|
||||||
if (msgbase_is_flagged(user, conference, area, msg)) {
|
|
||||||
sprintf(buffer, "<div class=\"msg-view-header-flagged\">\n");
|
|
||||||
} else {
|
|
||||||
sprintf(buffer, "<div class=\"msg-view-header\">\n");
|
|
||||||
}
|
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
|
||||||
max_len += 4096;
|
|
||||||
page = (char *)realloc(page, max_len);
|
|
||||||
}
|
|
||||||
strcat(page, buffer);
|
|
||||||
len += strlen(buffer);
|
|
||||||
subject_s = www_sanitize(subject);
|
|
||||||
sprintf(buffer, "<div class=\"msg-view-subject\">%s</div>\n", subject_s);
|
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
|
||||||
max_len += 4096;
|
|
||||||
page = (char *)realloc(page, max_len);
|
|
||||||
}
|
|
||||||
free(subject_s);
|
|
||||||
strcat(page, buffer);
|
|
||||||
len += strlen(buffer);
|
|
||||||
|
|
||||||
from_s = www_sanitize(from);
|
|
||||||
if (conf.mail_conferences[conference]->mail_areas[area]->type != TYPE_LOCAL_AREA && oaddress != NULL) {
|
|
||||||
|
|
||||||
if (conf.mail_conferences[conference]->nettype == NETWORK_MAGI) {
|
|
||||||
sprintf(buffer, "<div class=\"msg-view-from\">From: %s (@%s)</div>\n", from_s, oaddress);
|
|
||||||
} else if (conf.mail_conferences[conference]->nettype == NETWORK_FIDO) {
|
|
||||||
nodeno = parse_fido_addr(oaddress);
|
|
||||||
if (nodeno != NULL) {
|
|
||||||
nodename = nl_get_bbsname(nodeno, conf.mail_conferences[conference]->domain);
|
|
||||||
if (strcmp(nodename, "Unknown") == 0) {
|
|
||||||
sprintf(buffer, "<div class=\"msg-view-from\">From: %s (%s)</div>\n", from_s, oaddress);
|
|
||||||
} else {
|
|
||||||
sprintf(buffer, "<div class=\"msg-view-from\">From: %s (<span class=\"bbsname\">%s</span> - %s)</div>\n", from_s, nodename, oaddress);
|
|
||||||
}
|
|
||||||
free(nodename);
|
|
||||||
free(nodeno);
|
|
||||||
} else {
|
|
||||||
sprintf(buffer, "<div class=\"msg-view-from\">From: %s (%s)</div>\n", from_s, oaddress);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
sprintf(buffer, "<div class=\"msg-view-from\">From: %s (%s)</div>\n", from_s, oaddress);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
sprintf(buffer, "<div class=\"msg-view-from\">From: %s</div>\n", from_s);
|
|
||||||
}
|
|
||||||
free(from_s);
|
|
||||||
|
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
|
||||||
max_len += 4096;
|
|
||||||
page = (char *)realloc(page, max_len);
|
|
||||||
}
|
|
||||||
strcat(page, buffer);
|
|
||||||
len += strlen(buffer);
|
|
||||||
to_s = www_sanitize(to);
|
|
||||||
sprintf(buffer, "<div class=\"msg-view-to\">To: %s</div>\n", to_s);
|
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
|
||||||
max_len += 4096;
|
|
||||||
page = (char *)realloc(page, max_len);
|
|
||||||
}
|
|
||||||
free(to_s);
|
|
||||||
strcat(page, buffer);
|
|
||||||
len += strlen(buffer);
|
|
||||||
|
|
||||||
date = (time_t)jmh.DateWritten;
|
|
||||||
gmtime_r(&date, &msg_date);
|
|
||||||
if (conf.date_style == 1) {
|
|
||||||
sprintf(buffer, "<div class=\"msg-view-date\">Date: %.2d:%.2d %.2d-%.2d-%.2d</div>\n", msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mon + 1, msg_date.tm_mday, msg_date.tm_year - 100);
|
|
||||||
} else {
|
|
||||||
sprintf(buffer, "<div class=\"msg-view-date\">Date: %.2d:%.2d %.2d-%.2d-%.2d</div>\n", msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
|
||||||
max_len += 4096;
|
|
||||||
page = (char *)realloc(page, max_len);
|
|
||||||
}
|
|
||||||
strcat(page, buffer);
|
|
||||||
len += strlen(buffer);
|
|
||||||
|
|
||||||
sprintf(buffer, "<div class=\"msg-view-options\"><a href=\"%smsgs/flag/%d/%d/%d\"><img src=\"%sstatic/flag.png\" /></a></div>", conf.www_url, conference, area, msg, conf.www_url);
|
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
|
||||||
max_len += 4096;
|
|
||||||
page = (char *)realloc(page, max_len);
|
|
||||||
}
|
|
||||||
strcat(page, buffer);
|
|
||||||
len += strlen(buffer);
|
|
||||||
|
|
||||||
sprintf(buffer, "</div>\n");
|
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
|
||||||
max_len += 4096;
|
|
||||||
page = (char *)realloc(page, max_len);
|
|
||||||
}
|
|
||||||
strcat(page, buffer);
|
|
||||||
len += strlen(buffer);
|
|
||||||
sprintf(buffer, "<div id=\"msgbody\">\n");
|
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
|
||||||
max_len += 4096;
|
|
||||||
page = (char *)realloc(page, max_len);
|
|
||||||
}
|
|
||||||
strcat(page, buffer);
|
|
||||||
len += strlen(buffer);
|
|
||||||
|
|
||||||
aha_text = (char *)malloz(jmh.TxtLen + 1);
|
|
||||||
|
|
||||||
memcpy(aha_text, body, jmh.TxtLen);
|
|
||||||
aha_text[jmh.TxtLen] = '\0';
|
|
||||||
aha_out = aha(aha_text);
|
|
||||||
while (len + strlen(aha_out) > max_len - 1) {
|
|
||||||
max_len += 4096;
|
|
||||||
page = (char *)realloc(page, max_len);
|
|
||||||
}
|
|
||||||
strcat(page, aha_out);
|
|
||||||
len += strlen(aha_out);
|
|
||||||
|
|
||||||
free(aha_out);
|
|
||||||
free(aha_text);
|
|
||||||
|
|
||||||
sprintf(buffer, "</div>\n");
|
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
|
||||||
max_len += 4096;
|
|
||||||
page = (char *)realloc(page, max_len);
|
|
||||||
}
|
|
||||||
strcat(page, buffer);
|
|
||||||
len += strlen(buffer);
|
|
||||||
|
|
||||||
sprintf(buffer, "<div class=\"msg-reply-form\">\n");
|
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
|
||||||
max_len += 4096;
|
|
||||||
page = (char *)realloc(page, max_len);
|
|
||||||
}
|
|
||||||
strcat(page, buffer);
|
|
||||||
len += strlen(buffer);
|
|
||||||
if (conf.mail_conferences[conference]->mail_areas[area]->write_sec_level <= user->sec_level && conf.mail_conferences[conference]->mail_areas[area]->type != TYPE_NETMAIL_AREA) {
|
|
||||||
sprintf(buffer, "<h3>Reply</h3>\n");
|
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
|
||||||
max_len += 4096;
|
|
||||||
page = (char *)realloc(page, max_len);
|
|
||||||
}
|
|
||||||
strcat(page, buffer);
|
|
||||||
len += strlen(buffer);
|
|
||||||
sprintf(buffer, "<form action=\"%smsgs/\" method=\"POST\" enctype=\"application/x-www-form-urlencoded;charset=UTF-8\">\n", conf.www_url);
|
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
|
||||||
max_len += 4096;
|
|
||||||
page = (char *)realloc(page, max_len);
|
|
||||||
}
|
|
||||||
strcat(page, buffer);
|
|
||||||
len += strlen(buffer);
|
|
||||||
|
|
||||||
sprintf(buffer, "<input type=\"hidden\" name=\"conference\" value=\"%d\" />\n", conference);
|
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
|
||||||
max_len += 4096;
|
|
||||||
page = (char *)realloc(page, max_len);
|
|
||||||
}
|
|
||||||
strcat(page, buffer);
|
|
||||||
len += strlen(buffer);
|
|
||||||
sprintf(buffer, "<input type=\"hidden\" name=\"area\" value=\"%d\" />\n", area);
|
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
|
||||||
max_len += 4096;
|
|
||||||
page = (char *)realloc(page, max_len);
|
|
||||||
}
|
|
||||||
strcat(page, buffer);
|
|
||||||
len += strlen(buffer);
|
|
||||||
|
|
||||||
sprintf(buffer, "<input type=\"hidden\" name=\"replyid\" value=\"%s\" />\n", msgid);
|
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
|
||||||
max_len += 4096;
|
|
||||||
page = (char *)realloc(page, max_len);
|
|
||||||
}
|
|
||||||
strcat(page, buffer);
|
|
||||||
len += strlen(buffer);
|
|
||||||
|
|
||||||
sprintf(buffer, "To : <input type=\"text\" name=\"recipient\" value=\"%s\" /><br />\n", from);
|
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
|
||||||
max_len += 4096;
|
|
||||||
page = (char *)realloc(page, max_len);
|
|
||||||
}
|
|
||||||
strcat(page, buffer);
|
|
||||||
len += strlen(buffer);
|
|
||||||
|
|
||||||
if (strncasecmp(subject, "re:", 3) == 0) {
|
|
||||||
sprintf(buffer, "Subject : <input type=\"text\" name=\"subject\" value=\"%s\" /><br />\n", subject);
|
|
||||||
} else {
|
|
||||||
sprintf(buffer, "Subject : <input type=\"text\" name=\"subject\" value=\"RE: %s\" /><br />\n", subject);
|
|
||||||
}
|
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
|
||||||
max_len += 4096;
|
|
||||||
page = (char *)realloc(page, max_len);
|
|
||||||
}
|
|
||||||
strcat(page, buffer);
|
|
||||||
len += strlen(buffer);
|
|
||||||
|
|
||||||
sprintf(buffer, "<textarea name=\"body\" rows=\"25\" cols=\"79\" wrap=\"soft\" id=\"replybody\">");
|
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
|
||||||
max_len += 4096;
|
|
||||||
page = (char *)realloc(page, max_len);
|
|
||||||
}
|
|
||||||
strcat(page, buffer);
|
|
||||||
len += strlen(buffer);
|
|
||||||
|
|
||||||
sprintf(buffer, " %c> ", from[0]);
|
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
|
||||||
max_len += 4096;
|
|
||||||
page = (char *)realloc(page, max_len);
|
|
||||||
}
|
|
||||||
strcat(page, buffer);
|
|
||||||
len += strlen(buffer);
|
|
||||||
|
|
||||||
replybody = (char *)malloz(strlen(body) + 1);
|
|
||||||
|
|
||||||
l2 = 0;
|
|
||||||
for (l1 = 0; l1 < strlen(body); l1++) {
|
|
||||||
if (body[l1] == '\e' && body[l1 + 1] == '[') {
|
|
||||||
while (strchr("ABCDEFGHIGJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", body[l1]) == NULL && l1 < strlen(body))
|
|
||||||
l1++;
|
|
||||||
} else {
|
|
||||||
replybody[l2++] = body[l1];
|
|
||||||
replybody[l2] = '\0';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
free(body);
|
|
||||||
chars = 0;
|
|
||||||
body2 = www_wordwrap(replybody, 69);
|
|
||||||
|
|
||||||
if (body2 == NULL) {
|
|
||||||
body2 = replybody;
|
|
||||||
} else {
|
|
||||||
free(replybody);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < strlen(body2); i++) {
|
|
||||||
if (body2[i] == '\r') {
|
|
||||||
sprintf(buffer, "\n %c> ", from[0]);
|
|
||||||
chars = 0;
|
|
||||||
} else if (chars == 73) {
|
|
||||||
sprintf(buffer, "\n %c> %c", from[0], body2[i]);
|
|
||||||
chars = 1;
|
|
||||||
} else {
|
|
||||||
sprintf(buffer, "%c", body2[i]);
|
|
||||||
chars++;
|
|
||||||
}
|
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
|
||||||
max_len += 4096;
|
|
||||||
page = (char *)realloc(page, max_len);
|
|
||||||
}
|
|
||||||
strcat(page, buffer);
|
|
||||||
len += strlen(buffer);
|
|
||||||
}
|
|
||||||
free(body2);
|
|
||||||
sprintf(buffer, "</textarea>\n<br />");
|
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
|
||||||
max_len += 4096;
|
|
||||||
page = (char *)realloc(page, max_len);
|
|
||||||
}
|
|
||||||
strcat(page, buffer);
|
|
||||||
len += strlen(buffer);
|
|
||||||
|
|
||||||
sprintf(buffer, "<input type=\"submit\" name=\"submit\" value=\"Reply\" />\n<br />");
|
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
|
||||||
max_len += 4096;
|
|
||||||
page = (char *)realloc(page, max_len);
|
|
||||||
}
|
|
||||||
strcat(page, buffer);
|
|
||||||
len += strlen(buffer);
|
|
||||||
|
|
||||||
sprintf(buffer, "</form>\n");
|
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
|
||||||
max_len += 4096;
|
|
||||||
page = (char *)realloc(page, max_len);
|
|
||||||
}
|
|
||||||
strcat(page, buffer);
|
|
||||||
len += strlen(buffer);
|
|
||||||
|
|
||||||
sprintf(buffer, "</div>\n");
|
|
||||||
if (len + strlen(buffer) > max_len - 1) {
|
|
||||||
max_len += 4096;
|
|
||||||
page = (char *)realloc(page, max_len);
|
|
||||||
}
|
|
||||||
strcat(page, buffer);
|
|
||||||
len += strlen(buffer);
|
|
||||||
}
|
|
||||||
if (subject != NULL) {
|
|
||||||
free(subject);
|
|
||||||
}
|
|
||||||
if (from != NULL) {
|
|
||||||
free(from);
|
|
||||||
}
|
|
||||||
if (to != NULL) {
|
|
||||||
free(to);
|
|
||||||
}
|
|
||||||
if (oaddress != NULL) {
|
|
||||||
free(oaddress);
|
|
||||||
}
|
|
||||||
if (daddress != NULL) {
|
|
||||||
free(daddress);
|
|
||||||
}
|
|
||||||
if (msgid != NULL) {
|
|
||||||
free(msgid);
|
|
||||||
}
|
|
||||||
if (replyid != NULL) {
|
|
||||||
free(replyid);
|
|
||||||
}
|
|
||||||
return page;
|
|
||||||
} else {
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
jb = open_jam_base(conf.mail_conferences[conference]->mail_areas[area]->path);
|
||||||
|
if (!jb) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
JAM_ReadMBHeader(jb, &jbh);
|
||||||
|
|
||||||
|
memset(&jmh, 0, sizeof(s_JamMsgHeader));
|
||||||
|
z = JAM_ReadMsgHeader(jb, msg - 1, &jmh, &jsp);
|
||||||
|
if (z != 0) {
|
||||||
|
JAM_CloseMB(jb);
|
||||||
|
free(jb);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (jmh.Attribute & JAM_MSG_DELETED) {
|
||||||
|
JAM_DelSubPacket(jsp);
|
||||||
|
JAM_CloseMB(jb);
|
||||||
|
free(jb);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (z = 0; z < jsp->NumFields; z++) {
|
||||||
|
if (jsp->Fields[z]->LoID == JAMSFLD_SUBJECT) {
|
||||||
|
subject = strndup(jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
||||||
|
} else if (jsp->Fields[z]->LoID == JAMSFLD_SENDERNAME) {
|
||||||
|
from = strndup(jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
||||||
|
} else if (jsp->Fields[z]->LoID == JAMSFLD_RECVRNAME) {
|
||||||
|
to = strndup(jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
||||||
|
} else if (jsp->Fields[z]->LoID == JAMSFLD_DADDRESS) {
|
||||||
|
daddress = strndup(jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
||||||
|
} else if (jsp->Fields[z]->LoID == JAMSFLD_OADDRESS) {
|
||||||
|
oaddress = strndup(jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
||||||
|
} else if (jsp->Fields[z]->LoID == JAMSFLD_MSGID) {
|
||||||
|
msgid = strndup(jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
||||||
|
} else if (jsp->Fields[z]->LoID == JAMSFLD_REPLYID) {
|
||||||
|
replyid = strndup(jsp->Fields[z]->Buffer, jsp->Fields[z]->DatLen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JAM_DelSubPacket(jsp);
|
||||||
|
|
||||||
|
if (subject == NULL) {
|
||||||
|
subject = strdup("(No Subject)");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (from == NULL) {
|
||||||
|
from = strdup("(No Sender)");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (to == NULL) {
|
||||||
|
to = strdup("(No Recipient)");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (jmh.Attribute & JAM_MSG_PRIVATE) {
|
||||||
|
if (!msg_is_to(user, to, daddress, conf.mail_conferences[conference]->nettype, conf.mail_conferences[conference]->realnames, conference) &&
|
||||||
|
!msg_is_from(user, from, oaddress, conf.mail_conferences[conference]->nettype, conf.mail_conferences[conference]->realnames, conference) &&
|
||||||
|
!msg_is_to(user, to, daddress, conf.mail_conferences[conference]->nettype, !conf.mail_conferences[conference]->realnames, conference) &&
|
||||||
|
!msg_is_from(user, from, oaddress, conf.mail_conferences[conference]->nettype, !conf.mail_conferences[conference]->realnames, conference)) {
|
||||||
|
|
||||||
|
free(subject);
|
||||||
|
free(from);
|
||||||
|
free(to);
|
||||||
|
free(oaddress);
|
||||||
|
free(daddress);
|
||||||
|
free(msgid);
|
||||||
|
free(replyid);
|
||||||
|
JAM_CloseMB(jb);
|
||||||
|
free(jb);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
body = (char *)malloz(jmh.TxtLen + 1);
|
||||||
|
|
||||||
|
JAM_ReadMsgText(jb, jmh.TxtOffset, jmh.TxtLen, (char *)body);
|
||||||
|
|
||||||
|
if (JAM_ReadLastRead(jb, user->id, &jlr) == JAM_NO_USER) {
|
||||||
|
jlr.UserCRC = JAM_Crc32(user->loginname, strlen(user->loginname));
|
||||||
|
jlr.UserID = user->id;
|
||||||
|
jlr.HighReadMsg = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
jlr.LastReadMsg = msg;
|
||||||
|
if (jlr.HighReadMsg < msg) {
|
||||||
|
jlr.HighReadMsg = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
JAM_WriteLastRead(jb, user->id, &jlr);
|
||||||
|
JAM_CloseMB(jb);
|
||||||
|
free(jb);
|
||||||
|
|
||||||
|
stralloc_copys(&page, "<div class=\"content-header\"><a href=\"");
|
||||||
|
stralloc_cats(&page, conf.www_url);
|
||||||
|
stralloc_cats(&page, "msgs/");
|
||||||
|
stralloc_cat_long(&page, conference);
|
||||||
|
stralloc_append1(&page, '/');
|
||||||
|
stralloc_cat_long(&page, area);
|
||||||
|
stralloc_cats(&page, "\"><h2>");
|
||||||
|
stralloc_cats(&page, conf.mail_conferences[conference]->name);
|
||||||
|
stralloc_cats(&page, " - ");
|
||||||
|
stralloc_cats(&page, conf.mail_conferences[conference]->mail_areas[area]->name);
|
||||||
|
stralloc_cats(&page, "</h2></a></div>\n");
|
||||||
|
|
||||||
|
if (msgbase_is_flagged(user, conference, area, msg)) {
|
||||||
|
stralloc_cats(&page, "<div class=\"msg-view-header-flagged\">\n");
|
||||||
|
} else {
|
||||||
|
stralloc_cats(&page, "<div class=\"msg-view-header\">\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
subject_s = www_sanitize(subject);
|
||||||
|
stralloc_cats(&page, "<div class=\"msg-view-subject\">");
|
||||||
|
stralloc_cats(&page, subject_s);
|
||||||
|
stralloc_cats(&page, "</div>\n");
|
||||||
|
free(subject_s);
|
||||||
|
|
||||||
|
from_s = www_sanitize(from);
|
||||||
|
if (conf.mail_conferences[conference]->mail_areas[area]->type != TYPE_LOCAL_AREA && oaddress != NULL) {
|
||||||
|
if (conf.mail_conferences[conference]->nettype == NETWORK_MAGI) {
|
||||||
|
snprintf(buffer, sizeof buffer, "<div class=\"msg-view-from\">From: %s (@%s)</div>\n", from_s, oaddress);
|
||||||
|
} else if (conf.mail_conferences[conference]->nettype == NETWORK_FIDO) {
|
||||||
|
nodeno = parse_fido_addr(oaddress);
|
||||||
|
if (nodeno != NULL) {
|
||||||
|
nodename = nl_get_bbsname(nodeno, conf.mail_conferences[conference]->domain);
|
||||||
|
if (strcmp(nodename, "Unknown") == 0) {
|
||||||
|
snprintf(buffer, sizeof buffer, "<div class=\"msg-view-from\">From: %s (%s)</div>\n", from_s, oaddress);
|
||||||
|
} else {
|
||||||
|
snprintf(buffer, sizeof buffer, "<div class=\"msg-view-from\">From: %s (<span class=\"bbsname\">%s</span> - %s)</div>\n", from_s, nodename, oaddress);
|
||||||
|
}
|
||||||
|
free(nodename);
|
||||||
|
free(nodeno);
|
||||||
|
} else {
|
||||||
|
snprintf(buffer, sizeof buffer, "<div class=\"msg-view-from\">From: %s (%s)</div>\n", from_s, oaddress);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
snprintf(buffer, sizeof buffer, "<div class=\"msg-view-from\">From: %s (%s)</div>\n", from_s, oaddress);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
snprintf(buffer, sizeof buffer, "<div class=\"msg-view-from\">From: %s</div>\n", from_s);
|
||||||
|
}
|
||||||
|
free(from_s);
|
||||||
|
|
||||||
|
stralloc_cats(&page, buffer);
|
||||||
|
|
||||||
|
to_s = www_sanitize(to);
|
||||||
|
stralloc_cats(&page, "<div class=\"msg-view-to\">To: ");
|
||||||
|
stralloc_cats(&page, to_s);
|
||||||
|
stralloc_cats(&page, "</div>\n");
|
||||||
|
free(to_s);
|
||||||
|
|
||||||
|
date = (time_t)jmh.DateWritten;
|
||||||
|
gmtime_r(&date, &msg_date);
|
||||||
|
if (conf.date_style == 1) {
|
||||||
|
snprintf(buffer, sizeof buffer, "<div class=\"msg-view-date\">Date: %.2d:%.2d %.2d-%.2d-%.2d</div>\n", msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mon + 1, msg_date.tm_mday, msg_date.tm_year - 100);
|
||||||
|
} else {
|
||||||
|
snprintf(buffer, sizeof buffer, "<div class=\"msg-view-date\">Date: %.2d:%.2d %.2d-%.2d-%.2d</div>\n", msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
stralloc_cats(&page, buffer);
|
||||||
|
|
||||||
|
snprintf(buffer, sizeof buffer, "<div class=\"msg-view-options\"><a href=\"%smsgs/flag/%d/%d/%d\"><img src=\"%sstatic/flag.png\" /></a></div>", conf.www_url, conference, area, msg, conf.www_url);
|
||||||
|
stralloc_cats(&page, buffer);
|
||||||
|
|
||||||
|
stralloc_cats(&page, "</div>\n");
|
||||||
|
stralloc_cats(&page, "<div id=\"msgbody\">\n");
|
||||||
|
|
||||||
|
aha_text = strndup(body, jmh.TxtLen);
|
||||||
|
aha_out = aha(aha_text);
|
||||||
|
stralloc_cats(&page, aha_out);
|
||||||
|
|
||||||
|
free(aha_out);
|
||||||
|
free(aha_text);
|
||||||
|
|
||||||
|
stralloc_cats(&page, "</div>\n");
|
||||||
|
|
||||||
|
stralloc_cats(&page, "<div class=\"msg-reply-form\">\n");
|
||||||
|
if (conf.mail_conferences[conference]->mail_areas[area]->write_sec_level <= user->sec_level && conf.mail_conferences[conference]->mail_areas[area]->type != TYPE_NETMAIL_AREA) {
|
||||||
|
stralloc_cats(&page, "<h3>Reply</h3>\n");
|
||||||
|
stralloc_cats(&page, "<form action=\"");
|
||||||
|
stralloc_cats(&page, conf.www_url);
|
||||||
|
stralloc_cats(&page, "msgs/\" method=\"POST\" enctype=\"application/x-www-form-urlencoded;charset=UTF-8\">\n");
|
||||||
|
|
||||||
|
stralloc_cats(&page, "<input type=\"hidden\" name=\"conference\" value=\"");
|
||||||
|
stralloc_cat_long(&page, conference);
|
||||||
|
stralloc_cats(&page, "\" />\n");
|
||||||
|
|
||||||
|
stralloc_cats(&page, "<input type=\"hidden\" name=\"area\" value=\"");
|
||||||
|
stralloc_cat_long(&page, area);
|
||||||
|
stralloc_cats(&page, "\" />\n");
|
||||||
|
|
||||||
|
stralloc_cats(&page, "<input type=\"hidden\" name=\"replyid\" value=\"");
|
||||||
|
stralloc_cats(&page, msgid);
|
||||||
|
stralloc_cats(&page, "\" />\n");
|
||||||
|
|
||||||
|
stralloc_cats(&page, "To : <input type=\"text\" name=\"recipient\" value=\"");
|
||||||
|
stralloc_cats(&page, from);
|
||||||
|
stralloc_cats(&page, "\" /><br />\n");
|
||||||
|
|
||||||
|
stralloc_cats(&page, "Subject : <input type=\"text\" name=\"subject\" value=\"");
|
||||||
|
if (strncasecmp(subject, "re:", 3) == 0) {
|
||||||
|
stralloc_cats(&page, "RE: ");
|
||||||
|
}
|
||||||
|
stralloc_cats(&page, subject);
|
||||||
|
stralloc_cats(&page, "\" /><br />\n");
|
||||||
|
|
||||||
|
stralloc_cats(&page, "<textarea name=\"body\" rows=\"25\" cols=\"79\" wrap=\"soft\" id=\"replybody\">");
|
||||||
|
|
||||||
|
stralloc_append1(&page, ' ');
|
||||||
|
stralloc_append1(&page, from[0]);
|
||||||
|
stralloc_cats(&page, "> ");
|
||||||
|
|
||||||
|
replybody = (char *)malloz(strlen(body) + 1);
|
||||||
|
|
||||||
|
l2 = 0;
|
||||||
|
for (l1 = 0; l1 < strlen(body); l1++) {
|
||||||
|
if (body[l1] == '\e' && body[l1 + 1] == '[') {
|
||||||
|
while (strchr("ABCDEFGHIGJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", body[l1]) == NULL && l1 < strlen(body))
|
||||||
|
l1++;
|
||||||
|
} else {
|
||||||
|
replybody[l2++] = body[l1];
|
||||||
|
replybody[l2] = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free(body);
|
||||||
|
chars = 0;
|
||||||
|
body2 = www_wordwrap(replybody, 69);
|
||||||
|
|
||||||
|
if (body2 == NULL) {
|
||||||
|
body2 = replybody;
|
||||||
|
} else {
|
||||||
|
free(replybody);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < strlen(body2); i++) {
|
||||||
|
if (body2[i] == '\r') {
|
||||||
|
snprintf(buffer, sizeof buffer, "\n %c> ", from[0]);
|
||||||
|
chars = 0;
|
||||||
|
} else if (chars == 73) {
|
||||||
|
snprintf(buffer, sizeof buffer, "\n %c> %c", from[0], body2[i]);
|
||||||
|
chars = 1;
|
||||||
|
} else {
|
||||||
|
snprintf(buffer, sizeof buffer, "%c", body2[i]);
|
||||||
|
chars++;
|
||||||
|
}
|
||||||
|
stralloc_cats(&page, buffer);
|
||||||
|
}
|
||||||
|
free(body2);
|
||||||
|
stralloc_cats(&page, "</textarea>\n<br />");
|
||||||
|
stralloc_cats(&page, "<input type=\"submit\" name=\"submit\" value=\"Reply\" />\n<br />");
|
||||||
|
stralloc_cats(&page, "</form>\n");
|
||||||
|
stralloc_cats(&page, "</div>\n");
|
||||||
|
}
|
||||||
|
stralloc_0(&page);
|
||||||
|
|
||||||
|
free(subject);
|
||||||
|
free(from);
|
||||||
|
free(to);
|
||||||
|
free(oaddress);
|
||||||
|
free(daddress);
|
||||||
|
free(msgid);
|
||||||
|
free(replyid);
|
||||||
|
|
||||||
|
return page.s;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *www_wordwrap(char *content, int cutoff) {
|
static char *www_wordwrap(char *content, int cutoff) {
|
||||||
@ -899,12 +700,14 @@ int www_send_msg(struct user_record *user, char *to, char *subj, int conference,
|
|||||||
|
|
||||||
if (conf.mail_conferences[conference]->nettype == NETWORK_FIDO) {
|
if (conf.mail_conferences[conference]->nettype == NETWORK_FIDO) {
|
||||||
if (conf.mail_conferences[conference]->fidoaddr->point) {
|
if (conf.mail_conferences[conference]->fidoaddr->point) {
|
||||||
sprintf(buffer, "%d:%d/%d.%d", conf.mail_conferences[conference]->fidoaddr->zone,
|
snprintf(buffer, sizeof buffer, "%d:%d/%d.%d",
|
||||||
|
conf.mail_conferences[conference]->fidoaddr->zone,
|
||||||
conf.mail_conferences[conference]->fidoaddr->net,
|
conf.mail_conferences[conference]->fidoaddr->net,
|
||||||
conf.mail_conferences[conference]->fidoaddr->node,
|
conf.mail_conferences[conference]->fidoaddr->node,
|
||||||
conf.mail_conferences[conference]->fidoaddr->point);
|
conf.mail_conferences[conference]->fidoaddr->point);
|
||||||
} else {
|
} else {
|
||||||
sprintf(buffer, "%d:%d/%d", conf.mail_conferences[conference]->fidoaddr->zone,
|
snprintf(buffer, sizeof buffer, "%d:%d/%d",
|
||||||
|
conf.mail_conferences[conference]->fidoaddr->zone,
|
||||||
conf.mail_conferences[conference]->fidoaddr->net,
|
conf.mail_conferences[conference]->fidoaddr->net,
|
||||||
conf.mail_conferences[conference]->fidoaddr->node);
|
conf.mail_conferences[conference]->fidoaddr->node);
|
||||||
}
|
}
|
||||||
@ -914,7 +717,8 @@ int www_send_msg(struct user_record *user, char *to, char *subj, int conference,
|
|||||||
jsf.Buffer = (char *)buffer;
|
jsf.Buffer = (char *)buffer;
|
||||||
JAM_PutSubfield(jsp, &jsf);
|
JAM_PutSubfield(jsp, &jsf);
|
||||||
|
|
||||||
sprintf(buffer, "%d:%d/%d.%d %08lx", conf.mail_conferences[conference]->fidoaddr->zone,
|
snprintf(buffer, sizeof buffer, "%d:%d/%d.%d %08lx",
|
||||||
|
conf.mail_conferences[conference]->fidoaddr->zone,
|
||||||
conf.mail_conferences[conference]->fidoaddr->net,
|
conf.mail_conferences[conference]->fidoaddr->net,
|
||||||
conf.mail_conferences[conference]->fidoaddr->node,
|
conf.mail_conferences[conference]->fidoaddr->node,
|
||||||
conf.mail_conferences[conference]->fidoaddr->point,
|
conf.mail_conferences[conference]->fidoaddr->point,
|
||||||
@ -936,7 +740,7 @@ int www_send_msg(struct user_record *user, char *to, char *subj, int conference,
|
|||||||
jmh.ReplyCRC = JAM_Crc32(buffer, strlen(replyid));
|
jmh.ReplyCRC = JAM_Crc32(buffer, strlen(replyid));
|
||||||
}
|
}
|
||||||
} else if (conf.mail_conferences[conference]->nettype == NETWORK_MAGI) {
|
} else if (conf.mail_conferences[conference]->nettype == NETWORK_MAGI) {
|
||||||
sprintf(buffer, "%d", conf.mail_conferences[conference]->maginode);
|
snprintf(buffer, sizeof buffer, "%d", conf.mail_conferences[conference]->maginode);
|
||||||
jsf.LoID = JAMSFLD_OADDRESS;
|
jsf.LoID = JAMSFLD_OADDRESS;
|
||||||
jsf.HiID = 0;
|
jsf.HiID = 0;
|
||||||
jsf.DatLen = strlen(buffer);
|
jsf.DatLen = strlen(buffer);
|
||||||
|
Reference in New Issue
Block a user