Example #1
0
int
bbsspam_main()
{
	int num;
	struct spamheader *sh = NULL;
	struct spamheader *sh1;
	uint16_t spamnum;
	struct yspam_ctx *yctx;
	unsigned long long mid;
	char midbuf[100];
	int ret;

	if ((!loginok || isguest) && (!tempuser)) 
		http_fatal("您尚未登录, 请先登录");
	html_header(1);
	changemode(RMAIL);
	printf("<body><center>\n");
	printf("%s -- 垃圾信件列表 [使用者: %s]\n", BBSNAME, currentuser->userid);
	yctx = yspam_init("127.0.0.1");
	ret = yspam_getallspam(yctx, currentuser->userid, &sh, &spamnum);
	yspam_fini(yctx);
	if (ret < 0 && ret != -YSPAM_ERR_NOSUCHMAIL) {
		if (sh)
			free(sh);
		http_fatal("内部错误 1");
	}
	printf("共有 %d 封垃圾邮件", spamnum);
	printf("<table>");
	printf
	    ("<tr><td>序号</td><td>发信人</td><td>日期</td><td>信件标题</td></tr>\n");
	sh1 = sh;
	for (num = 1; num <= spamnum; num++) {
		mid = ((unsigned long long)ntohl(sh1->mailid_high) << 32) + ntohl(sh1->mailid_low);
		sprintf(midbuf, "%llu", mid);
		printf("<tr><td>%d</td><td>%s</td><td>%12.12s</td><td><a href=bbsspamcon?id=%s&magic=%d>", num, void1(titlestr(sh1->sender)), Ctime(ntohl(sh1->time)) + 4, midbuf, ntohl(sh1->magic));
		if (sh1->title[0] == 0)
			printf("无题");
		else
			printf("%s", void1(titlestr(sh1->title)));
		printf("</a></td></tr>");
		sh1++;
	}
	if (sh)
		free(sh);
	printf("</table>");
	http_quit();
	return 0;
}
Example #2
0
int
bbsdelmail_main()
{
	int fd;
	struct fileheader f;
	struct fileheader *fhmw, *fhw;
	char path[80], file[80], *ptr, list[40][20], fullpath[256];
	int num, ndelfile = 0;
	struct stat st;
	int count;
	int wcount, wstart;
	int spam;
	struct yspam_ctx *yctx;
	html_header(1);
	//check_msg();
	if (!loginok || isguest)
		http_fatal("您尚未登录");
	changemode(RMAIL);

	spam=atoi(getparm("spam"));
	strsncpy(list[ndelfile], getparm("file"), 20);
	if (list[ndelfile][0] == 'M')
		ndelfile++;
	for (num = 0; num < 40 && ndelfile < 40; num++) {
		sprintf(file, "F%d", num);
		strsncpy(list[ndelfile], getparm(file), 20);
		if (list[ndelfile][0] == 'M' || list[ndelfile][0] == 'G')
			ndelfile++;
	}
	
	if(-2==get_mailsize(currentuser)){
		errlog("strange user %s",currentuser->userid);
		http_fatal("邮箱内部错误! 请联系系统维护!");
	}

	setmailfile(path, currentuser->userid, ".DIR");
	fd = open(path, O_RDWR);
	if (fd < 0)
		http_fatal("错误的参数2");
	flock(fd, LOCK_EX);
	fstat(fd, &st);
	if (st.st_size % sizeof (struct fileheader) != 0) {
		flock(fd, LOCK_UN);
		close(fd);
		return -1;
	}
	fhmw = malloc(st.st_size);
	if (fhmw == NULL) {
		flock(fd, LOCK_UN);
		close(fd);
		return -1;
	}
	fhw = fhmw;
	count = 0;
	wstart = -1;
	wcount = 0;
	yctx = yspam_init("127.0.0.1");
	while (read(fd, &f, sizeof (struct fileheader)) == sizeof (struct fileheader)) {
		count++;
		ptr = fh2fname(&f);
		for (num = 0; num < ndelfile; num++) {
			if (!strcmp(ptr, list[num]))
				break;
		}
		if (num == ndelfile) {
			if (wstart == -1)
				continue;
			memcpy(fhw, &f, sizeof (struct fileheader));
			wcount++;
			fhw++;
		} else {
			if (wstart == -1)
				wstart = count - 1;
			if (!f.filetime)
				continue;
			setmailfile(fullpath, currentuser->userid, fh2fname(&f));
			update_mailsize_down(&f, currentuser->userid);
			if (spam && yspam_feed_spam(yctx, currentuser->userid, fh2fname(&f)) == 0) {
				unlink(fullpath);
				continue;
			}
			deltree(fullpath);
		}
	}
	yspam_fini(yctx);
	if (wstart != -1) {
		ftruncate(fd, (wstart + wcount) * sizeof (struct fileheader));
		if (wcount > 0) {
			lseek(fd, wstart * sizeof (struct fileheader), SEEK_SET);
			write(fd, fhmw, wcount * sizeof (struct fileheader));
		}
	}
	free(fhmw);
	flock(fd, LOCK_UN);
	close(fd);
	printf("信件已删除.<br><a href=bbsmail>返回所有信件列表</a>\n");
	printf("<script>top.f4.location.reload();</script>");
	http_quit();
	return 0;
}
Example #3
0
int
bbsspamcon_main()
{
	unsigned long long id;
	int magic;
	char title[60], sender[40];
	char path[256];
	char idbuf[100];
	int ret;
	int feedham;
	struct yspam_ctx *yctx;
	if ((!loginok || isguest) && (!tempuser))
		http_fatal("请先登录%d", tempuser);
	changemode(RMAIL);
	id = strtoull(getparm("id"), NULL, 10);
	magic = atoi(getparm("magic"));
	feedham = atoi(getparm("feed"));
	
	if (feedham) {
		html_header(1);
		printf("<body><center>\n");
		yctx = yspam_init("127.0.0.1");
		ret =yspam_feed_ham(yctx, currentuser->userid, id, magic);
		yspam_fini(yctx);
		if (ret == 0)
			printf("成功");
		else
			printf("真失败 %d",ret);
		printf("<br><a href=bbsspam>返回垃圾邮件列表</a>");
		printf("</center></body>\n");
		http_quit();
	}
	snprintf(path, sizeof(path), MY_BBS_HOME"/maillog/%llu.bbs", id);
	if (*getparm("attachname") == '/') {
		showbinaryattach(path);
		return 0;
	}
	html_header(1);
	yctx = yspam_init("127.0.0.1");
	ret = yspam_getspam(yctx, currentuser->userid, id, magic, title, sender);
	yspam_fini(yctx);
	if (ret < 0) {
		printf("%d", ret);
		http_quit();
		http_fatal("内部错误");	
	}
	printf("<body><center>\n");
	printf("%s -- 垃圾信件 [使用者: %s]<hr>\n", BBSNAME, currentuser->userid);
	if (title[0] == 0)
		printf("</center>标题: 无题<br>");
	else
		printf("</center>标题: %s<br>", void1(titlestr(title)));
	printf("发信人: %s<br>", void1(titlestr(sender)));
	printf("<center>");
	showcon(path);
	sprintf(idbuf, "%llu", id);
	printf("这不是一封垃圾邮件,<a onclick='return confirm(\"这封信真的不是垃圾邮件吗?您的准确判断将有助于我们改善系统\")' href=bbsspamcon?id=%s&magic=%d&feed=1>请还给我</a><br>", idbuf, magic);
	printf("<a href=bbsspam>返回垃圾邮件列表</a>");
	printf("</center></body>\n");
	http_quit();
	return 0;
}