diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-10-30 22:57:43 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-10-30 22:57:43 +0800 |
commit | a54667b33a721bec34e51c39c769fc8fd1726c72 (patch) | |
tree | fcb2e48749ddff42c159482fb8e3258a8b14990e | |
parent | ca85397c5d47151895524e32b407c04b179f30d4 (diff) | |
download | pttbbs-a54667b33a721bec34e51c39c769fc8fd1726c72.tar pttbbs-a54667b33a721bec34e51c39c769fc8fd1726c72.tar.gz pttbbs-a54667b33a721bec34e51c39c769fc8fd1726c72.tar.bz2 pttbbs-a54667b33a721bec34e51c39c769fc8fd1726c72.tar.lz pttbbs-a54667b33a721bec34e51c39c769fc8fd1726c72.tar.xz pttbbs-a54667b33a721bec34e51c39c769fc8fd1726c72.tar.zst pttbbs-a54667b33a721bec34e51c39c769fc8fd1726c72.zip |
* ability to give 'badpost' according to X comments
* still need ADM's approval because this is a buggy implementation
git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5013 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | pttbbs/include/proto.h | 2 | ||||
-rw-r--r-- | pttbbs/mbbsd/assess.c | 173 | ||||
-rw-r--r-- | pttbbs/mbbsd/bbs.c | 107 |
3 files changed, 199 insertions, 83 deletions
diff --git a/pttbbs/include/proto.h b/pttbbs/include/proto.h index 2a691660..7207df5f 100644 --- a/pttbbs/include/proto.h +++ b/pttbbs/include/proto.h @@ -51,6 +51,8 @@ int Announce(void); /* assess */ int inc_badpost(const char *, int num); +int bad_comment(const char *fn); +int assign_badpost(const char *userid, fileheader_t *fhdr, const char *newpath, const char *comment); /* bbs */ void delete_allpost(const char *userid); diff --git a/pttbbs/mbbsd/assess.c b/pttbbs/mbbsd/assess.c index aa9abe71..6dba6c93 100644 --- a/pttbbs/mbbsd/assess.c +++ b/pttbbs/mbbsd/assess.c @@ -28,4 +28,177 @@ int inc_##_attr(const char *userid, int num) \ modify_column(badpost); /* inc_badpost */ +static char * const badpost_reason[] = { + "廣告", "不當用辭", "人身攻擊" +}; + +#define DIM(x) (sizeof(x)/sizeof(x[0])) + +int assign_badpost(const char *userid, fileheader_t *fhdr, + const char *newpath, const char *comment) +{ + char genbuf[STRLEN]; + char rptpath[PATHLEN]; + int i, tusernum = searchuser(userid, NULL); + + strcpy(rptpath, newpath); + assert(tusernum > 0 && tusernum < MAX_USERS); + move(b_lines - 2, 0); + clrtobot(); + for (i = 0; i < DIM(badpost_reason); i++) + prints("%d.%s ", i + 1, badpost_reason[i]); + + prints("%d.%s", i + 1, "其他"); + getdata(b_lines - 1, 0, "請選擇[0:取消劣文]:", genbuf, 3, LCECHO); + i = genbuf[0] - '1'; + if (i < 0 || i > DIM(badpost_reason)) + { + vmsg("取消設定劣文。"); + return -1; + } + + if (i < DIM(badpost_reason)) + sprintf(genbuf,"劣%s文退回(%s)", comment ? "推" : "", badpost_reason[i]); + else if(i==DIM(badpost_reason)) + { + char *s = genbuf; + strcpy(genbuf, comment ? "劣推文退回(" : "劣文退回("); + s += strlen(genbuf); + getdata_buf(b_lines, 0, "請輸入原因", s, 50, DOECHO); + // 對於 comment 目前可以重來,但非comment 文直接刪掉所以沒法 cancel + if (!*s && comment) + { + vmsg("取消設定劣文。"); + return -1; + } + strcat(genbuf,")"); + } + + assert(i >= 0 && i <= DIM(badpost_reason)); + if (fhdr) strncat(genbuf, fhdr->title, 64-strlen(genbuf)); + +#ifdef USE_COOLDOWN + add_cooldowntime(tusernum, 60); + add_posttimes(tusernum, 15); //Ptt: 凍結 post for 1 hour +#endif + + if (!(inc_badpost(userid, 1) % 5)){ + userec_t xuser; + post_violatelaw(userid, BBSMNAME " 系統警察", + "劣文累計 5 篇", "罰單一張"); + mail_violatelaw(userid, BBSMNAME " 系統警察", + "劣文累計 5 篇", "罰單一張"); + kick_all(userid); + passwd_sync_query(tusernum, &xuser); + xuser.money = moneyof(tusernum); + xuser.vl_count++; + xuser.userlevel |= PERM_VIOLATELAW; + xuser.timeviolatelaw = now; + passwd_sync_update(tusernum, &xuser); + } + +#ifdef BAD_POST_RECORD + // we also change rptpath because such record contains more information + { + int rpt_bid = getbnum(BAD_POST_RECORD); + if (rpt_bid > 0) { + fileheader_t report_fh; + char rptdir[PATHLEN]; + FILE *fp; + + setbpath(rptpath, BAD_POST_RECORD); + stampfile(rptpath, &report_fh); + + strcpy(report_fh.owner, "[" BBSMNAME "警察局]"); + snprintf(report_fh.title, sizeof(report_fh.title), + "%s 板 %s 板主給予 %s 一篇劣%s文", + currboard, cuser.userid, userid, comment ? "推" : ""); + Copy(newpath, rptpath); + fp = fopen(rptpath, "at"); + + if (fp) + { + fprintf(fp, "\n劣文原因: %s\n", genbuf); + if (comment) + fprintf(fp, "\n被劣推文項目:\n%s", comment); + fprintf(fp, "\n"); + fclose(fp); + } + + setbdir(rptdir, BAD_POST_RECORD); + append_record(rptdir, &report_fh, sizeof(report_fh)); + + touchbtotal(rpt_bid); + } + } +#endif /* defined(BAD_POST_RECORD) */ + + sendalert(userid, ALERT_PWD_PERM); + mail_id(userid, genbuf, rptpath, cuser.userid); + + return 0; +} + +// 推文目前的設計一整個就是無法管理, +// 不過在重寫整套短文回應系統前也是沒辦法的事, +// 先寫個應應急的吧 +int +bad_comment(const char *fn) +{ + FILE *fp = NULL; + char buf[ANSILINELEN]; + char uid[IDLEN+1]; + int done = 0; + int i = 0, c; + + vs_hdr("劣推文"); + usercomplete("請輸入要劣推文的 ID: ", uid); + if (!*uid) + return -1; + + fp = fopen(fn, "rt"); + if (!fp) + return -1; + + vs_hdr2(" 劣推文 ", uid); + // search file for it + while (fgets(buf, sizeof(buf), fp) && *buf) + { + if (strstr(buf, uid) == NULL) + continue; + if (strstr(buf, ANSI_COLOR(33)) == NULL) + continue; + + // found something, let's show it + move(2, 0); clrtobot(); + prints("第 %d 項推文:\n", ++i); + outs(buf); + + move (5, 0); + outs("請問是要劣這個推文嗎?(Y:確定,N:找下個,Q:離開) [y/N/q]: "); + c = vkey(); + if (isascii(c)) c = tolower(c); + if (c == 'q') + break; + if (c != 'y') + continue; + + if (assign_badpost(uid, NULL, fn, buf) != 0) + continue; + + done = 1; + vmsg("已劣推文。"); + break; + } + fclose(fp); + + if (!done) + { + vmsgf("找不到其它「%s」的推文了", uid); + return -1; + } + + return 0; +} + #endif // ASSESS diff --git a/pttbbs/mbbsd/bbs.c b/pttbbs/mbbsd/bbs.c index 8a36e227..8848f4a4 100644 --- a/pttbbs/mbbsd/bbs.c +++ b/pttbbs/mbbsd/bbs.c @@ -32,12 +32,6 @@ enum { RECTYPE_DEFAULT = RECTYPE_GOOD, // match traditional user behavior }; -#ifdef ASSESS -static char * const badpost_reason[] = { - "廣告", "不當用辭", "人身攻擊" -}; -#endif - /* TODO multi.money is a mess. * please help verify and finish these. */ @@ -2380,11 +2374,32 @@ recommend_cancel(int ent, fileheader_t * fhdr, const char *direct) char yn[5]; if (!(currmode & MODE_BOARD)) return DONOTHING; - getdata(b_lines - 1, 0, "確定要推薦歸零[y/N]? ", yn, 5, LCECHO); +#if defined(ASSESS) && defined(EXP_BAD_COMMENT) + // supporting bad_comment +#if 0 + // XXX 推文可能會一直跑出來,所以... + if (now - atoi(fhdr->filename + 2) > 2 * 7 * 24 * 60 * 60) + { + move(b_lines-2, 0); clrtoeol(); + outs("超過兩週,禁止劣推文。"); + } else +#endif + { + getdata(b_lines - 1, 0, "請問您要 (1) 推薦歸零 (2) 劣推文 [1/2]? ", yn, 3, LCECHO); + if (yn[0] == '2') + { + char fn[PATHLEN]; + setbfile(fn, currboard, fhdr->filename); + bad_comment(fn); + return FULLUPDATE; + } else if (yn[0] != '1') + return FULLUPDATE; + } +#endif + getdata(b_lines - 1, 0, "確定要推薦歸零[y/N]? ", yn, 3, LCECHO); if (yn[0] != 'y') return FULLUPDATE; fhdr->recommend = 0; - substitute_ref_record(direct, fhdr, ent); return FULLUPDATE; } @@ -2991,10 +3006,6 @@ del_post(int ent, fileheader_t * fhdr, char *direct) del_ok = (cancelpost(fhdr, not_owned, newpath) == 0) ? 1 : 0; deleteCrossPost(fhdr, bp->brdname); -#ifdef ASSESS -#define SIZE sizeof(badpost_reason) / sizeof(char *) - - // badpost assignment // case one, self-owned, invalid author, or digest mode - should not give bad posts if (!not_owned || tusernum <= 0 || (currmode & MODE_DIGEST) ) @@ -3022,79 +3033,9 @@ del_post(int ent, fileheader_t * fhdr, char *direct) getdata(1, 40, "惡劣文章?(y/N)", genbuf, 3, LCECHO); if (genbuf[0]=='y') { - int i; - char *userid=getuserid(tusernum); - - move(b_lines - 2, 0); - clrtobot(); - for (i = 0; i < SIZE; i++) - prints("%d.%s ", i + 1, badpost_reason[i]); - prints("%d.%s", i + 1, "其他"); - getdata(b_lines - 1, 0, "請選擇[0:取消劣文]:", genbuf, 3, LCECHO); - i = genbuf[0] - '1'; - if (i >= 0 && i < SIZE) - sprintf(genbuf,"劣文退回(%s)", badpost_reason[i]); - else if(i==SIZE) - { - strcpy(genbuf,"劣文退回("); - getdata_buf(b_lines, 0, "請輸入原因", genbuf+9, - 50, DOECHO); - strcat(genbuf,")"); - } - if(i>=0 && i <= SIZE) - { - strncat(genbuf, fhdr->title, 64-strlen(genbuf)); - -#ifdef USE_COOLDOWN - add_cooldowntime(tusernum, 60); - add_posttimes(tusernum, 15); //Ptt: 凍結 post for 1 hour -#endif - - if (!(inc_badpost(userid, 1) % 5)){ - userec_t xuser; - post_violatelaw(userid, BBSMNAME " 系統警察", - "劣文累計 5 篇", "罰單一張"); - mail_violatelaw(userid, BBSMNAME " 系統警察", - "劣文累計 5 篇", "罰單一張"); - kick_all(userid); - passwd_sync_query(tusernum, &xuser); - xuser.money = moneyof(tusernum); - xuser.vl_count++; - xuser.userlevel |= PERM_VIOLATELAW; - xuser.timeviolatelaw = now; - passwd_sync_update(tusernum, &xuser); - } - sendalert(userid, ALERT_PWD_PERM); - mail_id(userid, genbuf, newpath, cuser.userid); - -#ifdef BAD_POST_RECORD - { - int rpt_bid = getbnum(BAD_POST_RECORD); - if (rpt_bid > 0) { - fileheader_t report_fh; - char report_path[PATHLEN]; - - setbpath(report_path, BAD_POST_RECORD); - stampfile(report_path, &report_fh); - - strcpy(report_fh.owner, "[" BBSMNAME "警察局]"); - snprintf(report_fh.title, sizeof(report_fh.title), - "%s 板 %s 板主給予 %s 一篇劣文", - currboard, cuser.userid, userid); - Copy(newpath, report_path); - - setbdir(report_path, BAD_POST_RECORD); - append_record(report_path, &report_fh, sizeof(report_fh)); - - touchbtotal(rpt_bid); - } - } -#endif /* defined(BAD_POST_RECORD) */ - } + assign_badpost(getuserid(tusernum), fhdr, newpath, NULL); } } -#undef SIZE -#endif setbtotal(currbid); |