diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-04-09 23:35:48 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-04-09 23:35:48 +0800 |
commit | f680ef20c2d16966a408c56608b28c1e014c2105 (patch) | |
tree | c2fcf02c6d4cb8147e9ea8f5ed219348b9264970 | |
parent | 2320c0c0743af362779009ae09dee8053df9738b (diff) | |
download | pttbbs-f680ef20c2d16966a408c56608b28c1e014c2105.tar pttbbs-f680ef20c2d16966a408c56608b28c1e014c2105.tar.gz pttbbs-f680ef20c2d16966a408c56608b28c1e014c2105.tar.bz2 pttbbs-f680ef20c2d16966a408c56608b28c1e014c2105.tar.lz pttbbs-f680ef20c2d16966a408c56608b28c1e014c2105.tar.xz pttbbs-f680ef20c2d16966a408c56608b28c1e014c2105.tar.zst pttbbs-f680ef20c2d16966a408c56608b28c1e014c2105.zip |
- restrict VIOLATE_LAW cross-posting
- add owner/delete in SAFEDEL title as log
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4118 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | include/common.h | 9 | ||||
-rw-r--r-- | include/proto.h | 1 | ||||
-rw-r--r-- | include/pttstruct.h | 1 | ||||
-rw-r--r-- | mbbsd/bbs.c | 18 | ||||
-rw-r--r-- | mbbsd/cache.c | 12 | ||||
-rw-r--r-- | mbbsd/mail.c | 8 | ||||
-rw-r--r-- | mbbsd/record.c | 26 |
7 files changed, 61 insertions, 14 deletions
diff --git a/include/common.h b/include/common.h index 1086a796..4d3d7d5d 100644 --- a/include/common.h +++ b/include/common.h @@ -34,6 +34,15 @@ #define FN_BRDLISTHELP "etc/boardlist.help" #define FN_BOARDHELP "etc/board.help" + +// 自訂刪除文章時出現的標題與檔案 +#ifndef FN_SAFEDEL +#define FN_SAFEDEL ".deleted" +#endif +#ifndef STR_SAFEDEL_TITLE +#define STR_SAFEDEL_TITLE "(本文已被刪除)" +#endif + #define MSG_DEL_CANCEL "取消刪除" #define MSG_BIG_BOY "我是大帥哥! ^o^Y" #define MSG_BIG_GIRL "世紀大美女 *^-^*" diff --git a/include/proto.h b/include/proto.h index cfea73d6..ade34488 100644 --- a/include/proto.h +++ b/include/proto.h @@ -507,6 +507,7 @@ int get_records_fd(const char *fpath, void *rptr, int size, int id, int number, void stamplink(char *fpath, fileheader_t *fh); int delete_record(const char fpath[], int size, int id); int delete_files(const char* dirname, int (*filecheck)(), int record); +void set_safedel_fhdr(fileheader_t *fhdr); #ifdef SAFE_ARTICLE_DELETE #ifndef _BBS_UTIL_C_ void safe_delete_range(const char *fpath, int id1, int id2); diff --git a/include/pttstruct.h b/include/pttstruct.h index 263cad44..ec116601 100644 --- a/include/pttstruct.h +++ b/include/pttstruct.h @@ -560,6 +560,7 @@ typedef struct { /* statistic */ int statistic[STAT_MAX]; + // TODO XXX 有 fromd 後可以拔掉了。 /* 故鄉 fromcache */ unsigned int home_ip[MAX_FROM]; unsigned int home_mask[MAX_FROM]; diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index 90538221..e99874a1 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -770,9 +770,7 @@ delete_allpost(const char *userid) setbfile(file, BN_ALLPOST, fhdr.filename); unlink(file); - sprintf(fhdr.title, "(本文已被刪除)"); - strcpy(fhdr.filename, ".deleted"); - strcpy(fhdr.owner, "-"); + set_safedel_fhdr(&fhdr); lseek(fd, sizeof(fileheader_t) * i, SEEK_SET); write(fd, &fhdr, sizeof(fileheader_t)); } @@ -1730,7 +1728,11 @@ cross_post(int ent, fileheader_t * fhdr, const char *direct) bp = getbcache(currbid); if (bp && (bp->brdattr & BRD_VOTEBOARD) ) - return FULLUPDATE; + return DONOTHING; + + // if file is SAFE_DELETED, skip it. + if (fhdr->owner[0] == '-' && fhdr->owner[1] == 0) + return DONOTHING; setbfile(fname, currboard, fhdr->filename); if (!dashf(fname)) @@ -1756,6 +1758,14 @@ cross_post(int ent, fileheader_t * fhdr, const char *direct) } #endif // USE_AUTOCPLOG + // XXX TODO 為避免違法使用者大量對申訴板轉文,限定每次發文量。 + if (HasUserPerm(PERM_VIOLATELAW)) + { + static int violatecp = 0; + if (violatecp++ >= MAX_CROSSNUM) + return DONOTHING; + } + move(2, 0); clrtoeol(); if (postrecord.times > 1) diff --git a/mbbsd/cache.c b/mbbsd/cache.c index 0ca1d740..2a046969 100644 --- a/mbbsd/cache.c +++ b/mbbsd/cache.c @@ -822,10 +822,14 @@ postperm_msg(const char *bname) !is_hidden_board_friend(i, usernum)) return "看板限制發文"; - if (HasUserPerm(PERM_VIOLATELAW) && (bp->level & PERM_VIOLATELAW)) - return NULL; - else if (HasUserPerm(PERM_VIOLATELAW)) - return "罰單未繳"; + if (HasUserPerm(PERM_VIOLATELAW)) + { + // 在罰單的討論相關板可以發文 + if (bp->level & PERM_VIOLATELAW) + return NULL; + else + return "罰單未繳"; + } if (!(bp->level & ~PERM_POST)) return NULL; diff --git a/mbbsd/mail.c b/mbbsd/mail.c index 545027ca..60d2b34f 100644 --- a/mbbsd/mail.c +++ b/mbbsd/mail.c @@ -1422,6 +1422,14 @@ mail_cross_post(int ent, fileheader_t * fhdr, const char *direct) char genbuf[200]; char genbuf2[4]; + // XXX TODO 為避免違法使用者大量對申訴板轉文,限定每次發文量。 + if (HasUserPerm(PERM_VIOLATELAW)) + { + static int violatecp = 0; + if (violatecp++ >= MAX_CROSSNUM) + return DONOTHING; + } + move(2, 0); clrtoeol(); if (postrecord.times > 1) diff --git a/mbbsd/record.c b/mbbsd/record.c index 6b8a8af9..48c61fe2 100644 --- a/mbbsd/record.c +++ b/mbbsd/record.c @@ -383,6 +383,24 @@ delete_range(const char *fpath, int id1, int id2) } #endif +void +set_safedel_fhdr(fileheader_t *fhdr) +{ + if ( strcmp(fhdr->owner, cuser.userid) == 0 || + !fhdr->owner[0] || + (fhdr->owner[0] == '-' && fhdr->owner[1] == 0) ) + { + // i'm the one to delete it, or if the owner is corpse. + snprintf(fhdr->title, sizeof(fhdr->title), + "%s [%s]", STR_SAFEDEL_TITLE, cuser.userid); + } else { + snprintf(fhdr->title, sizeof(fhdr->title), + "%s [%s/%s]", STR_SAFEDEL_TITLE, fhdr->owner, cuser.userid); + } + // snprintf(fhdr->title, sizeof(fhdr->title), "%s", STR_SAFEDEL_TITLE); + strcpy(fhdr->filename, FN_SAFEDEL); + strcpy(fhdr->owner, "-"); +} #ifdef SAFE_ARTICLE_DELETE int @@ -390,9 +408,7 @@ safe_article_delete(int ent, const fileheader_t *fhdr, const char *direct) { fileheader_t newfhdr; memcpy(&newfhdr, fhdr, sizeof(fileheader_t)); - sprintf(newfhdr.title, "(本文已被刪除)"); - strcpy(newfhdr.filename, ".deleted"); - strcpy(newfhdr.owner, "-"); + set_safedel_fhdr(&newfhdr); substitute_record(direct, &newfhdr, sizeof(newfhdr), ent); return 0; } @@ -420,9 +436,7 @@ safe_article_delete_range(const char *direct, int from, int to) strlcpy(ptr, newfhdr.filename, sizeof(newfhdr.filename)); unlink(fn); - sprintf(newfhdr.title, "(本文已被刪除)"); - strcpy(newfhdr.filename, ".deleted"); - strcpy(newfhdr.owner, "-"); + set_safedel_fhdr(&newfhdr); // because off_t is unsigned, we could NOT seek backward. lseek(fd, sizeof(fileheader_t) * (from - 1), SEEK_SET); write(fd, &newfhdr, sizeof(fileheader_t)); |