summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/bbs.c47
-rw-r--r--mbbsd/cache.c6
-rw-r--r--mbbsd/passwd.c30
3 files changed, 74 insertions, 9 deletions
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index be55fa57..c9beeffd 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -2314,6 +2314,43 @@ board_etc()
setbdir(currdirect, currboard);
return NEWDIRECT;
}
+static int
+push_bottom(int ent, fileheader_t * fhdr, char *direct)
+{
+ int num, i;
+ char buf[256];
+ if ((currmode & MODE_DIGEST) || !(currmode & MODE_BOARD))
+ return DONOTHING;
+ setbfile(buf, currboard, ".BOTTOM");
+ num = get_num_records(buf, sizeof(fileheader_t));
+ if(getans(fhdr->filemode & FILE_BOTTOM ?
+ "¨ú®ø­«­n¤½½?(y/N)":
+ "¥[¤J­«­n¤½§i?(y/N)")!='y') return READ_REDRAW;
+ fhdr->filemode ^= FILE_BOTTOM;
+ if(fhdr->filemode & FILE_BOTTOM)
+ {
+ if(num >= 5)
+ {
+ outmsg("¤£±o¶W¹L 5 ½g­«­n¤½§i ½Ðºë²!");
+ pressanykey();
+ return READ_REDRAW;
+ }
+ append_record(buf, fhdr, sizeof(fileheader_t));
+ }
+ else
+ {
+ fileheader_t headers[5];
+ if(num>5) num=5;
+ num = get_records(buf, &headers, sizeof(fileheader_t), 1, num);
+ for(i=0; i<num; i++)
+ {
+ if(!strcmp(fhdr->filename, headers[i].filename))
+ delete_record(buf, sizeof(fileheader_t), i+1);
+ }
+ }
+ substitute_record(direct, fhdr, sizeof(fileheader_t), ent);
+ return READ_REDRAW;
+}
static int
good_post(int ent, fileheader_t * fhdr, char *direct)
@@ -2325,10 +2362,9 @@ good_post(int ent, fileheader_t * fhdr, char *direct)
if ((currmode & MODE_DIGEST) || !(currmode & MODE_BOARD))
return DONOTHING;
- getdata(1, 0, fhdr->filemode & FILE_DIGEST ?
- "¨ú®ø¬ÝªO¤åºK?(Y/n)" : "¦¬¤J¬ÝªO¤åºK?(Y/n)", genbuf2, 3, LCECHO);
- if(genbuf2[0] == 'n')
- return FULLUPDATE;
+ if(getans(fhdr->filemode & FILE_DIGEST ?
+ "¨ú®ø¬ÝªO¤åºK?(Y/n)" : "¦¬¤J¬ÝªO¤åºK?(Y/n)") == 'n')
+ return READ_REDRAW;
if (fhdr->filemode & FILE_DIGEST) {
fhdr->filemode = (fhdr->filemode & ~FILE_DIGEST);
@@ -2710,9 +2746,6 @@ Select()
void
mobile_message(char *mobile, char *message)
{
-
-
-
bsmtp(char *fpath, char *title, char *rcpt, int method);
}
diff --git a/mbbsd/cache.c b/mbbsd/cache.c
index 67a405d3..21319c8e 100644
--- a/mbbsd/cache.c
+++ b/mbbsd/cache.c
@@ -460,7 +460,7 @@ setumoney(int uid, int money)
int
deumoney(int uid, int money)
{
- if (money < 0 && SHM->money[uid - 1] < -money)
+ if (money < 0 && moneyof(uid) < -money)
return setumoney(uid, 0);
else
return setumoney(uid, SHM->money[uid - 1] + money);
@@ -475,6 +475,10 @@ demoney(int money)
int
moneyof(int uid)
{ /* ptt §ï¶iª÷¿ú³B²z®Ä²v */
+ if(SHM->money[uid - 1] == -1)
+ {
+ SHM->money[uid - 1] = passwd_query_money(uid);
+ }
return SHM->money[uid - 1];
}
diff --git a/mbbsd/passwd.c b/mbbsd/passwd.c
index 0f46f65f..ce6cd233 100644
--- a/mbbsd/passwd.c
+++ b/mbbsd/passwd.c
@@ -49,7 +49,9 @@ passwd_init()
}
int
-passwd_update_money(int num) /* update money only */
+passwd_update_money(int num)
+/* update money only
+ Ptt: don't call it directly, call deumoney() */
{
userec_t user;
int pwdfd, money = moneyof(num);
@@ -77,6 +79,32 @@ passwd_update_money(int num) /* update money only */
}
int
+passwd_query_money(int num)
+/* query money only
+ Ptt: don't call it directly, call moneyof() */
+{
+ userec_t user;
+ int pwdfd, money;
+ char path[256];
+
+ if (num < 1 || num > MAX_USERS)
+ return -1;
+
+ sethomefile(path, getuserid(num), ".passwd");
+
+ if ((pwdfd = open(path, O_WRONLY)) < 0)
+ {
+ if(passwd_index_query(num, &user)<0) // tempory code, will be removed
+ return -1;
+ return user.money;
+ }
+ if(lseek(pwdfd, (off_t)((int)&user.money - (int)&user), SEEK_SET) >= 0)
+ read(pwdfd, &money, sizeof(int));
+ close(pwdfd);
+ return money;
+}
+
+int
passwd_index_update(int num, userec_t * buf)
{
int pwdfd;