diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-09-14 01:13:33 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-09-14 01:13:33 +0800 |
commit | 9bb2b461450f6b953032aac4e57238cdff4e296a (patch) | |
tree | d102bbf927737bf989f5916c7c26f3d178734a1c | |
parent | 05dd93de8f37b2fcb2c7ed26c0cb18e550678494 (diff) | |
download | pttbbs-9bb2b461450f6b953032aac4e57238cdff4e296a.tar pttbbs-9bb2b461450f6b953032aac4e57238cdff4e296a.tar.gz pttbbs-9bb2b461450f6b953032aac4e57238cdff4e296a.tar.bz2 pttbbs-9bb2b461450f6b953032aac4e57238cdff4e296a.tar.lz pttbbs-9bb2b461450f6b953032aac4e57238cdff4e296a.tar.xz pttbbs-9bb2b461450f6b953032aac4e57238cdff4e296a.tar.zst pttbbs-9bb2b461450f6b953032aac4e57238cdff4e296a.zip |
* put-back the code to handle numlogin (changed to numlogindays)
* we can enable this after current code base becomes stable
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4838 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | mbbsd/bbs.c | 34 | ||||
-rw-r--r-- | mbbsd/board.c | 17 | ||||
-rw-r--r-- | mbbsd/chess.c | 4 | ||||
-rw-r--r-- | mbbsd/vote.c | 11 | ||||
-rw-r--r-- | mbbsd/voteboard.c | 11 |
5 files changed, 66 insertions, 11 deletions
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index 04a726ca..ae216a02 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -346,10 +346,15 @@ CheckPostPerm(void) // check if my own permission is changed. if (ISNEWPERM(currutmp)) { - // XXX let pwcuReload handle NEWPERM? - CLEAR_ALERT_NEWPERM(currutmp); +#ifdef DEBUG + log_filef("log/newperm.log", LOG_CREAT, + "%-13s: reloaded perm %s\n", + cuser.userid, Cdate(&now)); +#endif currmode &= ~MODE_POSTCHECKED; pwcuReload(); + // XXX let pwcuReload handle NEWPERM? + CLEAR_ALERT_NEWPERM(currutmp); } if (currmode & MODE_POSTCHECKED) @@ -405,6 +410,10 @@ int CheckPostRestriction(int bid) // check first-login if (cuser.firstlogin > (now - (time4_t)bp->post_limit_regtime * MONTH_SECONDS)) return 0; +#ifdef USE_LOGIN_LIMITS + if (cuser.numlogindays / 10 < (unsigned int)bp->post_limit_logins) + return 0; +#endif // XXX numposts itself is an integer, but some records (by del post!?) may // create invalid records as -1... so we'd better make it signed for real // comparison. @@ -939,7 +948,6 @@ do_general(int garbage) return READ_REDRAW; } -#ifndef DEBUG if ( !CheckPostRestriction(currbid) ) { vmsg("你不夠資深喔! (可按 i 查看限制)"); @@ -949,7 +957,6 @@ do_general(int garbage) if(check_cooldown(bp)) return READ_REDRAW; #endif -#endif clear(); setbfile(genbuf, currboard, FN_POST_NOTE); @@ -1978,7 +1985,8 @@ read_post(int ent, fileheader_t * fhdr, const char *direct) } void -editLimits(unsigned char *pregtime, unsigned char *pposts, unsigned char *pbadpost) +editLimits(unsigned char *pregtime, unsigned char *plogins, + unsigned char *pposts, unsigned char *pbadpost) { char genbuf[STRLEN]; int temp; @@ -1986,6 +1994,7 @@ editLimits(unsigned char *pregtime, unsigned char *pposts, unsigned char *pbadpo // load var unsigned char regtime = *pregtime, + logins = *plogins, posts = *pposts, badpost = *pbadpost; @@ -1998,6 +2007,17 @@ editLimits(unsigned char *pregtime, unsigned char *pposts, unsigned char *pbadpo } while (temp < 0 || temp > 255); regtime = (unsigned char)temp; +#ifdef USE_LOGIN_LIMITS + sprintf(genbuf, "%u", logins*10); + do { + move(b_lines-1, 0); clrtoeol(); // because previous prompt has same BIG5 prefix here + getdata_buf(b_lines - 1, 0, + STR_LOGINDAYS "下限 (0~2550,以10為單位,個位數字將自動捨去):", genbuf, 5, NUMECHO); + temp = atoi(genbuf); + } while (temp < 0 || temp > 2550); + logins = (unsigned char)(temp / 10); +#endif + sprintf(genbuf, "%u", posts*10); do { getdata_buf(b_lines - 1, 0, @@ -2016,6 +2036,7 @@ editLimits(unsigned char *pregtime, unsigned char *pposts, unsigned char *pbadpo // save var *pregtime = regtime; + *plogins = logins; *pposts = posts; *pbadpost = badpost; } @@ -2044,6 +2065,7 @@ do_limitedit(int ent, fileheader_t * fhdr, const char *direct) editLimits( &bp->post_limit_regtime, + &bp->post_limit_logins, &bp->post_limit_posts, &bp->post_limit_badpost); @@ -2057,6 +2079,7 @@ do_limitedit(int ent, fileheader_t * fhdr, const char *direct) editLimits( &bp->vote_limit_regtime, + &bp->vote_limit_logins, &bp->vote_limit_posts, &bp->vote_limit_badpost); @@ -2070,6 +2093,7 @@ do_limitedit(int ent, fileheader_t * fhdr, const char *direct) editLimits( &fhdr->multi.vote_limits.regtime, + &fhdr->multi.vote_limits.logins, &fhdr->multi.vote_limits.posts, &fhdr->multi.vote_limits.badpost); diff --git a/mbbsd/board.c b/mbbsd/board.c index 082b0903..3b2d8784 100644 --- a/mbbsd/board.c +++ b/mbbsd/board.c @@ -311,7 +311,8 @@ b_config(void) while(!finished) { // limits - uint8_t lpost = bp->post_limit_posts, + uint8_t llogin = bp->post_limit_logins, + lpost = bp->post_limit_posts, lreg = bp->post_limit_regtime, lbp = bp->post_limit_badpost; @@ -438,11 +439,25 @@ b_config(void) if (bp->brdattr & BRD_VOTEBOARD) { + llogin = bp->vote_limit_logins; lpost = bp->vote_limit_posts; lreg = bp->vote_limit_regtime; lbp = bp->vote_limit_badpost; } +#ifdef USE_LOGIN_LIMITS + if (llogin) + { + move_ansi(ipostres++, COLPOSTRES); + i = (int)llogin * 10; + attr = (cuser.numlogindays < i) ? 1 : 0; + if (attr) outs(ANSI_COLOR(1;31)); + prints(STR_LOGINDAYS " %d " STR_LOGINDAYS_QTY "以上", i); + if (attr) outs(ANSI_RESET); + hasres = 1; + } +#endif + if (lpost) { move_ansi(ipostres++, COLPOSTRES); diff --git a/mbbsd/chess.c b/mbbsd/chess.c index 11cb2a6f..84fda17f 100644 --- a/mbbsd/chess.c +++ b/mbbsd/chess.c @@ -1441,7 +1441,7 @@ ChessPhotoInitial(ChessInfo* info) switch (line) { case 0: sprintf(genbuf, " <代號> %s", xuser.userid); break; case 1: sprintf(genbuf, " <暱稱> %.16s", xuser.nickname); break; - case 2: sprintf(genbuf, " <上站> %d", xuser.numlogindays); break; + case 2: sprintf(genbuf, " <登入> %d", xuser.numlogindays); break; case 3: sprintf(genbuf, " <文章> %d", xuser.numposts); break; case 4: sprintf(genbuf, " <職位> %-4s %s", country, level); break; case 5: sprintf(genbuf, " <來源> %.16s", xuser.lasthost); break; @@ -1494,7 +1494,7 @@ ChessPhotoInitial(ChessInfo* info) switch (line - 9) { case 0: sprintf(PHOTO(line), "<代號> %-16.16s ", xuser.userid); break; case 1: sprintf(PHOTO(line), "<暱稱> %-16.16s ", xuser.nickname); break; - case 2: sprintf(PHOTO(line), "<上站> %-16d ", xuser.numlogindays); break; + case 2: sprintf(PHOTO(line), "<登入> %-16d ", xuser.numlogindays); break; case 3: sprintf(PHOTO(line), "<文章> %-16d ", xuser.numposts); break; case 4: sprintf(PHOTO(line), "<職位> %-4s %-10s ", country, level); break; case 5: sprintf(PHOTO(line), "<來源> %-16.16s ", xuser.lasthost); break; diff --git a/mbbsd/vote.c b/mbbsd/vote.c index 030c6704..b54cd6b1 100644 --- a/mbbsd/vote.c +++ b/mbbsd/vote.c @@ -646,9 +646,14 @@ vote_maintain(const char *bname) closetime = atoi(inbuf); // borrow variable } while (closetime < 0 || closetime > 120); fprintf(fp, "%d\n", now - (MONTH_SECONDS * closetime)); - - fprintf(fp, "%d\n", 0); // was: numlogins - + closetime = 0; +#ifdef USE_LOGIN_LIMITS + do { + getdata(6, 0, STR_LOGINDAYS "下限", inbuf, 6, DOECHO); + closetime = atoi(inbuf); // borrow variable + } while (closetime < 0); +#endif + fprintf(fp, "%d\n", closetime); do { getdata(6, 0, "文章篇數下限", inbuf, 6, DOECHO); closetime = atoi(inbuf); // borrow variable diff --git a/mbbsd/voteboard.c b/mbbsd/voteboard.c index 50c6053d..796fa31b 100644 --- a/mbbsd/voteboard.c +++ b/mbbsd/voteboard.c @@ -12,6 +12,10 @@ int CheckVoteRestriction(int bid) // check first-login if (cuser.firstlogin > (now - (time4_t)bcache[bid - 1].vote_limit_regtime * MONTH_SECONDS)) return 0; +#ifdef USE_LOGIN_LIMITS + if (cuser.numlogindays / 10 < (unsigned int)bcache[bid - 1].vote_limit_logins) + return 0; +#endif if (cuser.numposts / 10 < (unsigned int)bcache[bid - 1].vote_limit_posts) return 0; if (cuser.badpost > (255 - (unsigned int)bcache[bid - 1].vote_limit_badpost)) @@ -29,6 +33,10 @@ int CheckVoteRestrictionFile(const fileheader_t * fhdr) // check first-login if (cuser.firstlogin > (now - (time4_t)fhdr->multi.vote_limits.regtime * MONTH_SECONDS)) return 0; +#ifdef USE_LOGIN_LIMITS + if (cuser.numlogindays / 10 < (unsigned int)fhdr->multi.vote_limits.logins) + return 0; +#endif if (cuser.numposts / 10 < (unsigned int)fhdr->multi.vote_limits.posts) return 0; if (cuser.badpost > (255 - (unsigned int)fhdr->multi.vote_limits.badpost)) @@ -392,6 +400,9 @@ do_voteboard(int type) /* use lower 16 bits of 'money' to store limits */ /* lower 8 bits are posts, higher 8 bits are logins */ votefile.multi.vote_limits.regtime = bcache[currbid - 1].vote_limit_regtime; +#ifdef USE_LOGIN_LIMITS + votefile.multi.vote_limits.logins = bcache[currbid - 1].vote_limit_logins; +#endif votefile.multi.vote_limits.posts = bcache[currbid - 1].vote_limit_posts; votefile.multi.vote_limits.badpost = bcache[currbid - 1].vote_limit_badpost; setbdir(genbuf, currboard); |