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

📄 display.cpp

📁 一个国外学生做的基于Web浏览器的email程序
💻 CPP
📖 第 1 页 / 共 2 页
字号:
#include "webemail.h"void intro() //login screen{	char * browsertype;	if ((browsertype = getenv("HTTP_USER_AGENT"))==NULL)	{		error("intro(): error reading browser type");		return;	}	char *env;	if ((env = getenv("SERVER_NAME"))==NULL)	{		error("intro(): can't read env"); 		return;	}	cout << "content-type: text/HTML" << endl;	cout << "Pragma: No-Cache" << endl << endl;	cout << "<html>" << endl;	cout << "<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\"";	cout << " background=/email/bg1.gif>" << endl;	cout << "<table COLS=1 WIDTH=\"100%\" HEIGHT=\"100%\" NOSAVE >" << endl;	cout << "<tr NOSAVE>" << endl;	cout << "<td ALIGN=CENTER VALIGN=CENTER NOSAVE>" << endl;	cout << "<center>" << endl;	cout << "<p><b><font size=\"+4\">" << WEM_Web_E_Mail << "</font></b>\n";	if (HOSTMODE == 2) //use defined name;		cout << "<font size=-1><br>(" << HOSTNAME << ")<br></font>" << endl;	else if (HOSTMODE == 1)	//use httpds name	 	cout << "<font size=-1><br>(" << env << ")<br></font>" << endl;	else	//display no name;	{	}			cout << "<form method=post action=\"" << EMAILPATH << "\">" << WEM_User_ID << ":<input type=text name=user size=15>&nbsp;\n";	cout << WEM_Password << ":<input type=password name=pass size=15>\n";	cout << "<br><input type=submit value=" << WEM_Enter << "></form>" << endl;	if (USELINKHOME)	{		if (USELINKHOMENAME)		{			//cout << "<font size=\"+2\">";			cout << "<a href=\"" << LINKHOME << "\">" << LINKHOMENAME << "</a>";			//cout << "</font>";			cout << "<br>";		}		else		{			//cout << "<font size=\"+2\">";			cout << "<a href=\""<< LINKHOME << "\">Click here</a> to return home.";			//cout << "</font>";			cout << "<br>";		}	}	if (USEISPHELP)	{		cout << "<BR>";		cout << ISPHELP;		cout << "<br>";	}	if (USEAUTHORINFO)	{		cout << "<br>" << WEM_Written_by << " <a href=\"http://ashaw.dyn.cheapnet.net/webmail\">Andrew Shaw</a>\n";		cout << "<br>Best viewed with a 4.0 browser with javascript enabled." << endl;	}	//warn if browser is incompatible	if (strncmp(browsertype, "Konquerer/1", 11) == 0 ||	strncmp(browsertype, "Lynx/2", 6) == 0 ||	strncmp(browsertype, "Mozilla/3", 9) == 0 ||	strncmp(browsertype, "Mozilla/2", 9) == 0 ||	strncmp(browsertype, "Mozilla/1", 9) == 0 ||	strncmp(browsertype, "Lynx/1", 6) == 0)	{			cout << "<font color=\"#FF0000\">";		cout << "<br><br>Your browser does not pass the current system test!!!";		cout << "<br>Web e-mail may not work with your browser!!!";		cout << "</font>";	}	cout << "</center>" << endl;		cout << "</td></tr></table>" << endl;	cout << "</body>" << endl;	cout << "</html>" << endl;	return;}	void wewrite(int mode, char *email, int reply) //compose/reply screen{	//mode 0 = normal	//mode 1 = reply	//mode 2 = from address book	//mode 3 = forward	FILE *mailstore;	FILE *signature;	char signaturename[400];	char mailname[400];	passwd *info;	int count = 0;	char data[500];	char fromline[500];	char subjectline[500];	int fromfound = 0;	int subjectfound = 0;		info=getpwnam(globaluser);	snprintf(signaturename, 400, "%s/.signature", info->pw_dir);	if (mode == 1 || mode == 3)  //finds From:/subject				     //replying/forwarding 	{		snprintf(mailname, 400, MAILBOXPATH);		mailstore = fopen(mailname, "r");		if (mailstore == NULL)		{			error("wewrite():Error opening file!");				return;		}		if (bothlock(mailstore, 'r')!=0)		{			fclose(mailstore);			error("wewrite():Error locking file");			return;		}		while (fgets(data, 499, mailstore) != NULL)		{			if (strncmp(data, "From ", 5)==0)			{				count++;			}			if (count == reply)			{				if (strncasecmp(data, "From: ", 6)==0)				{					quotestospace(data);					commatospace(data);					strncpy(fromline, data, 499);					fromline[500] = '\0';					fromfound = 1;				}				if (strncasecmp(data, "Subject: ", 9)==0)				{					strncpy(subjectline, data, 499);					subjectline[500] = '\0';					subjectfound = 1;				}				if (strncmp(data, "\n", 1)==0 && fromfound == 1)				{					break;				}			}		}	}	cout << "content-type: text/HTML" << endl;	cout << "Pragma: No-Cache" << endl << endl;	cout << "<html>" << endl;	cout << "<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\" ";	cout << "vlink=\"#0000EF\" alink=\"#FF0000\" background=/email/bg1.gif>" << endl;		if (mode == 1)		header(WEM_Reply);	else if (mode == 3)		header("Forward");		else		header(WEM_Send);	cout << "<form EncType=\"Multipart/form-data\" Method=\"post\" action=\"" << EMAILPATH << "?send\">\n";	//TO:	if (fromfound == 1 && mode == 1)	{		removereturn(fromline+6);		cout << WEM_To << ":&nbsp;<input type=text name=to size=25 value=\"" << fromline+6 << "\">"; 	}	else if (mode == 2)	{		removereturn(email);		cout << WEM_To << ":&nbsp;<input type=text name=to size=25 value=\"" << email << "\">"; 				}	else		cout << WEM_To << ":&nbsp;<input type=text name=to size=25>"; 			cout << "&nbsp;" << WEM_Cc << ":&nbsp;<input type=text name=cc size=25>";	//second set of send buttons for convinence	cout << "&nbsp;&nbsp;&nbsp;";	cout << "<input type=Submit value=\"" << WEM_Send << "\">";	cout << "&nbsp;<input type=reset value=" << WEM_Reset << ">" << endl;	//Subject:	if (subjectfound == 1 && mode == 1)	{		cout << "<br>" << WEM_Subject << ":&nbsp;<input type=text name=subject ";		removereturn(subjectline);		cout << "size=50 value=\"Re: " << subjectline+9 << "\">";	}	else if (subjectfound == 1 && mode == 3)	{		cout << "<br>" << WEM_Subject << ":&nbsp;<input type=text name=subject ";		removereturn(subjectline);		cout << "size=50 value=\"fwd: " << subjectline+9 << "\">";	}	else		cout << "<br>" << WEM_Subject << ":&nbsp;<input type=text name=subject size=50>";		cout << "<br>" << WEM_Message << ":";	//TEXT AREA	cout << "<br><textarea wrap=hard cols=80 rows=20 name=message>";		if (mode == 1 || mode == 3)	{		cout << endl << endl;		int inattachment = 0;		while (fgets(data, 499, mailstore) != NULL)		{			if (strncmp(data, "From ", 5)==0)			{				count++;				break;			}			if (strncmp(data, "begin ", 6)==0)				inattachment=1;			if (count == reply)			{				if (inattachment == 0)					cout << ">" << data;				else 					cout << data;			}			if (strncmp(data, "end", 3) == 0)				inattachment=0;		}		bothunlock(mailstore);		fclose(mailstore);	}	signature = fopen(signaturename, "r");	if (signature != NULL)	{		if (bothlock(signature, 'r')==0)		{			cout << endl << endl;			while(fgets(data, 499, signature) != NULL)			{				cout << data;			}		}		bothunlock(signature);		fclose(signature);	}	cout << "</textarea>" << endl;	if (USEATTACHMENTS)	{		cout << "<br>" << WEM_Attachment << "<br>";		cout << "<input type=\"File\" name=\"fileupload\" size=\"50\">";		cout << "<br>Attach Method:&nbsp;";		cout << "<input type=\"Radio\" name=\"attachtype\" value=\"Mime\" Checked>";		cout << "Mime&nbsp;";		cout << "<input type=\"Radio\" name=\"attachtype\" value=\"Uuencode\" >";		cout << "Uuencode";		cout << "<br>" << WEM_AttachInfo;		cout << "<br>";	}	cout << "<br><input type=Submit value=\"" << WEM_Send << "\">";	cout << "&nbsp;<input type=reset value=" << WEM_Reset << ">" << endl;	cout << "&nbsp;&nbsp;&nbsp;";	cout << "<input type=Checkbox name=receipt>&nbsp;Request Receipt" << endl;	//if repling tell sending function!!!	if (mode == 1)	{	cout << "<input type=\"HIDDEN\" name=\"replied\" value=\"";		cout << reply;		cout << "\">";	}	else		cout << "<input type=\"HIDDEN\" name=\"replied\" value=\"0\">";	cout << endl;	cout << "<br></form>" << endl;	tail();	cout << "</body>" << endl;	cout << "</html>" << endl;	return;}	void menu() //main menu{	char *env;	cout << "Content-type: text/HTML" << endl;	cout << "Pragma: no-cache" << endl << endl;	cout << "<html>" << endl;	cout << "<head>" << endl;	cout << "<title>Web E-Mail</title>" << endl;	cout << "<META HTTP-EQUIV=\"expires\" content=\"0\">" << endl;	cout << "</head>" << endl;	cout << "<FRAMESET ROWS=\"35,*\" BORDER=\"0\">" << endl;	cout << "<NOFRAME>Sorry, your browser does not ";	cout << "support frames.  The current release of ";	cout << "Web E-Mail does not have a non frame version.</NOFRAME>";	cout << "<FRAME SRC=\"" << EMAILPATH << "?distitle\" NAME=\"TITLE\"";	cout << "MARGINHEIGHT=\"0\" MARGINWIDTH=\"0\" SCROLLING=\"NO\">";	cout << "<FRAMESET COLS=\"170,*\">";	cout << "<FRAME SRC=\"" << EMAILPATH << "?dismenu\" NAME=\"MENU\" ";	cout << "MARGINHEIGHT=\"0\" MARGINWIDTH=\"0\" SCROLLING=\"NO\">";	if ((env = getenv("QUERY_STRING")) != NULL)	{		if (strncmp(env, "menusaved", 9) == 0)                {			cout << "<FRAME SRC=\"" << EMAILPATH << "?dissaved#bottom\" NAME=\"MAIL\" ";			cout << "MARGINHEIGHT=\"0\" MARGINWIDTH=\"0\" SCROLLING=\"AUTO\">";		}		else if (strncmp(env, "menusent", 8) == 0)                {			cout << "<FRAME SRC=\"" << EMAILPATH << "?dissent#bottom\" NAME=\"MAIL\" ";			cout << "MARGINHEIGHT=\"0\" MARGINWIDTH=\"0\" SCROLLING=\"AUTO\">";		}		else		{			cout << "<FRAME SRC=\"" << EMAILPATH << "?dismail#bottom\" NAME=\"MAIL\" ";			cout << "MARGINHEIGHT=\"0\" MARGINWIDTH=\"0\" SCROLLING=\"AUTO\">";		}	}	else 	{		cout << "<FRAME SRC=\"" << EMAILPATH << "?dismail#bottom\" NAME=\"MAIL\" ";		cout << "MARGINHEIGHT=\"0\" MARGINWIDTH=\"0\" SCROLLING=\"AUTO\">";	}	cout << "</FRAMESET>" << endl;	cout << "</FRAMESET>" << endl;	cout << "</html>" << endl;	return;}void distitle(){	cout << "Content-type: text/HTML" << endl;	cout << "Pragma: No-Cache" << endl << endl;	cout << "<html>" << endl;	cout << "<head>" << endl;	cout << "<title>Web E-Mail</title>" << endl;	cout << "</head>" << endl;	cout << "<body text=\"#000000\" bgcolor=\"#FFFFFF\" link=\"#0000FF\" vlink=\"#0000FF\" alink=\"#FF0000\" background=/email/bg1.gif>";	cout << "<table CELLSPACING=0 CELLPADDING=0 COLS=2 WIDTH=\"100%\" NOSAVE >";	cout << "<tr NOSAVE>";	cout << "<td ALIGN=LEFT VALIGN=TOP NOSAVE>";	cout << "<img SRC=\"/email/title.gif\" ALT=\"";	cout << WEM_Web_E_Mail;	cout << "\" height=23 width=147 align=CENTER>" << endl;	cout << "<font size=-1>&nbsp;&nbsp;&nbsp;(";	cout << globaluser;	cout << ")</font>" << endl;	cout << "</td>";	cout << "<td ALIGN=RIGHT VALIGN=TOP NOSAVE>";	cout << "&lt;Folders: ";	cout << "<a href=\"" << EMAILPATH << "?dismail\" TARGET=MAIL>" << "InBox" << "</a>";	cout << "&nbsp;-&nbsp;";	cout << "<a href=\"" << EMAILPATH << "?dissaved\" TARGET=MAIL>" << "Saved" << "</a>";	cout << " - ";	cout << "<a href=\"" << EMAILPATH << "?dissent\" TARGET=MAIL>" << "Sent" << "</a>";	cout << " ></td>";	cout << "</tr></table>";	cout << "</body>" << endl;	cout << "</html>" << endl;	return;}void dismenu(){	char * env;	if ((env = getenv("HTTP_USER_AGENT"))==NULL)	{		error("dismenu(): error reading browser type");		return;	}	cout << "Content-type: text/HTML" << endl;	cout << "Pragma: no-cache" << endl << endl;	cout << "<html>" << endl;	cout << "<head>" << endl;	cout << "<title>Web E-Mail</title>" << endl;	cout << "</head>" << endl;	//checks for bad browsers	if (strncmp(env, "Konquerer/1", 11) == 0)		cout << "<body text=\"#000000\" bgcolor=\"#FFFFFF\" link=\"#000099\" vlink=\"#000099\" alink=\"#FF0000\" background=/email/bg1.gif>" << endl;	else		cout << "<body text=\"#000000\" bgcolor=\"#FFFFFF\" link=\"#FFFFFF\" vlink=\"#FFFFFF\" alink=\"#FF0000\" background=/email/bg1.gif>" << endl;	cout << "<table CELLSPACING=0 CELLPADDING=0 COLS=1 WIDTH=\"150\" HEIGHT=\"300\" BACKGROUND=\"/email/bk.gif\" NOSAVE >" << endl;	cout << "<tr ALIGN=LEFT VALIGN=TOP NOSAVE >" << endl;	cout << "<td NOSAVE><br>" << endl;	cout << "<table CELLSPACING=0 CELLPADDING=0 BACKGROUND=\"/email/none.gif\" NOSAVE >" << endl;	cout << "<tr NOSAVE>" << endl;	cout << "<td ALIGN=CENTER VALIGN=CENTER NOSAVE>" << endl;	cout << "<a href=\"" << EMAILPATH << "?write\" TARGET=_top>\n";	cout << "<img SRC=\"/email/compose.gif\" ALT=\"\" BORDER=0 height=17 width=11 align=ABSCENTER></a></td>" << endl;	cout << "<td NOSAVE><b><font color=\"#FFFFFF\">";	cout << "<a href=\"" << EMAILPATH << "?write\" TARGET=_top>" << WEM_Compose_Mail;	cout << "</a></font></b></td>" << endl;	cout << "</tr>" << endl;	cout << "<tr NOSAVE>" << endl;	cout << "<td ALIGN=CENTER VALIGN=CENTER NOSAVE>" << endl;	cout << "<a href=\"" << EMAILPATH << "?dismail\" TARGET=MAIL>";	cout << "<img SRC=\"/email/reload.gif\" ALT=\"\"" << endl;	cout << "BORDER=0 height=21 width=28 align=CENTER></a></td>" << endl;	cout << "<td><b><font color=\"#FFFFFF\">" << endl;	cout << "<a href=\"" << EMAILPATH << "?dismail\" TARGET=MAIL>" << WEM_Rescan_Mail_Box << "</a></font></b></td>\n";	cout << "</tr>" << endl;	cout << "<tr NOSAVE>" << endl;	cout << "<td ALIGN=CENTER VALIGN=CENTER NOSAVE>";	cout << "<a href=\"" << EMAILPATH << "?book\" TARGET=_top>" << endl;	cout << "<img SRC=\"/email/address.gif\" ALT=\"\"" << endl;	cout << "BORDER=0 height=16 width=22 align=CENTER></a></td>" << endl;	cout << "<td><b><font color=\"#FFFFFF\">";	cout << "<a href=\"" << EMAILPATH << "?book\" TARGET=_top>" << WEM_Address_Book << "</a>" << endl;	cout << "</font></b></td></tr>" << endl;	cout << "<tr NOSAVE>" << endl;	cout << "<td ALIGN=CENTER VALIGN=CENTER NOSAVE>" << endl;	cout << "<a href=\"" << EMAILPATH << "?conf\" TARGET=_top>" << endl;	cout << "<img SRC=\"/email/conf.gif\" ALT=\"\"" << endl;	cout << "BORDER=0 height=16 width=22 align=CENTER></a></td>" << endl;	cout << "<td><b><font color=\"#FFFFFF\">";	cout << "<a href=\"" << EMAILPATH << "?conf\" TARGET=_top>";	cout << WEM_Configure << "</a>" << endl;	cout << "</font></b></td></tr>" << endl;	cout << "<tr NOSAVE>" << endl;	cout << "<td ALIGN=CENTER VALIGN=CENTER NOSAVE>" << endl;	cout << "<a href=\"" << EMAILPATH << "?about\" TARGET=_top>" << endl;	cout << "<img SRC=\"/email/about.gif\" ALT=\"\"" << endl;	cout << "BORDER=0 height=16 width=22 align=CENTER></a></td>" << endl;	cout << "<td><b><font color=\"#FFFFFF\">" << endl;	cout << "<a href=\"" << EMAILPATH << "?about\" TARGET=_top>" << WEM_About << "</a>";	cout << "</font></b></td></tr>" << endl;	cout << "<tr NOSAVE>" << endl;	cout << "<td ALIGN=CENTER VALIGN=CENTER NOSAVE>" << endl;	cout << "<a href=\"" << EMAILPATH << "?reset\" TARGET=_top>" << endl;	cout << "<img SRC=\"/email/logout.gif\" ALT=\"\" BORDER=0 height=22 width=15 align=CENTER>";	cout << "</a></td>" << endl;	cout << "<td><b><font color=\"#FFFFFF\">";	cout << "<a href=\"" << EMAILPATH << "?reset\" TARGET=_top>" << endl;	cout << WEM_Logout << "</a></font></b></td>" << endl;	cout << "</tr>" << endl;	cout << "</table></td></tr></table>" << endl;		cout << "</body></html>" << endl;	return;}void disconf(){	FILE *sign;	FILE *forward;	char signname[400];	char signdata[500];	char forwardname[400];	char forwarddata[500];	signdata[0] = '\0';	forwarddata[0] = '\0';	//fetchmail	char popuser[400];	char poppass[400];	char popserver[400];	FILE *popfile;	char poppath[400];	char popdata[400];	int nopop = 0;	//return address	FILE *returnfile;	char returnaddr[400];	char returnname[400];	returnaddr[0] = '\0';	passwd *info;	info=getpwnam(globaluser);	snprintf(forwardname, 400, "%s/.forward", info->pw_dir);	forward = fopen(forwardname, "r");	if (forward != NULL)	{		for (int i = 0; i < 500; i++)		{			forwarddata[i] = fgetc(forward);			if (forwarddata[i] == EOF)			{				forwarddata[i] = '\0';				break;			}		}		fclose(forward);	}	if (USERRETURN)	{		snprintf(returnname, 400, "%s/.webmail/return", info->pw_dir);		returnfile = fopen(returnname, "r");

⌨️ 快捷键说明

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