summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pttbbs/include/config.h10
-rw-r--r--pttbbs/mbbsd/bbs.c51
-rw-r--r--pttbbs/mbbsd/talk.c7
3 files changed, 32 insertions, 36 deletions
diff --git a/pttbbs/include/config.h b/pttbbs/include/config.h
index 296041a0..524143f1 100644
--- a/pttbbs/include/config.h
+++ b/pttbbs/include/config.h
@@ -111,6 +111,10 @@
#define BN_UNANONYMOUS "UnAnonymous"
#endif
+#ifndef BN_NEWIDPOST
+#define BN_NEWIDPOST "NEWIDPOST"
+#endif
+
#ifndef RECYCLE_BIN_NAME
#define RECYCLE_BIN_NAME "戈方Μ旦" // "︰В表"
#endif
@@ -271,6 +275,10 @@
#define BADPOST_MIN_CLEAR_DURATION (3) // ゅ丁
#endif
+#ifndef MAX_CROSSNUM
+#define MAX_CROSSNUM (9) /* 程crosspostΩ计 */
+#endif
+
/* (deprecated) more.c いゅ彻计(lines/22), +4 for safe */
#define MAX_PAGES (MAX_EDIT_LINE / 22 + 4)
@@ -283,14 +291,12 @@
#define MAX_ADBANNER_HEIGHT (11) /* 程笆篈狾ず甧蔼 */
#define MAX_ITEMS (1000) /* ヘ魁程Τ碭兜 */
#define MAX_HISTORY (12) /* 笆篈狾玂 12 掸菌癘魁 */
-#define MAX_CROSSNUM (9) /* 程crosspostΩ计 */
#define MAX_QUERYLINES (16) /* 陪ボ Query/Plan 癟程︽计 */
#define MAX_LOGIN_INFO (128) /* 程絬硄计 */
#define MAX_POST_INFO (32) /* 程穝ゅ彻硄计 */
#define MAX_NAMELIST (128) /* 程ㄤ疭虫计 */
#define MAX_NOTE (20) /* 程玂痙碭絞痙ē */
#define MAX_SIGLINES (6) /* 帽郎ま程︽计 */
-#define MAX_CROSSNUM (9) /* 程crosspostΩ计 */
#define MAX_REVIEW (7) /* 程瞴臮 */
#define NUMVIEWFILE (15) /* 秈礶程计 */
#define MAX_SWAPUSED (0.7) /* SWAP程蔼ㄏノ瞯 */
diff --git a/pttbbs/mbbsd/bbs.c b/pttbbs/mbbsd/bbs.c
index 1937f1f6..5ccefd87 100644
--- a/pttbbs/mbbsd/bbs.c
+++ b/pttbbs/mbbsd/bbs.c
@@ -10,6 +10,8 @@
#define WHEREAMI_LEVEL 16
+#define NEWIDPOST_LIMIT_DAYS (14)
+
static int recommend(int ent, fileheader_t * fhdr, const char *direct);
static int do_add_recommend(const char *direct, fileheader_t *fhdr,
int ent, const char *buf, int type);
@@ -225,7 +227,7 @@ anticrosspost(void)
pwcuViolateLaw();
mail_id(cuser.userid, "Cross-Post籃虫",
"etc/crosspost.txt", BBSMNAME "牡诡场钉");
- if ((now - cuser.firstlogin) / DAY_SECONDS < 14)
+ if (cuser.numlogindays < 50 || cuser.numposts < 50)
delete_allpost(cuser.userid);
kick_all(cuser.userid); // XXX: in2: wait for testing
u_exit("Cross Post");
@@ -932,6 +934,9 @@ cancelpost(const char *direct, const fileheader_t *fh,
static void
do_deleteCrossPost(const fileheader_t *fh, char bname[])
{
+ // TODO FIXME this function is used when some user violates policy (ex,
+ // crosspost) and system is trying to delete all the posts in every boards.
+
char bdir[PATHLEN], file[PATHLEN];
fileheader_t newfh;
boardheader_t *bp;
@@ -951,10 +956,8 @@ do_deleteCrossPost(const fileheader_t *fh, char bname[])
memcpy(&newfh, fh, sizeof(fileheader_t));
// XXX TODO FIXME This (finding file by getindex) sucks. getindex checks
- // only timestamp by binary search, and we know that BN_ALLPOST has plenty
- // of files sharing same timestamp, so deleting cross post has a very big
- // chance to delete wrong file, or failed to find the target.
- // (there's no promise that entries in BN_ALLPOST are sequential)
+ // only timestamp by binary search, but that is not always true in current
+ // system.
// Ptt: protect original fh
// because getindex safe_article_delete will change fh in some case
@@ -971,6 +974,7 @@ do_deleteCrossPost(const fileheader_t *fh, char bname[])
// the getindex is not stable. in order to prevent leaving files,
// no matter what, delete the file.
+ delete_file_content2(bdir, fh, bdir, NULL, 0, "Cross-Post(╰参牡诡埃)");
unlink(file);
}
@@ -979,9 +983,9 @@ 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, BN_UNANONYMOUS))
- {
+ if(strcmp(bname, BN_ALLPOST) == 0 || strcmp(bname, BN_NEWIDPOST == 0) ||
+ strcmp(bname, BN_ALLHIDPOST) == 0 || strcmp(bname, BN_UNANONYMOUS) == 0) {
+ // These files (in BN_ALLPOST etc) has a '.BOARD' refrence in title
int len=0;
char xbname[TTLEN + 1], *po = strrchr(fh->title, '.');
if(!po) return;
@@ -991,9 +995,7 @@ deleteCrossPost(const fileheader_t *fh, char *bname)
if(len > TTLEN) return;
sprintf(xbname, "%.*s", len, po);
do_deleteCrossPost(fh, xbname);
- }
- else
- {
+ } else {
// Always delete file content in ALLPOST and keep the header
// because that will be reset by cron jobs
char file[PATHLEN];
@@ -1018,22 +1020,10 @@ delete_allpost(const char *userid)
if(strcmp(fhdr.owner, userid))
continue;
deleteCrossPost(&fhdr, BN_ALLPOST);
+ // No need to touch the file since ALLPOST is cleared weekly.
setbfile(file, BN_ALLPOST, fhdr.filename);
unlink(file);
-
- // usually delete_allpost are initiated by system,
- // so don't set normal safedel.
-#ifdef FN_SAFEDEL_PREFIX_LEN
- strncpy(fhdr.filename, FN_SAFEDEL, FN_SAFEDEL_PREFIX_LEN);
-#else
- strcpy(fhdr.filename, FN_SAFEDEL);
-#endif
- strcpy(fhdr.owner, "-");
- snprintf(fhdr.title, sizeof(fhdr.title),
- "%s", STR_SAFEDEL_TITLE);
-
- lseek(fd, sizeof(fileheader_t) * i, SEEK_SET);
- write(fd, &fhdr, sizeof(fileheader_t));
+ // No need to touch header in ALLPOST.
}
close(fd);
}
@@ -1442,8 +1432,8 @@ do_general(int garbage GCC_UNUSED)
brc_addlist(postfile.filename, postfile.modified);
if (IsBoardForAllpost(bp)) {
- if ((now - cuser.firstlogin) / DAY_SECONDS < 14)
- do_crosspost("NEWIDPOST", &postfile, fpath, 0);
+ if (cuser.numlogindays < NEWIDPOST_LIMIT_DAYS)
+ do_crosspost(BN_NEWIDPOST, &postfile, fpath, 0);
if (!(currbrdattr & BRD_HIDE) )
do_crosspost(BN_ALLPOST, &postfile, fpath, 0);
@@ -3206,9 +3196,7 @@ recommend(int ent, fileheader_t * fhdr, const char *direct)
{
static int tolog = 0;
if( tolog == 0 )
- tolog =
- (cuser.numlogindays < 50 || (now - cuser.firstlogin) < DAY_SECONDS * 7)
- ? 1 : 2;
+ tolog = (cuser.numlogindays < 50) ? 1 : 2;
if( tolog == 1 ){
FILE *fp;
if( (fp = fopen("log/push", "a")) != NULL ){
@@ -3608,6 +3596,9 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
del_ret = cancelpost(direct, fhdr, not_owned,
newpath, sizeof(newpath), reason);
+ // delete the file reference in BN_ALLPOST, or delete all related
+ // posts if we (SYSOP) are working in a special board like
+ // BN_NEWIDPOST.
deleteCrossPost(fhdr, bp->brdname);
move(b_lines - 10, 0); clrtobot();
diff --git a/pttbbs/mbbsd/talk.c b/pttbbs/mbbsd/talk.c
index 01c4c683..04b4afd4 100644
--- a/pttbbs/mbbsd/talk.c
+++ b/pttbbs/mbbsd/talk.c
@@ -2967,10 +2967,9 @@ t_chat(void)
#endif
#ifdef CHAT_REGDAYS
- if ((now - cuser.firstlogin)/DAY_SECONDS < CHAT_REGDAYS)
- {
- int i = CHAT_REGDAYS - (now-cuser.firstlogin)/DAY_SECONDS +1;
- vmsgf("眤﹟ゼ笷秈兵ン (叫单 %d ぱ)", i);
+ if (cuser.numlogindays < CHAT_REGDAYS) {
+ vmsgf("眤﹟ゼ笷秈兵ン (" STR_LOGINDAYS ": %d, 惠璶: %d)",
+ cuser.numlogindays, CHAT_REGDAYS);
return 0;
}
#endif