/* DBOX Module Copyright (C) 1994-2000 Daniel Kroening Purpose: */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "ostatus.h" #include "webtools.h" #include "readwebmail.h" #include "webmail.h" #include "challenge.h" #include "attachment.h" struct msginfot { folderindext fi; dword msgnr; bool highlight; }; void show_mail_line(ostream &out, const string &base_url, const string &sort_str, bool bg, const msginfot &msginfo, const string &challenge, const string &mailbox_str, bool show_delete, bool show_reply) { out << ""; out << ""; if(show_delete) { out << "\"Nachricht "; } if(show_reply) { out << "\"Nachricht "; } if(!show_reply && !show_delete) out << " "; out << ""; { struct tm *tm=localtime(&msginfo.fi.received); char size[TEXTLEN]; if(msginfo.fi.len<10000) snprintf(size, TEXTLEN, "%lu", msginfo.fi.len); else { dword l=msginfo.fi.len/1024; if(l>999) { l/=1024; if(l==0) l=1; snprintf(size, TEXTLEN, "%luM", l); } else { if(l==0) l=1; snprintf(size, TEXTLEN, "%luK", l); } } out.form("" "
%02u.%02u.
" "%s", msginfo.fi.flags.binary?"unknown":"text", tm->tm_mday, tm->tm_mon+1, size); } out << ""; if(msginfo.highlight) out << ""; { char tempstr[TEXTLEN]; string from, mailto; strmaxcpy(tempstr, msginfo.fi.abs, TEXTLEN-1); ibm2iso(tempstr, strlen(tempstr)); char *tptr=strstr(tempstr, " ("); if(tptr==NULL) mailto=from=tempstr; else { *tptr=0; tptr+=2; char *tptr2=strrchr(tptr, ')'); if(tptr2!=NULL) *tptr2=0; mailto=htmlize_string(tempstr); from=tptr; } htmlize_string(from); htmlize_string(mailto); if(msginfo.fi.flags.deleted) out << "" << from << ""; else out << "" << from << ""; } if(msginfo.highlight) out << ""; out << ""; out << ""; if(msginfo.highlight) out << ""; { string subject=msginfo.fi.bet; ibm2iso(subject); htmlize_string(subject); if(msginfo.fi.flags.deleted) out << "" << subject << ""; else out << "" << subject << ""; } if(msginfo.highlight) out << ""; out << ""; out << "\n"; } bool sort_by_from(const msginfot &a, const msginfot &b) { return stringcasecmp(a.fi.abs, b.fi.abs)<0; } bool sort_by_subj(const msginfot &a, const msginfot &b) { return stringcasecmp(a.fi.bet, b.fi.bet)<0; } bool sort_by_size(const msginfot &a, const msginfot &b) { return a.fi.len=0; } bool sort_by_subj_reverse(const msginfot &a, const msginfot &b) { return stringcasecmp(a.fi.bet, b.fi.bet)>=0; } bool sort_by_size_reverse(const msginfot &a, const msginfot &b) { return a.fi.len>=b.fi.len; } bool sort_by_date_reverse(const msginfot &a, const msginfot &b) { return a.fi.received>=b.fi.received; } void read_web_folder(httpt &http, ostream &out, const string &title, getrfct &getrfc, bool show_delete, bool show_reply, bool highlight_unseen) { startpage(out, title); out << "

" << title << "

\n"; string mailbox_str; { const char *ptr; ptr=http.getparameter("group"); if(ptr!=NULL) { mailbox_str+="&group="; mailbox_str+=urlize_string(ptr); } ptr=http.getparameter("mailbox"); if(ptr!=NULL) { mailbox_str+="&mailbox="; mailbox_str+=urlize_string(ptr); } } vector index; { msginfot msginfo; dword number_of_messages=getrfc.get_number_of_messages(); for(unsigned i=0; iDieses Fach ist leer!

\n"; } else { bool reverse_sort=(atol(status.userprofile.get("Nachrichtenanzeige"))!=0); const char *sort_by; dword msg_per_page=50; dword start_nr=0, end_nr=min((dword)index.size(), msg_per_page)-1; { const char *ptr; ptr=http.getparameter("start_nr"); if(ptr!=NULL) start_nr=min((unsigned long)atol(ptr), (unsigned long)index.size()-1); ptr=http.getparameter("end_nr"); if(ptr!=NULL) end_nr=min((unsigned long)atol(ptr), (unsigned long)index.size()-1); } out << "

\n"; if(http.getparameter("reverse")!=NULL) reverse_sort=(atol(http.getparameter("reverse"))!=0); sort_by=http.getparameter("sort"); if(sort_by==NULL) sort_by="date"; string sort_str; sort_str="sort="; sort_str+=sort_by; if(reverse_sort) sort_str+="&reverse=1"; else sort_str+="&reverse=0"; string msg_str=sort_str; if(start_nr!=0 || end_nr!=index.size()-1) { char tempstr[TEXTLEN]; snprintf(tempstr, TEXTLEN, "&start_nr=%lu&end_nr=%lu", start_nr, end_nr); msg_str+=tempstr; out << "\n"; } { const char *reverse; if(reverse_sort) reverse="&reverse=0"; else reverse="&reverse=1"; out << "" "
"; if(start_nr!=0) { dword new_start_nr=0; if(start_nr>msg_per_page) new_start_nr=start_nr-msg_per_page; out << "" << new_start_nr+1 << "-" << start_nr << " "; } out << start_nr+1 << "-" << end_nr+1; if(end_nr!=index.size()-1) { dword new_end_nr=min((dword)(index.size()-1), end_nr+msg_per_page); out << " " << end_nr+2 << "-" << new_end_nr+1 << ""; } out << "
Aktionen" "Typ" "Datum" "Größe" "Absender" "Betreff" "\n"; } if(stricmp(sort_by, "size")==0) sort(index.begin(), index.end(), reverse_sort?sort_by_size_reverse:sort_by_size); else if(stricmp(sort_by, "from")==0) sort(index.begin(), index.end(), reverse_sort?sort_by_from_reverse:sort_by_from); else if(stricmp(sort_by, "subj")==0) sort(index.begin(), index.end(), reverse_sort?sort_by_subj_reverse:sort_by_subj); else if(stricmp(sort_by, "date")==0) sort(index.begin(), index.end(), reverse_sort?sort_by_date_reverse:sort_by_date); bool bg=FALSE; string challenge; get_challenge(challenge, status.userprofile); for(dword msgnr=start_nr; msgnr<=end_nr; msgnr++) show_mail_line(out, http.url, msg_str, bg^=1, index[msgnr], challenge, mailbox_str, show_delete, show_reply); out << "

\n"; out << index.size() << " Nachricht"; if(index.size()!=1) out << "en"; out << " insgesamt im Folder.\n"; out << "

\n"; } showcopyright(out); endpage(out); }