⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 email.cpp

📁 一个国外学生做的基于Web浏览器的email程序
💻 CPP
字号:
#include "webemail.h"#include "save.h"#include "sent.h"#include "inbox.h"#include "delete.h"#include "security.h"//ttd = things to do//Use old send() for ie 3.0char *SENDMAIL;int USEATTACHMENTS;int HOSTMODE;int FOUNDNAME;char *HOSTNAME;int USEQUOTAS;int MAX_MBOX_SIZE;int USEEXTERNMAIL;int USELINKHOME;char *LINKHOME;int USELINKHOMENAME;char *LINKHOMENAME;char globaluser[400];int USEISPHELP;char *ISPHELP;int USEAUTHORINFO;int USERRETURN;int ALLOWROOT;main(){	umask(066); //sets the mask	handlesignals(); //prevent early interuption	globaluser[0] = '\0';	doconfig(); //sets up webemail	int todo;	char line[400];	todo = status(line);	FILE *lockfile;	if (todo == 2) //no cookie but has pass and user name	{		if (setcookies(line) == 1)			menu();		else //cookies not set			intro();	}	else if (todo == 4) //reset cookies and goto intro	{		reset();		intro();	}	else if (verifycookies()==0)	{		lockfile = processlock();//		fprintf(stderr, "Starting webmail...");//		fprintf(stderr, "%i ", todo);//		char *f;//		f = getenv("REQUEST_METHOD");//		fprintf(stderr, "%s\n", f);		if (todo == 1) //has cookie no other action			menu();		else if (todo == 3) //cookie and sending mail			send();		else if (todo == 5) //wants to write			wewrite(0, "", 0);		else if (todo == 6) // display cfgstatus			cfgstatus();		else if (todo == 7) // read message			showinbox();		else if (todo == 8)			deleteinbox();		else if (todo == 9)			reply();		else if (todo == 10)			address();		else if (todo == 11)			addaddress("", -1);		else if (todo == 12)			addaddressproc();		else if (todo == 13)			removeaddr(-1);		else if (todo == 14)			sendto();		else if (todo == 15)			addredit();		else if (todo == 16)			readd();		else if (todo == 17)			addname();		else if (todo == 18)			gaddaddress(-1);		else if (todo == 19)			gaddaddressproc();		else if (todo == 20)			gaddrremove(-1);		else if (todo == 21)			gaddrsend();		else if (todo == 22)			gaddredit();		else if (todo == 23)			greadd();		else if (todo == 24)			about();		else if (todo == 25)			setup();		else if (todo == 26)			viewhtml();		else if (todo == 27)			distitle();		else if (todo == 28)			dismenu();		else if (todo == 29)			disinbox();		else if (todo == 30)		{	//prevents lock up on large files			processunlock(lockfile);			disattch();		}		else if (todo == 31)			disconf();		else if (todo == 32)			procconf();		else if (todo == 33 && USEEXTERNMAIL)		{	//needs to prevent a lock up			//if popcheck gets stuck			processunlock(lockfile);			popcheck();			return 0; 			//exit early so we don't unlock twice 		}		else if (todo == 34)			multidel();		else if (todo == 35)			forward();		else if (todo == 36)		{			printableview();		}		else if (todo == 37)			savefile();		else if (todo == 38)			dissaved();		else if (todo == 39)			showsaved();		else if (todo == 40)			deletesaved();		else if (todo == 41)			multidelsaved();		else if (todo == 42)			dissent();		else if (todo == 43)			showsent();		else if (todo == 44)			deletesent();		else if (todo == 45)			multidelsent();		else if (todo == 46)		{			processunlock(lockfile);			showsavedattach();		}		else if (todo == 47)		{			processunlock(lockfile);			showsentattach();		}		else if (todo == 48)		{			processunlock(lockfile);			mdisattch();		}		else if (todo == 49)		{			processunlock(lockfile);			mshowsavedattach();		}		else if (todo == 50)		{			processunlock(lockfile);			mshowsentattach();		}		else //has no cookies or pass/user			intro();//		fprintf(stderr, "%i", todo);//		fprintf(stderr, "....Stoping webmail\n\n");		processunlock(lockfile);	}	else		intro();	return 0;}void reset() //sends two cookies to reset the user and password cookies{	cout << "Set-cookie: EUSER=none; expires=Wednesday, 09-JAN-1980 23:00:00 GMT" << endl;	cout << "Set-cookie: EPASS=none; expires=Wednesday, 09-JAN-1980 23:00:00 GMT" << endl;//	cout << "Set-cookie: EUSER=none" << endl;//	cout << "Set-cookie: EPASS=none" << endl;//	cout << "Set-cookie: EUSER=none; expires=Sunday, 09-JAN-2000 23:00:00 GMT" << endl;//	cout << "Set-cookie: EPASS=none; expires=Sunday, 09-JAN-2000 23:00:00 GMT" << endl;	return;}int status(char line[400]) //choices what should happen{	char *env;	char userspace[100];	char *user;	if ((env = getenv("HTTP_COOKIE")) != NULL)	{		//check for problematic cookies		user = finddata(env, "EUSER=", userspace);		if (strncasecmp(userspace, "none", 4) == 0)		{			if (fgets(line, 399, stdin)!=NULL)			{				line[399] = '\0';				return 2; //getting pass from stdin			}			return 0; //intro screen			}		if ((env = getenv("QUERY_STRING")) != NULL)		{			if (strncmp(env, "send", 4) == 0)			{				return 3; //cookie & send mail					}				if (strncmp(env, "reset", 5) == 0)			{				return 4; //reset cookies			}			if (strncmp(env, "write", 5) == 0)			{				return 5; //write			}			if (strncmp(env, "cfgstatus", 9)==0)			{				return 6; //show cfgstatus			}			if (strncmp(env, "read=", 5)==0)			{				return 7; //wants to read an email message			}			if (strncmp(env, "delete=", 7)==0)			{				return 8; //delete a email message			}			if (strncmp(env, "reply=", 6)==0)			{				return 9; //reply to an email			}			if (strncmp(env, "book", 4)==0)			{				return 10; //goto addressbook			}			if (strncmp(env, "addtobook", 9)==0)			{				return 11; //add to addressbook			}			if (strncmp(env, "addproc", 7) == 0)			{				return 12; //proccess data to add to address book			}			if (strncmp(env, "addrdelete=", 11) == 0 )			{				return 13; //delete an address from the book			}			if (strncmp(env, "addrsend=", 9) == 0)			{				return 14; //send to selected user			}			if (strncmp(env, "addredit=", 9) == 0)			{				return 15; //edit an address			}			if (strncmp(env, "addreproc=", 10) == 0)			{				return 16; //add edited address			}			if (strncmp(env, "addname=", 8) == 0)			{				return 17; //add new address from email			}			if (strncmp(env, "gaddtobook", 10) == 0)			{				return 18; //add group address			}			if (strncmp(env, "gaddproc", 8) == 0)			{				return 19; //proc address			}			if (strncmp(env, "gaddrdelete=", 12) == 0)			{				return 20; //remove group address			}			if (strncmp(env, "gaddrsend=", 10) == 0)			{				return 21; //send to group			} 			if (strncmp(env, "gaddredit=", 10) == 0)			{				return 22; //edit group address			}			if (strncmp(env, "gaddreproc=", 11) == 0)			{				return 23; //readd group data			}			if (strncmp(env, "about", 5) == 0)			{				return 24; //about			}			if (strncmp(env, "wesetup", 7) == 0)			{				return 25; //run setup program			}			if (strncmp(env, "viewhtml=", 9) == 0)			{				return 26; //view e-mail in html mode			}			if (strncmp(env, "distitle", 8) == 0)			{				return 27; //view title			}			if (strncmp(env, "dismenu", 7) == 0)			{				return 28; //view menu			}			if (strncmp(env, "dismail", 7) == 0)			{				return 29; //view mail			}			if (strncmp(env, "disattch=", 9) ==0)			{				return 30; //view attachment			}			if (strncmp(env, "conf", 4)==0)			{				return 31; //view config menu			}			if (strncmp(env, "procconf", 8)==0)			{				return 32; //process conf			}			if (strncmp(env, "popcheck", 8)==0)			{				return 33; //check pop account			}			if (strncmp(env, "multidel", 8)==0)			{				return 34; //multidel			}			if (strncmp(env, "forward=", 8)==0)			{				return 35; //forward			}			if (strncmp(env, "viewprint=", 10)==0)			{				return 36; //printable view			}			if (strncmp(env, "save=", 5)==0)			{				return 37;  //saves mail			}			if (strncmp(env, "dissaved", 8)==0)			{				return 38;			}			if (strncmp(env, "showsaved=", 10)==0)			{				return 39;			}			if (strncmp(env, "deletesaved=", 12)==0)			{				return 40;			}			if (strncmp(env, "savedmultidel", 13)==0)			{				return 41;			} 			if (strncmp(env, "dissent", 7)==0)			{				return 42;			}			if (strncmp(env, "showsent=", 9)==0)			{				return 43;			}			if (strncmp(env, "deletesent=", 11)==0)			{				return 44;			}			if (strncmp(env, "sentmultidel", 12)==0)			{				return 45;			} 			if (strncmp(env, "showsavedattach=", 16)==0)			{				return 46;			} 			if (strncmp(env, "showsentattach=", 15)==0)			{				return 47;			} 			if (strncmp(env, "mdisattch=", 10)==0)			{				return 48;			} 			if (strncmp(env, "mshowsavedattach=", 17)==0)			{				return 49;			} 			if (strncmp(env, "mshowsentattach=", 16)==0)			{				return 50;			} 		}		return 1; //cookie only	}	if (fgets(line, 399, stdin)!=NULL)	{		line[399] = '\0';		return 2; //getting pass from stdin	}	return 0; //intro screen}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -