Exemplo n.º 1
0
void spell_check_continue()
{
const char *filename=cgi("draftmessage");
unsigned parnum=atol(cgi("row"));
unsigned pos=atol(cgi("col"));
char	*draftfilename;

	CHECKFILENAME(filename);
	draftfilename=maildir_find(DRAFTS, filename);
	if (!draftfilename)
	{
		output_form("folder.html");
		return;
	}

	if (search_spell(draftfilename, parnum, pos) &&
		*cgi("continue"))
		output_form("spellchk.html");
	else
	{
		cgi_put("draft", cgi("draftmessage"));
		cgi_put("previewmsg","SPELLCHK");
		output_form("newmsg.html");
	}
	free(draftfilename);
}
Exemplo n.º 2
0
void spell_show()
{
const char *draftmessage=cgi("draftmessage");
struct ispell_misspelled *msp;
struct ispell_suggestion *isps;
size_t	p, l=strlen(ispellline), n;
const char *ignorelab=getarg("IGNORE");
const char *ignorealllab=getarg("IGNOREALL");
const char *replacelab=getarg("REPLACE");
const char *replacealllab=getarg("REPLACEALL");
const char *insertlab=getarg("INSERT");
const char *continuelab=getarg("CONTINUE");
const char *finishlab=getarg("FINISH");

	if (!ispellptr)	enomem();

	if (!ignorelab)		ignorelab="";
	if (!ignorealllab)	ignorealllab="";
	if (!replacelab)	replacelab="";
	if (!replacealllab)	replacealllab="";
	if (!continuelab)	continuelab="";
	if (!finishlab)		finishlab="";

	for (msp=ispellptr->first_misspelled; msp; msp=msp->next)
		if (msp->misspelled_word)	break;
	if (!msp)	enomem();

	CHECKFILENAME(draftmessage);

	printf("<INPUT TYPE=HIDDEN NAME=form VALUE=\"spellchk\">\n");
	printf("<INPUT TYPE=HIDDEN NAME=pos VALUE=\"%s\">\n", cgi("pos"));
	if (*cgi("globignore"))
	{
		printf("<INPUT TYPE=HIDDEN NAME=globignore VALUE=\"");
		output_attrencoded(cgi("globignore"));
		printf("\">\n");
	}
	if (*cgi("globreplace"))
	{
		printf("<INPUT TYPE=HIDDEN NAME=globreplace VALUE=\"");
		output_attrencoded(cgi("globreplace"));
		printf("\">\n");
	}

	printf("<INPUT TYPE=HIDDEN NAME=draftmessage VALUE=\"");
	output_attrencoded(draftmessage);
	printf("\">");
	printf("<INPUT TYPE=HIDDEN NAME=row VALUE=\"%u\"><INPUT TYPE=HIDDEN NAME=col VALUE=\"%u\"><INPUT TYPE=HIDDEN NAME=word VALUE=\"",
		(unsigned)paragraph,
		(unsigned)msp->word_pos);
	output_attrencoded(msp->misspelled_word);

	printf("\"><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=1 "
	       "CLASS=\"box-small-outer\"><TR><TD>");
	printf("<TABLE BORDER=0 CELLSPACING=0 CLASS=\"spellcheck-background\"><TR><TD>");

	printf("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=8 CLASS=\"spellcheck-excerpt\"><TR><TD ALIGN=CENTER><TT><FONT COLOR=\"#000000\" class=\"spellcheck-excerpt\">");

	if (msp->word_pos > 30)
	{
		p=msp->word_pos-30;
		for (n=p; n<msp->word_pos; n++)
			if (ispellline[n] == ' ')
			{
				while (n < p && ispellline[n] == ' ')
					++n;
				p=n;
				break;
			}
		printf("...&nbsp;");
	}
	else
		p=0;
	filter_start(FILTER_FOR_DISPLAY, &showfunc);
	filter(ispellline+p, msp->word_pos-p);
	filter_end();
	printf("<B>");
	filter_start(FILTER_FOR_DISPLAY, &showfunc);
	filter(ispellline+msp->word_pos, strlen(msp->misspelled_word));
	filter_end();
	printf("</B>");
	p=msp->word_pos+strlen(msp->misspelled_word);
	if (l-p < 30)
	{
		n=l-p;
	}
	else	n=30;

	while (n)
	{
		if (ispellline[n+p] != ' ')
		{
			--n;
			continue;
		}
		while (n && ispellline[n+p-1] == ' ')
			--n;
		break;
	}
	filter_start(FILTER_FOR_DISPLAY, &showfunc);
	filter(ispellline+p, n);
	filter_end();
	if (n != l-p)
		printf("&nbsp;...");
	printf("</FONT></TT></TD></TR></TABLE><BR>");
	printf("<TABLE BORDER=1 CELLPADDING=8 CLASS=\"spellcheck-main\"><TR><TD>");

	printf("<TABLE BORDER=0><TR><TD>");
	for (isps=msp->first_suggestion; isps; isps=isps->next)
	{
		printf("<TR><TD>%s</TD><TD><INPUT BORDER=0 TYPE=RADIO NAME=REPLACE VALUE=\"%s\"></TD><TD>%s</TD></TR>\n",
			replacelab,
			isps->suggested_word,
			isps->suggested_word);
		replacelab=" ";
	}
	printf("<TR><TD>%s</TD><TD><INPUT BORDER=0 TYPE=RADIO NAME=REPLACE VALUE=\"#other\"></TD><TD><INPUT TYPE=TEXT NAME=OTHER WIDTH=20></TD></TR>\n",
		replacelab);
	printf("<TR><TD> </TD><TD><INPUT BORDER=0 TYPE=RADIO NAME=REPLACE VALUE=\"#insert\"></TD><TD>%s</TD></TR>\n",
		insertlab);

	printf("<TR><TD> </TD><TD><INPUT BORDER=0 TYPE=CHECKBOX NAME=REPLACEALL></TD><TD>%s</TD></TR>\n",
		replacealllab);
	printf("<TR><TD> </TD><TD COLSPAN=2><HR WIDTH=\"100%%\"></TD></TR>\n");
	printf("<TR><TD> </TD><TD><INPUT BORDER=0 TYPE=RADIO NAME=REPLACE VALUE=\"#ignore\"></TD><TD>%s</TD></TR>\n",
		ignorelab);
	printf("<TR><TD> </TD><TD><INPUT BORDER=0 TYPE=RADIO NAME=REPLACE VALUE=\"#ignoreall\"></TD><TD>%s</TD></TR>\n",
		ignorealllab);
	printf("</TABLE>");
	printf("</TD></TR></TABLE><BR>");
	printf("<TABLE BORDER=1 CELLPADDING=8 CLASS=\"spellcheck-continue\"><TR><TD>");
	printf("<INPUT TYPE=SUBMIT NAME=\"continue\" VALUE=\"%s\">\n",
			continuelab);
	printf("<INPUT TYPE=SUBMIT NAME=\"finish\" VALUE=\"%s\">\n",
			finishlab);
	printf("</TD></TR></TABLE>\n");
	printf("</TD></TR></TABLE>\n");
	printf("</TD></TR></TABLE>\n");
}
Exemplo n.º 3
0
Arquivo: newmsg.c Projeto: zixia/wmail
void newmsg_do(const char *folder)
{
const	char *draftmessage=cgi("draftmessage");

	if (*draftmessage)	/* It's ok if it's blank */
	{
		CHECKFILENAME(draftmessage);
	}

	if (*cgi("savedraft"))
	{
	char	*newdraft=newmsg_createdraft(draftmessage);

		if (!newdraft)	enomem();
		free(newdraft);
		sendmsg_done();
		return;
	}

	if (*cgi("sendmsg") && dosendmsg(draftmessage))
		return;

	if (*cgi("doattachments"))
	{
	char	*newdraft=newmsg_createdraft(draftmessage);
	char	*base;

		if (!newdraft)	enomem();
		if (*cgi("error"))
		{
			cgi_put("previewmsg", "1");
			output_form("newmsg.html");
			return;
		}

		base=maildir_basename(newdraft);
		http_redirect_argss("&form=attachments&pos=%s&draft=%s",
			cgi("pos"), base);
		free(base);
		free(newdraft);
		return;
	}
#ifdef	ISPELL
	if (*cgi("startspellchk"))
	{
	char	*newdraft=newmsg_createdraft(draftmessage);
	char	*base;

		if (!newdraft)	enomem();
		base=maildir_basename(newdraft);
		free(newdraft);
		if (spell_start(base) == 0)
		{
			cgi_put("draftmessage", base);
			output_form("spellchk.html");
		}
		else
		{
			http_redirect_argss("&form=newmsg&pos=%s&draft=%s&previewmsg=SPELLCHK",
				cgi("pos"), base);
		}
		free(base);
		return;
	}
#endif
	if (*ispreviewmsg()||cgi("return"))
	{
		output_form("newmsg.html");
		return;
	}
	http_redirect_argsss("&form=newmsg&pos=%s&draftmessage=%s&error=%s",
		cgi("pos"), draftmessage,
		cgi("error"));
}
Exemplo n.º 4
0
Arquivo: newmsg.c Projeto: zixia/wmail
void newmsg_init(const char *folder, const char *pos)
{
	const char	*tolab=getarg("TOLAB");
	const char	*cclab=getarg("CCLAB");
	const char	*bcclab=getarg("BCCLAB");
	const char	*subjectlab=getarg("SUBJECTLAB");
	const char	*messagelab=getarg("MESSAGELAB");
	const char	*sendlab=getarg("SENDLAB");
	const char	*previewlab=getarg("PREVIEWLAB");
	const char	*forwardsep=getarg("FORWARDLAB");
	const char	*savedraft=getarg("SAVEDRAFT");
	const char	*uploadlab=getarg("UPLOAD");
	const char	*attachedlab=getarg("ATTACHMENTS");
	const char	*replysalutation=getarg("SALUTATION");
	const char	*checkspellingdone=getarg("SPELLCHECKDONE");
	const char	*checkspelling=getarg("CHECKSPELLING");
	const char	*quotaerr=getarg("QUOTAERR");
	const char	*fromlab=getarg("FROMLAB");
	const char	*replytolab=getarg("REPLYTOLAB");
	const char	*addressbooklab=getarg("ADDRESSBOOK");
	char	*draftmessage;
	char	*draftmessagefilename;
	const	char *p;
	FILE	*fp;
	int	attachcnt=0;
	char	*cursubj, *curto, *curcc, *curbcc, *curfrom, *curreplyto;

	/* Picking up an existing draft? */

	p=cgi("draft");
	if (*p)
	{
		CHECKFILENAME(p);
	}

	if (*p)
	{
		draftmessage=strdup(p);
		if (!draftmessage)	enomem();
		p="";
	}
	else
	{
		draftmessage=newmsg_newdraft(folder, pos,
			forwardsep, replysalutation);

		if (!draftmessage)
		{
			if (*ispreviewmsg())
			{
				p=cgi("draftmessage");
				if (*p)
				{
					CHECKFILENAME(p);
				}
				draftmessage=newmsg_createdraft(p);
			}
		}
	}

	draftmessagefilename= draftmessage ?
				 maildir_find(DRAFTS, draftmessage):0;

	if (*(p=cgi("previewmsg")))
	{
#ifdef	ISPELL
		if (strcmp(p, "SPELLCHK") == 0)
			printf("%s<BR><BR>\n", checkspellingdone);
#endif
		printf("<TABLE WIDTH=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=1 CLASS=\"box-small-outer\"><TR><TD>\n");
		printf("<TABLE WIDTH=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=4 CLASS=\"preview\"><TR><TD>\n");

		if (draftmessagefilename)
		{
			const char *p=strrchr(draftmessagefilename, '/');

			if (p)
				++p;
			else
				p=draftmessagefilename;

			newmsg_preview(p);
		}
		printf("</TD></TR></TABLE>\n");
		printf("</TD></TR></TABLE>\n");

		printf("<TABLE WIDTH=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=6><TR><TD><HR WIDTH=\"80%%\"></TD></TR></TABLE>\n");
	}

	printf("<INPUT TYPE=HIDDEN NAME=form VALUE=\"donewmsg\">\n");
	newmsg_hiddenheader("pos", pos);
	newmsg_hiddenheader("focusto",
			    *cgi("newmsg") ? "headers":"text");

	/* Generate unique message token, to detect duplicate SUBMITs */

	tokennew();

	/* Display any error message */

	if (*cgi("foldermsg"))
	{
		printf("<P><FONT CLASS=\"error\" COLOR=\"#FF0000\">");
		output_attrencoded_nltobr(cgi("foldermsg"));
		printf("</FONT><BR>");
	}

	if (strcmp(cgi("error"), "quota") == 0)
		printf("%s", quotaerr);

	/* Read message from the draft file */

	cursubj=0;
	curto=0;
	curfrom=0;
	curreplyto=0;
	curcc=0;
	curbcc=0;
	fp=0;

	if (draftmessagefilename)
	{
	int	x=maildir_safeopen(draftmessagefilename, O_RDONLY, 0);

		if (x >= 0)
			if ((fp=fdopen(x, "r")) == 0)
				close(x);
	}

	if (fp != 0)
	{
	char *header, *value;

		while ((header=maildir_readheader(fp, &value, 0)) != 0)
		{
		char	**rfchp=0;

			if (strcmp(header, "subject") == 0)
			{
				if (!cursubj && !(cursubj=strdup(value)))
					enomem();
				continue;
			}

			if (strcmp(header, "from") == 0)
				rfchp= &curfrom;
			if (strcmp(header, "reply-to") == 0)
				rfchp= &curreplyto;
			if (strcmp(header, "to") == 0)
				rfchp= &curto;
			if (strcmp(header, "cc") == 0)
				rfchp= &curcc;
			if (strcmp(header, "bcc") == 0)
				rfchp= &curbcc;
			if (rfchp)
			{
			char	*newh=malloc ( (*rfchp ? strlen(*rfchp)+2:1)
					+strlen(value));

				if (!newh)	enomem();
				strcpy(newh, value);
				if (*rfchp)
					strcat(strcat(newh, ","), *rfchp);
				if (*rfchp)	free( *rfchp );
				*rfchp=newh;
			}
		}
	}

	//printf("<TABLE WIDTH=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=1 CLASS=\"box-small-outer\"><TR><TD>\n");
	printf("<TABLE WIDTH=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=4 CLASS=\"new-message-box\"><TR><TD>\n");

	printf("<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=1 WIDTH=\"100%%\">\n");
	/* by lfan
	if (access(NOCHANGINGFROM, 0))
		newmsg_header(fromlab, "headerfrom", curfrom ? curfrom:
			*cgi("from") ? cgi("from"):
			pref_from && *pref_from ? pref_from:
			login_fromhdr());

	printf("<TR VALIGN=MIDDLE><TH ALIGN=RIGHT>"
	       "<P CLASS=\"new-message-header\">"
	       "<FONT CLASS=\"new-message-header-addressbook\">"
	       "%s</FONT></TD><TD WIDTH=6>&nbsp;</TH>",
	       addressbooklab);
	*/
	printf("<TR VALIGN=MIDDLE><TD ALIGN=RIGHT CLASS=\"new-message-header\">"
	       "%s</TD><TD WIDTH=6>&nbsp;</TD>",
	       addressbooklab);

	printf("<TD VALIGN=MIDDLE>");
	printf("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0>");
	//printf("<TR VALIGN=MIDDLE><TD><SELECT NAME=\"nick\" SIZE=4 MULTIPLE>\n");
	printf("<TR VALIGN=MIDDLE><TD><SELECT NAME=\"nick\">\n");
	ab_listselect();
	printf("</select></TD><TD WIDTH=\"100%%\">");
	printf(" &nbsp;<input type=submit class=mybtn name=\"addressbook_to\" value=\"%s\">",
			tolab);
	printf(" <input type=submit class=mybtn name=\"addressbook_cc\" value=\"%s\">",
			cclab);
	printf(" <input type=submit class=mybtn name=\"addressbook_bcc\" value=\"%s\">",
			bcclab);
	printf("</TD></TR></TABLE>");

	printf("</TD></TR>\n");
	newmsg_header(tolab, "headerto", curto ? curto:cgi("to"));
	newmsg_header(cclab, "headercc", curcc ? curcc:cgi("cc"));
	newmsg_header(bcclab, "headerbcc", curbcc ? curbcc:cgi("bcc"));
	// by lfan
	//newmsg_header(replytolab, "headerreply-to", curreplyto ? curreplyto:cgi("replyto"));
	newmsg_header(subjectlab, "headersubject", cursubj ? cursubj:cgi("subject"));

	if (curto)	free(curto);
	if (curfrom)	free(curfrom);
	if (curreplyto)	free(curreplyto);
	if (curcc)	free(curcc);
	if (curbcc)	free(curbcc);
	if (cursubj)	free(cursubj);

	printf("<TR><TD COLSPAN=3><HR WIDTH=\"100%%\"></TD></TR>");
	/* by lfan
	printf("<TR><TH VALIGN=TOP ALIGN=RIGHT>"
			
	       "<P CLASS=\"new-message-header\">"
	       "<FONT CLASS=\"new-message-header-message\">"
	       "%s</FONT></P></TD><TD WIDTH=6>&nbsp;</TD>", messagelab);
	*/
	printf("<TR><TD WIDTH=60 VALIGN=TOP ALIGN=RIGHT CLASS=\"ctype\">"
	       "%s</TD><TD WIDTH=6>&nbsp;</TD>", messagelab);

	printf("<TD><TEXTAREA NAME=message COLS=%d ROWS=15 WRAP=soft>",
		MYLINESIZE);

	if (fp)
	{
		newmsg_showfp(fp, &attachcnt);
	}
	else
	{
		printf("%s", cgi("body"));
		if ((fp=fopen(SIGNATURE, "r")) != NULL)
		{
		char	buf[256];
		int	n;

			printf("\n\n");
			while ((n=fread(buf, 1, sizeof(buf)-1, fp)) > 0)
			{
				buf[n]=0;
				output_attrencoded_oknl(buf);
			}
			fclose(fp);
			fp=NULL;
		}
	}
	printf("</TEXTAREA><BR>\n");

	if (draftmessage && *draftmessage)
	{
		printf("<INPUT TYPE=HIDDEN NAME=draftmessage VALUE=\"");
		output_attrencoded(draftmessage);
		printf("\">");
	}
	if (draftmessage)	free(draftmessage);
	printf("</TD></TR>\n");

	//by lfan
	printf("<TR><TD>&nbsp;</TD><TD>&nbsp;</TD><TD>");

	printf("<INPUT TYPE=CHECKBOX "
	       "NAME=fcc%s><FONT class=ctype>%s</FONT>&nbsp;\n",
	       pref_noarchive ? "":" CHECKED",
	       getarg("PRESERVELAB"));

	if (access(NODSN, R_OK))
		printf("<TR><TD COLSPAN=2 ALIGN=RIGHT><INPUT TYPE=CHECKBOX "
		       "NAME=dsn></TD><TD>%s</TD></TR>\n",
		       getarg("DSN"));

#if HAVE_SQWEBMAIL_UNICODE
	if (has_gpg(GPGDIR) == 0)
	{
		char *all_addr;

		printf("<TR><TD COLSPAN=2 ALIGN=RIGHT><INPUT TYPE=CHECKBOX "
		       "NAME=sign></TD><TD>%s<SELECT NAME=signkey>",
		       getarg("SIGNLAB"));
		gpgselectkey();
		printf("</SELECT></TD></TR>\n");

		all_addr=newmsg_alladdrs(fp);

		printf("<TR VALIGN=MIDDLE><TD COLSPAN=2 ALIGN=RIGHT>"
		       "<INPUT TYPE=CHECKBOX NAME=encrypt></TD>"
		       "<TD><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 VALIGN=MIDDLE><TR><TD>%s</TD><TD><SELECT SIZE=4 MULTIPLE NAME=encryptkey>",
		       getarg("ENCRYPTLAB"));
		gpgencryptkeys(all_addr);
		printf("</SELECT></TD></TR>\n");
		printf("</TABLE></TD></TR>\n");

		if (ishttps())
			printf("<TR><TD COLSPAN=2 ALIGN>&nbsp;</TD><TD>%s<input type=password name=passphrase></TD></TR>\n",
			       getarg("PASSPHRASE"));

		if (all_addr)
			free(all_addr);
	}
#endif

	if (fp)
		fclose(fp);
	if (draftmessagefilename)
		free(draftmessagefilename);

	//printf("<TR><TD COLSPAN=2>&nbsp;</TD><TD>");
	//printf("<INPUT CLASS=mybtn TYPE=SUBMIT NAME=previewmsg VALUE=\"%s\">",
	//	previewlab);
	printf("<INPUT CLASS=mybtn TYPE=SUBMIT NAME=sendmsg onclick=\"return check();\" VALUE=\"%s\">&nbsp;",
		sendlab);
	printf("<INPUT CLASS=mybtn TYPE=SUBMIT NAME=previewmsg VALUE=\"%s\">&nbsp;",
		previewlab);
	printf("<INPUT CLASS=mybtn TYPE=SUBMIT NAME=savedraft VALUE=\"%s\">&nbsp;",
		savedraft);

        printf("<INPUT CLASS=\"mybtn\" TYPE=SUBMIT NAME=doattachments VALUE=\"");
	printf(uploadlab);
	printf("\">&nbsp;");
	printf(attachedlab, attachcnt);
	
#ifdef	ISPELL
	printf("<INPUT TYPE=SUBMIT NAME=startspellchk VALUE=\"%s\">",
		checkspelling);
#endif
	printf("</TD></TR>\n");
	printf("</TD></TABLE>\n");

	printf("</TD></TR></TABLE>\n");
	//printf("</TD></TR></TABLE>\n");
}
Exemplo n.º 5
0
void newmsg_init(const char *folder, const char *pos)
{
	const char	*tolab=getarg("TOLAB");
	const char	*cclab=getarg("CCLAB");
	const char	*bcclab=getarg("BCCLAB");
	const char	*subjectlab=getarg("SUBJECTLAB");
	const char	*messagelab=getarg("MESSAGELAB");
	const char	*sendlab=getarg("SENDLAB");
	const char	*previewlab=getarg("PREVIEWLAB");
	const char	*forwardsep=getarg("FORWARDLAB");
	const char	*savedraft=getarg("SAVEDRAFT");
	const char	*attachmentslab=getarg("ATTACHMENTS");
	const char      *uploadlab=getarg("UPLOAD");
	const char	*replysalutation=getarg("SALUTATION");
	const char	*checkspellingdone=getarg("SPELLCHECKDONE");
	const char	*checkspelling=getarg("CHECKSPELLING");
	const char	*quotaerr=getarg("QUOTAERR");
	const char	*fromlab=getarg("FROMLAB");
	const char	*replytolab=getarg("REPLYTOLAB");
	const char	*addressbooklab=getarg("ADDRESSBOOK");
	const char	*select1=getarg("SELECT1");
	const char	*select2=getarg("SELECT2");
	const char	*text1=getarg("TEXT1");
	const char	*text2=getarg("TEXT2");
	char	*draftmessage;
	char	*draftmessagefilename;
	const	char *p;
	FILE	*fp;
	int	attachcnt=0;
	char	*cursubj, *curto, *curcc, *curbcc, *curfrom, *curreplyto;
	int wbnochangingfrom;

	/* Picking up an existing draft? */

	p=cgi("draft");
	if (*p)
	{
		CHECKFILENAME(p);
	}

	if (*p)
	{
		draftmessage=strdup(p);
		if (!draftmessage)	enomem();
		p="";
	}
	else
	{
		draftmessage=newmsg_newdraft(folder, pos,
			forwardsep, replysalutation);

		if (!draftmessage)
		{
			if (*ispreviewmsg())
			{
				p=cgi("draftmessage");
				if (*p)
				{
					CHECKFILENAME(p);
				}
				draftmessage=newmsg_createdraft(p);
			}
		}
	}

	draftmessagefilename= draftmessage ?
				 maildir_find(INBOX "." DRAFTS, draftmessage):0;

	if (*(p=cgi("previewmsg")))
	{
#ifdef	ISPELL
		if (strcmp(p, "SPELLCHK") == 0)
			printf("%s<br /><br />\n", checkspellingdone);
#endif
		printf("<table width=\"100%%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\" class=\"box-small-outer\"><tr><td>\n");
		printf("<table width=\"100%%\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\" class=\"preview\"><tr><td>\n");

		if (draftmessagefilename)
		{
			const char *p=strrchr(draftmessagefilename, '/');

			if (p)
				++p;
			else
				p=draftmessagefilename;

			newmsg_preview(p);
		}
		printf("</td></tr></table>\n");
		printf("</td></tr></table>\n");

		printf("<table width=\"100%%\" border=\"0\" cellspacing=\"0\" cellpadding=\"6\"><tr><td><hr width=\"80%%\" /></td></tr></table>\n");
	}

	printf("<input type=\"hidden\" name=\"form\" value=\"donewmsg\" />\n");
	newmsg_hiddenheader("pos", pos);
	newmsg_hiddenheader("focusto",
			    *cgi("newmsg") ? "headers":"text");

	/* Generate unique message token, to detect duplicate SUBMITs */

	tokennew();

	/* Display any error message */

	if (*cgi("foldermsg"))
	{
		printf("<p><span class=\"error\" style=\"color: #ff0000\">");
		output_attrencoded_nltobr(cgi("foldermsg"));
		printf("</span></p>");
	}

	if (strcmp(cgi("error"), "quota") == 0)
		printf("%s", quotaerr);

	/* Read message from the draft file */

	cursubj=0;
	curto=0;
	curfrom=0;
	curreplyto=0;
	curcc=0;
	curbcc=0;
	fp=0;

	if (draftmessagefilename)
	{
	int	x=maildir_safeopen(draftmessagefilename, O_RDONLY, 0);

		if (x >= 0)
			if ((fp=fdopen(x, "r")) == 0)
				close(x);
	}

	if (fp != 0)
	{
	char *header, *value;

		while ((header=maildir_readheader(fp, &value, 0)) != 0)
		{
		char	**rfchp=0;

			if (strcmp(header, "subject") == 0)
			{
				if (!cursubj && !(cursubj=strdup(value)))
					enomem();
				continue;
			}

			while (*value && isspace(*value))
				++value;

			if (strcmp(header, "from") == 0)
				rfchp= &curfrom;
			if (strcmp(header, "reply-to") == 0)
				rfchp= &curreplyto;
			if (strcmp(header, "to") == 0)
				rfchp= &curto;
			if (strcmp(header, "cc") == 0)
				rfchp= &curcc;
			if (strcmp(header, "bcc") == 0)
				rfchp= &curbcc;
			if (rfchp)
			{
			char	*newh=malloc ( (*rfchp ? strlen(*rfchp)+2:1)
					+strlen(value));

				if (!newh)	enomem();
				strcpy(newh, value);
				if (*rfchp)
					strcat(strcat(newh, ","), *rfchp);
				if (*rfchp)	free( *rfchp );
				*rfchp=newh;
			}
		}
	}

	printf("<table width=\"100%%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\" class=\"box-small-outer\"><tr><td>\n");
	printf("<table width=\"100%%\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\" class=\"new-message-box\"><tr><td>\n");

	printf("<table border=\"0\" width=\"100%%\">\n");
	wbnochangingfrom=auth_getoptionenvint("wbnochangingfrom");
	if (wbnochangingfrom < 2)
		newmsg_header_rfc822(fromlab, "headerfrom", curfrom,
			*cgi("from") ? cgi("from"):
			pref_from && *pref_from ? pref_from:
			login_fromhdr(), wbnochangingfrom ? 1:0);

	printf("<tr valign=\"middle\"><th align=\"right\">"
	       "<p class=\"new-message-header\">"
	       "<span class=\"new-message-header-addressbook\">"
	       "%s</span></p></th><td width=\"6\">&nbsp;</td>",
	       addressbooklab);

	printf("<td valign=\"middle\">");
	printf("<table border=\"0\" cellpadding=\"0\" cellspacing=\"4\">");
	printf("<tr valign=\"middle\"><td>%s\n", select1);
	ab_listselect();
	printf("%s</td><td width=\"100%%\">", select2);
	printf("<input type=\"submit\" name=\"addressbook_to\" value=\"%s\" />",
			tolab);
	printf("<input type=\"submit\" name=\"addressbook_cc\" value=\"%s\" />",
			cclab);
	printf("<input type=\"submit\" name=\"addressbook_bcc\" value=\"%s\" />",
			bcclab);
	printf("</td></tr></table>");

	printf("</td></tr>\n");

#if 0
			{
				FILE *fp;
				fp=fopen("/tmp/pid", "w");
				fprintf(fp, "%d", getpid());
				fclose(fp);
				sleep(10);
			}
#endif

	newmsg_header_rfc822(tolab, "headerto", curto, cgi("to"), 0);
	newmsg_header_rfc822(cclab, "headercc", curcc, cgi("cc"), 0);
	newmsg_header_rfc822(bcclab, "headerbcc", curbcc, cgi("bcc"), 0);
	newmsg_header_rfc822(replytolab, "headerreply-to",
			     curreplyto, cgi("replyto"), 0);
	newmsg_header(subjectlab, "headersubject",
		      cursubj, cgi("subject"));

	if (curto)	free(curto);
	if (curfrom)	free(curfrom);
	if (curreplyto)	free(curreplyto);
	if (curcc)	free(curcc);
	if (curbcc)	free(curbcc);
	if (cursubj)	free(cursubj);

	printf("<tr><td colspan=\"3\"><hr width=\"100%%\" /></td></tr>");
	printf("<tr>"

	       "<th valign=\"top\" align=\"right\">"
	       "<p class=\"new-message-header\">"
	       "<span class=\"new-message-header-message\">"
	       "%s</span></p></th><td width=\"6\">&nbsp;</td>"
	       "<td><select name=\"textformat\">"
	       "<option value=\"plain\" %s>%s</option>"
	       "<option value=\"wiki\" %s>%s</option></select>"

	       "<small>(<a href='%s/wikifmt.html' target='_blank'>%s</a>)</small>"
	       "</td></tr>"
	       "<tr><th valign=\"top\" align=\"right\">"
	       "<p class=\"new-message-header\">"
	       "<span class=\"new-message-header-message\">"
	       "%s</span></p></th><td width=\"6\">&nbsp;</td>",

	       getarg("FMTNAME"),
	       pref_wikifmt ? "":"selected='selected'", getarg("FMTTEXTPLAIN"),
	       pref_wikifmt ? "selected='selected'":"", getarg("FMTTEXTWIKI"),

	       get_imageurl(), getarg("FMTHELP"),
	       messagelab);

	printf("<td>%s\n", text1);

	if (fp)
	{
		newmsg_showfp(fp, &attachcnt);
	}
	else
	{
		printf("%s", cgi("body"));
	}
	printf("%s\n", text2);

	if (draftmessage && *draftmessage)
	{
		printf("<input type=\"hidden\" name=\"draftmessage\" value=\"");
		output_attrencoded(draftmessage);

		printf("\" />");
	}
	if (draftmessage)	free(draftmessage);
	printf("</td></tr>\n");

	printf("<tr><th valign=\"top\" align=\"right\">"
	       "<p class=\"new-message-header\">"
	       "<span class=\"new-message-header-message\">"
		"%s</span></p></th><td>&nbsp;</td>"
		"<td>%d&nbsp;&nbsp;<input type=\"submit\" name=\"doattachments\" value=\"%s\" /></td></tr>",
		attachmentslab, attachcnt, uploadlab);

	printf("<tr><td colspan=\"2\" align=\"right\"><input type=\"checkbox\" "
	       "name=\"fcc\" id=\"fcc\"%s /></td><td><label for=\"fcc\">%s</label></td></tr>\n",
	       pref_noarchive ? "":" checked=\"checked\"",
	       getarg("PRESERVELAB"));

	if (auth_getoptionenvint("wbnodsn") == 0)
		printf("<tr><td colspan=\"2\" align=\"right\"><input type=\"checkbox\" "
		       "name=\"dsn\" id=\"dsn\" /></td><td><label for=\"dsn\">%s</label></td></tr>\n",
		       getarg("DSN"));

	if (libmail_gpg_has_gpg(GPGDIR) == 0)
	{
		char *all_addr;

		printf("<tr><td colspan=\"2\" align=\"right\"><input type=\"checkbox\" "
		       "name=\"sign\" id=\"sign\" /></td><td><label for=\"sign\">%s</label><select name=\"signkey\">",
		       getarg("SIGNLAB"));
		gpgselectkey();
		printf("</select></td></tr>\n");

		all_addr=newmsg_alladdrs(fp);

		printf("<tr valign=\"middle\"><td colspan=\"2\" align=\"right\">"
		       "<input type=\"checkbox\" name=\"encrypt\" id=\"encrypt\" /></td>"
		       "<td><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr valign=\"middle\"><td><label for=\"encrypt\">%s</label></td><td><select size=\"4\" multiple=\"multiple\" name=\"encryptkey\">",
		       getarg("ENCRYPTLAB"));
		gpgencryptkeys(all_addr);
		printf("</select></td></tr>\n");
		printf("</table></td></tr>\n");

		if (ishttps())
			printf("<tr><td colspan=\"2\" align=\"left\">&nbsp;</td><td>%s<input type=\"password\" name=\"passphrase\" /></td></tr>\n",
			       getarg("PASSPHRASE"));

		if (all_addr)
			free(all_addr);
	}

	if (fp)
		fclose(fp);
	if (draftmessagefilename)
		free(draftmessagefilename);

	printf("<tr><td colspan=\"2\">&nbsp;</td><td>");
	printf("<input type=\"submit\" name=\"previewmsg\" value=\"%s\" />",
		previewlab);
	printf("<input type=\"submit\" name=\"sendmsg\" value=\"%s\" />",
		sendlab);
	printf("<input type=\"submit\" name=\"savedraft\" value=\"%s\" />",
		savedraft);
#ifdef	ISPELL
	printf("<input type=\"submit\" name=\"startspellchk\" value=\"%s\" />",
		checkspelling);
#endif
	printf("</td></tr>\n");
	printf("</table>\n");

	printf("</td></tr></table>\n");
	printf("</td></tr></table>\n");
}
Exemplo n.º 6
0
void spell_show()
{
const char *draftmessage=cgi("draftmessage");
struct ispell_misspelled *msp;
struct ispell_suggestion *isps;
size_t	p, l=strlen(ispellline), n;
const char *ignorelab=getarg("IGNORE");
const char *ignorealllab=getarg("IGNOREALL");
const char *replacelab=getarg("REPLACE");
const char *replacealllab=getarg("REPLACEALL");
const char *insertlab=getarg("INSERT");
const char *continuelab=getarg("CONTINUE");
const char *finishlab=getarg("FINISH");

	if (!ispellptr)	enomem();

	if (!ignorelab)		ignorelab="";
	if (!ignorealllab)	ignorealllab="";
	if (!replacelab)	replacelab="";
	if (!replacealllab)	replacealllab="";
	if (!continuelab)	continuelab="";
	if (!finishlab)		finishlab="";

	for (msp=ispellptr->first_misspelled; msp; msp=msp->next)
		if (msp->misspelled_word)	break;
	if (!msp)	enomem();

	CHECKFILENAME(draftmessage);

	printf("<input type=\"hidden\" name=\"form\" value=\"spellchk\" />\n");
	printf("<input type=\"hidden\" name=\"pos\" value=\"%s\" />\n", cgi("pos"));
	if (*cgi("globignore"))
	{
		printf("<input type=\"hidden\" name=\"globignore\" value=\"");
		output_attrencoded(cgi("globignore"));
		printf("\" />\n");
	}
	if (*cgi("globreplace"))
	{
		printf("<input type=\"hidden\" name=\"globreplace\" value=\"");
		output_attrencoded(cgi("globreplace"));
		printf("\" />\n");
	}

	printf("<input type=\"hidden\" name=\"draftmessage\" value=\"");
	output_attrencoded(draftmessage);
	printf("\" />");
	printf("<input type=\"hidden\" name=\"row\" value=\"%u\" /><input type=\"hidden\" name=\"col\" value=\"%u\" /><input type=\"hidden\" name=\"word\" value=\"",
		(unsigned)paragraph,
		(unsigned)msp->word_pos);
	output_attrencoded(msp->misspelled_word);

	printf("\" /><table border=\"0\" cellspacing=\"0\" cellpadding=\"1\" "
	       "class=\"box-small-outer\"><tr><td>");
	printf("<table border=\"0\" cellspacing=\"0\" class=\"spellcheck-background\"><tr><td>");

	printf("<table border=\"1\" cellspacing=\"0\" cellpadding=\"8\" class=\"spellcheck-excerpt\"><tr><td align=\"center\"><span style=\"color: #000000\" class=\"spellcheck-excerpt\">");

	if (msp->word_pos > 30)
	{
		p=msp->word_pos-30;
		for (n=p; n<msp->word_pos; n++)
			if (ispellline[n] == ' ')
			{
				while (n < p && ispellline[n] == ' ')
					++n;
				p=n;
				break;
			}
		printf("...&nbsp;");
	}
	else
		p=0;


	show_part(ispellline+p, msp->word_pos-p);
	printf("<strong>");
	show_part(ispellline+msp->word_pos, strlen(msp->misspelled_word));
	printf("</strong>");

	p=msp->word_pos+strlen(msp->misspelled_word);
	if (l-p < 30)
	{
		n=l-p;
	}
	else	n=30;

	while (n)
	{
		if (ispellline[n+p] != ' ')
		{
			--n;
			continue;
		}
		while (n && ispellline[n+p-1] == ' ')
			--n;
		break;
	}

	show_part(ispellline+p, n);

	if (n != l-p)
		printf("&nbsp;...");
	printf("</span></td></tr></table><br />");
	printf("<table border=\"1\" cellpadding=\"8\" class=\"spellcheck-main\"><tr><td>");

	printf("<table border=\"0\">");
	for (isps=msp->first_suggestion; isps; isps=isps->next)
	{
		printf("<tr><td>%s</td><td><input type=\"radio\" name=\"REPLACE\" value=\"%s\" /></td><td>%s</td></tr>\n",
			replacelab,
			isps->suggested_word,
			isps->suggested_word);
		replacelab=" ";
	}
	printf("<tr><td>%s</td><td><input type=\"radio\" name=\"REPLACE\" value=\"#other\" /></td><td><input type=\"text\" name=\"OTHER\" size=\"20\" /></td></tr>\n",
		replacelab);
	printf("<tr><td> </td><td><input type=\"radio\" name=\"REPLACE\" value=\"#insert\" /></td><td>%s</td></tr>\n",
		insertlab);

	printf("<tr><td> </td><td><input type=\"checkbox\" name=\"REPLACEALL\" /></td><td>%s</td></tr>\n",
		replacealllab);
	printf("<tr><td> </td><td colspan=\"2\"><hr width=\"100%%\" /></td></tr>\n");
	printf("<tr><td> </td><td><input type=\"radio\" name=\"REPLACE\" value=\"#ignore\" /></td><td>%s</td></tr>\n",
		ignorelab);
	printf("<tr><td> </td><td><input type=\"radio\" name=\"REPLACE\" value=\"#ignoreall\" /></td><td>%s</td></tr>\n",
		ignorealllab);
	printf("</table>");
	printf("</td></tr></table><br />");
	printf("<table border=\"1\" cellpadding=\"8\" class=\"spellcheck-continue\"><tr><td>");
	printf("<input type=\"submit\" name=\"continue\" value=\"%s\" />\n",
			continuelab);
	printf("<input type=\"submit\" name=\"finish\" value=\"%s\" />\n",
			finishlab);
	printf("</td></tr></table>\n");
	printf("</td></tr></table>\n");
	printf("</td></tr></table>\n");
}