void main (int argc, char *argv[])
{
char *buf, *ptr;
FILE *fout;
int i, length, exchange = 1;
char board[20], title[100], username[20], passwd[20];
/* board[] from 15 to 20, changed by andrews */
char realfrom[20],bottomline[50]; /* add by triton */
length = atoi(getenv("CONTENT_LENGTH"));
ptr = buf = (char *)malloc(length + 1);
buf[length] = '\0';
fread(buf, sizeof(char), length, stdin);
strcpy(realfrom, getenv("REMOTE_ADDR")); /* add by triton */
read_form(buf, board, "board=", 20);
if(strstr(buf, "exchange=N") != NULL)
exchange = 0;
read_form(buf, title, "title=", 100);
read_form(buf, username, "username=", 20);
read_form(buf, passwd, "passwd=", 20);
if((buf = strstr(buf, "text=")) == NULL)
{
printf("Input error!\n");
exit(1);
}
else
buf += 5;
plustospace(buf);
unescape_url(buf);
if (username[0] != '\0' && passwd[0] != '\0')
{
/* fout = popen("/usr/lib/sendmail -f www-post@bbs bbs", "w"); */ /* rem b
y triton */
sprintf(bottomline,"/usr/lib/sendmail -f %s bbs",realfrom); /* add by trio
n */
fout = popen(bottomline, "w"); /* add by triton */
fprintf(fout, "#realfrom: %s\n", realfrom); /* add by triton */
fprintf(fout, "#name: %s\n", username);
fprintf(fout, "#password: %s\n", passwd);
fprintf(fout, "#board: %s\n", board);
fprintf(fout, "#title: %s\n", title);
if(exchange == 0)
fprintf(fout, "#localpost: \n");
fprintf(fout, "\n");
fputs(buf, fout);
pclose(fout);
}
free(ptr);
printf("Content-type: text/html\n\n\n");
printf("<html>\n");
printf("<head><title>Welcome to %sBBS</title>\n", SCHOOLSHORT);
printf("<meta http-equiv=Refresh content=\"5; url=/cgi-bin/bbsdoc?N%s\">\n",
board);
printf("<body background=\"%sbackground.gif\">\n", GIFSHOME);
printf("<P>您的文章现在正被送往BBS系统中,请等待片刻... </P>\n");
printf("<P>如果过会儿您没有在BBS上看到您的新文章,请检查您输入的讨论区名称、"
);
printf("用户名和口令是否正确。 过一会儿再试试看。</P>\n");
printf("</body></html>");
}
--
FROM oeswitch.hust.e