From ddb92d02a7e7a542047595519b6ad9e600751d69 Mon Sep 17 00:00:00 2001 From: victor Date: Sun, 18 May 2003 13:42:55 +0000 Subject: 1. never mark a non-exist post 2. avoid incorrect sequence after rebuilder if there is any edited post git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@865 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/bbs.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'mbbsd/bbs.c') diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index bd0e82a4..01324b22 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -1,4 +1,4 @@ -/* $Id: bbs.c,v 1.93 2003/05/14 08:31:29 in2 Exp $ */ +/* $Id: bbs.c,v 1.94 2003/05/18 13:42:55 victor Exp $ */ #include "bbs.h" static int recommend(int ent, fileheader_t * fhdr, char *direct); @@ -714,11 +714,12 @@ reply_post(int ent, fileheader_t * fhdr, char *direct) static int edit_post(int ent, fileheader_t * fhdr, char *direct) { + int num; char fpath[80], fpath0[80]; char genbuf[200]; fileheader_t postfile; - boardheader_t *bp; - bp = getbcache(currbid); + boardheader_t *bp = getbcache(currbid); + if (strcmp(bp->brdname, "Security") == 0) return DONOTHING; @@ -742,15 +743,25 @@ edit_post(int ent, fileheader_t * fhdr, char *direct) lock_substitute_record(direct, fhdr, sizeof(*fhdr), ent, LOCK_EX); setbpath(fpath, currboard); stampfile(fpath, &postfile); - unlink(fpath); + strlcpy(genbuf, fhdr->filename, strlen(genbuf)); setbfile(fpath0, currboard, fhdr->filename); + for(num = 2; genbuf[num] != NULL; num++){ + if(genbuf[num] == '.'){ + genbuf[num] = 0; + break; + } + } + + sprintf(postfile.filename, "%s.A.%3.3X", genbuf, rand() & 0xFFF); + setdirpath(fpath, fpath, postfile.filename); + unlink(fpath); + Rename(fpath0, fpath); /* rocker.011018: fix 串接模式改文章後文章就不見的bug */ if ((currmode & MODE_SELECT) && (fhdr->money & FHR_REFERENCE)) { fileheader_t hdr; - int num; num = fhdr->money & ~FHR_REFERENCE; setbdir(fpath0, currboard); @@ -1293,10 +1304,17 @@ recommend(int ent, fileheader_t * fhdr, char *direct) static int mark_post(int ent, fileheader_t * fhdr, char *direct) { + char buf[STRLEN], fpath[STRLEN]; if (!(currmode & MODE_BOARD)) return DONOTHING; + setbpath(fpath, currboard); + sprintf(buf, "%s/%s", fpath, fhdr->filename); + + if(access(buf, F_OK) < 0) + return DONOTHING; + fhdr->filemode ^= FILE_MARKED; substitute_record(direct, fhdr, sizeof(*fhdr), ent); substitute_check(fhdr); -- cgit v1.2.3