summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
authorscw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-11-16 18:20:15 +0800
committerscw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-11-16 18:20:15 +0800
commit97b26dd92cdd0f51051dd2762c2584db77273191 (patch)
tree77ca0241d8c3adcc5aeba43582f1696cbeafb289 /mbbsd
parente04cae0836e65a13d3ea8166df4b291aafaa4f53 (diff)
downloadpttbbs-97b26dd92cdd0f51051dd2762c2584db77273191.tar
pttbbs-97b26dd92cdd0f51051dd2762c2584db77273191.tar.gz
pttbbs-97b26dd92cdd0f51051dd2762c2584db77273191.tar.bz2
pttbbs-97b26dd92cdd0f51051dd2762c2584db77273191.tar.lz
pttbbs-97b26dd92cdd0f51051dd2762c2584db77273191.tar.xz
pttbbs-97b26dd92cdd0f51051dd2762c2584db77273191.tar.zst
pttbbs-97b26dd92cdd0f51051dd2762c2584db77273191.zip
Post and money update:
* no money for posts on boards without BM * BM and self deleting posts decrease number of posts regardless of login git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4420 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/bbs.c16
-rw-r--r--mbbsd/mail.c16
-rw-r--r--mbbsd/passwd.c10
-rw-r--r--mbbsd/var.c1
4 files changed, 36 insertions, 7 deletions
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index 344c534f..3831ec12 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -1108,8 +1108,9 @@ do_general(int isbid)
#endif
aborted /= 2;
- // drop money for free boards
- if (IsFreeBoardName(currboard) || (currbrdattr&BRD_BAD))
+ // drop money & numposts for free boards
+ // including: special boards (e.g. TEST, ALLPOST), bad boards, no BM boards
+ if (IsFreeBoardName(currboard) || (currbrdattr&BRD_BAD) || bp->BM[0] < ' ')
{
aborted = 0;
}
@@ -3330,8 +3331,15 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
// not owner case
if (tusernum)
{
+ userec_t xuser;
+ passwd_query(tusernum, &xuser);
+ xuser.numposts--;
+ passwd_update(tusernum, &xuser);
+ sendalert_uid(tusernum, ALERT_PWD_POSTS);
+
// TODO alert user?
deumoney(tusernum, -fhdr->multi.money);
+
#ifdef USE_COOLDOWN
if (bp->brdattr & BRD_COOLDOWN)
add_cooldowntime(tusernum, 15);
@@ -3341,8 +3349,10 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
else
{
// owner case
- if (cuser.numposts)
+ if (cuser.numposts){
cuser.numposts--;
+ sendalert(cuser.userid, ALERT_PWD_POSTS);
+ }
demoney(-fhdr->multi.money);
vmsgf("您的文章減為 %d 篇,支付清潔費 %d 銀",
cuser.numposts, fhdr->multi.money);
diff --git a/mbbsd/mail.c b/mbbsd/mail.c
index d0eecd2f..fc7ae823 100644
--- a/mbbsd/mail.c
+++ b/mbbsd/mail.c
@@ -119,16 +119,24 @@ built_mail_index(void)
int
sendalert(const char *userid, int alert)
{
- userinfo_t *uentp = NULL;
- int n, tuid, i;
+ int tuid;
if ((tuid = searchuser(userid, NULL)) == 0)
return -1;
- n = count_logins(tuid, 0);
+ return sendalert_uid(tuid, alert);
+}
+
+int
+sendalert_uid(int uid, int alert){
+ userinfo_t *uentp = NULL;
+ int n, i;
+
+ n = count_logins(uid, 0);
for (i = 1; i <= n; i++)
- if ((uentp = (userinfo_t *) search_ulistn(tuid, i)))
+ if ((uentp = (userinfo_t *) search_ulistn(uid, i)))
uentp->alerts |= alert;
+
return 0;
}
diff --git a/mbbsd/passwd.c b/mbbsd/passwd.c
index b5e85907..95e655a1 100644
--- a/mbbsd/passwd.c
+++ b/mbbsd/passwd.c
@@ -101,6 +101,7 @@ passwd_update(int num, userec_t * buf)
memcpy(buf->email, u.email, sizeof(u.email));
memcpy(cuser.email, u.email, sizeof(u.email));
}
+ cuser.numposts += u.numposts - latest_numposts;
currutmp->alerts &= ~ALERT_PWD;
// ALERT_PWD_RELOAD: reload all! No need to write.
@@ -115,6 +116,11 @@ passwd_update(int num, userec_t * buf)
lseek(pwdfd, sizeof(userec_t) * (num - 1), SEEK_SET);
write(pwdfd, buf, sizeof(userec_t));
close(pwdfd);
+
+ if (latest_numposts != cuser.numposts) {
+ sendalert_uid(usernum, ALERT_PWD_POSTS);
+ latest_numposts = cuser.numposts;
+ }
return 0;
}
@@ -129,6 +135,10 @@ passwd_query(int num, userec_t * buf)
lseek(pwdfd, sizeof(userec_t) * (num - 1), SEEK_SET);
read(pwdfd, buf, sizeof(userec_t));
close(pwdfd);
+
+ if (buf == &cuser)
+ latest_numposts = cuser.numposts;
+
return 0;
}
diff --git a/mbbsd/var.c b/mbbsd/var.c
index a6d3811e..46e58bd3 100644
--- a/mbbsd/var.c
+++ b/mbbsd/var.c
@@ -104,6 +104,7 @@ userec_t cuser; /* current user structure */
crosspost_t postrecord; /* anti cross post */
unsigned int currbrdattr;
unsigned int currstat;
+uint32_t latest_numposts;
/* global string variables */
/* filename */