summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwens <wens@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-03-03 21:14:59 +0800
committerwens <wens@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-03-03 21:14:59 +0800
commitfea64042f0f66b989215dfdf644dade15b2b6be1 (patch)
treec4ce862fecd857f32e5ceafbb4659145c1097d69
parentc8e482734eccf9567c8ca19edd126ab3d9d6404c (diff)
downloadpttbbs-fea64042f0f66b989215dfdf644dade15b2b6be1.tar
pttbbs-fea64042f0f66b989215dfdf644dade15b2b6be1.tar.gz
pttbbs-fea64042f0f66b989215dfdf644dade15b2b6be1.tar.bz2
pttbbs-fea64042f0f66b989215dfdf644dade15b2b6be1.tar.lz
pttbbs-fea64042f0f66b989215dfdf644dade15b2b6be1.tar.xz
pttbbs-fea64042f0f66b989215dfdf644dade15b2b6be1.tar.zst
pttbbs-fea64042f0f66b989215dfdf644dade15b2b6be1.zip
add regtime to post & vote limits
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2573 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--include/pttstruct.h10
-rw-r--r--mbbsd/bbs.c43
-rw-r--r--mbbsd/mail.c5
-rw-r--r--mbbsd/voteboard.c10
-rw-r--r--util/zero_limits.c2
5 files changed, 50 insertions, 20 deletions
diff --git a/include/pttstruct.h b/include/pttstruct.h
index 0223ceee..5e686a8b 100644
--- a/include/pttstruct.h
+++ b/include/pttstruct.h
@@ -170,11 +170,11 @@ typedef struct boardheader_t {
char chesscountry;
unsigned char vote_limit_posts; /* 連署 : 文章篇數下限 */
unsigned char vote_limit_logins; /* 連署 : 登入次數下限 */
- char pad[1]; /* 沒用到的 */
+ unsigned char vote_limit_regtime; /* 連署 : 註冊時間限制 */
time4_t bupdate; /* note update time */
unsigned char post_limit_posts; /* 發表文章 : 文章篇數下限 */
unsigned char post_limit_logins; /* 發表文章 : 登入次數下限 */
- char pad2[1]; /* 沒用到的 */
+ unsigned char post_limit_regtime; /* 發表文章 : 註冊時間限制 */
unsigned char bvote; /* 正舉辦 Vote 數 */
time4_t vtime; /* Vote close time */
unsigned int level; /* 可以看此板的權限 */
@@ -239,7 +239,8 @@ typedef struct fileheader_t {
/* different order to match alignment */
#ifdef _BIG_ENDIAN
struct {
- unsigned char pad[2]; /* money & 0xffff0000 */
+ unsigned char pad[1]; /* money & 0xff000000 */
+ unsigned char regtime; /* money & 0xff0000 */
unsigned char logins; /* money & 0xff00 */
unsigned char posts; /* money & 0xff */
} vote_limits;
@@ -251,7 +252,8 @@ typedef struct fileheader_t {
struct {
unsigned char posts; /* money & 0xff */
unsigned char logins; /* money & 0xff00 */
- unsigned char pad[2]; /* money & 0xffff0000 */
+ unsigned char regtime; /* money & 0xff0000 */
+ unsigned char pad[1]; /* money & 0xffff0000 */
} vote_limits;
struct {
unsigned int ref:31;
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index 76b9b748..b3eb3bc8 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -543,10 +543,11 @@ do_general(int isbid)
}
#ifndef DEBUG
- if ( cuser.numlogins < ((unsigned int)(bcache[currbid - 1].post_limit_logins) * 10) ||
+ if ( cuser.firstlogin > (now - (time4_t)bcache[currbid - 1].post_limit_regtime * 2592000) ||
+ cuser.numlogins < ((unsigned int)(bcache[currbid - 1].post_limit_logins) * 10) ||
cuser.numposts < ((unsigned int)(bcache[currbid - 1].post_limit_posts) * 10) ) {
move(5, 10);
- vmsg("你的上站數/文章數不足喔!");
+ vmsg("你不夠資深喔!");
return FULLUPDATE;
}
#endif
@@ -803,7 +804,8 @@ do_generalboardreply(fileheader_t * fhdr)
{
char genbuf[3];
- if ( cuser.numlogins < ((unsigned int)(bcache[currbid - 1].post_limit_logins) * 10) ||
+ if ( cuser.firstlogin > (now - (time4_t)bcache[currbid - 1].post_limit_regtime * 2592000) ||
+ cuser.numlogins < ((unsigned int)(bcache[currbid - 1].post_limit_logins) * 10) ||
cuser.numposts < ((unsigned int)(bcache[currbid - 1].post_limit_posts) * 10) ) {
getdata(b_lines - 1, 0, "▲ 回應至 (M)作者信箱 (Q)取消?[M] ",
genbuf, sizeof(genbuf), LCECHO);
@@ -1029,10 +1031,11 @@ cross_post(int ent, fileheader_t * fhdr, char *direct)
postrecord.checksum[0] = ent;
}
- if ( cuser.numlogins < ((unsigned int)(bcache[author - 1].post_limit_logins) * 10) ||
+ if ( cuser.firstlogin > (now - (time4_t)bcache[currbid - 1].post_limit_regtime * 2592000) ||
+ cuser.numlogins < ((unsigned int)(bcache[author - 1].post_limit_logins) * 10) ||
cuser.numposts < ((unsigned int)(bcache[author - 1].post_limit_posts) * 10) ) {
move(5, 10);
- vmsg("你的上站數/文章數不足喔!");
+ vmsg("你不夠資深喔!");
return FULLUPDATE;
}
@@ -1147,13 +1150,12 @@ read_post(int ent, fileheader_t * fhdr, char *direct)
int
do_limitedit(int ent, fileheader_t * fhdr, char *direct)
{
- char genbuf[256], buf[256];
- int temp;
- boardheader_t *bp = NULL;
+ char genbuf[256], buf[256];
+ int temp;
+ boardheader_t *bp = getbcache(currbid);
if (!((currmode & MODE_BOARD) || HAS_PERM(PERM_SYSOP)))
return DONOTHING;
- bp = getbcache(currbid);
strcpy(buf, "更改 ");
if (HAS_PERM(PERM_SYSOP))
@@ -1165,6 +1167,13 @@ do_limitedit(int ent, fileheader_t * fhdr, char *direct)
genbuf[0] = getans(buf);
if (HAS_PERM(PERM_SYSOP) && genbuf[0] == 'a') {
+ sprintf(genbuf, "%u", bp->post_limit_regtime);
+ do {
+ getdata_buf(b_lines - 1, 0, "註冊時間限制 (以'月'為單位,0~255):", genbuf, 4, LCECHO);
+ temp = atoi(genbuf);
+ } while (temp < 0 || temp > 255);
+ bp->post_limit_regtime = (unsigned char)temp;
+
sprintf(genbuf, "%u", bp->post_limit_logins * 10);
do {
getdata_buf(b_lines - 1, 0, "上站次數下限 (0~2550):", genbuf, 5, LCECHO);
@@ -1174,7 +1183,7 @@ do_limitedit(int ent, fileheader_t * fhdr, char *direct)
sprintf(genbuf, "%u", bp->post_limit_posts * 10);
do {
- getdata_buf(23, 0, "文章篇數下限 (0~2550):", genbuf, 5, LCECHO);
+ getdata_buf(b_lines - 1, 0, "文章篇數下限 (0~2550):", genbuf, 5, LCECHO);
temp = atoi(genbuf);
} while (temp < 0 || temp > 2550);
bp->post_limit_posts = (unsigned char)(temp / 10);
@@ -1184,6 +1193,13 @@ do_limitedit(int ent, fileheader_t * fhdr, char *direct)
return FULLUPDATE;
}
else if (genbuf[0] == 'b') {
+ sprintf(genbuf, "%u", bp->vote_limit_regtime);
+ do {
+ getdata_buf(b_lines - 1, 0, "註冊時間限制 (以'月'為單位,0~255):", genbuf, 4, LCECHO);
+ temp = atoi(genbuf);
+ } while (temp < 0 || temp > 255);
+ bp->vote_limit_regtime = (unsigned char)temp;
+
sprintf(genbuf, "%u", bp->vote_limit_logins * 10);
do {
getdata_buf(b_lines - 1, 0, "上站次數下限 (0~2550):", genbuf, 5, LCECHO);
@@ -1203,6 +1219,13 @@ do_limitedit(int ent, fileheader_t * fhdr, char *direct)
return FULLUPDATE;
}
else if ((fhdr->filemode & FILE_VOTE) && genbuf[0] == 'c') {
+ sprintf(genbuf, "%u", fhdr->multi.vote_limits.regtime);
+ do {
+ getdata_buf(b_lines - 1, 0, "註冊時間限制 (以'月'為單位,0~255):", genbuf, 4, LCECHO);
+ temp = atoi(genbuf);
+ } while (temp < 0 || temp > 255);
+ fhdr->multi.vote_limits.regtime = temp;
+
sprintf(genbuf, "%u", (unsigned int)(fhdr->multi.vote_limits.logins) * 10);
do {
getdata_buf(b_lines - 1, 0, "上站次數下限 (0~2550):", genbuf, 5, LCECHO);
diff --git a/mbbsd/mail.c b/mbbsd/mail.c
index dd571ee6..2b0b7160 100644
--- a/mbbsd/mail.c
+++ b/mbbsd/mail.c
@@ -1044,10 +1044,11 @@ mail_cross_post(int ent, fileheader_t * fhdr, char *direct)
return TITLE_REDRAW;
ent = getbnum(xboard);
- if ( cuser.numlogins < ((unsigned int)(bcache[ent - 1].post_limit_logins) * 10) ||
+ if ( cuser.firstlogin > (now - (time4_t)bcache[currbid - 1].post_limit_regtime * 2592000) ||
+ cuser.numlogins < ((unsigned int)(bcache[ent - 1].post_limit_logins) * 10) ||
cuser.numposts < ((unsigned int)(bcache[ent - 1].post_limit_posts) * 10) ) {
move(5, 10);
- vmsg("你的上站數/文章數不足喔!");
+ vmsg("你不夠資深喔!");
return FULLUPDATE;
}
diff --git a/mbbsd/voteboard.c b/mbbsd/voteboard.c
index 443b4d4b..73cc0742 100644
--- a/mbbsd/voteboard.c
+++ b/mbbsd/voteboard.c
@@ -165,10 +165,11 @@ do_voteboard(int type)
vmsg("對不起,您目前無法在此發表文章!");
return FULLUPDATE;
}
- if ( cuser.numlogins < ((unsigned int)(bcache[currbid - 1].vote_limit_logins) * 10) ||
+ if ( cuser.firstlogin > (now - (time4_t)bcache[currbid - 1].vote_limit_regtime * 2592000) ||
+ cuser.numlogins < ((unsigned int)(bcache[currbid - 1].vote_limit_logins) * 10) ||
cuser.numposts < ((unsigned int)(bcache[currbid - 1].vote_limit_posts) * 10) ) {
move(5, 10);
- vmsg("你的上站數/文章數不足喔!");
+ vmsg("你不夠資深喔!");
return FULLUPDATE;
}
move(0, 0);
@@ -345,8 +346,9 @@ do_voteboard(int type)
votefile.filemode |= FILE_VOTE;
/* use lower 16 bits of 'money' to store limits */
/* lower 8 bits are posts, higher 8 bits are logins */
- votefile.multi.vote_limits.logins = (unsigned int)bcache[currbid - 1].vote_limit_logins;
- votefile.multi.vote_limits.posts = (unsigned int)bcache[currbid - 1].vote_limit_posts;
+ votefile.multi.vote_limits.regtime = bcache[currbid - 1].vote_limit_regtime;
+ votefile.multi.vote_limits.logins = bcache[currbid - 1].vote_limit_logins;
+ votefile.multi.vote_limits.posts = bcache[currbid - 1].vote_limit_posts;
setbdir(genbuf, currboard);
if (append_record(genbuf, &votefile, sizeof(votefile)) != -1)
setbtotal(currbid);
diff --git a/util/zero_limits.c b/util/zero_limits.c
index e9824ff5..7305abc5 100644
--- a/util/zero_limits.c
+++ b/util/zero_limits.c
@@ -8,8 +8,10 @@ void transform(boardheader_t *new, boardheader_t *old)
memcpy(new, old, sizeof(boardheader_t));
new->post_limit_posts = (unsigned char) 0;
new->post_limit_logins = (unsigned char) 0;
+ new->post_limit_regtime = (unsigned char) 0;
new->vote_limit_posts = (unsigned char) 0;
new->vote_limit_logins = (unsigned char) 0;
+ new->vote_limit_regtime = (unsigned char) 0;
memset(new->pad, 0, sizeof(new->pad));
memset(new->pad2, 0, sizeof(new->pad2));
memset(new->pad3, 0, sizeof(new->pad3));