summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2009-08-30 16:25:07 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2009-08-30 16:25:07 +0800
commit37019e5c460e64a6dec35863d53603fbe9825ce1 (patch)
tree720a97a54076991509a13484b344f7d176973c66
parent7b2cc2e83030882b319bbf87932c7727c174adc7 (diff)
downloadpttbbs-37019e5c460e64a6dec35863d53603fbe9825ce1.tar
pttbbs-37019e5c460e64a6dec35863d53603fbe9825ce1.tar.gz
pttbbs-37019e5c460e64a6dec35863d53603fbe9825ce1.tar.bz2
pttbbs-37019e5c460e64a6dec35863d53603fbe9825ce1.tar.lz
pttbbs-37019e5c460e64a6dec35863d53603fbe9825ce1.tar.xz
pttbbs-37019e5c460e64a6dec35863d53603fbe9825ce1.tar.zst
pttbbs-37019e5c460e64a6dec35863d53603fbe9825ce1.zip
* (pwcu branch) code refine, remove unused code, and finetune alerts
git-svn-id: http://opensvn.csie.org/pttbbs/branches/pttbbs.pwcu@4796 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--common/bbs/cache.c3
-rw-r--r--common/bbs/passwd.c3
-rw-r--r--include/pttstruct.h10
-rw-r--r--mbbsd/announce.c10
-rw-r--r--mbbsd/bbs.c20
-rw-r--r--mbbsd/card.c22
-rw-r--r--mbbsd/passwd.c43
-rw-r--r--mbbsd/read.c8
-rw-r--r--mbbsd/register.c7
-rw-r--r--mbbsd/talk.c11
-rw-r--r--mbbsd/user.c3
11 files changed, 22 insertions, 118 deletions
diff --git a/common/bbs/cache.c b/common/bbs/cache.c
index 1166a85b..a23326bd 100644
--- a/common/bbs/cache.c
+++ b/common/bbs/cache.c
@@ -27,7 +27,10 @@
// these cannot be used!
#define currutmp YOU_FAILED
#define usernum YOU_FAILED
+#undef cuser
+#undef cuser_ref
#define cuser YOU_FAILED
+#define cuser_ref YOU_FAILED
#define abort_bbs YOU_FAILED
#define log_usies YOU_FAILED
diff --git a/common/bbs/passwd.c b/common/bbs/passwd.c
index 3e55d4d2..71d995d9 100644
--- a/common/bbs/passwd.c
+++ b/common/bbs/passwd.c
@@ -23,7 +23,10 @@
// these cannot be used!
#define currutmp YOU_FAILED
#define usernum YOU_FAILED
+#undef cuser
+#undef cuser_ref
#define cuser YOU_FAILED
+#define cuser_ref YOU_FAILED
#define abort_bbs YOU_FAILED
#define log_usies YOU_FAILED
diff --git a/include/pttstruct.h b/include/pttstruct.h
index a79e2bb6..3d554e54 100644
--- a/include/pttstruct.h
+++ b/include/pttstruct.h
@@ -315,14 +315,8 @@ typedef struct msgque_t {
#define ALERT_NEW_MAIL (0x01)
#define ISNEWMAIL(utmp) (utmp->alerts & ALERT_NEW_MAIL)
-#define ALERT_PWD_PERM (0x02)
-#define ALERT_PWD_BADPOST (0x04)
-#define ALERT_PWD_GOODPOST (0x08)
-#define ALERT_PWD_JUSTIFY (0x10)
-// #define ALERT_PWD_LOGINS (0x20)
-#define ALERT_PWD_POSTS (0x40)
-#define ALERT_PWD_RELOAD (0x80) // reload entire pwd
-#define ALERT_PWD (ALERT_PWD_PERM|ALERT_PWD_BADPOST|ALERT_PWD_GOODPOST|ALERT_PWD_JUSTIFY|ALERT_PWD_POSTS|ALERT_PWD_RELOAD)
+#define ALERT_PWD_PERM (0x02)
+#define ISNEWPERM(utmp) (utmp->alerts & ALERT_PWD_PERM)
// userinfo_t.angelpause values
#define ANGELPAUSE_NONE (0) // reject none (accept all)
diff --git a/mbbsd/announce.c b/mbbsd/announce.c
index 8663d392..0ec3f6ce 100644
--- a/mbbsd/announce.c
+++ b/mbbsd/announce.c
@@ -119,10 +119,6 @@ int copyqueue_toggle(CopyQueue *pcq)
int i = copyqueue_locate(pcq);
if(i >= 0)
{
-#if 0
- if (vans("已標記過此檔,要取消標記嗎 [y/N]: ") != 'y')
- return 1;
-#endif
/* remove it */
used_copyqueue --;
if(head_copyqueue > used_copyqueue)
@@ -172,14 +168,8 @@ a_copyitem(const char *fpath, const char *title, const char *owner, int mode)
//copyqueue_append(&cq);
copyqueue_toggle(&cq);
if (mode && flFirstAlert) {
-#if 0
- move(b_lines-2, 0); clrtoeol();
- prints("目前已標記 %d 個檔案。[注意] 拷貝後才能刪除原文!",
- copyqueue_querysize());
-#else
vmsg("[注意] 提醒您複製/標記後要貼上(p)或附加(a)後才能刪除原文!");
flFirstAlert = 0;
-#endif
}
}
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index d19c8d91..dc8390b5 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -242,12 +242,12 @@ save_violatelaw(void)
demoney(-1000 * cuser.vl_count);
pwcuSaveViolateLaw();
- sendalert(cuser.userid, ALERT_PWD_PERM);
log_filef("log/violation", LOG_CREAT,
"%s %s pay-violation: $%d complete.\n",
Cdate(&now), cuser.userid, (int)cuser.vl_count*1000);
- vmsg("罰單已付,請盡速重新登入。");
+ vmsg("罰單已付,請重新登入。");
+ exit(0);
return 0;
}
@@ -340,6 +340,13 @@ CheckPostPerm(void)
if (currmode & MODE_DIGEST)
return 0;
+ // check if my own permission is changed.
+ if (ISNEWPERM(currutmp))
+ {
+ currmode &= ~MODE_POSTCHECKED;
+ pwcuReload();
+ }
+
if (currmode & MODE_POSTCHECKED)
{
/* checked? let's check if perm reloaded */
@@ -3021,7 +3028,7 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
xuser.timeviolatelaw = now;
passwd_sync_update(tusernum, &xuser);
}
- sendalert(userid, ALERT_PWD_BADPOST);
+ sendalert(userid, ALERT_PWD_PERM);
mail_id(userid, genbuf, newpath, cuser.userid);
#ifdef BAD_POST_RECORD
@@ -3084,11 +3091,8 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
if (xuser.numposts > 0)
xuser.numposts--;
passwd_update(tusernum, &xuser);
- sendalert_uid(tusernum, ALERT_PWD_POSTS);
-
- // TODO alert user?
deumoney(tusernum, -fhdr->multi.money);
-
+ sendalert_uid(tusernum, ALERT_PWD_PERM);
#ifdef USE_COOLDOWN
if (bp->brdattr & BRD_COOLDOWN)
add_cooldowntime(tusernum, 15);
@@ -3100,7 +3104,7 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
// owner case
pwcuDecNumPost();
demoney(-fhdr->multi.money);
- sendalert(cuser.userid, ALERT_PWD_POSTS);
+ sendalert(cuser.userid, ALERT_PWD_PERM);
vmsgf("您的文章減為 %d 篇,支付清潔費 %d 元",
cuser.numposts, fhdr->multi.money);
}
diff --git a/mbbsd/card.c b/mbbsd/card.c
index 5735c4c6..48f29b98 100644
--- a/mbbsd/card.c
+++ b/mbbsd/card.c
@@ -441,28 +441,6 @@ game_log(int type, int money)
if (money > 0)
card_add_money(money);
- // if the money is not real user money, no need to log anymore.
-#if 0
- FILE *fp;
-
- switch (type) {
- case JACK:
- fp = fopen(BBSHOME "/etc/card/jack.log", "a");
- if (!fp)
- return 0;
- fprintf(fp, "%s win:%d\n", cuser.userid, money);
- fclose(fp);
- break;
- case TEN_HALF:
- fp = fopen(BBSHOME "/etc/card/tenhalf.log", "a");
- if (!fp)
- return 0;
- fprintf(fp, "%s win:%d\n", cuser.userid, money);
- fclose(fp);
- break;
- }
-#endif
-
return 0;
}
diff --git a/mbbsd/passwd.c b/mbbsd/passwd.c
index 161239bd..05363661 100644
--- a/mbbsd/passwd.c
+++ b/mbbsd/passwd.c
@@ -11,14 +11,6 @@
#define cuser pwcuser
#endif
-void
-passwd_force_update(int flag)
-{
- if(!currutmp || (currutmp->alerts & ALERT_PWD) == 0)
- return;
- currutmp->alerts &= ~flag;
-}
-
int
initcuser(const char *userid)
{
@@ -26,60 +18,27 @@ initcuser(const char *userid)
return usernum;
}
-// XXX I don't like the stupid synchronization here,
-// but simply following previous work here...
int
passwd_sync_update(int num, userec_t * buf)
{
- int alerts;
-
if (num < 1 || num > MAX_USERS)
return -1;
// money update should be done before everything.
buf->money = moneyof(num);
-
- if(usernum == num && currutmp && ((alerts = currutmp->alerts) & ALERT_PWD))
- {
- userec_t u;
- if (passwd_sync_query(num, &u) != 0)
- return -1;
-
- if(alerts & ALERT_PWD_BADPOST)
- cuser.badpost = buf->badpost = u.badpost;
- if(alerts & ALERT_PWD_PERM)
- cuser.userlevel = buf->userlevel = u.userlevel;
- if(alerts & ALERT_PWD_JUSTIFY)
- {
- memcpy(buf->justify, u.justify, sizeof(u.justify));
- memcpy(cuser.justify, u.justify, sizeof(u.justify));
- memcpy(buf->email, u.email, sizeof(u.email));
- memcpy(cuser.email, u.email, sizeof(u.email));
- }
- currutmp->alerts &= ~ALERT_PWD;
-
- // ALERT_PWD_RELOAD: reload all! No need to write.
- if (alerts & ALERT_PWD_RELOAD)
- {
- memcpy(&cuser, &u, sizeof(u));
- return 0;
- }
- }
-
if (passwd_update(num, buf) != 0)
return -1;
return 0;
}
-// XXX I don't like the stupid synchronization here,
-// but simply following previous work here...
int
passwd_sync_query(int num, userec_t * buf)
{
if (passwd_query(num, buf) < 0)
return -1;
+ buf->money = moneyof(num);
return 0;
}
diff --git a/mbbsd/read.c b/mbbsd/read.c
index 6071ac39..4616cd62 100644
--- a/mbbsd/read.c
+++ b/mbbsd/read.c
@@ -87,14 +87,6 @@ Tagger(time4_t chrono, int recno, int mode)
return YEA;
}
-#if 0
-static void
-EnumTagName(char *fname, int locus) /* unused */
-{
- snprintf(fname, sizeof(fname), "M.%d.A", (int)TagList[locus].chrono);
-}
-#endif
-
void
EnumTagFhdr(fileheader_t * fhdr, char *direct, int locus)
{
diff --git a/mbbsd/register.c b/mbbsd/register.c
index ac490c76..9f9a2b74 100644
--- a/mbbsd/register.c
+++ b/mbbsd/register.c
@@ -246,12 +246,6 @@ compute_user_value(const userec_t * urec, time4_t clock)
return 30 - value;
#endif
-#if 0
- if (!urec->numlogins) /* 未 login 成功者,不保留 */
- return -1;
- if (urec->numlogins <= 3) /* #login 少於三者,保留 20 天 */
- return 20 * 24 * 60 - value;
-#endif
/* 未完成註冊者,保留 15 天 */
/* 一般情況,保留 120 天 */
return (urec->userlevel & PERM_LOGINOK ? 120 : 15) * 24 * 60 - value;
@@ -1690,7 +1684,6 @@ regform_accept(const char *userid, const char *justify)
// alert online users?
if (search_ulist(unum))
{
- sendalert(muser.userid, ALERT_PWD_PERM|ALERT_PWD_JUSTIFY); // force to reload perm
kick_all(muser.userid);
}
diff --git a/mbbsd/talk.c b/mbbsd/talk.c
index bc728b8d..da909076 100644
--- a/mbbsd/talk.c
+++ b/mbbsd/talk.c
@@ -450,16 +450,7 @@ my_query(const char *uident)
move(1, 0);
setutmpmode(TQUERY);
currutmp->destuid = tuid;
-
- // XXX some users keep complaining that query result (for numpost)
- // is not synced...
- // well, make them happy now.
- if (tuid == usernum)
- {
- // XXX there're still users asking why money is not updated...
- reload_money();
- memcpy(&muser, cuser_ref, sizeof(muser));
- }
+ reload_money();
if ((uentp = (userinfo_t *) search_ulist(tuid)))
fri_stat = friend_stat(currutmp, uentp);
diff --git a/mbbsd/user.c b/mbbsd/user.c
index 0b356eab..b03ac25b 100644
--- a/mbbsd/user.c
+++ b/mbbsd/user.c
@@ -1122,10 +1122,7 @@ uinfo_query(const char *orig_uid, int adminmode, int unum)
passwd_sync_update(unum, &x);
if (adminmode)
- {
- sendalert(x.userid, ALERT_PWD_RELOAD);
kick_all(x.userid);
- }
// resolve_over18 only works for cuser
if (!adminmode)