diff options
-rw-r--r-- | pttbbs/include/proto.h | 1 | ||||
-rw-r--r-- | pttbbs/mbbsd/bbs.c | 69 | ||||
-rw-r--r-- | pttbbs/mbbsd/mail.c | 1 |
3 files changed, 57 insertions, 14 deletions
diff --git a/pttbbs/include/proto.h b/pttbbs/include/proto.h index c59320a0..69a63d10 100644 --- a/pttbbs/include/proto.h +++ b/pttbbs/include/proto.h @@ -86,6 +86,7 @@ int save_violatelaw(void); int board_select(void); int board_digest(void); int do_limitedit(int ent, fileheader_t * fhdr, const char *direct); +void log_crosspost_in_allpost(const char *brd, const fileheader_t *postfile); #ifdef USE_COOLDOWN int check_cooldown(boardheader_t *bp); #endif diff --git a/pttbbs/mbbsd/bbs.c b/pttbbs/mbbsd/bbs.c index bb192e52..e3c4ca6f 100644 --- a/pttbbs/mbbsd/bbs.c +++ b/pttbbs/mbbsd/bbs.c @@ -82,6 +82,17 @@ query_file_money(const fileheader_t *pfh) return pfh->multi.money; } +static int +cp_IsHiddenBoard(const boardheader_t *bp) +{ + // rules: see HasBoardPerm(). + if ((bp->brdattr & BRD_HIDE) && (bp->brdattr & BRD_POSTMASK)) + return 1; + if (bp->level && !(bp->brdattr & BRD_POSTMASK)) + return 1; + return 0; +} + // lite weight version to update dir files static int modify_dir_lite( @@ -377,6 +388,11 @@ int IsFreeBoardName(const char *brdname) return 0; } +int +IsBoardForAllpost(boardheader_t *bp) { + return (!bp->level) || (bp->brdattr & BRD_POSTMASK); +} + /* check post perm on demand, no double checks in current board * currboard MUST be defined! * XXX can we replace currboard with currbid ? */ @@ -1007,6 +1023,38 @@ do_reply_title(int row, const char *title, char result[STRLEN]) getdata(++row, 0, "標題:", result, TTLEN, DOECHO); } +void +log_crosspost_in_allpost(const char *brd, const fileheader_t *postfile) { +#ifdef BN_ALLPOST + char genbuf[PATHLEN]; + int len = 42-4-strlen(brd); + fileheader_t fh; + int bid = getbnum(BN_ALLPOST), brd_id = getbnum(brd); + if(bid <= 0 || bid > MAX_BOARD) + return; + if(brd_id <= 0 || brd_id > MAX_BOARD) + return; + + // don't log when brd is a hidden board. + if (cp_IsHiddenBoard(getbcache(brd_id))) + return; + + if(!strncasecmp(postfile->title, str_reply, 3)) + len=len+4; + + memcpy(&fh, postfile, sizeof(fileheader_t)); + strlcpy(fh.owner, cuser.userid, sizeof(fh.owner)); + fh.filemode = FILE_LOCAL; + + sprintf(fh.title, "%-*.*s[轉].%s板", len, len, postfile->title, brd); + setbdir(genbuf, BN_ALLPOST); + if (append_record(genbuf, &fh, sizeof(fileheader_t)) != -1) { + SHM->lastposttime[bid - 1] = now; + touchbpostnum(bid, 1); + } +#endif +} + void do_crosspost(const char *brd, fileheader_t *postfile, const char *fpath, int isstamp) @@ -1036,6 +1084,7 @@ do_crosspost(const char *brd, fileheader_t *postfile, const char *fpath, sprintf(fh.title,"%-*.*s.%s板", len, len, postfile->title, currboard); unlink(genbuf); Copy((char *)fpath, genbuf); + // should be fh.filemode ? postfile->filemode = FILE_LOCAL; setbdir(genbuf, brd); if (append_record(genbuf, &fh, sizeof(fileheader_t)) != -1) { @@ -1298,8 +1347,7 @@ do_general(int garbage) } brc_addlist(postfile.filename, postfile.modified); - if( !bp->level || (currbrdattr & BRD_POSTMASK)) - { + if (IsBoardForAllpost(bp)) { if ((now - cuser.firstlogin) / DAY_SECONDS < 14) do_crosspost("NEWIDPOST", &postfile, fpath, 0); @@ -1800,17 +1848,6 @@ edit_post(int ent, fileheader_t * fhdr, const char *direct) #define UPDATE_USEREC (currmode |= MODE_DIRTY) -static int -cp_IsHiddenBoard(const boardheader_t *bp) -{ - // rules: see HasBoardPerm(). - if ((bp->brdattr & BRD_HIDE) && (bp->brdattr & BRD_POSTMASK)) - return 1; - if (bp->level && !(bp->brdattr & BRD_POSTMASK)) - return 1; - return 0; -} - int old_cross_post(int ent, fileheader_t * fhdr, const char *direct) { @@ -1826,7 +1863,7 @@ cross_post(int ent, fileheader_t * fhdr, const char *direct) fileheader_t xfile; FILE *xptr; int author, xbid, hashPost; - boardheader_t *bp; + boardheader_t *bp, *xbp; assert(0<=currbid-1 && currbid-1<MAX_BOARD); bp = getbcache(currbid); @@ -1910,6 +1947,7 @@ cross_post(int ent, fileheader_t * fhdr, const char *direct) hashPost = StringHash(fhdr->filename); // let's try filename xbid = getbnum(xboard); assert(0<=xbid-1 && xbid-1<MAX_BOARD); + xbp = getbcache(xbid); if (xbid == currbid) { @@ -2031,6 +2069,9 @@ cross_post(int ent, fileheader_t * fhdr, const char *direct) cuser.userid, Cdatelite(&now)); fclose(xptr); + // try to record in ALLPOST + log_crosspost_in_allpost(xboard, &xfile); + #ifdef USE_AUTOCPLOG /* add cp log. bp is currboard now. */ if(bp->brdattr & BRD_CPLOG) diff --git a/pttbbs/mbbsd/mail.c b/pttbbs/mbbsd/mail.c index 92894cf2..f445b861 100644 --- a/pttbbs/mbbsd/mail.c +++ b/pttbbs/mbbsd/mail.c @@ -1638,6 +1638,7 @@ mail_cross_post(int unused_arg, fileheader_t * fhdr, const char *direct) add_cooldowntime(usernum, 5); add_posttimes(usernum, 1); #endif + log_crosspost_in_allpost(xboard, &xfile); // cross-post does not add numpost. outs("轉錄信件不增加文章數,敬請包涵。"); |