Beispiel #1
0
int fix_title(struct fileheader *fh, int *fd) {
	struct fileheader fw;
	char *ptr;
	FILE *fp;
	char buf[1024];
	char title[60];
	memcpy(&fw, fh, sizeof(struct fileheader));
	fp=fopen(fh2fname(fh), "r");
	if (!fp)
		return 0;
	strncpy(title, fh->title,60);
	ptr=strstr(title, " - ");
	if (ptr)
		*ptr=0;
	while (fgets(buf, 1024, fp)) {
		if (!strncmp(buf, "Бъ  Ьт", 6)) {
			strncpy(title, buf+8, 60);
			break;
		}
	}
	fclose(fp);
	strncpy(fw.title, title,60);
	ptr=strchr(fw.title, '\n');
	if (ptr)
		*ptr=0;
	write(*fd, &fw, sizeof(struct fileheader));
	return 0;
}
Beispiel #2
0
int
bbsnewmail_main()
{
	FILE *fp;
	struct fileheader x;
	int total = 0, total2 = 0;
	char dir[80];
	if (!loginok || isguest)
		http_fatal("您尚未登录, 请先登录");
	sprintf(dir, "mail/%c/%s/.DIR", mytoupper(currentuser->userid[0]),
		currentuser->userid);

	if (cache_header(file_time(dir), 1))
		return 0;
	html_header(1);
	//check_msg();
	changemode(RMAIL);
//去掉了框架
	printf("<body topmargin=0 leftMargin=1 MARGINWIDTH=1 MARGINHEIGHT=0>" WWWLEFT_DIV);
	printf("<center>\n");
	printf
	    ("%s -- 未读邮件列表 [使用者: %s] [信箱容量: %dk, 已用空间: %dk]<hr>\n",
	     BBSNAME, currentuser->userid, max_mailsize(currentuser), get_mailsize(currentuser));
	fp = fopen(dir, "r");
	if (fp == 0)
		http_fatal("目前您的信箱没有任何信件");
	printf("<table border=1>\n");
	printf
	    ("<tr><td>序号</td><td>状态</td><td>发信人</td><td>日期</td><td>信件标题</td></tr>\n");
	while (1) {
		if (fread(&x, sizeof (x), 1, fp) <= 0)
			break;
		total++;
		if (x.accessed & FH_READ)
			continue;
		printf("<tr><td>%d</td><td>N</td>", total);
		printf("<td>%s</td>", userid_str(fh2owner(&x)));
		printf("<td>%6.6s</td>", Ctime(x.filetime) + 4);
		printf("<td><a href=bbsmailcon?file=%s&num=%d>", fh2fname(&x),
		       total - 1);
		if (strncmp("Re: ", x.title, 4))
			printf("★ ");
		hprintf("%42.42s", void1(x.title));
		printf(" </a></td></tr>\n");
		total2++;
	}
	fclose(fp);
	printf("</table><hr>\n");
	printf("您的信箱共有%d封信件, 其中新信%d封.", total, total2);
	printf("</center>");
	showfile(MY_BBS_HOME "/wwwtmp/googleanalytics");
//	printf("</body>");
	//修改框架,页面底部
	printf(WWWFOOT_DIV "</body></html>\n");
	http_quit();
	return 0;
}
Beispiel #3
0
int
bbsnewmail_main()
{	//modify by mintbaggio 20040829 for new www
	FILE *fp;
	struct fileheader x;
	int total = 0, total2 = 0;
	char dir[80];
	if (!loginok || isguest)
		http_fatal("您尚未登录, 请先登录");
	sprintf(dir, "mail/%c/%s/.DIR", mytoupper(currentuser.userid[0]),
		currentuser.userid);

	if(cache_header(file_time(dir),1))
		return 0;
	html_header(1);
	check_msg();
	changemode(RMAIL);
	printf("<body><center>\n");
	printf
	    ("<div class=rhead>%s -- 新邮件列表 [使用者: <span class=h11>%s</span>]<br>[信箱容量: <span class=h11>%d</span>k, 已用空间: <span class=h11>%dk</span>]</div><hr>\n",
	     BBSNAME, currentuser.userid, max_mail_size(), get_mail_size());
	fp = fopen(dir, "r");
	if (fp == 0)
		http_fatal("目前您的信箱没有任何信件");
	printf("<table border=1>\n");
	printf
	    ("<tr><td>序号</td><td>状态</td><td>发信人</td><td>日期</td><td>信件标题</td></tr>\n");
	while (1) {
		if (fread(&x, sizeof (x), 1, fp) <= 0)
			break;
		total++;
		if (x.accessed & FH_READ)
			continue;
		printf("<tr><td>%d</td><td>N</td>", total);
		printf("<td>%s</td>", userid_str(fh2owner(&x)));
		printf("<td>%6.6s</td>", Ctime(x.filetime) + 4);
		printf("<td><a href=bbsmailcon?file=%s&num=%d>", fh2fname(&x),
		       total - 1);
		if (strncmp("Re: ", x.title, 4))
			printf("★ ");
		hprintf("%42.42s", void1(x.title));
		printf(" </a></td></tr>\n");
		total2++;
	}
	fclose(fp);
	printf("</table><hr>\n");
	printf("您的信箱共有%d封信件, 其中新信%d封.", total, total2);
	printf("</center></body>");
	http_quit();
	return 0;
}
Beispiel #4
0
int
countfile(struct fileheader *fhdr, void *farg)
{
	int i, h;
	char *fname = fh2fname(fhdr);
	nindexitem++;
	if (fhdr->filetime == 0) {
		nstrangeitem++;
		return 0;
	}
	h = hash(fname);
	for (i = 0; i < nfile[h]; i++) {
		if (strcmp(allpost[h][i], fname))
			continue;
		refcount[h][i]++;
		break;
	}
	return 0;
}
Beispiel #5
0
int
save_lost(char *path)
{
	int i, h, total, totalref, lost, fd;
	char buf[MAXPATHLEN];
	struct fileheader fh;
	for (h = 0, total = 0, totalref = 0, lost = 0; h < HASHSIZE; h++) {
		total += nfile[h];
		for (i = 0; i < nfile[h]; i++) {
			totalref += refcount[h][i];
			if (!refcount[h][i]) {
				lost++;
				sprintf(buf, "%s/%s", path, allpost[h][i]);
				if (allpost[h][i][0] == 'M'
				    && makefileheader(buf, allpost[h][i],
						      &fh) == 0) {
					sprintf(buf, "%s/%s", path, ".DIR");
					fd = open(buf, O_WRONLY | O_APPEND);
					if (fd < 0) {
						printf
						    ("can't open .DIR for write");
						return -1;
					}
					write(fd, &fh, sizeof (fh));
					close(fd);
					printf("%s %s\n", fh2fname(&fh),
					       fh.title);
				}
			}
		}
	}
	allfile += total;
	allref += totalref;
	alllost += lost;
	printf(" total %d, refcount %d, %d file(s) was lost\n", total, totalref,
	       lost);
	if (strlen(otherfile) > 0)
		printf("%s\n", otherfile);
	return 0;
}
Beispiel #6
0
static int get_user_mail_size(char * userid)
{
	int currsize = 0;
	char currmaildir[STRLEN], tmpmail[STRLEN];
	struct fileheader tmpfh;
	FILE *fp;
	time_t t;

	sethomefile(tmpmail, userid, "msgindex");
	if(file_time(tmpmail))
		currsize += file_size_s(tmpmail);

	sethomefile(tmpmail, userid, "msgindex2");
	if(file_time(tmpmail))
		currsize += file_size_s(tmpmail);

	sethomefile(tmpmail, userid, "msgcontent");
	if(file_time(tmpmail))
		currsize += file_size_s(tmpmail);

	sprintf(currmaildir, "mail/%c/%s/%s", mytoupper(userid[0]), userid, DOT_DIR);
	t = file_time(currmaildir);
	if(!t)
		return (currsize/1024);

	fp = fopen(currmaildir, "r");
	if(!fp)
		return (currsize/1024);

	while(fread(&tmpfh, 1, sizeof(tmpfh), fp) == sizeof(tmpfh)) {
		setmailfile(tmpmail, userid, fh2fname(&tmpfh));
		currsize += file_size_s(tmpmail);
	}

	fclose(fp);
	return (currsize/1024);
}
Beispiel #7
0
int
get_mail(char *host, char *oboard, char *iboard)
{
	int fd;
	FILE *fp0;
	int i;
	struct sockaddr_in xs;
	struct hostent *he;
	char dir[80], file[80], buf[256], brk[80];
//      file: 本地文件名, buf: 临时变量, brk: 分隔符.

	servernow = host;

	do_log("gethostbyname %s", host);
	bzero((char *) &xs, sizeof (xs));
	xs.sin_family = AF_INET;
	if ((he = gethostbyname(host)) != NULL)
		bcopy(he->h_addr, (char *) &xs.sin_addr, he->h_length);
	else
		xs.sin_addr.s_addr = inet_addr(host);
	xs.sin_port = htons(PORT);
	do_log("connecting %s", host);
	fd = socket(AF_INET, SOCK_STREAM, 0);
	fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK);
	if (connect(fd, (struct sockaddr *) &xs, sizeof (xs)) < 0) {
		fd_set fds;
		struct timeval timeout;
		timeout.tv_sec = 10;
		timeout.tv_usec = 0;
		FD_ZERO(&fds);
		FD_SET(fd, &fds);
		if (select(fd + 1, NULL, &fds, NULL, &timeout) <= 0) {
			do_log("can't connect to %s", host);
			close(fd);
			return;
		}
		if (connect(fd, (struct sockaddr *) &xs, sizeof (xs)) < 0) {
			do_log("can't connect to %s", host);
			close(fd);
			return;
		}
	}
	fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_NONBLOCK);
	do_log("connected %s", host);
	fp0 = fdopen(fd, "r+");
	if (fgets(brk, 80, fp0) == 0)
		goto E;
	if (strlen(brk) < 10)
		goto E;
	fprintf(fp0, "select * from %s where dt < %d\n", oboard,
		time(0) - last);
	fflush(fp0);
	do_log("SEND request %s %d", oboard, time(0) - last);
	while (1) {
		FILE *fp;
		int t;
		struct fileheader x;
		char owner[256];
		bzero(&x, sizeof (x));
		do_log("reading...");
		if (fgets(x.title, sizeof (x.title), fp0) == 0)
			break;
		if (fgets(owner, sizeof (owner), fp0) == 0)
			break;
		fh_setowner(&x, owner, 0);
		check_str(x.title);
		check_str(x.owner);
		removetailspace(x.title);
		do_log("%s", x.title);
		sprintf(file, "boards/%s/", iboard);
		t = trycreatefile(file, "M.%d.A", time(NULL), 100);
		x.filetime = t;
		do_log(file);
		do_log(fh2fname(&x));
		fp = fopen(file, "w");
		while (1) {
			if (fgets(buf, 255, fp0) == 0)
				break;
			if (!strcmp(buf, brk))
				break;
			fprintf(fp, "%s", buf);
		}
		fclose(fp);
		if (!valid_user(x.owner)) {
			unlink(file);
			do_log("bad user: %s", x.owner);
			continue;
		}
		fh_find_thread(&x, iboard);
		sprintf(dir, "boards/%s/.DIR", iboard);
		fd = open(dir, O_WRONLY | O_APPEND | O_CREAT, 0660);
		write(fd, &x, sizeof (x));
		close(fd);
		do_log("updatelastpost %s", iboard);
		updatelastpost(iboard);
	};
      E:fclose(fp0);
	close(fd);
	do_log("done");
}
Beispiel #8
0
int
bbsbkndoc_main()
{
	FILE *fp;
	char board[80], bkn[80], dir[160], *ptr, genbuf[STRLEN];
	struct boardmem *x1;
	struct fileheader x;
	int i, start, total;
	html_header(1);
	printf("<script src=" BBSJS "></script>\n");
	changemode(BACKNUMBER);
	//check_msg();
	getparmboard(board, sizeof(board));
	strsncpy(bkn, getparm("bkn"), 32);
	ptr = bkn;
	while (*ptr) {
		if (*ptr != 'B' && *ptr != '.' && !isdigit(*ptr))
			http_fatal("错误的过刊号");
		ptr++;
	}
	if (strlen(bkn) < 3)
		http_fatal("错误的过刊号");

	x1 = getboard(board);
	if (x1 == 0)
		nosuchboard(board, "bbsbkndoc");
	else {
		updateinboard(x1);
		strcpy(board, x1->header.filename);
		sprintf(dir, "boards/.backnumbers/%s/%s", board, bkn);
		if (!file_exist(dir))
			http_fatal("没有这卷过刊");
		sprintf(dir, "boards/.backnumbers/%s/%s/.DIR", board, bkn);
		fp = fopen(dir, "r");
		total = file_size(dir) / sizeof (struct fileheader);
		start = getdocstart(total, w_info->t_lines);
		printf("<body topmargin=0>");
		printf("<nobr><center>\n");
		sprintf(genbuf, "阅览过刊 文章数[%d]", total);
		printboardtop(x1, 5, genbuf);
		if (total <= 0)
			http_fatal("本卷过刊目前没有文章");
		printf("<table cellSpacing=0 cellPadding=2>\n");
		printf
		    ("<tr class=docbgcolor><td>序号<td>状态<td>作者<td>日期<td>标题<td>星级<td>评价</td>\n");
		if (fp) {
			fseek(fp, (start - 1) * sizeof (struct fileheader),
			      SEEK_SET);
			for (i = 0; i < w_info->t_lines; i++) {
				char filename[255];
				char *ptr;
				if (fread(&x, sizeof (x), 1, fp) <= 0)
					break;
				if (x.accessed & FH_HIDE) {
					printf
					    ("<tr><td>%d<td>&nbsp;<td>不详<td>不详<td>-本文已经被删除-<td>\n",
					     start + i);
					continue;
				}
				ptr = flag_str2(x.accessed, 1);
				sprintf(filename,
					"boards/.backnumbers/%s/%s/%s", board,
					bkn, fh2fname(&x));
				printf("<tr><td>%d<td>%s<td>%s", start + i, ptr,
				       userid_str(x.owner));
				printf("<td>%12.12s", Ctime(x.filetime) + 4);
				x.title[40] = 0;
				printf
				    ("<td><a href=bbsbkncon?B=%d&bkn=%s&file=%s&num=%d>%s%s </a>%s",
				     getbnumx(x1), bkn, fh2fname(&x), start + i - 1,
				     strncmp(x.title, "Re: ", 4) ? "○ " : "",
				     void1(titlestr(x.title)),
				     size_str(eff_size(filename)));
				printf("<td><font color=%s>%d</font>\n",
				       x.staravg50 ? "red" : "black",
				       x.staravg50 / 50);
				printf("<td><font color=%s>%d人</font>\n",
				       x.hasvoted ? "red" : "black",
				       x.hasvoted);
			}
			printf("</table>");
			printhr();
			fclose(fp);
		}
		sprintf(genbuf, "bbsbkndoc?B=%d&bkn=%s", getbnumx(x1), bkn);
		bbsdoc_helper(genbuf, start, total, w_info->t_lines);
		printf("<table><tr><td><form name=form1 action=bbsbkndoc>\n");
		printf("<input type=hidden name=B value=%d>", getbnumx(x1));
		printf("<input type=hidden name=bkn value=%s>", bkn);
		printf
		    ("<input type=submit value=跳转到> 第 <input type=text name=start size=4> 篇");
		printf("</form>\n");
		printf("</td><td><form name=form2 action=bbsdoc>\n");
		printf
		    ("<input type=submit value=跳转到><input type=text name=board size=5> 讨论区");
		printf("</form></td></tr></table>\n");
		showfile(MY_BBS_HOME "/wwwtmp/googleanalytics");
		printf("</body>");
		http_quit();
	}
	return 0;
}
Beispiel #9
0
int
delete_old_junk(char *filename)
{
	struct fileheader fhdr;
	char tmpfile[STRLEN], deleted[STRLEN];
	int fdr, fdw;
	int count, mday, fmday, total, ndeleted;
	time_t now;
	struct stat statbuf;
	int normalboard;

	if (stat(filename, &statbuf)) {
		if (errno == ENOENT)
			return 0;
		return -1;
	}
	total = statbuf.st_size / sizeof (fhdr);

	time(&now);
	mday = now / (3600 * 24) % 100;

	tmpfilename(filename, tmpfile, deleted);
	if (digestmode == 4 || digestmode == 5) {
		tmpfile[strlen(tmpfile) - 1] = (digestmode == 4) ? 'D' : 'J';
		deleted[strlen(deleted) - 1] = (digestmode == 4) ? 'D' : 'J';
	}

	if ((fdr = open(filename, O_RDONLY, 0)) == -1) {
		if (errno == ENOENT)
			return 0;
		return -2;
	}

	ndeleted = 0;
	while (read(fdr, &fhdr, sizeof (fhdr)) == sizeof (fhdr)) {
		fmday = fhdr.deltime;
		while (fmday > mday)
			fmday -= 100;
		if (fhdr.accessed & FH_MARKED || mday - fmday < 30)
			continue;
		ndeleted++;
		break;
	}
	if (ndeleted == 0) {
		close(fdr);
		return 0;
	}
	if (lseek(fdr, 0, SEEK_SET) < 0) {
		close(fdr);
		return -3;
	}

	if ((fdw = open(tmpfile, O_WRONLY | O_CREAT | O_EXCL, 0660)) == -1) {
		close(fdr);
		return -4;
	}
	flock(fdw, LOCK_EX);

	count = 1;
	ndeleted = 0;
	normalboard = strcmp(currboard, "allarticle");
	while (read(fdr, &fhdr, sizeof (fhdr)) == sizeof (fhdr)) {
		char fullpath[STRLEN];
		sprintf(fullpath, MY_BBS_HOME "/boards/%s/%s", currboard,
			fh2fname(&fhdr));
		fmday = fhdr.deltime;
		while (fmday > mday)
			fmday -= 100;
		if (fhdr.accessed & FH_MARKED
		    || ((mday - fmday < 30 && normalboard)
			|| (mday - fmday < 2 && !normalboard))) {
			while (mday - fmday > 3 && mday - fmday < 7
			       && fhdr.accessed & FH_ATTACHED) {
				struct stat st;
				if (lstat(fullpath, &st) < 0)
					break;
				if (S_ISLNK(st.st_mode) || st.st_nlink > 1)
					break;
				filter_attach(fullpath);
				fhdr.accessed &= ~FH_ATTACHED;
				break;
			}
			if ((safewrite(fdw, &fhdr, sizeof (fhdr)) == -1)) {
				unlink(tmpfile);
				flock(fdw, LOCK_UN);
				close(fdw);
				close(fdr);
				return -5;
			}
		} else {
			//   char fullpath[STRLEN];
			//   sprintf(fullpath,"/home/bbs/boards/%s/%s",currboard,fh2fname(&fhdr));
			//printf("%d %d %s\n", count, (int)fhdr.accessed, fullpath);
			// unlink(fullpath);
			if (!normalboard) {
				unlink(fullpath);
			}
			ndeleted++;
		}
		count++;
	}
	close(fdr);

	if (rename(filename, deleted) == -1) {
		flock(fdw, LOCK_UN);
		close(fdw);
		return -6;
	}
	if (rename(tmpfile, filename) == -1) {
		flock(fdw, LOCK_UN);
		close(fdw);
		return -7;
	}

	flock(fdw, LOCK_UN);
	close(fdw);
	printf("%d %d ", count, ndeleted);
	return 0;
}
Beispiel #10
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;
}
Beispiel #11
0
int
bbsgdoc_main()
{	//modity by macintosh 050516 for new www
	FILE *fp;
	char board[80], buf[128];
	struct boardmem *x1;
	struct fileheader x;
	int i, start, total;
	html_header(1);
	check_msg();
	printf("<script src=/function.js></script>\n");
	changemode(READING);
	strsncpy(board, getparm2("B", "board"), 32);
	x1 = getboard(board);
	if (x1 == 0)
		nosuchboard(board, "bbsgdoc");
	updateinboard(x1);
	strcpy(board, x1->header.filename);
	sprintf(buf, "boards/%s/.DIGEST", board);
	fp = fopen(buf, "r");
	if (fp == 0)
		http_fatal("错误的讨论区目录");
	total = file_size(buf) / sizeof (struct fileheader);
	start = getdocstart(total, w_info->t_lines);
/*	printf("<body topmargin=0>");
	printf("<nobr><center>\n"); */
	printf("<body topmargin=0 leftmargin=0>\n");
	printf("<table width=\"100%\" border=0 cellpadding=0 cellspacing=0>\n"
		"<td><form name=form1 action=bbsgdoc>\n");
	printboardtop(x1, 4);

/*	printf("文章数[%d] ", total);
	printf("<a href=bbspst?board=%s>发表文章</a> ", board); */
	printf("<tr><td><a href=\"pst?B=%s\" class=\"btnsubmittheme\" title=\"发表文章 accesskey: p\" accesskey=\"p\">发表文章</a>\n", board);
	printf("文章数&lt;%d&gt; 在线&lt;%d&gt;</td>", total, x1->inboard);
	sprintf(buf, "bbsgdoc?board=%s", board);
//	bbsdoc_helper(buf, start, total, w_info->t_lines);
	printf("<td align=right><a href=\"gdoc?B=%s&S=%d\" title=\"第一页 accesskey: 1\" accesskey=\"1\">第一页</a>\n", board, 1);
	if(start > w_info->t_lines+1) printf("<a href=\"gdoc?B=%s&S=%d\" title=\"上一页 accesskey: f\" accesskey=\"f\">上一页</a>\n", board, (start-w_info->t_lines));
	if(start < total-w_info->t_lines+1) printf("<a href=\"gdoc?B=%s&S=%d\" title=\"下一页 accesskey: n\" accesskey=\"n\">下一页</a>\n", board, (start+w_info->t_lines));
	printf("<a href=\"gdoc?B=%s&S=%d\" title=\"最后一页 accesskey: l\" accesskey=\"l\">最后一页</a>\n", board, (total-w_info->t_lines+1)); 
	//add by macintosh 050519 for func "Go"
	printf("<input type=hidden name=B value=%s>", board);
	printf("<input name=Submit1 type=Submit class=sumbitgrey value=Go>\n"
		"<input name=S type=text style=\"font-size:11px;font-family:verdana;\" size=4></td>\n"
		"</tr></table></td></tr>\n");
	printf("</form></td>");
	if (NULL == fp)
		http_fatal("本讨论区目前没有文章");
	if (total <= 0) {
		fclose(fp);
		http_fatal("本讨论区文摘目前没有文章");
	}

/*	printhr();
	printf("<table border=0>\n");
	printf
	    ("<tr><td>序号</td><td>状态</td><td>作者</td><td>日期</td><td>标题</td><td>星级</td><td>评价</td></tr>\n");
*/
	printf("%s", "<tr><td width=40 class=\"level1\">&nbsp;</td>\n"
		"<td class=\"level1\"><TABLE width=\"95%\" cellpadding=2 cellspacing=0>\n"
		"<TBODY>\n");
	printf("%s", "<TR>\n"
		"<TD class=tdtitle>序号</TD>\n"
		"<TD class=tdtitle>状态</TD>\n"
		"<TD class=tduser>作者</TD>\n"
		"<TD align=center class=tdtitle>日期</TD>\n"
		"<TD align=center class=tdtitle>标题</TD>\n"
		"<TD class=tdtitle>星级</TD>\n"
		"<TD class=tdtitle>评价</TD>\n"
		"</TR>\n");
	
	fseek(fp, (start - 1) * sizeof (struct fileheader), SEEK_SET);
	for (i = 0; i < w_info->t_lines; i++) {
		if (fread(&x, sizeof (x), 1, fp) <= 0)
			break;
		printf("<tr><td class=tdborder>%d</td><td class=tdborder>%s</td><td class=tduser>%s</td>",
		       start + i, flag_str(x.accessed), userid_str(x.owner));
		printf("<td align=center class=tdborder>%12.12s</td>", Ctime(x.filetime) + 4);
		printf
		    ("<td class=tdborder><a href=bbsgcon?board=%s&file=%s&num=%d>%s%s</a></td><td class=tdborder>%d</td><td class=tdborder>%d人</td></tr>\n",
		     board, fh2fname(&x), start + i - 1, strncmp(x.title,
								 "Re: ",
								 4) ? "● " :
		     "", void1(titlestr(x.title)), x.staravg50 / 50,
		     x.hasvoted);
	}
	printf("</TR> </TBODY></TABLE></td></tr>\n");
/*	printhr();
  	printf("文章数[%d] ", total);
	printf("<a href=bbspst?board=%s>发表文章</a> ", board);
	bbsdoc_helper(buf, start, total, w_info->t_lines);
*/
	printf("<tr><td height=40 class=\"level1\">&nbsp;</td>\n"
		"<td height=40 class=\"level1\">\n"
		"<table width=\"95%\" height=\"100%\"  border=0 cellpadding=0 cellspacing=0 class=\"level1\">\n"
		"<td><form name=form2 action=bbsgdoc>\n");
	printf("<tr><td><a href=\"pst?B=%s\" class=\"btnsubmittheme\" title=\"发表文章 accesskey: p\" accesskey=\"p\">发表文章</a>\n", board);
	printf("文章数&lt;%d&gt; 在线&lt;%d&gt;</td>", total, x1->inboard);
	sprintf(buf, "bbsgdoc?board=%s", board);
	printf("<td align=right><a href=\"gdoc?B=%s&S=%d\" title=\"第一页 accesskey: 1\" accesskey=\"1\">第一页</a>\n", board, 1);
	if(start > w_info->t_lines+1) printf("<a href=\"gdoc?B=%s&S=%d\" title=\"上一页 accesskey: f\" accesskey=\"f\">上一页</a>\n", board, (start-w_info->t_lines));
	if(start < total-w_info->t_lines+1) printf("<a href=\"gdoc?B=%s&S=%d\" title=\"下一页 accesskey: n\" accesskey=\"n\">下一页</a>\n", board, (start+w_info->t_lines));
	printf("<a href=\"gdoc?B=%s&S=%d\" title=\"最后一页 accesskey: l\" accesskey=\"l\">最后一页</a>\n", board, (total-w_info->t_lines+1)); 
	//add by macintosh 050519 for func "Go"
	printf("<input type=hidden name=B value=%s>", board);
	printf("<input name=Submit2 type=Submit class=sumbitgrey value=Go>\n"
		"<input name=S type=text style=\"font-size:11px;font-family:verdana;\" size=4></td>\n"
		"</tr></table></td></tr>\n");
	printf("</form></td>");
	fclose(fp);
//	printdocform("bbsgdoc", board);
	printf("</table></td></tr></table></body>\n");
	http_quit();
	return 0;
}