diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2013-10-30 13:09:05 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2013-10-30 13:09:05 +0800 |
commit | 3441bba90ace14c53681e034fd82915de6924969 (patch) | |
tree | aa93e4d71d4cba44f74baf8d645f6e0bcd3899a3 | |
parent | 14b5fab890c5e91c850b678f2edf02c64f75fa85 (diff) | |
download | pttbbs-3441bba90ace14c53681e034fd82915de6924969.tar pttbbs-3441bba90ace14c53681e034fd82915de6924969.tar.gz pttbbs-3441bba90ace14c53681e034fd82915de6924969.tar.bz2 pttbbs-3441bba90ace14c53681e034fd82915de6924969.tar.lz pttbbs-3441bba90ace14c53681e034fd82915de6924969.tar.xz pttbbs-3441bba90ace14c53681e034fd82915de6924969.tar.zst pttbbs-3441bba90ace14c53681e034fd82915de6924969.zip |
Change expire to only take "max post".
In modern servers, it does not make any sense to expire by date.
Let's always only consider "max post".
git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5885 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | pttbbs/UPDATING | 4 | ||||
-rw-r--r-- | pttbbs/sample/etc/Makefile | 2 | ||||
-rw-r--r-- | pttbbs/sample/etc/editable | 2 | ||||
-rw-r--r-- | pttbbs/sample/etc/expire.conf | 4 | ||||
-rw-r--r-- | pttbbs/sample/etc/expire2.conf | 4 | ||||
-rw-r--r-- | pttbbs/util/expire.c | 60 |
6 files changed, 27 insertions, 49 deletions
diff --git a/pttbbs/UPDATING b/pttbbs/UPDATING index 4495125c..96cfcbb2 100644 --- a/pttbbs/UPDATING +++ b/pttbbs/UPDATING @@ -23,6 +23,10 @@ https://opensvn.csie.org/traccgi/pttbbs/changeset/2273 make r4871_uflag ----------------------------------------------------------------------------- +r5885: [expire] +util/expire 格式修改,不再看 days/minp. +為避免誤砍,設定檔也同時改名為 expire2.conf。請自行調整。 + r5858: [birthday] 不再要求輸入生日,直接要求輸入是否已滿十八歲,減少儲存的使用者個資。 請跑一下 upgrade/r5858_birth 用已知生日重建是否滿十八歲的資料。 diff --git a/pttbbs/sample/etc/Makefile b/pttbbs/sample/etc/Makefile index 35457c1c..faef1818 100644 --- a/pttbbs/sample/etc/Makefile +++ b/pttbbs/sample/etc/Makefile @@ -7,7 +7,7 @@ FILES= Welcome Welcome_login \ register registered registermail registeredmail \ feast sysop banip.conf \ ve.hlp board.help boardlist.help \ - editable expire.conf domain_name_query.cidr \ + editable expire2.conf domain_name_query.cidr \ banemail whitemail whitemail.notice ziphome.exclude all: diff --git a/pttbbs/sample/etc/editable b/pttbbs/sample/etc/editable index 1599781f..8df60298 100644 --- a/pttbbs/sample/etc/editable +++ b/pttbbs/sample/etc/editable @@ -29,7 +29,7 @@ etc/Welcome_login.4 進站畫面4 etc/crosspost.txt 過度轉錄開的罰單通知信 etc/myfav_defaults 我的最愛預設列表 etc/post.note 發文注意事項 -etc/expire.conf 看板期限 +etc/expire2.conf 看板期限 etc/feast 節日 etc/domain_name_query.cidr 故鄉 etc/whitemail 註冊 email 白名單 diff --git a/pttbbs/sample/etc/expire.conf b/pttbbs/sample/etc/expire.conf deleted file mode 100644 index 9cb8340d..00000000 --- a/pttbbs/sample/etc/expire.conf +++ /dev/null @@ -1,4 +0,0 @@ -# board days max min -# --------------------------------------- -cvslog 999 9999 -asciiart 50 3000 diff --git a/pttbbs/sample/etc/expire2.conf b/pttbbs/sample/etc/expire2.conf new file mode 100644 index 00000000..459fef5d --- /dev/null +++ b/pttbbs/sample/etc/expire2.conf @@ -0,0 +1,4 @@ +# board max +# --------------------------------------- +cvslog 9999 +asciiart 3000 diff --git a/pttbbs/util/expire.c b/pttbbs/util/expire.c index bfcf1e31..862500cc 100644 --- a/pttbbs/util/expire.c +++ b/pttbbs/util/expire.c @@ -5,11 +5,9 @@ #define QCAST int (*)(const void *, const void *) -#define DEF_DAYS 60 -#define DEF_MAXP 10000 -#define DEF_MINP 9000 +#define DEF_MAXP 30000 -#define EXPIRE_CONF BBSHOME "/etc/expire.conf" +#define EXPIRE_CONF BBSHOME "/etc/expire2.conf" #ifdef SAFE_ARTICLE_DELETE char safe_delete_only = 0; #endif @@ -18,9 +16,7 @@ int checkmode = 0; typedef struct { char bname[IDLEN + 1]; /* board ID */ - int days; /* expired days */ int maxp; /* max post */ - int minp; /* min post */ } life_t; void callsystem(char *s) @@ -68,11 +64,11 @@ void expire(life_t *brd) char fpath[128], index[128], *fname; int total, bid; int fdlock, fdr, fdw = 0, done, keep; - int duetime, ftime, nKeep = 0, nDelete = 0; + int ftime, nKeep = 0, nDelete = 0; printf("%s\n", brd->bname); /* XXX: bid of cache.c's getbnum starts from 1 */ - if( (bid = getbnum(brd->bname)) == 0 || + if( (bid = getbnum(brd->bname)) == 0 || strcmp(brd->bname, bcache[bid - 1].brdname) ){ printf("no such board?: %s\n", brd->bname); sprintf(cmd, "mv "BBSHOME"/boards/%c/%s "BBSHOME"/boards.error/%s", @@ -81,10 +77,6 @@ void expire(life_t *brd) return; } #ifdef VERBOSE - if( brd->days < 1 ){ - printf(":Err: expire time must more than 1 day.\n"); - return; - } else if( brd->maxp < 100 ){ printf(":Err: maxmum posts number must more than 100.\n"); return; @@ -103,7 +95,6 @@ void expire(life_t *brd) strcpy(fpath, index); fname = (char *) strrchr(fpath, '.'); - duetime = (int)time(NULL) - brd->days * 24 * 60 * 60; done = 0; if( (fdr = open(index, O_RDONLY, 0)) > 0 ){ fstat(fdr, &state); @@ -128,12 +119,12 @@ void expire(life_t *brd) ) keep = 0; #ifdef SAFE_ARTICLE_DELETE - else if( safe_delete_only ) + else if (safe_delete_only) keep = 1; #endif - else if( head.filemode & FILE_MARKED || total <= brd->minp ) + else if (head.filemode & FILE_MARKED) keep = 1; - else if( ftime < duetime || total > brd->maxp ) + else if (total > brd->maxp) keep = 0; else keep = 1; @@ -209,7 +200,7 @@ void visitdir(char c) while( (de = readdir(dirp)) != NULL ) if( de->d_name[0] != '.' ) toexpire(de->d_name); - + closedir(dirp); } @@ -228,11 +219,9 @@ int main(int argc, char **argv) chdir(BBSHOME); /* default value */ - db.days = DEF_DAYS; db.maxp = DEF_MAXP; - db.minp = DEF_MINP; - while( (ch = getopt(argc, argv, "d:M:m:hn" + while( (ch = getopt(argc, argv, "M:hn" #ifdef SAFE_ARTICLE_DELETE "D" #endif @@ -243,27 +232,19 @@ int main(int argc, char **argv) safe_delete_only = 1; break; #endif - case 'd': - db.days = atoi(optarg); - break; case 'M': db.maxp = atoi(optarg); break; - case 'm': - db.minp = atoi(optarg); - break; case 'n': checkmode = 1; break; case 'h': default: fprintf(stderr, - "usage: expire [-m minp] [-M MAXP] [-d days] [board name...] [-n]\n" + "usage: expire [-M MAXP] [board name...] [-n]\n" "deletion policy:\n" - " do nothing if #articles < minp (default:%d)\n" - " delete NOT MARKED articles which were post before days \n" - " (default:%d) or #articles > MAXP (default:%d)\n", - DEF_MINP, DEF_DAYS, DEF_MAXP); + " delete NOT MARKED articles if #articles > MAXP (default:%d)\n", + DEF_MAXP); return 0; } argc -= optind; @@ -285,23 +266,16 @@ int main(int argc, char **argv) if( ptr && (number = atoi(ptr)) > 0 ){ key = &(table[count++]); strcpy(key->bname, bname); - key->days = number; key->maxp = db.maxp; - key->minp = db.minp; - - ptr = (char *) strtok(NULL, " \t\r\n"); - if( ptr && (number = atoi(ptr)) > 0 ){ - key->maxp = number; - - ptr = (char *) strtok(NULL, " \t\r\n"); - if( ptr && (number = atoi(ptr)) > 0 ){ - key->minp = number; - } - } } } } fclose(fin); + } else { + printf("Sorry, failed to load configuration file %s.\n" + "The format has been changed, so please make sure you do\n" + "upgraded manually.\n", EXPIRE_CONF); + exit(1); } if( count > 1) |