diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-08-23 13:36:03 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-08-23 13:36:03 +0800 |
commit | 566c210f2b2f650e15569dc263b113710636eec9 (patch) | |
tree | 57c86c9a158d38b151748aa7e5a19c6d4ce5e710 /mbbsd | |
parent | 256c65c5b93d4213540676a42c81744b0ffeb7d8 (diff) | |
download | pttbbs-566c210f2b2f650e15569dc263b113710636eec9.tar pttbbs-566c210f2b2f650e15569dc263b113710636eec9.tar.gz pttbbs-566c210f2b2f650e15569dc263b113710636eec9.tar.bz2 pttbbs-566c210f2b2f650e15569dc263b113710636eec9.tar.lz pttbbs-566c210f2b2f650e15569dc263b113710636eec9.tar.xz pttbbs-566c210f2b2f650e15569dc263b113710636eec9.tar.zst pttbbs-566c210f2b2f650e15569dc263b113710636eec9.zip |
* use SAFE_ARTICLE_DELETE even if nuser < 30
* because we can make rich UI to allow leaving delete reasons in this mode
* also because it's stupid to determine by magic 30
* changed board name UnAnonymous to macro in config.h
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4762 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r-- | mbbsd/bbs.c | 90 | ||||
-rw-r--r-- | mbbsd/read.c | 2 | ||||
-rw-r--r-- | mbbsd/record.c | 17 | ||||
-rw-r--r-- | mbbsd/register.c | 4 |
4 files changed, 94 insertions, 19 deletions
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index d34f5799..43b32a2d 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -760,8 +760,8 @@ do_deleteCrossPost(const fileheader_t *fh, char bname[]) if( (i=getindex(bdir, &newfh, 0))>0) { #ifdef SAFE_ARTICLE_DELETE - if(bp && !(currmode & MODE_DIGEST) && bp->nuser > 30 ) - safe_article_delete(i, &newfh, bdir); + if(bp && !(currmode & MODE_DIGEST)) + safe_article_delete(i, &newfh, bdir, NULL); else #endif delete_record(bdir, sizeof(fileheader_t), i); @@ -776,7 +776,7 @@ deleteCrossPost(const fileheader_t *fh, char *bname) if(!fh || !fh->filename[0]) return; if(!strcmp(bname, BN_ALLPOST) || !strcmp(bname, "NEWIDPOST") || - !strcmp(bname, BN_ALLHIDPOST) || !strcmp(bname, "UnAnonymous")) + !strcmp(bname, BN_ALLHIDPOST) || !strcmp(bname, BN_UNANONYMOUS)) { int len=0; char xbname[TTLEN + 1], *po = strrchr(fh->title, '.'); @@ -888,7 +888,7 @@ do_crosspost(const char *brd, fileheader_t *postfile, const char *fpath, else setbfile(genbuf, brd, postfile->filename); - if(!strcmp(brd, "UnAnonymous")) + if(!strcasecmp(brd, BN_UNANONYMOUS)) strcpy(fh.owner, cuser.userid); sprintf(fh.title,"%-*.*s.%s板", len, len, postfile->title, currboard); @@ -1185,7 +1185,7 @@ do_general(int garbage) curredit ^= EDIT_BOTH; } // if (curredit & EDIT_BOTH) if (currbrdattr & BRD_ANONYMOUS) - do_crosspost("UnAnonymous", &postfile, fpath, 0); + do_crosspost(BN_UNANONYMOUS, &postfile, fpath, 0); #ifdef USE_COOLDOWN if(bp->nuser>30) { @@ -2885,7 +2885,7 @@ del_range(int ent, const fileheader_t *fhdr, const char *direct) outmsg("處理中,請稍後..."); refresh(); #ifdef SAFE_ARTICLE_DELETE - if(bp && !(currmode & MODE_DIGEST) && bp->nuser > 30 ) + if(bp && !(currmode & MODE_DIGEST)) ret = safe_article_delete_range(direct, inum1, inum2); else #endif @@ -2918,7 +2918,8 @@ static int del_post(int ent, fileheader_t * fhdr, char *direct) { char genbuf[100], newpath[PATHLEN]; - int not_owned, tusernum, del_ok = 0; + char reason[PROPER_TITLE_LEN]; + int not_owned, is_anon, tusernum, del_ok = 0; boardheader_t *bp; assert(0<=currbid-1 && currbid-1<MAX_BOARD); @@ -2938,7 +2939,8 @@ del_post(int ent, fileheader_t * fhdr, char *direct) (fhdr->owner[0] == '-')) return DONOTHING; - if(fhdr->filemode & FILE_ANONYMOUS) + is_anon = (fhdr->filemode & FILE_ANONYMOUS); + if(is_anon) /* When the file is anonymous posted, fhdr->multi.anon_uid is author. * see do_general() */ tusernum = fhdr->multi.anon_uid; @@ -2953,12 +2955,78 @@ del_post(int ent, fileheader_t * fhdr, char *direct) if (fhdr->filename[0]=='L') fhdr->filename[0]='M'; - getdata(1, 0, msg_del_ny, genbuf, 3, LCECHO); +#ifdef SAFE_ARTICLE_DELETE + reason[0] = 0; + // query if user really wants to delete it + if (not_owned && !is_anon && fhdr->owner[0]) + { + // manager (bm, sysop, police) + do { + char oreason[PROPER_TITLE_LEN]; + int keep_cuserid = 0; + const char *pat_withuid = "(已被%s刪除: %s) <%s>", + *pat_anon = "(已被刪除: %s) <%s>"; + int pat_withuid_modlen = 2*3, // length caused by %s + pat_anon_modlen = 2*2; + + getdata(1, 0, "請確定刪除(Y/N/R加註理由)?[N]", genbuf, 3, LCECHO); + + // for y/n, skip. + if (genbuf[0] != 'r') + break; + + // query anonymous + // XXX allow only if HasUserPerm(PERM_POLICE | PERM_POLICE_MAN | PERM_SYSOP) ? + move(3,0); clrtoeol(); + getdata(2, 0, "要留下您的 ID 嗎(Y/N)?[N]", genbuf, 3, LCECHO); + if (genbuf[0] == 'y') + keep_cuserid = 1; + + // input reason + move(4,0); clrtoeol(); + getdata(3, 0, "理由: ", oreason, + sizeof(oreason) - strlen(fhdr->owner) - + (keep_cuserid ? strlen(pat_withuid)-pat_withuid_modlen: + strlen(pat_anon) -pat_anon_modlen) - + (keep_cuserid ? strlen(cuser.userid) : 0), + DOECHO); + + if (!oreason[0]) + { + vmsg("未輸入理由,放棄刪除。"); + genbuf[0] = 'n'; + break; + } + + // build reason string (based on STR_SAFEDEL_TITLE) + if (keep_cuserid) + { + snprintf(reason, sizeof(reason), + pat_withuid, cuser.userid, oreason, fhdr->owner); + } else { + snprintf(reason, sizeof(reason), + pat_anon, oreason, fhdr->owner); + } + + // confirm again! + move(3, 0); clrtoeol(); prints("將會顯示為: " ANSI_COLOR(1) + "%s" ANSI_RESET "\n", reason); + move(5, 0); clrtoeol(); + getdata(4, 0, "請再次確定是否要用上述理由刪除(Y/N)?[N]", + genbuf, 3, LCECHO); + + // since the default y/n is same to msg_del_ny, we reuse the genbuf[0] here. + } while (0); + } else +#endif + { + getdata(1, 0, msg_del_ny, genbuf, 3, LCECHO); + } if (genbuf[0] == 'y') { if( #ifdef SAFE_ARTICLE_DELETE - (bp->nuser > 30 && !(currmode & MODE_DIGEST) && - !safe_article_delete(ent, fhdr, direct)) || + (!(currmode & MODE_DIGEST) && + !safe_article_delete(ent, fhdr, direct, reason[0] ? reason : NULL)) || #endif // XXX TODO delete_record is really really dangerous - // we should verify the header (maybe by filename) is the same. diff --git a/mbbsd/read.c b/mbbsd/read.c index 7740d3cf..4d73dcd9 100644 --- a/mbbsd/read.c +++ b/mbbsd/read.c @@ -187,7 +187,7 @@ TagPruner(int bid) if (vans("刪除所有標記[N]?") != 'y') return READ_REDRAW; #ifdef SAFE_ARTICLE_DELETE - if(bp && !(currmode & MODE_DIGEST) && bp->nuser>30 ) + if(bp && !(currmode & MODE_DIGEST)) safe_delete_range(currdirect, 0, 0); else #endif diff --git a/mbbsd/record.c b/mbbsd/record.c index 348c4d8d..bd0f9ab7 100644 --- a/mbbsd/record.c +++ b/mbbsd/record.c @@ -165,7 +165,7 @@ void safe_delete_range(const char *fpath, int id1, int id2) (fhdr.filemode & FILE_DIGEST) || /* 文摘 */ (id1 && (i < id1 || i > id2)) || /* range */ (!id1 && Tagger(atoi(t + 2), i, TAG_NIN)))) /* TagList */ - safe_article_delete(i, &fhdr, fpath); + safe_article_delete(i, &fhdr, fpath, NULL); } close(fd); } @@ -245,9 +245,14 @@ delete_range(const char *fpath, int id1, int id2) #endif // _BBS_UTIL_C_ void -set_safedel_fhdr(fileheader_t *fhdr) +set_safedel_fhdr(fileheader_t *fhdr, const char *newtitle) { - if (fhdr->filemode & FILE_ANONYMOUS || + if (newtitle && *newtitle) + { + snprintf(fhdr->title, sizeof(fhdr->title), + "%s", newtitle); + } + else if (fhdr->filemode & FILE_ANONYMOUS || !fhdr->owner[0] || (fhdr->owner[0] == '-' && fhdr->owner[1] == 0) ) { @@ -275,11 +280,11 @@ set_safedel_fhdr(fileheader_t *fhdr) #ifdef SAFE_ARTICLE_DELETE int -safe_article_delete(int ent, const fileheader_t *fhdr, const char *direct) +safe_article_delete(int ent, const fileheader_t *fhdr, const char *direct, const char *newtitle) { fileheader_t newfhdr; memcpy(&newfhdr, fhdr, sizeof(fileheader_t)); - set_safedel_fhdr(&newfhdr); + set_safedel_fhdr(&newfhdr, newtitle); substitute_record(direct, &newfhdr, sizeof(newfhdr), ent); return 0; } @@ -309,7 +314,7 @@ safe_article_delete_range(const char *direct, int from, int to) strlcpy(ptr, newfhdr.filename, sizeof(newfhdr.filename)); unlink(fn); - set_safedel_fhdr(&newfhdr); + set_safedel_fhdr(&newfhdr, NULL); // 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)); diff --git a/mbbsd/register.c b/mbbsd/register.c index ea9f546a..5b278584 100644 --- a/mbbsd/register.c +++ b/mbbsd/register.c @@ -706,7 +706,9 @@ new_register(void) else if (reserved_user_id(passbuf)) outs("此代號已由系統保留,請使用別的代號\n"); #if !defined(NO_CHECK_AMBIGUOUS_USERID) && defined(USE_REGCHECKD) - else if (regcheck_ambiguous_userid_exist(passbuf) > 0) // ignore if error occurs + // XXX if we check id == 0 here, replacing an expired id will be delayed. + else if (/*id == 0 && */ + regcheck_ambiguous_userid_exist(passbuf) > 0) // ignore if error occurs outs("此代號過於近似它人帳號,請改用別的代號。\n"); #endif else // success |