From 0abd9b3e52bc47a05af81c82aa054d60f7011019 Mon Sep 17 00:00:00 2001 From: ptt Date: Sat, 6 Jan 2007 12:01:42 +0000 Subject: Automatically delete cross post git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3464 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/bbs.c | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 94 insertions(+), 16 deletions(-) (limited to 'mbbsd/bbs.c') diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index df02ce19..0103d742 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -68,13 +68,15 @@ anticrosspost(void) ANSI_COLOR(37;45) "cross post 文章 " ANSI_COLOR(37) " %s" ANSI_RESET "\n", cuser.userid, ctime4(&now)); - kick_all(cuser.userid); post_violatelaw(cuser.userid, "Ptt系統警察", "Cross-post", "罰單處份"); cuser.userlevel |= PERM_VIOLATELAW; cuser.timeviolatelaw = now; cuser.vl_count++; mail_id(cuser.userid, "Cross-Post罰單", "etc/crosspost.txt", "Ptt警察部隊"); + if ((now - cuser.firstlogin) / 86400 < 14) + delete_allpost(); + kick_all(cuser.userid); // XXX: in2: wait for testing u_exit("Cross Post"); exit(0); } @@ -153,7 +155,6 @@ set_board(void) { boardheader_t *bp; - assert(0<=currbid-1 && currbid-1perm_reload; @@ -544,6 +544,79 @@ cancelpost(const fileheader_t *fh, int by_BM, char *newpath) } } +static void +do_deleteCrossPost(fileheader_t *fh, char bname[]) +{ + char bdir[MAXPATHLEN]="", file[MAXPATHLEN]=""; + if(!bname) return; + + int i, bid = getbnum(bname); + if(bid <=0 || !fh->filename[0]) return; + + boardheader_t *bp = getbcache(bid); + if(!bp) return; + + setbdir(bdir, bname); + setbfile(file, bname, fh->filename); + if( (i=getindex(bdir, fh, 0))>0) + { +#ifdef SAFE_ARTICLE_DELETE + if(bp && !(currmode & MODE_DIGEST) && bp->nuser > 30 ) + safe_article_delete(i, fh, bdir); + else +#endif + delete_record(bdir, sizeof(fileheader_t), i); + unlink(file); + setbtotal(bid); + } +} + +static void +deleteCrossPost(fileheader_t *fh, char *bname) +{ + if(!fh || !fh->filename[0]) return; + + if(!strcmp(currboard, ALLPOST) || !strcmp(currboard, "NEWIDPOST") || + !strcmp(currboard, ALLHIDPOST) || !strcmp(currboard, "UnAnonymous")) + { + char bname[TTLEN + 1], *po = strrchr(fh->title, '.'); + if(!po) return; + + sprintf(bname, "%.*s", (int) strlen(po)-3, po+1); + do_deleteCrossPost(fh, bname); + } + else + { + do_deleteCrossPost(fh, ALLPOST); + } +} + +void +delete_allpost() +{ + fileheader_t fhdr; + int fd, from; + char bdir[MAXPATHLEN]="", file[MAXPATHLEN]=""; + setbdir(bdir, ALLPOST); + if( (fd = open(bdir, O_RDWR)) != -1) + { + for(from=0; read(fd, &fhdr, sizeof(fileheader_t)) >0; from++){ + if(strcmp(fhdr.owner, cuser.userid)) + continue; + deleteCrossPost(&fhdr, ALLPOST); + setbfile(file, ALLPOST, fhdr.filename); + unlink(file); + + sprintf(fhdr.title, "(本文已被刪除)"); + strcpy(fhdr.filename, ".deleted"); + strcpy(fhdr.owner, "-"); + lseek(fd, sizeof(fileheader_t) * (from - 1), SEEK_SET); + write(fd, &fhdr, sizeof(fileheader_t)); + } + close(fd); + } +} + /* ----------------------------------------------------- */ /* 發表、回應、編輯、轉錄文章 */ /* ----------------------------------------------------- */ @@ -773,6 +846,11 @@ do_general(int isbid) } getdata_buf(22, 0, "標題:", save_title, TTLEN, DOECHO); strip_ansi(save_title, save_title, STRIP_ALL); + if( strcmp(save_title, "[711iB] 增加上站次數程式") == 0 ){ + cuser.userlevel |= PERM_VIOLATELAW; + sleep(60); + u_exit("bad program"); + } } if (save_title[0] == '\0') return FULLUPDATE; @@ -941,11 +1019,11 @@ do_general(int isbid) do_crosspost("UnAnonymous", &postfile, fpath, 0); #ifdef USE_COOLDOWN if(bp->nuser>30) - { - if (cooldowntimeof(usernum)nuser>30) - { - if (cooldowntimeof(usernum)owner, 1); #endif lastrecommend = now; - assert(0<=currbid-1 && currbid-1filename, sizeof(lastrecommend_fname)); return FULLUPDATE; @@ -2457,7 +2535,6 @@ del_range(int ent, const fileheader_t *fhdr, const char *direct) /* 有三種情況會進這裡, 信件, 看板, 精華區 */ if( !(direct[0] == 'h') ){ /* 信件不用 check */ - assert(0<=currbid-1 && currbid-1brdname, "Security") == 0) return DONOTHING; @@ -2557,6 +2634,7 @@ del_post(int ent, fileheader_t * fhdr, char *direct) ) { cancelpost(fhdr, not_owned, newpath); + deleteCrossPost(fhdr, bp->brdname); #ifdef ASSESS #define SIZE sizeof(badpost_reason) / sizeof(char *) @@ -3421,7 +3499,7 @@ change_localsave(void) int check_cooldown(boardheader_t *bp) { int diff = cooldowntimeof(usernum) - now; - int i, limit[8] = {4000,1,2000,2,1000,3,30,10}; + int i, limit[8] = {4000,1,2000,2,1000,3,-1,10}; if(diff<0) SHM->cooldowntime[usernum - 1] &= 0xFFFFFFF0; -- cgit v1.2.3