summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/proto.h5
-rw-r--r--mbbsd/bbs.c61
-rw-r--r--mbbsd/cache.c14
-rw-r--r--mbbsd/user.c14
4 files changed, 62 insertions, 32 deletions
diff --git a/include/proto.h b/include/proto.h
index ca3391a4..eebcc8fd 100644
--- a/include/proto.h
+++ b/include/proto.h
@@ -155,8 +155,10 @@ void buildBMcache(int);
void reload_bcache(void);
void reload_fcache(void);
#ifdef USE_COOLDOWN
-#define cooldowntimeof(uid) SHM->cooldowntime[uid - 1]
+#define cooldowntimeof(uid) (SHM->cooldowntime[uid - 1] & 0xFFFFFFF0)
+#define posttimesof(uid) (SHM->cooldowntime[uid - 1] & 0xF)
void add_cooldowntime(int uid, int min);
+void add_posttimes(int uid, int times);
#endif
/* cal */
@@ -689,6 +691,7 @@ int u_editcalendar(void);
void user_display(const userec_t *u, int real);
void uinfo_query(userec_t *u, int real, int unum);
int showsignature(char *fname, int *j);
+void kick_all(char *user);
void mail_violatelaw(const char* crime, const char* police, const char* reason, const char* result);
void showplans(const char *uid);
int u_info(void);
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index 33734295..b017d3b0 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -18,7 +18,7 @@ anticrosspost(void)
log_file("etc/illegal_money", LOG_CREAT | LOG_VF,
"\033[1;33;46m%s \033[37;45mcross post 文章 \033[37m %s\033[m\n",
cuser.userid, ctime4(&now));
-
+ kick_all(cuser.userid);
post_violatelaw(cuser.userid, "Ptt系統警察", "Cross-post", "罰單處份");
cuser.userlevel |= PERM_VIOLATELAW;
cuser.vl_count++;
@@ -418,12 +418,6 @@ do_unanonymous_post(const char *fpath)
}
}
*/
-#ifdef NO_WATER_POST
-#ifndef DEBUG
-static time4_t last_post_time = 0;
-#endif
-static time4_t water_counts = 0;
-#endif
void
do_crosspost(const char *brd, fileheader_t *postfile, const char *fpath)
@@ -551,23 +545,21 @@ do_general(int isbid)
vmsg("冷靜一下吧!");
return FULLUPDATE;
}
-#endif
-#endif
#ifdef NO_WATER_POST
-#ifndef DEBUG /* why we need this in DEBUG mode? */
- /* 三分鐘內最多發表五篇文章 */
- if (currutmp->lastact - last_post_time < 60 * 3 &&
- water_counts >= 5) {
- vmsg("對不起,您的文章太水囉,待會再post吧!可用'X'推薦文章");
- return READ_REDRAW;
- }
- else
- {
- last_post_time = currutmp->lastact;
- water_counts = 0;
- }
-#endif
+ /* 三分鐘內最多發表 9篇文章 */
+ if(cooldowntimeof(usernum)<now)
+ {
+ add_cooldowntime(usernum, 3);
+ }
+ else if(posttimesof(usernum)>=9)
+ {
+ vmsg("對不起,您的文章太水囉,待會再post吧!可用'X'推薦文章");
+ return READ_REDRAW;
+ }
+#endif // NO_WATER_POST
+
+#endif // USE_COOLDOWN
#endif
clear();
@@ -654,7 +646,11 @@ do_general(int isbid)
pressanykey();
return FULLUPDATE;
}
- water_counts++; /* po成功 */
+#ifdef USE_COOLDOWN
+#ifdef NO_WATER_POST
+ add_posttimes(usernum, 1);
+#endif // NO_WATER_POST
+#endif // USE_COOLDOWN
/* set owner to Anonymous , for Anonymous board */
@@ -1972,11 +1968,20 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
strcat(genbuf,")");
}
strncat(genbuf, fhdr->title, 64-strlen(genbuf));
- if (!(inc_badpost(userid, 1) % 10)){
- post_violatelaw(userid, "Ptt 系統警察", "劣文累計十篇", "罰單一張");
- mail_violatelaw(userid, "Ptt 系統警察", "劣文累計十篇", "罰單一張");
- // XXX xuser 未指定, 也未寫回檔案, 沒有作用
- //xuser.userlevel |= PERM_VIOLATELAW;
+
+ add_cooldowntime(tusernum, 60);
+ add_posttimes(tusernum, 9); //Ptt: 凍結 post for 1 hour
+
+ if (!(inc_badpost(userid, 1) % 5)){
+ userec_t xuser;
+ post_violatelaw(userid, "Ptt 系統警察", "劣文累計 5 篇", "罰單一張");
+ mail_violatelaw(userid, "Ptt 系統警察", "劣文累計 5 篇", "罰單一張");
+ kick_all(userid);
+ passwd_query(tusernum, &xuser);
+ xuser.money = moneyof(uid);
+ xuser.vl_count++;
+ xuser.userlevel |= PERM_VIOLATELAW;
+ passwd_update(tusernum, &xuser);
}
mail_id(userid, genbuf, newpath, cuser.userid);
}
diff --git a/mbbsd/cache.c b/mbbsd/cache.c
index 703f0855..626ab06d 100644
--- a/mbbsd/cache.c
+++ b/mbbsd/cache.c
@@ -1037,8 +1037,16 @@ hbflcheck(int bid, int uid)
#ifdef USE_COOLDOWN
void add_cooldowntime(int uid, int min)
{
- time4_t new = now + 60 * min;
- time4_t old = SHM->cooldowntime[uid - 1];
- SHM->cooldowntime[uid - 1] = new > old ? new : old;
+ // Ptt: I will use the number below 15 seconds.
+ time4_t base = (now & 0xFFFFFFF0) + 1;
+
+ if(base < SHM->cooldowntime[uid - 1])
+ base = SHM->cooldowntime[uid - 1];
+
+ SHM->cooldowntime[uid - 1] = base + min*60;
+}
+void add_posttimes(int uid, int times)
+{
+ SHM->cooldowntime[uid - 1] + times;
}
#endif
diff --git a/mbbsd/user.c b/mbbsd/user.c
index 2788aebc..e67d4c68 100644
--- a/mbbsd/user.c
+++ b/mbbsd/user.c
@@ -196,6 +196,19 @@ mail_violatelaw(const char *crime, const char *police, const char *reason, const
append_record(genbuf, &fhdr, sizeof(fhdr));
}
+void
+kick_all(char *user)
+{
+ userinfo_t *ui;
+ int num = searchuser(user, NULL);
+ while(!(ui = (userinfo_t *) search_ulist(num)))
+ {
+ if(ui == currutmp) continue;
+ kill(ui->pid, SIGHUP);
+ log_usies("KICK ALL", user);
+ }
+}
+
static void
violate_law(userec_t * u, int unum)
{
@@ -241,6 +254,7 @@ violate_law(userec_t * u, int unum)
kill_user(unum);
} else {
+ kick_all(u->userid);
u->userlevel |= PERM_VIOLATELAW;
u->vl_count++;
passwd_update(unum, u);