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

📄 display.cpp.save

📁 一个国外学生做的基于Web浏览器的email程序
💻 SAVE
📖 第 1 页 / 共 2 页
字号:
	{		snprintf(returnname, 400, "%s/.webmail/return", info->pw_dir);		returnfile = fopen(returnname, "r");		if (returnfile != NULL)		{			for (int i = 0; i < 500; i++)			{				returnaddr[i] = fgetc(returnfile);				if (returnaddr[i] == EOF)				{					returnaddr[i] = '\0';					break;				}			}			fclose(returnfile);		}	}	snprintf(signname, 400, "%s/.signature", info->pw_dir);	sign = fopen(signname, "r");	if (sign != NULL)	{		for (int i = 0; i < 500; i++)		{			signdata[i] = fgetc(sign);			if (signdata[i] == EOF)			{				signdata[i] = '\0';				break;			}		}		fclose(sign);	}	if(USEEXTERNMAIL)	{		snprintf(poppath, 400, "%s/.fetchmailrc", info->pw_dir);		popfile = fopen(poppath, "r");		if (popfile != NULL)		{			fgets(popdata, 400, popfile);			if (finddata(popdata, "popuser=", popuser) == NULL)			{				nopop = 1;			}			if (finddata(popdata, "poppass=", poppass) == NULL)			{				nopop = 1;			}			if (finddata(popdata, "popserver=", popserver) == NULL)			{				nopop = 1;			}			fclose(popfile);		}		else			nopop = 1; //no .fetchmailrc		removereturn(poppass);	}	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>" << endl;		header(WEM_Configure);	cout << "<form Method=\"post\" action=\"./email.cgi?procconf\">" << endl;		cout << "<table WIDTH=\"100%\" NOSAVE >" << endl;	cout << "<tr NOSAVE>" << endl;	cout << "<td ALIGN=LEFT VALIGN=TOP NOSAVE><b>Forwarding:</b>" << endl;	cout << "<br><input type=text name=forward size=30 ";	cout << "value=\"" << forwarddata << "\"";	cout << "></td>" << endl;	cout << "<td ALIGN=LEFT VALIGN=TOP NOSAVE>" << endl;	cout << "<br>Enter an address, if you want your e-mail forwarded to another e-mail" << endl;	cout << "box.&nbsp; If you do not want your mail forwarded leave the box blank.&nbsp;" << endl;	cout << "(Note, forwarding must be enabled/supported by the server.&nbsp; Under" << endl;	cout << "linux this means procmail must be installed.)</td>" << endl;	cout << "</tr>" << endl;	cout << "<tr NOSAVE>" << endl;	cout << "<td><b>Signature:</b>" << endl;	cout << "<br><textarea wrap=virtual cols=30 rows=5 name=sign>";	cout << signdata;	cout << "</textarea></td>" << endl;	cout << "<td ALIGN=LEFT VALIGN=TOP NOSAVE>" << endl;	cout << "<br>The signature gets attached to the botton of every out going massage.&nbsp;" << endl;	cout << "If you would like to not have a signature, leave the box blank.</td>" << endl;	cout << "</tr>";	if (USEEXTERNMAIL)	{		cout << "<tr NOSAVE>" << endl;		cout << "<td ALIGN=LEFT VALIGN=TOP NOSAVE><b>Pop3 setup:</b>" << endl;		cout << "<br>User:&nbsp;<input type=text name=popuser size=25 value=\"";		if (nopop == 0)			cout << popuser;		cout <<"\">" << endl;		cout << "<br>Password:&nbsp;<input type=password name=poppass size=22 value=\"";		if (nopop == 0)			cout << poppass;		cout << "\">" << endl;		cout << "<br>Popserver:&nbsp;<input type=text name=popserver size=22 value=\"";		if (nopop == 0)			cout << popserver;		cout << "\"></td>" << endl;		cout << "<td ALIGN=LEFT VALIGN=TOP NOSAVE>" << endl;		cout << "<br>Fill in the boxes to the left if you wish to have web e-mail check" << endl;		cout << "another pop3 mail box.&nbsp; If you don't want webmail to get your pop" << endl;		cout << "mail, leave the first (user) box blank.&nbsp; (Note, Fetchmail must be" << endl;		cout << "installed on the server for this to work.)</td>" << endl;		cout << "</tr>" << endl;	}	if (USERRETURN)	{		cout << "<tr NOSAVE>" << endl;		cout << "<td ALIGN=LEFT VALIGN=TOP NOSAVE><b>Return address:</b>" << endl;		cout << "<br><input type=text name=userreturn size=25 value=\"";		cout << returnaddr;		cout <<"\">" << endl;		cout << "</td>" << endl;		cout << "<td ALIGN=LEFT VALIGN=TOP NOSAVE>" << endl;		cout << "<br>Fill in the boxes to the left if you wish to use an e-mail address" << endl;		cout << "other then the default." << endl;		cout << "</td></tr>" << endl;	}	cout << "</table>" << endl;	cout << "<input type=Submit value=\"Save\"><input type=reset value=" << WEM_Reset << "></form>" << endl;	tail();	cout << "</body>" << endl;	cout << "</html>" << endl;	return;}void disjavascript(char *url, char *message1, char *message2){	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 << "<script>window.location=\"" << EMAILPATH << url << "\"</script>";	cout << "<NOSCRIPT>" << message1 << ", click <a href=\"" << EMAILPATH << url << "\">here</a> ";	cout << "to return to the " << message2 << ".<br>";	cout << "To avoid seeing this message, enable javascript on your browser.</NOSCRIPT>";	cout << "</body>";	cout << "</html>";	return;}void popcheck(){	system("fetchmail -s 2> /dev/null 1> /dev/null"); //gets pop mail 	disjavascript("?dismail#bottom", "Mail checked", "mail list");}void multidel(){	char data;	char number[10];	vector <int> todel;	int i = 0;	int mark = 0;	int k =0;	while (1)	{		data = fgetc(stdin);		if (data == EOF)			break;		if (data == '=')		{			mark = 0;			number[k] = '\0';			k = 0;			//cout << atoi(number) << endl;			todel.push_back(atoi(number));		}				if (mark == 1)		{			number[k] = data;			k++;		}		if (data == 'm')		{			mark=1;			k=0;		}	}	multideletemail(todel);	return;}void multideletemail(vector<int>& todel){	passwd *info;	FILE *data;	FILE *tmp;	char dataname[400];	char tmpname[400];	char buf[500];	int number = 0;	int emailcount = 0;	int delme = 0;	info=getpwnam(globaluser);	snprintf(dataname, 400, MAILBOXPATH);	snprintf(tmpname, 400, "%s/.webmail/tmp", info->pw_dir);		data = fopen(dataname, "r");	if (data == NULL)	{		error("multideletemail():Error opening data for read");		return;	}	if (bothlock(data, 'r')!=0)	{		fclose(data);		error("multideletemail():Error locking data for read");		return;	}	tmp = fopen(tmpname, "w");	if (tmp == NULL)	{		error("multideletemail():error opening temp for write");		fclose(data);		return;	}	if (bothlock(tmp, 'w')!=0)	{		fclose(data);		fclose(tmp);		error("multideletemail():Error locking tmp for write");		return;	}	while (fgets(buf, 499, data) != NULL)	{		fputs(buf, tmp);	}	bothunlock(data);	fclose(data);	bothunlock(tmp);	fclose(tmp);	//rename(dataname, tmpname);	sync();	data = fopen(dataname, "w");	if (data == NULL)	{		error("multideletemail():Error opening data for write");		return;	}	if (bothlock(data, 'w')!=0)	{		fclose(data);		error("multideletemail():Error locking data for write");		return;	}	tmp = fopen(tmpname, "r");	if (tmp == NULL)	{		error("multideletemail():error opening temp for read");		fclose(data);		return;	}	if (bothlock(tmp, 'r')!=0)	{		fclose(data);		fclose(tmp);		error("multideletemail():Error locking temp for read");		return;	}		while (fgets(buf, 499, tmp) != NULL)	{		if (strncmp(buf, "From ", 5)==0)		{			emailcount++;			delme = 0;			for (int p = 0; p<todel.size();p++)			{				if (emailcount == todel[p])				{					delme = 1;				}			}		}		if (delme == 0)		{			fputs(buf, data);		}	}	bothunlock(tmp);	fclose(tmp);	bothunlock(data);	fclose(data);	remove(tmpname);	sync();	disjavascript("?dismail#bottom", "Mail deleted", "mail list");	return;}void escapeprint(char * data){	int i = 0;	while (data[i] != '\0')	{		if (data[i] == '<')			cout << "&lt;";		else if (data[i] == '>')			cout << "&gt;";		else if (data[i] == '&')			cout << "&amp;";		else if (data[i] == '\"')			cout << "&quot;";		else			cout << data[i];		i++;	}	return;}void forward(){	char *env;	int number = 0;	if ((env = getenv("QUERY_STRING")) == NULL)	{		error("forward(): ERROR! no environment");		return;	}	number = atoi(env+8);	wewrite(3, "", number);	return;}char* cleanfilename(char * data){	for (int i = 0; data[i] != '\0'; i++)	{		if (data[i] == '"' ||data[i] == '?' || data[i] == ' ')			data[i] = '_';	}	return data;}void doconfig(){	FILE *config;	char data[400];	config = fopen("/etc/webemail.conf", "r");	if (config == NULL)	{		error("doconfig(): No config file found.");		return;	}	//if (bothlock(config, 'r')!=0)	//{	//	fclose(config);	//	error("doconfig():Error locking config file");	//	return;	//}	USEATTACHMENTS = 0;	HOSTMODE = 3; //1=httpd, 2=define, 3=sendmail	FOUNDNAME=0;  //used by define	USEQUOTAS = 0;	MAX_MBOX_SIZE = 0;	int gotquotasize = 0;	USEEXTERNMAIL = 0;	USELINKHOME = 0;	USELINKHOMENAME = 0;	USEISPHELP=0;	USEAUTHORINFO=0;	USERRETURN=0;	ALLOWROOT=0;	SENDMAIL = new char[400];	strncpy(SENDMAIL, "/usr/sbin/sendmail -t -i > /dev/null", 400);	while(fgets(data, 400, config)!=NULL)	{		if (strncasecmp(data, "Attachments ", 12) == 0)		{			if (strncasecmp(data+12, "on", 2) == 0)			{				USEATTACHMENTS = 1;			}		}		else if (strncasecmp(data, "AllowRootLogins ", 16) == 0)		{			if (strncasecmp(data+16, "on", 2) == 0)			{				ALLOWROOT = 1;			}		}		else if (strncasecmp(data, "SendMailPath ", 13) ==0)		{			strncpy(SENDMAIL, data+13, 400);		} 		else if (strncasecmp(data, "UserDefineableReturn ", 21) ==0)		{			if (strncasecmp(data+21, "on", 2) == 0)			{				USERRETURN=1;			}		} 		else if (strncasecmp(data, "GetHostName ", 12) == 0)		{			if (strncasecmp(data+12, "httpd", 5)==0)			{				HOSTMODE=1;			}			else if (strncasecmp(data+12, "define", 6)==0)			{				HOSTMODE=2;			}			else if (strncasecmp(data+12, "Sendmail", 8)==0)			{				HOSTMODE=3;			}			else			{			}		}		else if (strncasecmp(data, "DefineHostName ", 15) == 0)		{			FOUNDNAME=1;			removereturn(data+15);			HOSTNAME = new char[strlen(data+15)+1];			strncpy(HOSTNAME, data+15, strlen(data+15)+1);			}		else if (strncasecmp(data, "DefineLinkHome ", 15) == 0)		{			USELINKHOME=1;			removereturn(data+15);			LINKHOME = new char[strlen(data+15)+1];			strncpy(LINKHOME, data+15, strlen(data+15)+1);			}		else if (strncasecmp(data, "DefineLinkHomeName ", 19) == 0)		{			USELINKHOMENAME=1;			removereturn(data+19);			LINKHOMENAME = new char[strlen(data+19)+1];			strncpy(LINKHOMENAME, data+19, strlen(data+19)+1);			}		else if (strncasecmp(data, "UseQuotas ", 10) == 0)		{			if (strncasecmp(data+10, "on", 2) == 0)			{				USEQUOTAS = 1;			}		}		else if (strncasecmp(data, "QuotaSize ", 10) == 0)		{			MAX_MBOX_SIZE = atoi(data+10);			gotquotasize = 1;		}		//else if (strncasecmp(data, "SendMailPath ", 13) == 0)		//{		//}		else if (strncasecmp(data, "UseExternMail ", 14) == 0)		{			if (strncasecmp(data+14, "on", 2) == 0)			{				USEEXTERNMAIL = 1;			}		}		else if (strncasecmp(data, "UseAuthorInfo ", 14) == 0)		{			if (strncasecmp(data+14, "on", 2) == 0)			{				USEAUTHORINFO = 1;			}		}		else if (strncasecmp(data, "DefineISPHelp ", 14) == 0)		{			USEISPHELP=1;			removereturn(data+14);			ISPHELP = new char[strlen(data+14)+1];			strncpy(ISPHELP, data+14, strlen(data+14)+1);			}		else		{		} 	}	//some tests	if (HOSTMODE == 2 && FOUNDNAME == 0)	{		HOSTMODE = 3;	} 	if (USEQUOTAS == 1 && gotquotasize == 0)	{		USEQUOTAS = 0;	}	//bothunlock(config);	fclose(config);	return;}

⌨️ 快捷键说明

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