📄 inbox.cpp
字号:
{ cout << data;} //not in attachment mode ok to dis //turns off message display if (USEATTACHMENTS && ismime) { if (onmimeheader && strncmp(data, "\n", 1) == 0) { onmimeheader = 0; } } else if (USEATTACHMENTS && !ismime) { if (strncmp(data, "begin ", 6)==0) { dontdisplay = 1; if (attachcount < 100) { attachcount++; cout << "Attached file removed from display." << endl; attachname[attachcount] = new char[500]; strncpy(attachname[attachcount], data, 499); attachname[attachcount][499] = '\0'; } } } else {} } // off header }//attach count == num } //while cout << "</textarea></form>" << endl; cout << "</td></tr></table>"; if (USEATTACHMENTS) { if (attachcount > 0) { cout << "<font size=\"+2\"><u>"; cout << WEM_Attachments << "</u></font><br>"; if (ismime) { attachcount--; //lower count because last break gets counted } for (int loop = 1; loop <= attachcount; loop++) { cout << "<a href=\"" << "./attachments/"; cout << cleanfilename(attachname[loop]+10); if (ismime) cout << "?mdisattch=" << number << "x"; else cout << "?disattch=" << number << "x"; cout << loop << "\">"; cout << attachname[loop]+10; cout << "</a><br>"; delete(attachname[loop]); } cout << "<br>"; } } tail(); bothunlock(mailstore); fclose(mailstore); //sends receipt if (sendreceipt == 1 && domarkold == 1) { FILE * out; out = popen(SENDMAIL, "w"); if (out != NULL) //if an error has occurred do not report it. { removereturn(receiptaddress+19); fprintf(out, "To: %s\n", receiptaddress+19); if (gotsubject == 1) { removereturn(subject+9); fprintf(out, "Subject: Receipt: %s\n", subject+9); } else fprintf(out, "Subject: Receipt\n"); //sending Return-Path FILE *returnfile; char returnpath[400]; char returnaddr[400]; snprintf(returnpath, 400, "%s/.webmail/return",info->pw_dir); returnfile = fopen(returnpath, "r"); if (returnfile != NULL && USERRETURN) { for (int i = 0; i < 400; i++) { returnaddr[i] = fgetc(returnfile); if (returnaddr[i] == EOF) { returnaddr[i] = '\0'; break; } } fclose(returnfile); fprintf(out, "Reply-to: <%s>\n", returnaddr); fprintf(out, "From: %s\n", returnaddr); } else { if (HOSTMODE == 2) //defined { fprintf(out, "Reply-to: <%s@%s>\n", info->pw_name, HOSTNAME); fprintf(out, "From: %s@%s\n", info->pw_name, HOSTNAME); } else if (HOSTMODE == 1) //httpd { char *host; if ((host = getenv("SERVER_NAME")) != NULL) { fprintf(out, "Reply-to: <%s@%s>\n", info->pw_name, host); fprintf(out, "From: %s@%s\n", info->pw_name, host); } else fprintf(out, "From: %s\n", info->pw_name); } else //Use sendmail { fprintf(out, "From: %s\n", info->pw_name); } } fprintf(out, "\n"); fprintf(out, "Your message has been delivered.\n"); if (pclose(out) != 0) { } sync(); //needed or markold will erase the receipt, to yourself only. } } cout << "</body></HTML>" << endl; if (domarkold == 1) markold(number); return;}void deleteinbox(){ char *env; int mailnum; char mailbox[400]; passwd *info; if ((env = getenv("QUERY_STRING"))==NULL) { disjavascript("", "delete error", "menu"); return; } mailnum = atoi(env+7); info=getpwnam(globaluser); snprintf(mailbox, 400, MAILBOXPATH); deletemail(mailbox, mailnum); disjavascript("", "Mail deleted", "menu");}void multidelinbox(){}void multideletemailinbox(vector<int>& todel){}void showinboxattach(){// not used char *env; char *env2; int loop = 16; int attachnum; int mailnum; char mailbox[400]; passwd *info; if ((env = getenv("QUERY_STRING"))==NULL) { disjavascript("?menusaved", "Attach display error", "menu"); return; } while (env[loop] != '\0') { if (env[loop] == 'x') { env[loop] = '\0'; env2=env+loop+1; } loop++; } attachnum = atoi(env2); mailnum = atoi(env+16); info=getpwnam(globaluser); snprintf(mailbox, 400, "%s/.webmail/saved", info->pw_dir); showattachment(mailbox, mailnum, attachnum); }void viewhtml(){ char *env; int number; passwd *info; FILE *mailstore; char filename[400]; char data[500]; int count = 0; int offofheader = 0; int domarkold = 1; if ((env = getenv("QUERY_STRING"))==NULL) { menu(); return; } number = atoi(env+9); info=getpwnam(globaluser); snprintf(filename, 400, MAILBOXPATH); mailstore = fopen(filename, "r"); if (mailstore == NULL) { error("viewhtml():ERROR while tring to read mail file"); return; } if (bothlock(mailstore, 'r')!=0) { fclose(mailstore); error("viewhtml():error while locking read mail file"); return; } cout << "content-type: text/HTML" << endl; cout << "Pragma: No-Cache" << endl << endl; cout << "<html><head>" << endl; cout << "<title>Web E-Mail</title>" << endl; cout << "<META HTTP-EQUIV=\"expires\" content=\"0\">" << endl; cout << "</head>" << endl; cout << "<body text=\"#000000\" bgcolor=\"#FFFFFF\" link=\"#0000EF\" vlink=\"#0000EF\" alink=\"#FF0000\" background=/email/bg1.gif>"; header(WEM_HTML_View);//cout << "<a href=\"" << EMAILPATH << "?addname=" << number << "\">" << WEM_Add_address << "</a> "; //cout << "<a href=\"" << EMAILPATH << "?reply=" << number << "\">" << WEM_Reply << "</a> ";//cout << "<a href=\"" << EMAILPATH << "?forward=" << number << "\">" << WEM_Forward << "</a><br>"; cout << "<a href=\"" << EMAILPATH << "?read=" << number << "\">" << WEM_Normal_View << "</a> "; cout << "<a href=\"" << EMAILPATH << "?viewprint=" << number << "\">" << "Printable view" << "</a> ";//cout << "<a href=\"" << EMAILPATH << "?delete=" << number << "\">" << WEM_Delete << "</a>"; cout << "<br><br>" << endl; while (fgets(data, 499, mailstore) != NULL) { if (strncmp(data, "From ", 5)==0) { count++; } if (count == number) { while (fgets(data, 499, mailstore) !=NULL) { if (strncmp(data, "From ", 5)==0) break; if (data[0] == '\n') offofheader = 1; if (offofheader == 0) { if (strncasecmp(data, "Status: R", 9) == 0) { domarkold =0; } /*if (strncasecmp(data,"From:", 5)==0 || strncasecmp(data, "To:", 3) == 0 || strncasecmp(data, "Subject:",8)==0 || strncasecmp(data, "Date:", 5)==0 || strncasecmp(data, "cc: ", 4)==0) { cout << data; }*/ } else { cout << data; } } break; } } cout << "<br><br>" << endl; tail(); cout << "</body></HTML>" << endl; bothunlock(mailstore); fclose(mailstore); if (domarkold == 1) markold(number); return;}void printableview(){ char *env; int number; FILE *mailstore; char filename[400]; char data[500]; passwd *info; int count = 0; int offofheader = 0; int extenddata = 0; if ((env = getenv("QUERY_STRING"))==NULL) { menu(); return; } number = atoi(env+10); info=getpwnam(globaluser); snprintf(filename, 400, MAILBOXPATH); mailstore = fopen(filename, "r"); if (mailstore == NULL) { error("printableview():ERROR while tring to read mail file"); return; } if (bothlock(mailstore, 'r')!=0) { fclose(mailstore); error("printableview():Error locking mail file"); return; } cout << "content-type: text/plain" << endl; cout << "Pragma: no-cache" << endl << endl; while (fgets(data, 499, mailstore) != NULL) { if (strncmp(data, "From ", 5)==0) { count++; } if (count == number) { while (fgets(data, 499, mailstore) !=NULL) { if (strncmp(data, "From ", 5)==0) break; if (data[0] == '\n') offofheader = 1; if (offofheader == 0) { if (strncasecmp(data,"From: ", 6)==0 || strncasecmp(data, "To: ", 4) == 0 || strncasecmp(data, "Date: ", 6)==0 || strncasecmp(data, "cc: ", 4)==0 || strncasecmp(data, "Reply-To: ", 10)==0 || strncasecmp(data, "Subject: ",9)==0 || strncasecmp(data, "Return-Receipt-To:",18)==0) { extenddata = 1; cout << data; } else if (extenddata == 1 && strncasecmp(data, " ",8)==0) { cout << data; } else //turn off extenddata { extenddata = 0; } } else { cout << data; } } break; } } bothunlock(mailstore); fclose(mailstore); return;}void mdisattch(){ char *env; char *env2; int loop = 16; int attachnum; int mailnum; char mailbox[400]; passwd *info; if ((env = getenv("QUERY_STRING"))==NULL) { disjavascript("?menusaved", "Attach display error", "menu"); return; } while (env[loop] != '\0') { if (env[loop] == 'x') { env[loop] = '\0'; env2=env+loop+1; } loop++; } attachnum = atoi(env2); mailnum = atoi(env+10); info=getpwnam(globaluser); snprintf(mailbox, 400, MAILBOXPATH); mshowattachment(mailbox, mailnum, attachnum);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -