summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorscw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-04-02 16:38:42 +0800
committerscw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-04-02 16:38:42 +0800
commitce50463a745c2a9af1f4310de6a12a2a461c97f1 (patch)
tree31c589739ddd4ecd6f144790dafb6fea654685e6
parent17cd044b7ce599bd480b4c2bff0eab42c9e2bb05 (diff)
downloadpttbbs-ce50463a745c2a9af1f4310de6a12a2a461c97f1.tar
pttbbs-ce50463a745c2a9af1f4310de6a12a2a461c97f1.tar.gz
pttbbs-ce50463a745c2a9af1f4310de6a12a2a461c97f1.tar.bz2
pttbbs-ce50463a745c2a9af1f4310de6a12a2a461c97f1.tar.lz
pttbbs-ce50463a745c2a9af1f4310de6a12a2a461c97f1.tar.xz
pttbbs-ce50463a745c2a9af1f4310de6a12a2a461c97f1.tar.zst
pttbbs-ce50463a745c2a9af1f4310de6a12a2a461c97f1.zip
merge from trunk:1680.
git-svn-id: http://opensvn.csie.org/pttbbs/branches/scw.brc2@1682 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--UPDATING12
-rw-r--r--blog/INSTALL7
-rw-r--r--include/bbs.h3
-rw-r--r--include/modes.h18
-rw-r--r--include/perm.h4
-rw-r--r--include/proto.h12
-rw-r--r--include/pttstruct.h2
-rw-r--r--include/util.h3
-rw-r--r--mbbsd.icc/.cvsignore3
-rw-r--r--mbbsd.icc/Makefile72
-rw-r--r--mbbsd/admin.c25
-rw-r--r--mbbsd/announce.c16
-rw-r--r--mbbsd/bbs.c186
-rw-r--r--mbbsd/board.c42
-rw-r--r--mbbsd/cache.c6
-rw-r--r--mbbsd/cal.c69
-rw-r--r--mbbsd/calendar.c4
-rw-r--r--mbbsd/card.c16
-rw-r--r--mbbsd/chat.c13
-rw-r--r--mbbsd/chc.c16
-rw-r--r--mbbsd/chicken.c57
-rw-r--r--mbbsd/dice.c18
-rw-r--r--mbbsd/edit.c44
-rw-r--r--mbbsd/fav.c2
-rw-r--r--mbbsd/friend.c81
-rw-r--r--mbbsd/gamble.c6
-rw-r--r--mbbsd/gomo.c69
-rw-r--r--mbbsd/guess.c26
-rw-r--r--mbbsd/indict.c2
-rw-r--r--mbbsd/kaede.c12
-rw-r--r--mbbsd/lovepaper.c6
-rw-r--r--mbbsd/mail.c129
-rw-r--r--mbbsd/mbbsd.c197
-rw-r--r--mbbsd/menu.c9
-rw-r--r--mbbsd/more.c21
-rw-r--r--mbbsd/othello.c16
-rw-r--r--mbbsd/page.c4
-rw-r--r--mbbsd/passwd.c106
-rw-r--r--mbbsd/read.c17
-rw-r--r--mbbsd/record.c72
-rw-r--r--mbbsd/register.c51
-rw-r--r--mbbsd/screen.c2
-rw-r--r--mbbsd/stuff.c7
-rw-r--r--mbbsd/syspost.c14
-rw-r--r--mbbsd/talk.c73
-rw-r--r--mbbsd/user.c194
-rw-r--r--mbbsd/var.c2
-rw-r--r--mbbsd/vote.c4
-rw-r--r--mbbsd/voteboard.c30
-rw-r--r--mbbsd/xyz.c12
-rw-r--r--util/birth.c26
-rw-r--r--util/horoscope.c32
-rw-r--r--util/reaper.c2
-rw-r--r--util/uhash_loader.c7
-rw-r--r--util/yearsold.c8
55 files changed, 911 insertions, 976 deletions
diff --git a/UPDATING b/UPDATING
deleted file mode 100644
index 8b22e3b8..00000000
--- a/UPDATING
+++ /dev/null
@@ -1,12 +0,0 @@
-Fri Jun 7 05:44:54 CST 2002
- only one shared memory
-
-Tue Jun 4 13:07:12 UTC 2002
- global variable move to var.c
-
-Sun May 26 04:49:03 CST 2002
- new userlist.
-
-Mon Apr 29 03:33:38 CST 2002:
- change getdata() constant to sizeof()
-
diff --git a/blog/INSTALL b/blog/INSTALL
index dfbfb3d0..1f216292 100644
--- a/blog/INSTALL
+++ b/blog/INSTALL
@@ -70,3 +70,10 @@ $Id$
`mtime` int(11) NOT NULL default '0',
PRIMARY KEY (`k`)
) TYPE=MyISAM;
+
+ CREATE TABLE `wcounter` (
+ `k` char(32) NOT NULL default '',
+ `v` int(11) NOT NULL default '0',
+ `mtime` int(11) NOT NULL default '0',
+ PRIMARY KEY (`k`)
+ ) TYPE=MyISAM;
diff --git a/include/bbs.h b/include/bbs.h
index 1132717f..20e4f091 100644
--- a/include/bbs.h
+++ b/include/bbs.h
@@ -46,7 +46,8 @@
#ifdef __linux__
#include <sys/param.h>
#include <limits.h>
- #include <sys/file.h> // for flock()
+ #include <sys/file.h> /* for flock() */
+ #include <strings.h> /* for strcasecmp() */
size_t
strlcpy(char *dst, const char *src, size_t size);
diff --git a/include/modes.h b/include/modes.h
index 175186c6..16d23754 100644
--- a/include/modes.h
+++ b/include/modes.h
@@ -12,6 +12,7 @@
#define DIRCHANGED 8 /* Index file was changed */
#define READ_REDRAW 9
#define PART_REDRAW 10
+#define TITLE_REDRAW 11
#define POS_NEXT 101 /* cursor_pos(locmem, locmem->crs_ln + 1, 1);*/
/* user 操作狀態與模式 */
@@ -103,14 +104,15 @@
#define XEASY 0x333 /* Return value to un-redraw screen */
/* for currmode */
-#define MODE_STARTED 1 /* 是否已經進入系統 */
-#define MODE_POST 2 /* 是否可以在 currboard 發表文章 */
-#define MODE_BOARD 4 /* 是否可以在 currboard 刪除、mark文章 */
-#define MODE_GROUPOP 8 /* 是否為小組長 (可以在 MENU 開板) */
-#define MODE_DIGEST 0x10 /* 是否為 digest mode */
-#define MODE_ETC 0x20 /* 是否為 etc mode */
-#define MODE_SELECT 0x40 /* 搜尋使用者標題 */
-#define MODE_DIRTY 0x80 /* 是否更動過 userflag */
+#define MODE_STARTED 0x0001 /* 是否已經進入系統 */
+#define MODE_POST 0x0002 /* 是否可以在 currboard 發表文章 */
+#define MODE_POSTCHECKED 0x0004 /* 是否已檢查在 currboard 發表文章的權限 */
+#define MODE_BOARD 0x0008 /* 是否可以在 currboard 刪除、mark文章 */
+#define MODE_GROUPOP 0x0010 /* 是否為小組長 (可以在 MENU 開板) */
+#define MODE_DIGEST 0x0020 /* 是否為 digest mode */
+#define MODE_ETC 0x0040 /* 是否為 etc mode */
+#define MODE_SELECT 0x0080 /* 搜尋使用者標題 */
+#define MODE_DIRTY 0x0100 /* 是否更動過 userflag */
/* for curredit */
#define EDIT_MAIL 1 /* 目前是 mail/board ? */
diff --git a/include/perm.h b/include/perm.h
index 2d676bae..93232bdb 100644
--- a/include/perm.h
+++ b/include/perm.h
@@ -49,8 +49,8 @@
#define PERM_FORWARD (PERM_BASIC) /* to do the forwarding */
#define PERM_INTERNET (PERM_LOGINOK) /* 身份認證過關的才能寄信到 Internet */
-#define HAS_PERM(x) ((x) ? cuser.userlevel & (x) : 1)
-#define HAVE_PERM(x) (cuser.userlevel&(x))
+#define HAS_PERM(x) ((x) ? cuser->userlevel & (x) : 1)
+#define HAVE_PERM(x) (cuser->userlevel&(x))
#define PERM_HIDE(u) ((u)->userlevel & PERM_SYSOP && \
(u)->userlevel & PERM_DENYPOST)
diff --git a/include/proto.h b/include/proto.h
index 5c423bbb..2828a196 100644
--- a/include/proto.h
+++ b/include/proto.h
@@ -54,6 +54,7 @@ int del_range(int ent, fileheader_t *fhdr, char *direct);
int cmpfowner(fileheader_t *fhdr);
int b_note_edit_bname(int bid);
int Read();
+int CheckPostPerm(void);
void anticrosspost();
int Select();
void do_reply_title(int row, char *title);
@@ -152,7 +153,7 @@ int give_tax(int money);
int vice(int money, char* item);
int inumoney(char *tuser, int money);
int cal();
-#define reload_money() cuser.money=moneyof(usernum)
+#define reload_money() cuser->money=moneyof(usernum)
int demoney(int money);
int deumoney(int uid, int money);
int lockutmpmode(int unmode, int state);
@@ -350,7 +351,6 @@ void abort_bbs(int sig);
void del_distinct(char *fname, char *line);
void add_distinct(char *fname, char *line);
void show_last_call_in(int save);
-int dosearchuser(char *userid);
void u_exit(char *mode);
void talk_request(int sig);
int reply_connection_request(userinfo_t *uip);
@@ -584,6 +584,7 @@ void sortsong();
int topsong();
/* user */
+int kill_user(int num);
int u_editcalendar();
void user_display(userec_t *u, int real);
void uinfo_query(userec_t *u, int real, int unum);
@@ -644,11 +645,16 @@ unsigned StringHash(unsigned char *s);
/* passwd */
int passwd_init();
int passwd_update(int num, userec_t *buf);
+int passwd_index_update(int num, userec_t *buf);
int passwd_query(int num, userec_t *buf);
-int passwd_apply(int (*fptr)(userec_t *));
+int passwd_index_query(int num, userec_t *buf);
+int passwd_apply(int (*fptr)(int, userec_t *));
void passwd_lock();
void passwd_unlock();
int passwd_update_money(int num);
+int initcuser(char *userid);
+int freecuser();
+
/* calendar */
int calendar();
diff --git a/include/pttstruct.h b/include/pttstruct.h
index d3d8083f..9f950c92 100644
--- a/include/pttstruct.h
+++ b/include/pttstruct.h
@@ -114,7 +114,7 @@ typedef struct userec_t {
#define WATER_ORIG 0x0
#define WATER_NEW 0x1
#define WATER_OFO 0x2
-#define WATERMODE(mode) ((cuser.uflag2 & WATER_MASK) == mode)
+#define WATERMODE(mode) ((cuser->uflag2 & WATER_MASK) == mode)
#define FAVNOHILIGHT 0x10 /* false if hilight favorite */
#define FAVNEW_FLAG 0x20 /* true if add new board into one's fav */
#define FOREIGN 0x100 /* true if a foreign */
diff --git a/include/util.h b/include/util.h
index d19944cc..44f8ca58 100644
--- a/include/util.h
+++ b/include/util.h
@@ -1,7 +1,6 @@
#ifndef INCLUDE_UTIL_H
#define INCLUDE_UTIL_H
int passwd_mmap(void);
-int passwd_apply(int (*fptr)(userec_t *));
-int passwd_apply2(int (*fptr)(int, userec_t *));
+int passwd_apply(int (*fptr)(int, userec_t *));
#endif // INCLUDE_UTIL_H
diff --git a/mbbsd.icc/.cvsignore b/mbbsd.icc/.cvsignore
deleted file mode 100644
index 7eaf2809..00000000
--- a/mbbsd.icc/.cvsignore
+++ /dev/null
@@ -1,3 +0,0 @@
-*.o
-mbbsd.icc
-*.il
diff --git a/mbbsd.icc/Makefile b/mbbsd.icc/Makefile
deleted file mode 100644
index bbbe1a7a..00000000
--- a/mbbsd.icc/Makefile
+++ /dev/null
@@ -1,72 +0,0 @@
-.PATH: ../mbbsd
-
-BBSHOME=/home/bbs
-PROG= mbbsd.icc
-OBJS= admin.o announce.o args.o bbs.o board.o cache.o cal.o card.o\
- chat.o chc_draw.o chc_net.o chc_play.o chc_rule.o chicken.o dark.o\
- edit.o friend.o gamble.o gomo.o gomo1.o guess.o indict.o io.o\
- kaede.o lovepaper.o mail.o mbbsd.o menu.o more.o name.o osdep.o\
- othello.o page.o read.o record.o register.o screen.o stuff.o\
- talk.o term.o topsong.o user.o vice.o vote.o xyz.o\
- voteboard.o syspost.o var.o toolkit.o passwd.o\
- calendar.o
-
-ICCFLAGS= -O -march=pentiumiii -Ob2 -tpp6 -mcpu=pentiumpro -march=pentiumiii \
- -ipo -ipo_obj
-GCCFLAGS= -O -march=pentium3
-
-CFLAGS= -DHAVE_SETPROCTITLE -DBBSHOME='"$(BBSHOME)"' -DFreeBSD -I../include
-LDFLAGS= -lutil -lkvm -lcrypt
-
-.if defined(GDB) || defined(DEBUG)
-CFLAGS+= -g
-FDFLAGS+= -g
-.else
-CFLAGS+= -O
-LDFLAGS+= -O
-.endif
-
-.if defined(DEBUG)
-CFLAGS+= -DDEBUG
-LDFLAGS+= -DDEBUG
-.endif
-
-.if defined(NO_FORK)
-CFLAGS+= -DNO_FORK
-.endif
-
-CFLAGS+= "-DCOMPILE_TIME=\"`date`\""
-GCCUSE=gcc -pipe -Wall $(CFLAGS) -c
-
-.SUFFIXES: .c .o
-.c.o: ../include/var.h
- icc -D__FreeBSD__ -D__FreeBSD $(CFLAGS) $(ICCFLAGS) -c ../mbbsd/$*.c
-
-all: $(PROG)
-
-$(PROG): $(OBJS)
- icc $(LDFLAGS) $(ICCFLAGS) -o $(PROG) $(OBJS)
-
-../include/var.h: var.c
- perl ../util/parsevar.pl < ../mbbsd/var.c > ../include/var.h
-
-cache.o: cache.c
- $(GCCUSE) $(GCCFLAGS) ../mbbsd/$*.c
-
-topsong.o: topsong.c
- $(GCCUSE) $(GCCFLAGS) ../mbbsd/$*.c
-
-install: $(PROG)
- install -d $(BBSHOME)/bin/
- install -c -m 755 $(PROG) $(BBSHOME)/bin/
- rm -f $(BBSHOME)/bin/mbbsd
- ln -sv $(BBSHOME)/bin/$(PROG) $(BBSHOME)/bin/mbbsd
-
-test: $(PROG)
- killall -9 testmbbsd || true
- cp $(PROG) testmbbsd
- ./testmbbsd 9000
- rm -f testmbbsd
-
-clean:
- rm -f $(OBJS) $(PROG)
diff --git a/mbbsd/admin.c b/mbbsd/admin.c
index 0dfb74dc..654f045f 100644
--- a/mbbsd/admin.c
+++ b/mbbsd/admin.c
@@ -2,7 +2,6 @@
#include "bbs.h"
/* 進站水球宣傳 */
-
int
m_loginmsg()
{
@@ -24,7 +23,7 @@ m_loginmsg()
{
SHM->loginmsg.pid=currutmp->pid; /*站長不多 就不管race condition */
strcpy(SHM->loginmsg.last_call_in, msg);
- strcpy(SHM->loginmsg.userid, cuser.userid);
+ strcpy(SHM->loginmsg.userid, cuser->userid);
}
return 0;
}
@@ -131,7 +130,7 @@ search_key_user(char *passwdfile, int mode)
if (ch == 's' && !mode) {
if ((ch = searchuser(user.userid))) {
setumoney(ch, user.money);
- passwd_update(ch, &user);
+ passwd_index_update(ch, &user);
fclose(fp1);
return 0;
} else {
@@ -149,7 +148,7 @@ search_key_user(char *passwdfile, int mode)
fprintf(stderr, "本站人口已達飽和!\n");
exit(1);
}
- if (passwd_update(allocid, &user) == -1) {
+ if (passwd_index_update(allocid, &user) == -1) {
fprintf(stderr, "客滿了,再見!\n");
exit(1);
}
@@ -259,7 +258,6 @@ setup_man(boardheader_t * board)
mkdir(genbuf, 0755);
}
-
int
m_mod_board(char *bname)
{
@@ -354,7 +352,7 @@ m_mod_board(char *bname)
system(genbuf);
memset(&bh, 0, sizeof(bh));
snprintf(bh.title, sizeof(bh.title),
- "%s 看板 %s 刪除", bname, cuser.userid);
+ "%s 看板 %s 刪除", bname, cuser->userid);
post_msg("Security", bh.title, "請注意刪除的合法性", "[系統安全局]");
substitute_record(fn_board, &bh, sizeof(bh), bid);
reset_board(bid);
@@ -371,7 +369,7 @@ m_mod_board(char *bname)
if (getbnum(genbuf)) {
move(3, 0);
outs("錯誤! 板名雷同");
- } else if (!invalid_brdname(genbuf)) {
+ } else if ( !invalid_brdname(genbuf) ){
strlcpy(newbh.brdname, genbuf, sizeof(newbh.brdname));
break;
}
@@ -428,7 +426,7 @@ m_mod_board(char *bname)
clear();
}
}
- getdata_str(b_lines - 1, 0, msg_sure_ny, genbuf, 4, LCECHO, "Y");
+ getdata_str(b_lines - 1, 0, msg_sure_ny, genbuf, 4, LCECHO, "N");
if ((*genbuf == 'y') && memcmp(&newbh, &bh, sizeof(bh))) {
if (strcmp(bh.brdname, newbh.brdname)) {
@@ -884,7 +882,7 @@ scan_register_form(char *regfile, int automode, int neednum)
int n = 0, unum = 0;
int nSelf = 0, nAuto = 0;
- uid = cuser.userid;
+ uid = cuser->userid;
snprintf(fname, sizeof(fname), "%s.tmp", regfile);
move(2, 0);
if (dashf(fname)) {
@@ -933,7 +931,7 @@ scan_register_form(char *regfile, int automode, int neednum)
uid = autoid;
if ((!automode || !auto_scan(fdata, ans))) {
- uid = cuser.userid;
+ uid = cuser->userid;
move(1, 0);
prints("帳號位置 :%d\n", unum);
@@ -1016,7 +1014,7 @@ scan_register_form(char *regfile, int automode, int neednum)
sethomepath(buf1, muser.userid);
stampfile(buf1, &mhdr);
- strlcpy(mhdr.owner, cuser.userid, sizeof(mhdr.owner));
+ strlcpy(mhdr.owner, cuser->userid, sizeof(mhdr.owner));
strlcpy(mhdr.title, "[註冊失敗]", TTLEN);
mhdr.filemode = 0;
sethomedir(title, muser.userid);
@@ -1070,6 +1068,7 @@ scan_register_form(char *regfile, int automode, int neednum)
strncat(genbuf, "\n", sizeof(genbuf));
log_file(buf, genbuf, 1);
passwd_update(unum, &muser);
+ passwd_index_update(unum, &muser);
if ((fout = fopen(logfile, "a"))) {
for (n = 0; field[n]; n++)
@@ -1103,10 +1102,10 @@ scan_register_form(char *regfile, int automode, int neednum)
* &xfile); strcpy(xfile.owner, "系統"); strcpy(xfile.title, "[報告]
* 審核記錄"); xptr = fopen(xfpath, "w"); fprintf(xptr, "\n時間:%s %s
* 審了 %d 份註冊單\n AutoScan 審了 %d 份註冊單\n 共計 %d 份。", buf,
- * cuser.userid, nSelf, nAuto, nSelf+nAuto); fclose(xptr); setbdir(fname,
+ * cuser->userid, nSelf, nAuto, nSelf+nAuto); fclose(xptr); setbdir(fname,
* xboard); append_record(fname, &xfile, sizeof(xfile));
* outgo_post(&xfile, xboard); touchbtotal(getbnum(xboard));
- * cuser.numposts++;
+ * cuser->numposts++;
*/
/*********************************************/
pressanykey();
diff --git a/mbbsd/announce.c b/mbbsd/announce.c
index 3bb1aad5..a7cd016f 100644
--- a/mbbsd/announce.c
+++ b/mbbsd/announce.c
@@ -299,7 +299,7 @@ a_newitem(menu_t * pm, int mode)
break;
}
- strlcpy(item.owner, cuser.userid, sizeof(item.owner));
+ strlcpy(item.owner, cuser->userid, sizeof(item.owner));
a_additem(pm, &item);
}
@@ -364,7 +364,7 @@ a_pasteitem(menu_t * pm, int mode)
igetch();
return;
}
- strlcpy(item.owner, *copyowner ? copyowner : cuser.userid,
+ strlcpy(item.owner, *copyowner ? copyowner : cuser->userid,
sizeof(item.owner));
strlcpy(item.title, copytitle, sizeof(item.title));
a_additem(pm, &item);
@@ -441,7 +441,7 @@ a_pastetagpost(menu_t * pm, int mode)
char dirname[200], buf[200];
if (TagBoard == 0){
- sethomedir(dirname, cuser.userid);
+ sethomedir(dirname, cuser->userid);
}
else{
bh = getbcache(TagBoard);
@@ -455,7 +455,7 @@ a_pastetagpost(menu_t * pm, int mode)
while (tagnum--) {
EnumTagFhdr(&fhdr, dirname, ent++);
if (TagBoard == 0)
- sethomefile(buf, cuser.userid, fhdr.filename);
+ sethomefile(buf, cuser->userid, fhdr.filename);
else
setbfile(buf, bh->brdname, fhdr.filename);
@@ -565,7 +565,7 @@ a_delete(menu_t * pm)
setbpath(buf, "deleted");
stampfile(buf, &backup);
- strlcpy(backup.owner, cuser.userid, sizeof(backup.owner));
+ strlcpy(backup.owner, cuser->userid, sizeof(backup.owner));
strlcpy(backup.title,
pm->header[pm->now - pm->page].title + 2,
sizeof(backup.title));
@@ -590,7 +590,7 @@ a_delete(menu_t * pm)
"rm -rf %s;/bin/mv -f %s %s", buf, fpath, buf);
system(cmd);
- strlcpy(backup.owner, cuser.userid, sizeof(backup.owner));
+ strlcpy(backup.owner, cuser->userid, sizeof(backup.owner));
strlcpy(backup.title,
pm->header[pm->now - pm->page].title + 2,
sizeof(backup.title));
@@ -846,7 +846,7 @@ a_menu(char *maintitle, char *path, int lastlevel)
fhdr.filename,
sizeof(me.header[me.now - me.page].filename));
strlcpy(me.header[me.now - me.page].owner,
- cuser.userid,
+ cuser->userid,
sizeof(me.header[me.now - me.page].owner));
setadir(fpath, path);
substitute_record(fpath, me.header + me.now - me.page,
@@ -1191,7 +1191,7 @@ void BlogMain(int num)
sprintf(fpath, "man/boards/%c/%s", currboard[0], currboard);
stampdir(fpath, &item);
strlcpy(item.title, "◆ Blog", sizeof(item.title));
- strlcpy(item.owner, cuser.userid, sizeof(item.owner));
+ strlcpy(item.owner, cuser->userid, sizeof(item.owner));
sprintf(adir, "man/boards/%c/%s/.DIR", currboard[0], currboard);
append_record(adir, &item, FHSZ);
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index 1a455c75..0960080e 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -14,16 +14,14 @@ mail_by_link(char *owner, char *title, char *path)
{
char genbuf[200];
fileheader_t mymail;
-
- snprintf(genbuf, sizeof(genbuf),
- BBSHOME "/home/%c/%s", cuser.userid[0], cuser.userid);
+
+ sethomepath(genbuf, cuser->userid);
stampfile(genbuf, &mymail);
strlcpy(mymail.owner, owner, sizeof(mymail.owner));
snprintf(mymail.title, sizeof(mymail.title), title);
unlink(genbuf);
Link(path, genbuf);
- snprintf(genbuf, sizeof(genbuf),
- BBSHOME "/home/%c/%s/.DIR", cuser.userid[0], cuser.userid);
+ sethomedir(genbuf, cuser->userid);
append_record(genbuf, &mymail, sizeof(mymail));
}
@@ -36,15 +34,15 @@ anticrosspost()
snprintf(buf, sizeof(buf),
"\033[1;33;46m%s \033[37;45mcross post 文章 \033[37m %s\033[m\n",
- cuser.userid, ctime(&now));
+ cuser->userid, ctime(&now));
log_file("etc/illegal_money", buf, 1);
- post_violatelaw(cuser.userid, "Ptt系統警察", "Cross-post", "罰單處份");
- cuser.userlevel |= PERM_VIOLATELAW;
- cuser.vl_count++;
+ post_violatelaw(cuser->userid, "Ptt系統警察", "Cross-post", "罰單處份");
+ cuser->userlevel |= PERM_VIOLATELAW;
+ cuser->vl_count++;
mail_by_link("Ptt警察部隊", "Cross-Post罰單",
BBSHOME "/etc/crosspost.txt");
- passwd_update(usernum, &cuser);
+ u_exit("Cross Post");
exit(0);
}
@@ -58,16 +56,16 @@ save_violatelaw()
clear();
stand_title("繳罰單中心");
- if (!(cuser.userlevel & PERM_VIOLATELAW)) {
+ if (!(cuser->userlevel & PERM_VIOLATELAW)) {
mprints(22, 0, "\033[1;31m你無聊啊? 你又沒有被開罰單~~\033[m");
pressanykey();
return 0;
}
reload_money();
- if (cuser.money < (int)cuser.vl_count * 1000) {
+ if (cuser->money < (int)cuser->vl_count * 1000) {
snprintf(buf, sizeof(buf), "\033[1;31m這是你第 %d 次違反本站法規"
"必須繳出 %d $Ptt ,你只有 %d 元, 錢不夠啦!!\033[m",
- (int)cuser.vl_count, (int)cuser.vl_count * 1000, cuser.money);
+ (int)cuser->vl_count, (int)cuser->vl_count * 1000, cuser->money);
mprints(22, 0, buf);
pressanykey();
return 0;
@@ -85,7 +83,7 @@ save_violatelaw()
return 0;
}
snprintf(buf, sizeof(buf), "這是你第 %d 次違法 必須繳出 %d $Ptt",
- cuser.vl_count, cuser.vl_count * 1000);
+ cuser->vl_count, cuser->vl_count * 1000);
mprints(11, 0, buf);
if (!getdata(10, 0, "要付錢[y/n]:", ok, sizeof(ok), LCECHO) ||
@@ -95,9 +93,9 @@ save_violatelaw()
pressanykey();
return 0;
}
- demoney(-1000 * cuser.vl_count);
- cuser.userlevel &= (~PERM_VIOLATELAW);
- passwd_update(usernum, &cuser);
+ demoney(-1000 * cuser->vl_count);
+ cuser->userlevel &= (~PERM_VIOLATELAW);
+ passwd_update(usernum, cuser);
return 0;
}
@@ -123,12 +121,27 @@ set_board()
strcpy(currBM, "徵求中");
else
snprintf(currBM, sizeof(currBM), "板主:%s", bp->BM);
+
+ /* init basic perm, but post perm is checked on demand */
currmode = (currmode & (MODE_DIRTY | MODE_GROUPOP)) | MODE_STARTED;
+ if (HAS_PERM(PERM_ALLBOARD) || is_BM_cache(currbid)) {
+ currmode = currmode | MODE_BOARD | MODE_POST | MODE_POSTCHECKED;
+ }
+}
- if (HAS_PERM(PERM_ALLBOARD) || is_BM_cache(currbid))
- currmode = currmode | MODE_BOARD | MODE_POST;
- else if (haspostperm(currboard))
- currmode |= MODE_POST;
+/* check post perm on demand, no double checks in current board */
+int CheckPostPerm(void)
+{
+ if (!(currmode & MODE_POSTCHECKED)) {
+ currmode |= MODE_POSTCHECKED;
+ if (haspostperm(currboard)) {
+ currmode |= MODE_POST;
+ return 1;
+ }
+ currmode &= ~MODE_POST;
+ return 0;
+ }
+ return (currmode & MODE_POST);
}
static void
@@ -306,10 +319,10 @@ do_select(int ent, fileheader_t * fhdr, char *direct)
completeboard_permission,
completeboard_getname);
if (bname[0] == '\0' || !(i = getbnum(bname)))
- return FULLUPDATE;
+ return TITLE_REDRAW;
bh = getbcache(i);
if (!HasPerm(bh))
- return FULLUPDATE;
+ return TITLE_REDRAW;
strlcpy(bname, bh->brdname, sizeof(bname));
currbid = i;
@@ -318,7 +331,7 @@ do_select(int ent, fileheader_t * fhdr, char *direct)
move(2, 0);
clrtoeol();
outs(err_bid);
- return FULLUPDATE;
+ return TITLE_REDRAW;
}
setutmpbid(currbid);
@@ -341,7 +354,7 @@ outgo_post(fileheader_t * fh, char *board)
if ((foo = fopen("innd/out.bntp", "a"))) {
fprintf(foo, "%s\t%s\t%s\t%s\t%s\n", board,
- fh->filename, cuser.userid, cuser.username, fh->title);
+ fh->filename, cuser->userid, cuser->username, fh->title);
fclose(foo);
}
}
@@ -377,7 +390,7 @@ cancelpost(fileheader_t * fh, int by_BM, char *newpath)
if ((fout = fopen("innd/cancel.bntp", "a"))) {
fprintf(fout, "%s\t%s\t%s\t%s\t%s\n", currboard, fh->filename,
- cuser.userid, nick, fh->title);
+ cuser->userid, nick, fh->title);
fclose(fout);
}
fclose(fin);
@@ -420,7 +433,7 @@ do_unanonymous_post(char *fpath)
stampfile(genbuf, &mhdr);
unlink(genbuf);
Link(fpath, genbuf);
- strlcpy(mhdr.owner, cuser.userid, sizeof(mhdr.owner));
+ strlcpy(mhdr.owner, cuser->userid, sizeof(mhdr.owner));
strlcpy(mhdr.title, save_title, sizeof(mhdr.title));
mhdr.filemode = 0;
setbdir(title, "UnAnonymous");
@@ -526,26 +539,24 @@ do_general(int isbid)
bp = getbcache(currbid);
clear();
- if (!(currmode & MODE_POST)
+ if (!CheckPostPerm()
#ifdef FOREIGN_REG
// 不是外籍使用者在 PttForeign 板
- && !((cuser.uflag2 & FOREIGN) && strcmp(bp->brdname, "PttForeign") == 0)
+ && !((cuser->uflag2 & FOREIGN) && strcmp(bp->brdname, "PttForeign") == 0)
#endif
) {
- move(5, 10);
- outs("對不起,您目前無法在此發表文章!");
+ outmsg("對不起,您目前無法在此發表文章!");
pressanykey();
- return FULLUPDATE;
+ return READ_REDRAW;
}
#ifdef NO_WATER_POST
#ifndef DEBUG /* why we need this in DEBUG mode? */
/* 三分鐘內最多發表五篇文章 */
if (currutmp->lastact - last_post_time < 60 * 3) {
if (water_counts >= 5) {
- move(5, 10);
- outs("對不起,您的文章太水囉,待會再post吧!小秘訣:可用'X'推薦文章");
+ outmsg("對不起,您的文章太水囉,待會再post吧!小秘訣:可用'X'推薦文章");
pressanykey();
- return FULLUPDATE;
+ return READ_REDRAW;
}
} else {
last_post_time = currutmp->lastact;
@@ -656,9 +667,9 @@ do_general(int isbid)
owner = real_name;
ifuseanony = 1;
} else
- owner = cuser.userid;
+ owner = cuser->userid;
#else
- owner = cuser.userid;
+ owner = cuser->userid;
#endif
/* 錢 */
aborted = (aborted > MAX_POST_MONEY * 2) ? MAX_POST_MONEY : aborted / 2;
@@ -701,7 +712,7 @@ do_general(int isbid)
aborted = (aborted > MAX_POST_MONEY) ? MAX_POST_MONEY : aborted;
#endif
if (strcmp(currboard, "Test") && !ifuseanony) {
- prints("這是您的第 %d 篇文章。",++cuser.numposts);
+ prints("這是您的第 %d 篇文章。",++cuser->numposts);
if(postfile.filemode&FILE_BID)
prints("招標文章沒有稿酬。");
else if(currbrdattr&BRD_BAD)
@@ -711,7 +722,6 @@ do_general(int isbid)
prints(" 稿酬 %d 銀。",aborted);
demoney(aborted);
}
- passwd_update(usernum, &cuser); /* post 數 */
} else
outs("測試信件不列入紀錄,敬請包涵。");
@@ -735,7 +745,7 @@ do_general(int isbid)
unlink(genbuf);
Link(fpath, genbuf);
- strlcpy(postfile.owner, cuser.userid, sizeof(postfile.owner));
+ strlcpy(postfile.owner, cuser->userid, sizeof(postfile.owner));
strlcpy(postfile.title, save_title, sizeof(postfile.title));
sethomedir(genbuf, quote_user);
if (append_record(genbuf, &postfile, sizeof(postfile)) == -1)
@@ -829,7 +839,7 @@ invalid_brdname(char *brd)
register char ch;
ch = *brd++;
- if (not_alnum(ch))
+ if (!isalpha(ch))
return 1;
while ((ch = *brd++)) {
if (not_alnum(ch) && ch != '_' && ch != '-' && ch != '.')
@@ -917,7 +927,7 @@ do_reply(fileheader_t * fhdr)
static int
reply_post(int ent, fileheader_t * fhdr, char *direct)
{
- if (!(currmode & MODE_POST))
+ if (!CheckPostPerm())
return DONOTHING;
setdirpath(quote_file, direct, fhdr->filename);
@@ -942,7 +952,7 @@ edit_post(int ent, fileheader_t * fhdr, char *direct)
return DONOTHING;
if( !HAS_PERM(PERM_SYSOP) &&
- (!(currmode & MODE_POST) || strcmp(fhdr->owner, cuser.userid) != 0) )
+ (!CheckPostPerm() || strcmp(fhdr->owner, cuser->userid) != 0) )
return DONOTHING;
if( currmode & MODE_SELECT )
@@ -1019,7 +1029,7 @@ cross_post(int ent, fileheader_t * fhdr, char *direct)
char genbuf[200];
char genbuf2[4];
boardheader_t *bp;
- if (!(currmode & MODE_POST)) {
+ if (!CheckPostPerm()) {
move(5, 10);
outs("對不起,您目前無法轉錄文章!");
pressanykey();
@@ -1027,8 +1037,6 @@ cross_post(int ent, fileheader_t * fhdr, char *direct)
}
move(2, 0);
clrtoeol();
- move(3, 0);
- clrtoeol();
move(1, 0);
bp = getbcache(currbid);
if (bp && (bp->brdattr & BRD_VOTEBOARD) )
@@ -1052,7 +1060,7 @@ cross_post(int ent, fileheader_t * fhdr, char *direct)
}
ent = 1;
- if (HAS_PERM(PERM_SYSOP) || !strcmp(fhdr->owner, cuser.userid)) {
+ if (HAS_PERM(PERM_SYSOP) || !strcmp(fhdr->owner, cuser->userid)) {
getdata(2, 0, "(1)原文轉載 (2)舊轉錄格式?[1] ",
genbuf, 3, DOECHO);
if (genbuf[0] != '2') {
@@ -1083,7 +1091,7 @@ cross_post(int ent, fileheader_t * fhdr, char *direct)
if (author)
strlcpy(xfile.owner, fhdr->owner, sizeof(xfile.owner));
else
- strlcpy(xfile.owner, cuser.userid, sizeof(xfile.owner));
+ strlcpy(xfile.owner, cuser->userid, sizeof(xfile.owner));
strlcpy(xfile.title, xtitle, sizeof(xfile.title));
if (genbuf[0] == 'l') {
xfile.filemode = FILE_LOCAL;
@@ -1111,7 +1119,7 @@ cross_post(int ent, fileheader_t * fhdr, char *direct)
if (!xfile.filemode && !(bp->brdattr & BRD_NOTRAN))
outgo_post(&xfile, xboard);
setbtotal(getbnum(xboard));
- cuser.numposts++;
+ cuser->numposts++;
UPDATE_USEREC;
outs("文章轉錄完成");
pressanykey();
@@ -1152,7 +1160,7 @@ read_post(int ent, fileheader_t * fhdr, char *direct)
return FULLUPDATE;
case 7:
case 8:
- if ((currmode & MODE_POST)) {
+ if (CheckPostPerm()) {
strlcpy(quote_file, genbuf, sizeof(quote_file));
do_reply(fhdr);
*quote_file = 0;
@@ -1223,7 +1231,7 @@ read_post(int ent, fileheader_t * fhdr, char *direct)
case 'r':
case 'R':
case 'Y':
- if ((currmode & MODE_POST)) {
+ if (CheckPostPerm()) {
strlcpy(quote_file, genbuf, sizeof(quote_file));
do_reply(fhdr);
*quote_file = 0;
@@ -1371,7 +1379,7 @@ hold_gamble(int ent, fileheader_t * fhdr, char *direct)
move(8 + i, 0);
prints("賭盤設定完成");
snprintf(genbuf, sizeof(genbuf), "[公告] %s 板 開始賭博!", currboard);
- post_msg(currboard, genbuf, msg, cuser.userid);
+ post_msg(currboard, genbuf, msg, cuser->userid);
post_msg("Record", genbuf + 7, msg, "[馬路探子]");
/* Tim 控制CS, 以免正在玩的user把資料已經寫進來 */
rename(fn_ticket_end, fn_ticket);
@@ -1403,7 +1411,7 @@ edit_title(int ent, fileheader_t * fhdr, char *direct)
fileheader_t tmpfhdr = *fhdr;
int dirty = 0;
- if (currmode & MODE_BOARD || !strcmp(cuser.userid, fhdr->owner)) {
+ if (currmode & MODE_BOARD || !strcmp(cuser->userid, fhdr->owner)) {
if (getdata(b_lines - 1, 0, "標題:", genbuf, TTLEN, DOECHO)) {
strlcpy(tmpfhdr.title, genbuf, sizeof(tmpfhdr.title));
dirty++;
@@ -1419,7 +1427,7 @@ edit_title(int ent, fileheader_t * fhdr, char *direct)
dirty++;
}
}
- if (currmode & MODE_BOARD || !strcmp(cuser.userid, fhdr->owner)) {
+ if (currmode & MODE_BOARD || !strcmp(cuser->userid, fhdr->owner)) {
getdata(b_lines - 1, 0, "確定(Y/N)?[n] ", genbuf, 3, DOECHO);
if ((genbuf[0] == 'y' || genbuf[0] == 'Y') && dirty) {
*fhdr = tmpfhdr;
@@ -1563,13 +1571,13 @@ do_bid(int ent, fileheader_t * fhdr, boardheader_t *bp, char *direct, struct t
prints("起標價: %d", bidinfo.high);
next=bidinfo.high;
}
- if(!strcmp(cuser.userid,bidinfo.userid))
+ if(!strcmp(cuser->userid,bidinfo.userid))
{
prints("你是最高得標者!");
pressanykey();
return FULLUPDATE;
}
- if (strcmp(cuser.userid, fhdr->owner) == 0){
+ if (strcmp(cuser->userid, fhdr->owner) == 0){
vmsg("警告! 本人不能出價!");
return FULLUPDATE;
}
@@ -1592,7 +1600,7 @@ do_bid(int ent, fileheader_t * fhdr, boardheader_t *bp, char *direct, struct t
next=bidinfo.high + bidinfo.increment;
- if(mymax< next || (bidinfo.payby==0 && cuser.money<mymax ))
+ if(mymax< next || (bidinfo.payby==0 && cuser->money<mymax ))
{
vmsg("取消下標或標金不足搶標");
return FULLUPDATE;
@@ -1600,8 +1608,8 @@ do_bid(int ent, fileheader_t * fhdr, boardheader_t *bp, char *direct, struct t
snprintf(genbuf, sizeof(genbuf),
"\033[1;31m→ \033[33m%s\033[m\033[33m:%s\033[m%*s %s%-15d標%15s %02d/%02d\n",
- cuser.userid,say,
- 31 - strlen(cuser.userid) - strlen(say), " ",
+ cuser->userid,say,
+ 31 - strlen(cuser->userid) - strlen(say), " ",
money,
next, fromhost,
ptime->tm_mon + 1, ptime->tm_mday);
@@ -1610,19 +1618,19 @@ do_bid(int ent, fileheader_t * fhdr, boardheader_t *bp, char *direct, struct t
{
bidinfo.usermax=mymax;
bidinfo.high=next;
- strcpy(bidinfo.userid,cuser.userid);
+ strcpy(bidinfo.userid,cuser->userid);
}
else if(mymax>bidinfo.usermax)
{
bidinfo.high=bidinfo.usermax+bidinfo.increment;
if(bidinfo.high>mymax) bidinfo.high=mymax;
bidinfo.usermax=mymax;
- strcpy(bidinfo.userid,cuser.userid);
+ strcpy(bidinfo.userid,cuser->userid);
snprintf(genbuf, sizeof(genbuf),
"\033[1;31m→ \033[33m自動競標%s勝出\033[m\033[33m\033[m%*s%s%-15d標 %02d/%02d\n",
- cuser.userid,
- 20 - strlen(cuser.userid) , " ",money,
+ cuser->userid,
+ 20 - strlen(cuser->userid) , " ",money,
bidinfo.high,
ptime->tm_mon + 1, ptime->tm_mday);
do_add_recommend(direct, fhdr, ent, genbuf);
@@ -1659,7 +1667,7 @@ recommend(int ent, fileheader_t * fhdr, char *direct)
vmsg("抱歉, 本板禁止推薦或競標");
return FULLUPDATE;
}
- if (!(currmode & MODE_POST) || bp->brdattr & BRD_VOTEBOARD || fhdr->filemode & FILE_VOTE) {
+ if (!CheckPostPerm() || bp->brdattr & BRD_VOTEBOARD || fhdr->filemode & FILE_VOTE) {
vmsg("您權限不足, 無法推薦!");
return FULLUPDATE;
}
@@ -1675,12 +1683,12 @@ recommend(int ent, fileheader_t * fhdr, char *direct)
}
setdirpath(path, direct, fhdr->filename);
- if (fhdr->recommend == 0 && strcmp(cuser.userid, fhdr->owner) == 0){
+ if (fhdr->recommend == 0 && strcmp(cuser->userid, fhdr->owner) == 0){
vmsg("警告! 本人不能推薦第一次!");
return FULLUPDATE;
}
#ifndef DEBUG
- if (!(currmode & MODE_BOARD) && getuser(cuser.userid) &&
+ if (!(currmode & MODE_BOARD) && getuser(cuser->userid) &&
now - lastrecommend < 40) {
move(b_lines - 1, 0);
prints("離上次推薦時間太近囉, 請多花點時間仔細閱\讀文章!");
@@ -1699,8 +1707,8 @@ recommend(int ent, fileheader_t * fhdr, char *direct)
snprintf(buf, sizeof(buf),
"\033[1;31m→ \033[33m%s\033[m\033[33m:%s\033[m%*s推%15s %02d/%02d\n",
- cuser.userid, path,
- 51 - strlen(cuser.userid) - strlen(path), " ", fromhost,
+ cuser->userid, path,
+ 51 - strlen(cuser->userid) - strlen(path), " ", fromhost,
ptime->tm_mon + 1, ptime->tm_mday);
do_add_recommend(direct, fhdr, ent, buf);
#ifdef ASSESS
@@ -1796,7 +1804,7 @@ del_range(int ent, fileheader_t *fhdr, char *direct)
fileheader_t rsfh;
int i = inum1, now;
if (currstat == RMAIL)
- sethomedir(genbuf, cuser.userid);
+ sethomedir(genbuf, cuser->userid);
else
setbdir(genbuf, currboard);
if ((fd = (open(direct, O_RDONLY, 0))) != -1) {
@@ -1849,10 +1857,10 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
(fhdr->owner[0] == '-'))
return DONOTHING;
- not_owned = strcmp(fhdr->owner, cuser.userid);
+ not_owned = strcmp(fhdr->owner, cuser->userid);
if ((!(currmode & MODE_BOARD) && not_owned) ||
((bp->brdattr & BRD_VOTEBOARD) && !HAS_PERM(PERM_SYSOP)) ||
- !strcmp(cuser.userid, STR_GUEST))
+ !strcmp(cuser->userid, STR_GUEST))
return DONOTHING;
getdata(1, 0, msg_del_ny, genbuf, 3, LCECHO);
@@ -1917,7 +1925,7 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
xuser.userlevel |= PERM_VIOLATELAW;
}
sprintf(genbuf,"劣文退回(%s):%-40.40s", reason, fhdr->title);
- mail_id(xuser.userid, genbuf, newpath, cuser.userid);
+ mail_id(xuser.userid, genbuf, newpath, cuser->userid);
}
}
#undef SIZE
@@ -1930,16 +1938,14 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
deumoney(num, -fhdr->money);
}
if (!not_owned && strcmp(currboard, "Test")) {
- if (cuser.numposts)
- cuser.numposts--;
- /* XXX: is_BM(cuser.userid) is always true @_@ */
+ if (cuser->numposts)
+ cuser->numposts--;
if (!(currmode & MODE_DIGEST && currmode & MODE_BOARD)){
move(b_lines - 1, 0);
clrtoeol();
demoney(-fhdr->money);
- passwd_update(usernum, &cuser); /* post 數 */
- prints("%s,您的文章減為 %d 篇,支付清潔費 %d 銀", msg_del_ok,
- cuser.numposts, fhdr->money);
+ prints("%s,您的文章減為 %d 篇,支付清潔費 %d 銀", msg_del_ok,
+ cuser->numposts, fhdr->money);
refresh();
pressanykey();
}
@@ -1950,6 +1956,17 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
return FULLUPDATE;
}
+static int // Ptt: 修石頭文
+show_filename(int ent, fileheader_t * fhdr, char *direct)
+{
+ if(!HAS_PERM(PERM_SYSOP)) return DONOTHING;
+
+ move(b_lines - 1, 0);
+ prints("檔案名稱: %s ", fhdr->filename);
+ pressanykey();
+ return PART_REDRAW;
+}
+
static int
view_postmoney(int ent, fileheader_t * fhdr, char *direct)
{
@@ -2015,7 +2032,7 @@ tar_addqueue(int ent, fileheader_t * fhdr, char *direct)
return FULLUPDATE;
}
fp = fopen(qfn, "w");
- fprintf(fp, "%s\n", cuser.userid);
+ fprintf(fp, "%s\n", cuser->userid);
fprintf(fp, "%s\n", email);
fprintf(fp, "%d,%d\n", bakboard, bakman);
fclose(fp);
@@ -2080,7 +2097,7 @@ sequent_messages(fileheader_t * fptr)
case 'r':
case 'Y':
case 'R':
- if (currmode & MODE_POST) {
+ if (CheckPostPerm()) {
strlcpy(quote_file, genbuf, sizeof(quote_file));
do_reply(fptr);
*quote_file = 0;
@@ -2257,11 +2274,11 @@ board_select()
char genbuf[100];
currmode &= ~MODE_SELECT;
- snprintf(fpath, sizeof(fpath), "SR.%s", cuser.userid);
+ snprintf(fpath, sizeof(fpath), "SR.%s", cuser->userid);
setbfile(genbuf, currboard, fpath);
unlink(genbuf);
if (currstat == RMAIL)
- sethomedir(currdirect, cuser.userid);
+ sethomedir(currdirect, cuser->userid);
else
setbdir(currdirect, currboard);
return NEWDIRECT;
@@ -2507,7 +2524,7 @@ change_counting(int ent, fileheader_t * fhdr, char *direct)
/* ----------------------------------------------------- */
/* onekey_size was defined in ../include/pttstruct.h, as ((int)'z') */
onekey_t read_comms[] = {
- NULL, // Ctrl('A') 1
+ show_filename, // Ctrl('A')
NULL, // Ctrl('B')
NULL, // Ctrl('C')
NULL, // Ctrl('D')
@@ -2640,6 +2657,7 @@ Read()
curredit &= ~EDIT_MAIL;
i_read(READING, buf, readtitle, readdoent, read_comms,
currbid);
+ currmode &= ~MODE_POSTCHECKED;
#ifdef LOG_BOARD
log_board(currboard, now - usetime);
#endif
@@ -2673,7 +2691,7 @@ log_board(char *mode, time_t usetime)
if (usetime > 30) {
snprintf(buf, sizeof(buf), "USE %-20.20s Stay: %5ld (%s) %s\n",
- mode, usetime, cuser.userid, ctime(&now));
+ mode, usetime, cuser->userid, ctime(&now));
log_file(FN_USEBOARD, buf, 1);
}
}
diff --git a/mbbsd/board.c b/mbbsd/board.c
index 525cc020..200376eb 100644
--- a/mbbsd/board.c
+++ b/mbbsd/board.c
@@ -129,7 +129,7 @@ brc_insert_record(const char* board, int num, int* list)
void
brc_update(){
- if (brc_changed && cuser.userlevel && brc_num > 0)
+ if (brc_changed && cuser->userlevel && brc_num > 0)
brc_insert_record(currboard, brc_num, brc_list);
}
@@ -223,7 +223,7 @@ brc_addlist(const char *fname)
{
int ftime, n, i;
- if (!cuser.userlevel)
+ if (!cuser->userlevel)
return;
ftime = atoi(&fname[2]);
@@ -340,20 +340,6 @@ void imovefav(int old)
move_in_current_folder(old, new);
}
-void load_brdbuf(void)
-{
- char buf[128];
- setuserfile(buf, FAV4);
- if( !dashf(buf) ) {
- fav_v3_to_v4();
- }
- fav_load();
-
- /* subscribe new fav (deprecated) */
- if (get_fav_root() != NULL)
- updatenewfav(1);
-}
-
void
init_brdbuf()
{
@@ -506,7 +492,7 @@ static void
load_boards(char *key)
{
boardheader_t *bptr = NULL;
- int type = cuser.uflag & BRDSORT_FLAG ? 1 : 0;
+ int type = cuser->uflag & BRDSORT_FLAG ? 1 : 0;
int i, n;
int state;
char byMALLOC = 0, needREALLOC = 0;
@@ -800,12 +786,12 @@ show_brdlist(int head, int clsflag, int newflag)
prints("%5d %c %sMyFavFolder\033[m 目錄 □%-34s\033[m",
head,
ptr->myattr & NBRD_TAG ? 'D' : ' ',
- !(cuser.uflag2 & FAVNOHILIGHT) ? "\033[1;36m" : "",
+ !(cuser->uflag2 & FAVNOHILIGHT) ? "\033[1;36m" : "",
title);
else
prints("%6d %sMyFavFolder\033[m 目錄 □%-34s\033[m",
get_data_number(get_fav_folder(getfolder(ptr->bid))),
- !(cuser.uflag2 & FAVNOHILIGHT) ? "\033[1;36m" : "",
+ !(cuser->uflag2 & FAVNOHILIGHT) ? "\033[1;36m" : "",
title);
continue;
}
@@ -833,7 +819,7 @@ show_brdlist(int head, int clsflag, int newflag)
else {
prints("%s%-13s\033[m%s%5.5s\033[0;37m%2.2s\033[m"
"%-34.34s",
- ((!(cuser.uflag2 & FAVNOHILIGHT) &&
+ ((!(cuser->uflag2 & FAVNOHILIGHT) &&
getboard(ptr->bid) != NULL))? "\033[1;36m" : "",
B_BH(ptr)->brdname,
color[(unsigned int)
@@ -901,7 +887,7 @@ set_menu_BM(char *BM)
{
if (HAS_PERM(PERM_ALLBOARD) || is_BM(BM)) {
currmode |= MODE_GROUPOP;
- cuser.userlevel |= PERM_SYSSUBOP;
+ cuser->userlevel |= PERM_SYSSUBOP;
}
}
@@ -921,10 +907,10 @@ choose_board(int newflag)
setutmpmode(newflag ? READNEW : READBRD);
if( get_current_fav() == NULL )
- load_brdbuf();
+ fav_load();
++choose_board_depth;
brdnum = 0;
- if (!cuser.userlevel) /* guest yank all boards */
+ if (!cuser->userlevel) /* guest yank all boards */
yank_flag = 2;
do {
@@ -1073,7 +1059,7 @@ choose_board(int newflag)
case 'F':
case 'f':
if (class_bid>0 && HAS_PERM(PERM_SYSOP)) {
- bcache[class_bid - 1].firstchild[cuser.uflag & BRDSORT_FLAG ? 1 : 0]
+ bcache[class_bid - 1].firstchild[cuser->uflag & BRDSORT_FLAG ? 1 : 0]
= NULL;
brdnum = -1;
}
@@ -1099,7 +1085,7 @@ choose_board(int newflag)
fav_sort_by_class();
}
else
- cuser.uflag ^= BRDSORT_FLAG;
+ cuser->uflag ^= BRDSORT_FLAG;
brdnum = -1;
break;
case 'y':
@@ -1291,12 +1277,12 @@ choose_board(int newflag)
case 'Z':
if (HAS_PERM(PERM_LOGINOK)) {
char genbuf[256];
- sprintf(genbuf, "確定要 %s訂閱\ 新看板? [N/y] ", cuser.uflag2 & FAVNEW_FLAG ? "取消" : "");
+ sprintf(genbuf, "確定要 %s訂閱\ 新看板? [N/y] ", cuser->uflag2 & FAVNEW_FLAG ? "取消" : "");
if (getans(genbuf) != 'y')
break;
- cuser.uflag2 ^= FAVNEW_FLAG;
- if (cuser.uflag2 & FAVNEW_FLAG) {
+ cuser->uflag2 ^= FAVNEW_FLAG;
+ if (cuser->uflag2 & FAVNEW_FLAG) {
subscribe_newfav();
vmsg("切換為訂閱\新看板模式");
}
diff --git a/mbbsd/cache.c b/mbbsd/cache.c
index ff409191..bac961cb 100644
--- a/mbbsd/cache.c
+++ b/mbbsd/cache.c
@@ -492,7 +492,7 @@ setutmpmode(unsigned int mode)
if (HAS_PERM(PERM_LOGUSER)) {
char msg[200];
snprintf(msg, sizeof(msg), "%s setutmpmode to %s(%d) at %s",
- cuser.userid, modestring(currutmp, 0), mode, Cdate(&COMMON_TIME));
+ cuser->userid, modestring(currutmp, 0), mode, Cdate(&COMMON_TIME));
log_user(msg);
}
}
@@ -761,7 +761,7 @@ haspostperm(char *bname)
char buf[200];
setbfile(buf, bname, fn_water);
- if (belong(buf, cuser.userid))
+ if (belong(buf, cuser->userid))
return 0;
if (!strcasecmp(bname, DEFAULT_BOARD))
@@ -817,7 +817,7 @@ int is_BM_cache(int bid) /* bid starts from 1 */
currutmp->uid == SHM->BMcache[bid][1] ||
currutmp->uid == SHM->BMcache[bid][2] ||
currutmp->uid == SHM->BMcache[bid][3] ){
- cuser.userlevel |= PERM_BM;
+ cuser->userlevel |= PERM_BM;
return 1;
}
return 0;
diff --git a/mbbsd/cal.c b/mbbsd/cal.c
index d2cec676..462818de 100644
--- a/mbbsd/cal.c
+++ b/mbbsd/cal.c
@@ -59,21 +59,16 @@ unlockutmpmode()
int
vice(int money, char *item)
{
- char buf[128];
- unsigned int viceserial = (currutmp->lastact % 1000000) * 100 + rand() % 100;
- FILE *fp;
+ char buf[128], vice[12];
+ unsigned int viceserial = (currutmp->lastact % 1000000) * 100 + rand() % 100;
+
demoney(-money);
- snprintf(buf, sizeof(buf), BBSHOME "/home/%c/%s/%s",
- cuser.userid[0], cuser.userid, VICE_NEW);
- fp = fopen(buf, "a");
- if (!fp) {
- return 0;
- }
- fprintf(fp, "%08d\n", viceserial);
- fclose(fp);
+ setuserfile(buf, VICE_NEW);
+ sprintf(vice,"%8.8d\n", viceserial);
+ log_file(buf, vice, 1);
snprintf(buf, sizeof(buf),
"%s 花了%d$ 編號[%08d]", item, money, viceserial);
- mail_id(cuser.userid, buf, "etc/vice.txt", "Ptt經濟部");
+ mail_id(cuser->userid, buf, "etc/vice.txt", "Ptt經濟部");
return 0;
}
@@ -99,7 +94,7 @@ osong(char *defaultid)
lockreturn0(OSONG, LOCK_MULTI);
/* Jaky 一人一天點一首 */
- if (!strcmp(buf, Cdatedate(&cuser.lastsong)) && !HAS_PERM(PERM_SYSOP)) {
+ if (!strcmp(buf, Cdatedate(&cuser->lastsong)) && !HAS_PERM(PERM_SYSOP)) {
move(22, 0);
outs("你今天已經點過囉,明天再點吧....");
refresh();
@@ -108,7 +103,7 @@ osong(char *defaultid)
unlockutmpmode();
return 0;
}
- if (cuser.money < 200) {
+ if (cuser->money < 200) {
move(22, 0);
outs("點歌要200銀唷!....");
refresh();
@@ -118,7 +113,7 @@ osong(char *defaultid)
}
move(12, 0);
clrtobot();
- prints("親愛的 %s 歡迎來到歐桑自動點歌系統\n", cuser.userid);
+ prints("親愛的 %s 歡迎來到歐桑自動點歌系統\n", cuser->userid);
trans_buffer[0] = 0;
if (!defaultid) {
getdata(13, 0, "要點給誰呢:[可直接按 Enter 先選歌]",
@@ -142,7 +137,7 @@ osong(char *defaultid)
getdata_str(14, 0, "想要要對他(她)說..:", say,
sizeof(say), DOECHO, "我愛妳..");
snprintf(save_title, sizeof(save_title),
- "%s:%s", (ano[0] == 'y') ? "匿名者" : cuser.userid, say);
+ "%s:%s", (ano[0] == 'y') ? "匿名者" : cuser->userid, say);
getdata_str(16, 0, "寄到誰的信箱(可用E-mail)?",
receiver, sizeof(receiver), LCECHO, destid);
@@ -170,7 +165,7 @@ osong(char *defaultid)
strlcpy(mail.owner, "點歌機", sizeof(mail.owner));
snprintf(mail.title, sizeof(mail.title),
"◇ %s 點給 %s ",
- (ano[0] == 'y') ? "匿名者" : cuser.userid, destid);
+ (ano[0] == 'y') ? "匿名者" : cuser->userid, destid);
while (fgets(buf, sizeof(buf), fp)) {
char *po;
@@ -188,7 +183,7 @@ osong(char *defaultid)
po[0] = 0;
snprintf(genbuf, sizeof(genbuf),
"%s%s%s", buf,
- (ano[0] == 'y') ? "匿名者" : cuser.userid, po + 7);
+ (ano[0] == 'y') ? "匿名者" : cuser->userid, po + 7);
strlcpy(buf, genbuf, sizeof(buf));
}
while ((po = strstr(buf, "<~Des~>"))) {
@@ -208,7 +203,7 @@ osong(char *defaultid)
if (append_record(OSONGPATH "/.DIR", &mail, sizeof(mail)) != -1) {
- cuser.lastsong = now;
+ cuser->lastsong = now;
/* Jaky 超過 500 首歌就開始砍 */
nsongs = get_num_records(OSONGPATH "/.DIR", sizeof(mail));
if (nsongs > 500) {
@@ -218,7 +213,7 @@ osong(char *defaultid)
vice(200, "點歌");
}
snprintf(save_title, sizeof(save_title),
- "%s:%s", (ano[0] == 'y') ? "匿名者" : cuser.userid, say);
+ "%s:%s", (ano[0] == 'y') ? "匿名者" : cuser->userid, say);
hold_mail(filename, destid);
if (receiver[0]) {
@@ -256,9 +251,9 @@ static int
inmailbox(int m)
{
passwd_query(usernum, &xuser);
- cuser.exmailbox = xuser.exmailbox + m;
- passwd_update(usernum, &cuser);
- return cuser.exmailbox;
+ cuser->exmailbox = xuser.exmailbox + m;
+ passwd_update(usernum, cuser);
+ return cuser->exmailbox;
}
@@ -273,8 +268,8 @@ p_cloak()
buf, sizeof(buf), LCECHO);
if (buf[0] != 'y')
return 0;
- if (cuser.money >= 19) {
- vice(19, "cloak");
+ if (cuser->money >= 19) {
+ vice(19, "付費隱身");
currutmp->invisible %= 2;
outs((currutmp->invisible ^= 1) ? MSG_CLOAKED : MSG_UNCLOAK);
refresh();
@@ -293,11 +288,11 @@ p_from()
if (ans[0] != 'y')
return 0;
reload_money();
- if (cuser.money < 49)
+ if (cuser->money < 49)
return 0;
if (getdata_buf(b_lines - 1, 0, "請輸入新故鄉:",
currutmp->from, sizeof(currutmp->from), DOECHO)) {
- vice(49, "home");
+ vice(49, "更改故鄉");
currutmp->from_alias = 0;
}
return 0;
@@ -309,13 +304,13 @@ p_exmail()
char ans[4], buf[200];
int n;
- if (cuser.exmailbox >= MAX_EXKEEPMAIL) {
+ if (cuser->exmailbox >= MAX_EXKEEPMAIL) {
prints("容量最多增加 %d 封,不能再買了。", MAX_EXKEEPMAIL);
refresh();
return 0;
}
snprintf(buf, sizeof(buf),
- "您曾增購 %d 封容量,還要再買多少?", cuser.exmailbox);
+ "您曾增購 %d 封容量,還要再買多少?", cuser->exmailbox);
getdata_str(b_lines - 2, 0, buf, ans, sizeof(ans), LCECHO, "10");
@@ -324,12 +319,12 @@ p_exmail()
return 0;
if (n < 0)
n = 100;
- if (n + cuser.exmailbox > MAX_EXKEEPMAIL)
- n = MAX_EXKEEPMAIL - cuser.exmailbox;
+ if (n + cuser->exmailbox > MAX_EXKEEPMAIL)
+ n = MAX_EXKEEPMAIL - cuser->exmailbox;
reload_money();
- if (cuser.money < n * 1000)
+ if (cuser->money < n * 1000)
return 0;
- vice(n * 1000, "mail");
+ vice(n * 1000, "購買信箱");
inmailbox(n);
return 0;
}
@@ -384,23 +379,23 @@ p_give()
move(1, 0);
usercomplete("這位幸運兒的id:", id);
- if (!id[0] || !strcmp(cuser.userid, id) ||
+ if (!id[0] || !strcmp(cuser->userid, id) ||
!getdata(2, 0, "要給多少錢:", genbuf, 7, LCECHO))
return 0;
money = atoi(genbuf);
reload_money();
- if (money > 0 && cuser.money >= money) {
+ if (money > 0 && cuser->money >= money) {
tax = give_tax(money);
if (money - tax <= 0)
return 0; /* 繳完稅就沒錢給了 */
deumoney(searchuser(id), money - tax);
demoney(-money);
snprintf(genbuf, sizeof(genbuf), "%s\t給%s\t%d\t%s\n",
- cuser.userid, id, money - tax, ctime(&now));
+ cuser->userid, id, money - tax, ctime(&now));
log_file(FN_MONEY, genbuf, 1);
genbuf[0] = 'n';
getdata(3, 0, "要自行書寫紅包袋嗎?[y/N]", genbuf, 2, LCECHO);
- mail_redenvelop(cuser.userid, id, money - tax, genbuf[0]);
+ mail_redenvelop(cuser->userid, id, money - tax, genbuf[0]);
}
return 0;
}
diff --git a/mbbsd/calendar.c b/mbbsd/calendar.c
index 67524a91..d5c1fe61 100644
--- a/mbbsd/calendar.c
+++ b/mbbsd/calendar.c
@@ -1,4 +1,4 @@
-/* $Id: calendar.c,v 1.8 2003/01/16 11:58:04 kcwu Exp $ */
+/* $Id$ */
#include "bbs.h"
typedef struct event_t {
@@ -129,7 +129,7 @@ ReadEvent(int today)
static event_t head;
head.next = NULL;
- setcalfile(buf, cuser.userid);
+ setcalfile(buf, cuser->userid);
fp = fopen(buf, "r");
if (fp) {
while (fgets(buf, sizeof(buf), fp)) {
diff --git a/mbbsd/card.c b/mbbsd/card.c
index 55102df5..806c5429 100644
--- a/mbbsd/card.c
+++ b/mbbsd/card.c
@@ -1,4 +1,4 @@
-/* $Id: card.c,v 1.6 2002/07/22 19:02:00 in2 Exp $ */
+/* $Id$ */
#include "bbs.h"
static int
@@ -353,14 +353,14 @@ game_log(int type, int money)
fp = fopen(BBSHOME "/etc/card/jack.log", "a");
if (!fp)
return 0;
- fprintf(fp, "%s win:%d\n", cuser.userid, money);
+ 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);
+ fprintf(fp, "%s win:%d\n", cuser->userid, money);
fclose(fp);
break;
}
@@ -374,9 +374,9 @@ card_double_ask()
snprintf(buf, sizeof(buf),
"[ %s ]您現在共有 %d P幣, 現在要分組(加收 %d 元)嗎? [y/N]",
- cuser.userid, cuser.money, JACK);
+ cuser->userid, cuser->money, JACK);
reload_money();
- if (cuser.money < JACK)
+ if (cuser->money < JACK)
return 0;
getdata(20, 0, buf, buf2, sizeof(buf2), LCECHO);
if (buf2[0] == 'y' || buf2[0] == 'Y')
@@ -390,7 +390,7 @@ card_ask()
char buf[100], buf2[3];
snprintf(buf, sizeof(buf), "[ %s ]您現在共有 %d P幣, 還要加牌嗎? [y/N]",
- cuser.userid, cuser.money);
+ cuser->userid, cuser->money);
getdata(20, 0, buf, buf2, sizeof(buf2), LCECHO);
if (buf2[0] == 'y' || buf2[0] == 'Y')
return 1;
@@ -541,7 +541,7 @@ g_card_jack()
setutmpmode(JACK_CARD);
while (1) {
reload_money();
- if (cuser.money < JACK) {
+ if (cuser->money < JACK) {
outs("您的錢不夠唷!去多發表些有意義的文章再來~~~");
return 0;
}
@@ -642,7 +642,7 @@ g_ten_helf()
setutmpmode(TENHALF);
while (1) {
reload_money();
- if (cuser.money < TEN_HALF) {
+ if (cuser->money < TEN_HALF) {
outs("您的錢不夠唷!去多發表些有意義的文章再來~~~");
return 0;
}
diff --git a/mbbsd/chat.c b/mbbsd/chat.c
index 28b488f9..66238334 100644
--- a/mbbsd/chat.c
+++ b/mbbsd/chat.c
@@ -332,13 +332,13 @@ t_chat()
while (1) {
getdata(b_lines - 1, 0, "請輸入聊天代號:", chatid, 9, DOECHO);
if(!chatid[0])
- strlcpy(chatid, cuser.userid, sizeof(chatid));
+ strlcpy(chatid, cuser->userid, sizeof(chatid));
chatid[8] = '\0';
/*
* 新格式: /! UserID ChatID Password
*/
snprintf(inbuf, sizeof(inbuf), "/! %s %s %s",
- cuser.userid, chatid, cuser.passwd);
+ cuser->userid, chatid, cuser->passwd);
chat_send(cfd, inbuf);
if (recv(cfd, inbuf, 3, 0) != 3) {
close(cfd);
@@ -381,9 +381,8 @@ t_chat()
print_chatid(chatid);
memset(inbuf, 0, sizeof(inbuf));
- sethomepath(fpath, cuser.userid);
- strlcpy(fpath, tempnam(fpath, "chat_"), sizeof(fpath));
- flog = fopen(fpath, "w");
+ setuserfile(fpath, "chat_XXXXXX");
+ flog = fdopen(mkstemp(fpath), "w");
while (chatting) {
move(b_lines - 1, currchar + chatid_len);
@@ -521,12 +520,12 @@ t_chat()
char title[128];
char genbuf[200];
- sethomepath(genbuf, cuser.userid);
+ sethomepath(genbuf, cuser->userid);
stampfile(genbuf, &mymail);
mymail.filemode = FILE_READ ;
strlcpy(mymail.owner, "[備.忘.錄]", sizeof(mymail.owner));
strlcpy(mymail.title, "會議\033[1;33m記錄\033[m", sizeof(mymail.title));
- sethomedir(title, cuser.userid);
+ sethomedir(title, cuser->userid);
append_record(title, &mymail, sizeof(mymail));
Rename(fpath, genbuf);
} else
diff --git a/mbbsd/chc.c b/mbbsd/chc.c
index e6436d0c..249b2d98 100644
--- a/mbbsd/chc.c
+++ b/mbbsd/chc.c
@@ -305,7 +305,11 @@ chc_log_step(board_t board, rc_t *from, rc_t *to)
}
static int
+#ifdef __linux__
+chc_filter(const struct dirent *dir)
+#else
chc_filter(struct dirent *dir)
+#endif
{
if (strcmp(dir->d_name, ".") == 0 || strcmp(dir->d_name, "..") == 0 )
return 0;
@@ -775,8 +779,8 @@ mainloop(int s, chcusr_t *user1, chcusr_t *user2, board_t board, play_func_t pla
currutmp->chc_tie++;
}
user1->lose--;
- chcusr_put(&cuser, user1);
- passwd_update(usernum, &cuser);
+ chcusr_put(cuser, user1);
+ passwd_update(usernum, cuser);
}
else if (chc_mode & CHC_WATCH) {
strlcpy(chc_warnmsg, "結束觀棋", sizeof(chc_warnmsg));
@@ -804,8 +808,8 @@ chc_init_play_func(chcusr_t *user1, chcusr_t *user2, play_func_t play_func[2])
char userid[2][IDLEN + 1];
if (chc_mode & CHC_PERSONAL) {
- strlcpy(userid[0], cuser.userid, sizeof(userid[0]));
- strlcpy(userid[1], cuser.userid, sizeof(userid[1]));
+ strlcpy(userid[0], cuser->userid, sizeof(userid[0]));
+ strlcpy(userid[1], cuser->userid, sizeof(userid[1]));
play_func[0] = play_func[1] = myplay;
}
else if (chc_mode & CHC_WATCH) {
@@ -815,7 +819,7 @@ chc_init_play_func(chcusr_t *user1, chcusr_t *user2, play_func_t play_func[2])
play_func[0] = play_func[1] = hisplay;
}
else {
- strlcpy(userid[0], cuser.userid, sizeof(userid[0]));
+ strlcpy(userid[0], cuser->userid, sizeof(userid[0]));
strlcpy(userid[1], currutmp->mateid, sizeof(userid[1]));
play_func[chc_my] = myplay;
play_func[chc_my ^ 1] = hisplay;
@@ -954,7 +958,7 @@ chc(int s, int mode)
chc_log("\n--\n\n");
chc_log_poem();
chc_log_close();
- mail_id(cuser.userid, title, file, "[楚河漢界]");
+ mail_id(cuser->userid, title, file, "[楚河漢界]");
}
else
chc_log_close();
diff --git a/mbbsd/chicken.c b/mbbsd/chicken.c
index 7bb7e5ee..56791de4 100644
--- a/mbbsd/chicken.c
+++ b/mbbsd/chicken.c
@@ -45,7 +45,6 @@ enum {
TEMPERAMENT, TIREDSTRONG, SICK, HP_MAX, MM_MAX
};
-static chicken_t *mychicken = &cuser.mychicken;
static int age;
static const short time_change[NUM_KINDS][14] =
@@ -86,6 +85,9 @@ static const short time_change[NUM_KINDS][14] =
int
reload_chicken()
{
+
+ chicken_t *mychicken = &cuser->mychicken;
+
passwd_query(usernum, &xuser);
memcpy(mychicken, &xuser.mychicken, sizeof(chicken_t));
if (!mychicken->name[0])
@@ -99,6 +101,7 @@ reload_chicken()
static int
new_chicken()
{
+ chicken_t *mychicken = &cuser->mychicken;
char buf[150];
int price;
@@ -123,7 +126,7 @@ new_chicken()
reload_money();
price = egg_price[(int)mychicken->type];
- if (cuser.money < price) {
+ if (cuser->money < price) {
prints("\n 錢不夠買蛋蛋,蛋蛋要 %d 元", price);
refresh();
return 0;
@@ -135,7 +138,7 @@ new_chicken()
snprintf(buf, sizeof(buf),
"\033[31m%s \033[m養了一隻叫\033[33m %s \033[m的 "
- "\033[32m%s\033[m 於 %s\n", cuser.userid,
+ "\033[32m%s\033[m 於 %s\n", cuser->userid,
mychicken->name, chicken_type[(int)mychicken->type], ctime(&now));
log_file(CHICKENLOG, buf, 1);
mychicken->lastvisit = mychicken->birthday = mychicken->cbirth = now;
@@ -280,6 +283,7 @@ show_chicken_data(chicken_t * thechicken, chicken_t * pkchicken)
static void
ch_eat()
{
+ chicken_t *mychicken = &cuser->mychicken;
if (mychicken->food) {
mychicken->weight += time_change[(int)mychicken->type][WEIGHT] +
mychicken->hp_max / 5;
@@ -299,6 +303,7 @@ ch_eat()
static void
ch_clean()
{
+ chicken_t *mychicken = &cuser->mychicken;
mychicken->clean = 0;
mychicken->tiredstrong +=
time_change[(int)mychicken->type][TIREDSTRONG] / 3;
@@ -311,6 +316,7 @@ ch_guess()
{
char *guess[3] = {"剪刀", "石頭", "布"}, me, ch, win;
+ chicken_t *mychicken = &cuser->mychicken;
mychicken->happy += time_change[(int)mychicken->type][HAPPY] * 1.5;
mychicken->satis += time_change[(int)mychicken->type][SATIS];
mychicken->tiredstrong += time_change[(int)mychicken->type][TIREDSTRONG];
@@ -326,7 +332,7 @@ ch_guess()
win = (int)(3.0 * rand() / (RAND_MAX + 1.0)) - 1;
ch = (me + win + 3) % 3;
prints("%s:%s ! %s:%s !.....%s",
- cuser.userid, guess[(int)me], mychicken->name, guess[(int)ch],
+ cuser->userid, guess[(int)me], mychicken->name, guess[(int)ch],
win == 0 ? "平手" : win < 0 ? "耶..贏了 :D!!" : "嗚..我輸了 :~");
pressanykey();
}
@@ -334,6 +340,7 @@ ch_guess()
static void
ch_book()
{
+ chicken_t *mychicken = &cuser->mychicken;
mychicken->book += time_change[(int)mychicken->type][BOOK];
mychicken->tiredstrong += time_change[(int)mychicken->type][TIREDSTRONG];
show_file(CHICKEN_PIC "/read", 5, 14, NO_RELOAD);
@@ -343,6 +350,7 @@ ch_book()
static void
ch_kiss()
{
+ chicken_t *mychicken = &cuser->mychicken;
mychicken->happy += time_change[(int)mychicken->type][HAPPY];
mychicken->satis += time_change[(int)mychicken->type][SATIS];
mychicken->tiredstrong +=
@@ -354,6 +362,7 @@ ch_kiss()
static void
ch_hit()
{
+ chicken_t *mychicken = &cuser->mychicken;
mychicken->attack += time_change[(int)mychicken->type][ATTACK];
mychicken->run += time_change[(int)mychicken->type][RUN];
mychicken->mm_max += time_change[(int)mychicken->type][MM_MAX] / 15;
@@ -384,7 +393,7 @@ ch_buyitem(int money, char *picture, int *item, int haveticket)
if (num < 1)
return;
reload_money();
- if (cuser.money > money * num) {
+ if (cuser->money > money * num) {
*item += num;
if( haveticket )
vice(money * num, "購買寵物,賭盤項目");
@@ -402,6 +411,7 @@ ch_buyitem(int money, char *picture, int *item, int haveticket)
static void
ch_eatoo()
{
+ chicken_t *mychicken = &cuser->mychicken;
if (mychicken->oo > 0) {
mychicken->oo--;
mychicken->tiredstrong = 0;
@@ -415,6 +425,7 @@ ch_eatoo()
static void
ch_eatmedicine()
{
+ chicken_t *mychicken = &cuser->mychicken;
if (mychicken->medicine > 0) {
mychicken->medicine--;
mychicken->sick = 0;
@@ -431,6 +442,7 @@ ch_eatmedicine()
static void
ch_kill()
{
+ chicken_t *mychicken = &cuser->mychicken;
char buf[150], ans[4];
snprintf(buf, sizeof(buf), "棄養這%s要被罰 100 元, 是否要棄養?(y/N)",
@@ -442,7 +454,7 @@ ch_kill()
more(CHICKEN_PIC "/deadth", YEA);
snprintf(buf, sizeof(buf),
"\033[31m%s \033[m把 \033[33m%s\033[m\033[32m %s "
- "\033[m宰了 於 %s\n", cuser.userid, mychicken->name,
+ "\033[m宰了 於 %s\n", cuser->userid, mychicken->name,
chicken_type[(int)mychicken->type], ctime(&now));
log_file(CHICKENLOG, buf, 1);
mychicken->name[0] = 0;
@@ -452,6 +464,7 @@ ch_kill()
static int
ch_sell()
{
+ chicken_t *mychicken = &cuser->mychicken;
/*
* int money = (mychicken->weight -
* time_change[(int)mychicken->type][WEIGHT])
@@ -501,11 +514,11 @@ ch_sell()
if (ans[0] == 'y') {
snprintf(buf, sizeof(buf), "\033[31m%s\033[m 把 \033[33m%s\033[m "
"\033[32m%s\033[m 用 \033[36m%d\033[m 賣了 於 %s\n",
- cuser.userid, mychicken->name,
+ cuser->userid, mychicken->name,
chicken_type[(int)mychicken->type], money, ctime(&now));
log_file(CHICKENLOG, buf, 1);
mychicken->lastvisit = mychicken->name[0] = 0;
- passwd_update(usernum, &cuser);
+ passwd_update(usernum, cuser);
more(CHICKEN_PIC "/sell", YEA);
demoney(money);
return 1;
@@ -583,8 +596,8 @@ time_diff(chicken_t * thechicken)
thechicken->satis = 0;
/* 髒病的 */
- if (mychicken->clean > 1000)
- mychicken->sick += (mychicken->clean - 400) / 10;
+ if (thechicken->clean > 1000)
+ thechicken->sick += (thechicken->clean - 400) / 10;
if (thechicken->weight > 1)
thechicken->sick -= diff / 60;
@@ -620,6 +633,7 @@ time_diff(chicken_t * thechicken)
static void
check_sick()
{
+ chicken_t *mychicken = &cuser->mychicken;
/* 髒病的 */
if (mychicken->tiredstrong > mychicken->hp * 0.3 && mychicken->clean > 150)
mychicken->sick += (mychicken->clean - 150) / 10;
@@ -637,6 +651,7 @@ check_sick()
static int
deadtype(chicken_t * thechicken)
{
+ chicken_t *mychicken = &cuser->mychicken;
int i;
char buf[150];
@@ -658,12 +673,12 @@ deadtype(chicken_t * thechicken)
snprintf(buf, sizeof(buf),
"\033[31m%s\033[m 所疼愛的\033[33m %s\033[32m %s "
"\033[m掛了 於 %s\n",
- cuser.userid, thechicken->name,
+ cuser->userid, thechicken->name,
chicken_type[(int)thechicken->type],
ctime(&now));
log_file(CHICKENLOG, buf, 1);
mychicken->name[0] = 0;
- passwd_update(usernum, &cuser);
+ passwd_update(usernum, cuser);
}
return i;
}
@@ -707,6 +722,7 @@ isdeadth(chicken_t * thechicken)
static void
ch_changename()
{
+ chicken_t *mychicken = &cuser->mychicken;
char buf[150], newname[20] = "";
getdata_str(b_lines - 1, 0, "嗯..改個好名字吧:", newname, 18, DOECHO,
@@ -716,7 +732,7 @@ ch_changename()
snprintf(buf, sizeof(buf),
"\033[31m%s\033[m 把疼愛的\033[33m %s\033[32m %s "
"\033[m改名為\033[33m %s\033[m 於 %s\n",
- cuser.userid, mychicken->name,
+ cuser->userid, mychicken->name,
chicken_type[(int)mychicken->type],
newname, ctime(&now));
strlcpy(mychicken->name, newname, sizeof(mychicken->name));
@@ -727,6 +743,7 @@ ch_changename()
static int
select_menu()
{
+ chicken_t *mychicken = &cuser->mychicken;
char ch;
reload_money();
@@ -741,7 +758,7 @@ select_menu()
"(\033[37mm\033[33m)買藥$10 (\033[37mk\033[33m)棄養 "
"(\033[37ms\033[33m)賣掉 (\033[37mn\033[33m)改名 "
"(\033[37mq\033[33m)離開:\033[m",
- cuser.money,
+ cuser->money,
/*
* chicken_food[(int)mychicken->type],
* chicken_type[(int)mychicken->type],
@@ -835,7 +852,7 @@ recover_chicken(chicken_t * thechicken)
getdata_str(21, 0, " 選擇:(N:坑人嘛/y:請幫幫我)", buf, 3, LCECHO, "N");
if (buf[0] == 'y' || buf[0] == 'Y') {
reload_money();
- if (cuser.money < price * 2) {
+ if (cuser->money < price * 2) {
outmsg("\033[33;44m★靈界守衛\033[37;45m 什麼 錢沒帶夠 "
"沒錢的小鬼 快去籌錢吧 \033[m");
bell();
@@ -860,7 +877,7 @@ recover_chicken(chicken_t * thechicken)
bell();
igetch();
thechicken->lastvisit = 0;
- passwd_update(usernum, &cuser);
+ passwd_update(usernum, cuser);
return 0;
}
@@ -869,8 +886,9 @@ recover_chicken(chicken_t * thechicken)
int
chicken_main()
{
+ chicken_t *mychicken = &cuser->mychicken;
lockreturn0(CHICKEN, LOCK_MULTI);
-
+ mychicken = &(cuser->mychicken);
reload_chicken();
age = ((now - mychicken->cbirth) / (60 * 60 * 24));
if (!mychicken->name[0] && !recover_chicken(mychicken) && !new_chicken()) {
@@ -884,7 +902,7 @@ chicken_main()
show_chicken_data(mychicken, NULL);
} while (select_menu());
reload_money();
- passwd_update(usernum, &cuser);
+ passwd_update(usernum, cuser);
unlockutmpmode();
return 0;
}
@@ -892,6 +910,7 @@ chicken_main()
int
chickenpk(int fd)
{
+ chicken_t *mychicken = &cuser->mychicken;
char mateid[IDLEN + 1], data[200], buf[200];
int ch = 0;
@@ -1016,7 +1035,7 @@ chickenpk(int fd)
outs(data + 1);
i = strlen(data) + 1;
passwd_update(duid, &ouser);
- passwd_update(usernum, &cuser);
+ passwd_update(usernum, cuser);
send(fd, data, i, 0);
if (data[0] == 'q' || data[0] == 'd')
break;
diff --git a/mbbsd/dice.c b/mbbsd/dice.c
index b6336d93..994bc000 100644
--- a/mbbsd/dice.c
+++ b/mbbsd/dice.c
@@ -209,7 +209,7 @@ del(int value[100],int total, dicedata_t * table)
demoney(money);
move(19, 0);
clrtoeol();
- prints("你現在有 %u Ptt$歐", cuser.money);
+ prints("你現在有 %u Ptt$歐", cuser->money);
table[i].mymoney -= money;
show_count(value, index, -money);
break;
@@ -336,7 +336,7 @@ dice_main(void)
more(DICE_TXT, NA);
reload_money();
- if (cuser.money < 10) {
+ if (cuser->money < 10) {
move(19, 0);
prints("\033[1;37m超過十元再來玩吧~~\033[m");
pressanykey();
@@ -362,11 +362,11 @@ dice_main(void)
while (1) {
move(19, 0);
prints("\033[1;32m你現在有\033[1;31m %u \033[1;32mPtt$歐\033[m",
- cuser.money);
+ cuser->money);
getdata(20, 0, "\033[1;37m數字:加選 d:退選 s:開始或離開\033[m: ",
input, 5, LCECHO);
reload_money();
- if (input[0] != 's' && input[0] != 'd' && cuser.money < 10) {
+ if (input[0] != 's' && input[0] != 'd' && cuser->money < 10) {
move(21, 0);
clrtoeol();
prints("\033[1;37m超過十元才能賭~\033[m");
@@ -387,14 +387,14 @@ dice_main(void)
continue;
/* 輸入錢的loop */
while (1) {
- if (cuser.money < 10)
+ if (cuser->money < 10)
break;
getdata(21, 0, "\033[1;32m賭多少錢呢\033[1;37m(大於10 小於500)"
"\033[m: ", input, sizeof(input), LCECHO);
if (!(money = IsLegal(input)) || input[0] == '0')
continue;
reload_money();
- if (money > cuser.money)
+ if (money > cuser->money)
continue;
for (j = 0, sig = 0; j < i; j++)
if (table[j].mybet == index) {
@@ -425,7 +425,7 @@ dice_main(void)
reload_money();
move(19, 0);
prints("\033[1;32m你現在有 \033[1;31m%u\033[1;32m Ptt$歐",
- cuser.money);
+ cuser->money);
if (sig != 2)
show_count(value,index, money);
}
@@ -450,7 +450,7 @@ dice_main(void)
if (table[j].mymoney * ya > 500) { /* 超過500塊錢才做log 減少io */
snprintf(data, sizeof(data),
"%-15s 押%-2d選項%-8d塊錢 中了%d倍 淨賺:%-8d\n",
- cuser.userid, table[j].mybet,
+ cuser->userid, table[j].mybet,
table[j].mymoney, ya, table[j].mymoney * ya);
fputs(data, winfp);
}
@@ -470,7 +470,7 @@ dice_main(void)
move(19, 0);
clrtoeol();
prints("\033[1;32m你現在有 \033[1;31m%u\033[1;32m Ptt$歐\033[m",
- cuser.money);
+ cuser->money);
getdata(23, 0, "\033[1;32m繼續奮鬥[\033[1;37my/n\033[1;32m]\033[m: ",
input, 2, LCECHO);
diff --git a/mbbsd/edit.c b/mbbsd/edit.c
index 36937d36..6b30ea4e 100644
--- a/mbbsd/edit.c
+++ b/mbbsd/edit.c
@@ -805,8 +805,8 @@ write_header(FILE * fp)
{
if (curredit & EDIT_MAIL || curredit & EDIT_LIST) {
- fprintf(fp, "%s %s (%s)\n", str_author1, cuser.userid,
- cuser.username
+ fprintf(fp, "%s %s (%s)\n", str_author1, cuser->userid,
+ cuser->username
);
} else {
char *ptr;
@@ -819,7 +819,7 @@ write_header(FILE * fp)
} postlog;
memset(&postlog, 0, sizeof(postlog));
- strlcpy(postlog.author, cuser.userid, sizeof(postlog.author));
+ strlcpy(postlog.author, cuser->userid, sizeof(postlog.author));
ifuseanony = 0;
#ifdef HAVE_ANONYMOUS
if (currbrdattr & BRD_ANONYMOUS) {
@@ -837,7 +837,7 @@ write_header(FILE * fp)
} else {
if (!strcmp("r", real_name) || (!defanony && !real_name[0]))
snprintf(postlog.author, sizeof(postlog.author),
- "%s", cuser.userid);
+ "%s", cuser->userid);
else {
snprintf(postlog.author, sizeof(postlog.author),
"%s.", real_name);
@@ -860,17 +860,17 @@ write_header(FILE * fp)
fprintf(fp, "%s %s (%s) %s %s\n", str_author1, postlog.author,
(((!strcmp(real_name, "r") && defanony) ||
- (!real_name[0] && (!defanony))) ? cuser.username :
+ (!real_name[0] && (!defanony))) ? cuser->username :
"猜猜我是誰 ? ^o^"),
local_article ? str_post2 : str_post1, currboard);
} else {
- fprintf(fp, "%s %s (%s) %s %s\n", str_author1, cuser.userid,
- cuser.username,
+ fprintf(fp, "%s %s (%s) %s %s\n", str_author1, cuser->userid,
+ cuser->username,
local_article ? str_post2 : str_post1, currboard);
}
#else /* HAVE_ANONYMOUS */
- fprintf(fp, "%s %s (%s) %s %s\n", str_author1, cuser.userid,
- cuser.username,
+ fprintf(fp, "%s %s (%s) %s %s\n", str_author1, cuser->userid,
+ cuser->username,
local_article ? str_post2 : str_post1, currboard);
#endif /* HAVE_ANONYMOUS */
@@ -890,7 +890,7 @@ addsignature(FILE * fp, int ifuseanony)
static char msg[] = "請選擇簽名檔 (1-9, 0=不加 X=隨機)[X]: ";
char ch;
- if (!strcmp(cuser.userid, STR_GUEST)) {
+ if (!strcmp(cuser->userid, STR_GUEST)) {
fprintf(fp, "\n--\n※ 發信站 :" BBSNAME "(" MYHOSTNAME
") \n◆ From: %s\n", fromhost);
return;
@@ -898,7 +898,7 @@ addsignature(FILE * fp, int ifuseanony)
if (!ifuseanony) {
num = showsignature(fpath, &i);
if (num){
- msg[34] = ch = isdigit(cuser.signature) ? cuser.signature : 'X';
+ msg[34] = ch = isdigit(cuser->signature) ? cuser->signature : 'X';
getdata(0, 0, msg, buf, 4, DOECHO);
if (!buf[0])
@@ -908,7 +908,7 @@ addsignature(FILE * fp, int ifuseanony)
ch = buf[0];
else
ch = '1' + rand() % num;
- cuser.signature = buf[0];
+ cuser->signature = buf[0];
if (ch != '0') {
fpath[i] = ch;
@@ -1000,14 +1000,18 @@ write_file(char *fpath, int saveheader, int *islocal)
}
if (!aborted) {
+ int tempfd;
+
if (saveheader && !(curredit & EDIT_MAIL) && check_quote())
return KEEP_EDITING;
- if (!*fpath) {
- sethomepath(fpath, cuser.userid);
- strcpy(fpath, tempnam(fpath, "ve_"));
+ if (*fpath) {
+ tempfd = open(fpath, O_WRONLY | O_CREAT | O_TRUNC, 0600);
+ }else{
+ setuserfile(fpath, "ve_XXXXXX");
+ tempfd = mkstemp(fpath);
}
- if ((fp = fopen(fpath, "w")) == NULL) {
+ if ((fp = fdopen(tempfd, "w")) == NULL) {
indigestion(5);
abort_bbs(0);
}
@@ -1067,7 +1071,7 @@ write_file(char *fpath, int saveheader, int *islocal)
ptime = localtime(&now);
fprintf(fp,
"※ 編輯: %-15s 來自: %-20s (%02d/%02d %02d:%02d)\n",
- cuser.userid, fromhost,
+ cuser->userid, fromhost,
ptime->tm_mon + 1, ptime->tm_mday, ptime->tm_hour, ptime->tm_min);
}
fclose(fp);
@@ -1697,12 +1701,12 @@ vedit(char *fpath, int saveheader, int *islocal)
if (count >= 240) {
char buf[200];
snprintf(buf, sizeof(buf), "\033[1;33;46m%s\033[37m在\033[37;45m%s\n"
- "\033[37m板違法賺錢 , %s\033[m", cuser.userid,
+ "\033[37m板違法賺錢 , %s\033[m", cuser->userid,
currboard, ctime(&now));
log_file("etc/illegal_money", buf, 1);
money = 0;
- post_violatelaw(cuser.userid, "Ptt 系統警察", "違法賺錢", "扣除不法所得");
- mail_violatelaw(cuser.userid, "Ptt 系統警察", "違法賺錢", "扣除不法所得");
+ post_violatelaw(cuser->userid, "Ptt 系統警察", "違法賺錢", "扣除不法所得");
+ mail_violatelaw(cuser->userid, "Ptt 系統警察", "違法賺錢", "扣除不法所得");
demoney(10000);
abort_bbs(0);
} */
diff --git a/mbbsd/fav.c b/mbbsd/fav.c
index f265db52..53a5ccb4 100644
--- a/mbbsd/fav.c
+++ b/mbbsd/fav.c
@@ -874,7 +874,7 @@ void updatenewfav(int mode)
int i, fd, brdnum;
char fname[80], *brd;
- if(!(cuser.uflag2 & FAVNEW_FLAG))
+ if(!(cuser->uflag2 & FAVNEW_FLAG))
return;
setuserfile(fname, FAVNB);
diff --git a/mbbsd/friend.c b/mbbsd/friend.c
index 6d7ed3f5..baf7a47c 100644
--- a/mbbsd/friend.c
+++ b/mbbsd/friend.c
@@ -248,49 +248,48 @@ friend_editdesc(char *uident, int type)
fclose(nfp);
}
-/* type == 0 : load all */
-void
-friend_load(int type)
+inline void friend_load_real(int tosort, int maxf,
+ short *destn, int *destar, char *fn)
{
- FILE *fp;
- int myfriends[MAX_FRIEND];
- int myrejects[MAX_REJECT];
- int friendcount, rejectedcount;
- char genbuf[200];
-
- if (!type || type & FRIEND_OVERRIDE) {
- memset(myfriends, 0, sizeof(myfriends));
- friendcount = 0;
- setuserfile(genbuf, fn_overrides);
- if ((fp = fopen(genbuf, "r"))) {
- int unum;
-
- while (fgets(genbuf, STRLEN, fp) && friendcount < MAX_FRIEND - 1)
- if (strtok(genbuf, str_space))
- if ((unum = searchuser(genbuf)))
- myfriends[friendcount++] = unum;
- fclose(fp);
- }
- qsort(myfriends, friendcount, sizeof(int), qsort_intcompar);
- memcpy(currutmp->friend, myfriends, sizeof(myfriends));
- currutmp->nFriends = friendcount;
+ char genbuf[200];
+ FILE *fp;
+ short nFriends = 0;
+ int uid, *tarray;
+
+ setuserfile(genbuf, fn);
+ if( (fp = fopen(genbuf, "r")) == NULL ){
+ destar[0] = 0;
+ if( destn )
+ *destn = 0;
}
+ else{
+ tarray = (int *)malloc(sizeof(int) * maxf);
+ --maxf; /* XXX? */
+ while( fgets(genbuf, STRLEN, fp) && nFriends < maxf )
+ if( strtok(genbuf, str_space) &&
+ (uid = searchuser(genbuf)) )
+ tarray[nFriends++] = uid;
+ fclose(fp);
- if (!type || type & FRIEND_REJECT) {
- memset(myrejects, 0, sizeof(myrejects));
- rejectedcount = 0;
- setuserfile(genbuf, fn_reject);
- if ((fp = fopen(genbuf, "r"))) {
- int unum;
-
- while (fgets(genbuf, STRLEN, fp) && rejectedcount < MAX_REJECT - 1)
- if (strtok(genbuf, str_space))
- if ((unum = searchuser(genbuf)))
- myrejects[rejectedcount++] = unum;
- fclose(fp);
- }
- memcpy(currutmp->reject, myrejects, sizeof(myrejects));
+ if( tosort )
+ qsort(tarray, nFriends, sizeof(int), qsort_intcompar);
+ tarray[nFriends++] = 0;
+ memcpy(destar, tarray, sizeof(int) * nFriends);
+ if( destn )
+ *destn = nFriends;
+ free(tarray);
}
+}
+
+/* type == 0 : load all */
+void friend_load(int type)
+{
+ if (!type || type & FRIEND_OVERRIDE)
+ friend_load_real(1, MAX_FRIEND, &currutmp->nFriends,
+ currutmp->friend, fn_overrides);
+
+ if (!type || type & FRIEND_REJECT)
+ friend_load_real(0, MAX_REJECT, NULL, currutmp->reject, fn_reject);
if (currutmp->friendtotal)
logout_friend_online(currutmp);
@@ -420,7 +419,7 @@ friend_edit(int type)
sscanf(line, "%s", uident); // XXX check buffer size
sethomefile(genbuf, uident,
type == FRIEND_ALOHA ? "aloha" : "postnotify");
- del_distinct(genbuf, cuser.userid);
+ del_distinct(genbuf, cuser->userid);
}
fclose(fp);
}
@@ -430,7 +429,7 @@ friend_edit(int type)
sscanf(line, "%s", uident); // XXX check buffer size
sethomefile(genbuf, uident,
type == FRIEND_ALOHA ? "aloha" : "postnotify");
- add_distinct(genbuf, cuser.userid);
+ add_distinct(genbuf, cuser->userid);
}
fclose(fp);
}
diff --git a/mbbsd/gamble.c b/mbbsd/gamble.c
index 33e67bb8..841d0926 100644
--- a/mbbsd/gamble.c
+++ b/mbbsd/gamble.c
@@ -101,7 +101,7 @@ append_ticket_record(char *direct, int ch, int n, int count)
snprintf(genbuf, sizeof(genbuf), "%s/" FN_TICKET_USER, direct);
if ((fp = fopen(genbuf, "a"))) {
- fprintf(fp, "%s %d %d\n", cuser.userid, ch, n);
+ fprintf(fp, "%s %d %d\n", cuser->userid, ch, n);
fclose(fp);
}
load_ticket_record(direct, ticket);
@@ -141,7 +141,7 @@ ticket(int bid)
move(20, 0);
reload_money();
prints("\033[44m錢: %-10d \033[m\n\033[1m請選擇要購買的種類(1~%d)"
- "[Q:離開]\033[m:", cuser.money, count);
+ "[Q:離開]\033[m:", cuser->money, count);
ch = igetch();
/*--
Tim011127
@@ -237,7 +237,7 @@ openticket(int bid)
if (bet != 98) {
money = total * price;
demoney(money * 0.02);
- mail_redenvelop("[賭場抽頭]", cuser.userid, money * 0.02, 'n');
+ mail_redenvelop("[賭場抽頭]", cuser->userid, money * 0.02, 'n');
money = ticket[bet] ? money * 0.95 / ticket[bet] : 9999999;
} else {
vice(price * 10, "賭盤退錢手續費");
diff --git a/mbbsd/gomo.c b/mbbsd/gomo.c
index d83f6f7d..91863888 100644
--- a/mbbsd/gomo.c
+++ b/mbbsd/gomo.c
@@ -189,7 +189,7 @@ HO_log(Horder_t *pool, char *user)
fileheader_t mymail;
snprintf(buf, sizeof(buf), "home/%c/%s/F.%d",
- cuser.userid[0], cuser.userid, rand() & 65535);
+ cuser->userid[0], cuser->userid, rand() & 65535);
log = fopen(buf, "w");
assert(log);
@@ -204,14 +204,14 @@ HO_log(Horder_t *pool, char *user)
} while (++ptr < v);
fclose(log);
- sethomepath(buf1, cuser.userid);
+ sethomepath(buf1, cuser->userid);
stampfile(buf1, &mymail);
mymail.filemode = FILE_READ ;
strlcpy(mymail.owner, "[備.忘.錄]", sizeof(mymail.owner));
snprintf(mymail.title, sizeof(mymail.title),
- "\033[37;41m棋譜\033[m %s VS %s", cuser.userid, user);
- sethomedir(title, cuser.userid);
+ "\033[37;41m棋譜\033[m %s VS %s", cuser->userid, user);
+ sethomedir(title, cuser->userid);
Rename(buf, buf1);
append_record(title, &mymail, sizeof(mymail));
@@ -289,16 +289,6 @@ gomo_key(int fd, int ch, Horder_t * mv)
return 0;
}
-static int
-reload_gomo()
-{
- passwd_query(usernum, &xuser);
- cuser.five_win = xuser.five_win;
- cuser.five_lose = xuser.five_lose;
- cuser.five_tie = xuser.five_tie;
- return 0;
-}
-
int
gomoku(int fd)
{
@@ -317,28 +307,27 @@ gomoku(int fd)
clear();
prints("\033[1;46m 五子棋對戰 \033[45m%30s VS %-30s\033[m",
- cuser.userid, my->mateid);
+ cuser->userid, my->mateid);
show_file("etc/@five", 1, -1, ONLY_COLOR);
move(11, 40);
prints("我是 %s", me == BBLACK ? "先手 ●, 有禁手" : "後手 ○");
move(16, 40);
- prints("\033[1;33m%s", cuser.userid);
+ prints("\033[1;33m%s", cuser->userid);
move(17, 40);
prints("\033[1;33m%s", my->mateid);
- reload_gomo();
move(16, 60);
prints("\033[1;31m%d\033[37m勝 \033[34m%d\033[37m敗 \033[36m%d\033[37m和"
- "\033[m", cuser.five_win, cuser.five_lose, cuser.five_tie);
+ "\033[m", cuser->five_win, cuser->five_lose, cuser->five_tie);
getuser(my->mateid);
move(17, 60);
prints("\033[1;31m%d\033[37m勝 \033[34m%d\033[37m敗 \033[36m%d\033[37m"
"和\033[m", xuser.five_win, xuser.five_lose, xuser.five_tie);
- cuser.five_lose++;
+ cuser->five_lose++;
/* 一進來先加一場敗場, 贏了後再扣回去, 避免快輸了惡意斷線 */
- passwd_update(usernum, &cuser);
+ passwd_update(usernum, cuser);
add_io(fd, 0);
@@ -365,10 +354,10 @@ gomoku(int fd)
if (lastcount <= -5 && !my->turn) {
move(19, 40);
outs("對手太久沒下, 你贏了!");
- cuser.five_lose--;
- cuser.five_win++;
+ cuser->five_lose--;
+ cuser->five_win++;
my->five_win++;
- passwd_update(usernum, &cuser);
+ passwd_update(usernum, cuser);
mv.x = mv.y = -2;
send(fd, &mv, sizeof(Horder_t), 0);
mv = *(v - 1);
@@ -387,8 +376,8 @@ gomoku(int fd)
iwantpass = 0;
if (ch == 'q') {
if (countgomo(pool) < 10) {
- cuser.five_lose--;
- passwd_update(usernum, &cuser);
+ cuser->five_lose--;
+ passwd_update(usernum, cuser);
}
send(fd, '\0', 1, 0);
break;
@@ -413,10 +402,10 @@ gomoku(int fd)
}
continue;
} else if (hewantpass) {
- cuser.five_lose--;
- cuser.five_tie++;
+ cuser->five_lose--;
+ cuser->five_tie++;
my->five_tie++;
- passwd_update(usernum, &cuser);
+ passwd_update(usernum, cuser);
mv.x = mv.y = -2;
send(fd, &mv, sizeof(Horder_t), 0);
mv = *(v - 1);
@@ -428,12 +417,12 @@ gomoku(int fd)
if (ch != sizeof(Horder_t)) {
lastcount = tick - now;
if (lastcount >= 0) {
- cuser.five_lose--;
+ cuser->five_lose--;
if (countgomo(pool) >= 10) {
- cuser.five_win++;
+ cuser->five_win++;
my->five_win++;
}
- passwd_update(usernum, &cuser);
+ passwd_update(usernum, cuser);
outmsg("對方認輸了!!");
break;
} else {
@@ -443,10 +432,10 @@ gomoku(int fd)
}
} else if (mv.x == -2 && mv.y == -2) {
if (iwantpass == 1) {
- cuser.five_lose--;
- cuser.five_tie++;
+ cuser->five_lose--;
+ cuser->five_tie++;
my->five_tie++;
- passwd_update(usernum, &cuser);
+ passwd_update(usernum, cuser);
break;
} else {
hewantpass = 1;
@@ -475,10 +464,10 @@ gomoku(int fd)
if (win) {
outmsg(win == 1 ? "對方贏了!" : "對方禁手");
if (win != 1) {
- cuser.five_lose--;
- cuser.five_win++;
+ cuser->five_lose--;
+ cuser->five_win++;
my->five_win++;
- passwd_update(usernum, &cuser);
+ passwd_update(usernum, cuser);
} else
my->five_lose++;
break;
@@ -508,10 +497,10 @@ gomoku(int fd)
if (win) {
outmsg(win == 1 ? "我贏囉~~" : "禁手輸了");
if (win == 1) {
- cuser.five_lose--;
- cuser.five_win++;
+ cuser->five_lose--;
+ cuser->five_win++;
my->five_win++;
- passwd_update(usernum, &cuser);
+ passwd_update(usernum, cuser);
} else
my->five_lose++;
break;
diff --git a/mbbsd/guess.c b/mbbsd/guess.c
index 5ec40080..bd092b27 100644
--- a/mbbsd/guess.c
+++ b/mbbsd/guess.c
@@ -29,7 +29,7 @@ get_money(void)
char data[20];
move(1, 0);
- prints("您目前有:%d Ptt$", cuser.money);
+ prints("您目前有:%d Ptt$", cuser->money);
do {
getdata(2, 0, "要賭多少(5-10或按q離開): ", data, 9, LCECHO);
money = 0;
@@ -45,7 +45,7 @@ get_money(void)
if (money != -1) {
money = atoi(data);
reload_money();
- if (money > cuser.money || money <= 4 || money > 10 ||
+ if (money > cuser->money || money <= 4 || money > 10 ||
money < 1)
money = -1;
}
@@ -53,7 +53,7 @@ get_money(void)
move(1, 0);
clrtoeol();
reload_money();
- prints("您目前有:%d Ptt$", cuser.money - money);
+ prints("您目前有:%d Ptt$", cuser->money - money);
return money;
}
@@ -231,7 +231,7 @@ guess_main()
lockreturn0(GUESSNUM, LOCK_MULTI);
reload_money();
- if (cuser.money < 5) {
+ if (cuser->money < 5) {
clear();
move(12, 35);
prints("錢不夠啦 至少要 5 Ptt$");
@@ -296,10 +296,10 @@ guess_main()
if ((file = fopen(LOGPASS, "a"))) {
fprintf(file, "電腦第%d次猜中, ", c_count);
if (youwin)
- fprintf(file, "%s 第%d次猜中, ", cuser.userid, count);
+ fprintf(file, "%s 第%d次猜中, ", cuser->userid, count);
else
- fprintf(file, "%s 沒猜中, ", cuser.userid);
- fprintf(file, "電腦賺走了%s %ld Ptt$\n", cuser.userid, money);
+ fprintf(file, "%s 沒猜中, ", cuser->userid);
+ fprintf(file, "電腦賺走了%s %ld Ptt$\n", cuser->userid, money);
fclose(file);
}
} else if (count < c_count) {
@@ -309,7 +309,7 @@ guess_main()
demoney(money * 2);
if ((file = fopen(LOGPASS, "a"))) {
fprintf(file, "id: %s, 第%d次猜中, 電腦第%d次猜中, "
- "贏了電腦 %ld Ptt$\n", cuser.userid, count,
+ "贏了電腦 %ld Ptt$\n", cuser->userid, count,
c_count, money * 2);
fclose(file);
}
@@ -317,7 +317,7 @@ guess_main()
prints("真厲害, 和電腦打成平手了, 拿回本錢%lu\n", money);
demoney(money);
if ((file = fopen(LOGPASS, "a"))) {
- fprintf(file, "id: %s 和電腦打成了平手\n", cuser.userid);
+ fprintf(file, "id: %s 和電腦打成了平手\n", cuser->userid);
fclose(file);
}
}
@@ -331,14 +331,14 @@ guess_main()
prints("真厲害, 錢被你賺走了");
if ((file = fopen(LOGPASS, "a"))) {
fprintf(file, "id: %s, 第%d次猜中, 贏了 %ld Ptt$\n",
- cuser.userid, count, TABLE[count] * money);
+ cuser->userid, count, TABLE[count] * money);
fclose(file);
}
} else if (count > 5) {
prints("唉, 太多次才猜出來了");
if ((file = fopen(LOGPASS, "a"))) {
fprintf(file, "id: %s, 第%d次才猜中, 賠了 %ld Ptt$\n",
- cuser.userid, count, money);
+ cuser->userid, count, money);
fclose(file);
}
} else {
@@ -348,7 +348,7 @@ guess_main()
prints("你拿回了%lu Ptt$\n", money);
if ((file = fopen(LOGPASS, "a"))) {
fprintf(file, "id: %s, 第%d次猜中, 拿回了本錢 %lu Ptt$\n",
- cuser.userid, count, money);
+ cuser->userid, count, money);
fclose(file);
}
}
@@ -361,7 +361,7 @@ guess_main()
move(18, 35);
prints("下次再來吧");
if ((file = fopen(BBSHOME "/etc/loseguess.log", "a"))) {
- fprintf(file, "id: %s 賭了 %ld Ptt$\n", cuser.userid, money);
+ fprintf(file, "id: %s 賭了 %ld Ptt$\n", cuser->userid, money);
fclose(file);
}
unlockutmpmode();
diff --git a/mbbsd/indict.c b/mbbsd/indict.c
index 317fb5b0..2a997bdb 100644
--- a/mbbsd/indict.c
+++ b/mbbsd/indict.c
@@ -25,7 +25,7 @@ addword(char *database,char word[])
if (buf[0]) {
getdata(13, 0, "確定新增?(Y/n)", a, sizeof(a), LCECHO);
if (a[0] != 'n')
- fprintf(fp, "%-65s[%s]\n", buf, cuser.userid);
+ fprintf(fp, "%-65s[%s]\n", buf, cuser->userid);
}
}
fclose(fp);
diff --git a/mbbsd/kaede.c b/mbbsd/kaede.c
index 9023557d..bf2e0302 100644
--- a/mbbsd/kaede.c
+++ b/mbbsd/kaede.c
@@ -18,7 +18,7 @@ Ptt_prints(char *str, int mode)
switch( str[++r] ){
case 's':
w += snprintf(&strbuf[w], sizeof(strbuf) - w,
- "%s", cuser.userid);
+ "%s", cuser->userid);
break;
case 't':
w += snprintf(&strbuf[w], sizeof(strbuf) - w,
@@ -30,23 +30,23 @@ Ptt_prints(char *str, int mode)
break;
case 'b':
w += snprintf(&strbuf[w], sizeof(strbuf) - w,
- "%d/%d", cuser.month, cuser.day);
+ "%d/%d", cuser->month, cuser->day);
break;
case 'l':
w += snprintf(&strbuf[w], sizeof(strbuf) - w,
- "%d", cuser.numlogins);
+ "%d", cuser->numlogins);
break;
case 'p':
w += snprintf(&strbuf[w], sizeof(strbuf) - w,
- "%d", cuser.numposts);
+ "%d", cuser->numposts);
break;
case 'n':
w += snprintf(&strbuf[w], sizeof(strbuf) - w,
- "%s", cuser.username);
+ "%s", cuser->username);
break;
case 'm':
w += snprintf(&strbuf[w], sizeof(strbuf) - w,
- "%d", cuser.money);
+ "%d", cuser->money);
break;
/* It's saver not to send these undefined escape string.
default:
diff --git a/mbbsd/lovepaper.c b/mbbsd/lovepaper.c
index 1ab87944..f5dfdfbb 100644
--- a/mbbsd/lovepaper.c
+++ b/mbbsd/lovepaper.c
@@ -1,4 +1,4 @@
-/* $Id: lovepaper.c,v 1.11 2003/01/19 16:06:06 kcwu Exp $ */
+/* $Id$ */
#include "bbs.h"
#define DATA "etc/lovepaper.dat"
@@ -15,7 +15,7 @@ x_love()
setutmpmode(LOVE);
gtime = localtime(&now);
snprintf(buf1, sizeof(buf1), "%c/%s/love%d%d",
- cuser.userid[0], cuser.userid, gtime->tm_sec, gtime->tm_min);
+ cuser->userid[0], cuser->userid, gtime->tm_sec, gtime->tm_min);
strcat(path, buf1);
move(1, 0);
clrtobot();
@@ -96,7 +96,7 @@ x_love()
stampfile(buf1, &mhdr);
Rename(path, buf1);
strncpy(mhdr.title, save_title, TTLEN);
- strlcpy(mhdr.owner, cuser.userid, sizeof(mhdr.owner));
+ strlcpy(mhdr.owner, cuser->userid, sizeof(mhdr.owner));
sethomedir(path, receiver);
if (append_record(path, &mhdr, sizeof(mhdr)) == -1)
return -1;
diff --git a/mbbsd/mail.c b/mbbsd/mail.c
index 85f4c142..60f52e2b 100644
--- a/mbbsd/mail.c
+++ b/mbbsd/mail.c
@@ -12,7 +12,7 @@ setforward()
char buf[80], ip[50] = "", yn[4];
FILE *fp;
- sethomepath(buf, cuser.userid);
+ sethomepath(buf, cuser->userid);
strcat(buf, "/.forward");
if ((fp = fopen(buf, "r"))) {
fscanf(fp, "%s", ip); // XXX check buffer size
@@ -58,7 +58,7 @@ built_mail_index()
snprintf(genbuf, sizeof(genbuf),
BBSHOME "/bin/buildir " BBSHOME "/home/%c/%s",
- cuser.userid[0], cuser.userid);
+ cuser->userid[0], cuser->userid);
move(22, 0);
prints("\033[1;31m已經處理完畢!! 諸多不便 敬請原諒~\033[m");
pressanykey();
@@ -85,7 +85,7 @@ mailalert(char *userid)
int
mail_muser(userec_t muser, char *title, char *filename)
{
- return mail_id(muser.userid, title, filename, cuser.userid);
+ return mail_id(muser.userid, title, filename, cuser->userid);
}
/* Heat: 用id來寄信,內容則link準備好的檔案 */
@@ -140,7 +140,7 @@ m_internet()
void
m_init()
{
- sethomedir(currmaildir, cuser.userid);
+ sethomedir(currmaildir, cuser->userid);
}
int
@@ -159,8 +159,8 @@ chkmailbox()
mailsumlimit = 200;
else
mailsumlimit = 50;
- mailsumlimit += cuser.exmailbox * 10;
- mailmaxkeep = max_keepmail + cuser.exmailbox;
+ mailsumlimit += cuser->exmailbox * 10;
+ mailmaxkeep = max_keepmail + cuser->exmailbox;
m_init();
if ((mailkeep = get_num_records(currmaildir, sizeof(fileheader_t))) >
mailmaxkeep) {
@@ -224,7 +224,7 @@ hold_mail(char *fpath, char *receiver)
buf, sizeof(buf), LCECHO);
if (buf[0] == 'y')
- do_hold_mail(fpath, receiver, cuser.userid);
+ do_hold_mail(fpath, receiver, cuser->userid);
}
int
@@ -289,7 +289,7 @@ do_send(char *userid, char *title)
strlcpy(receiver, userid, sizeof(receiver));
sethomepath(genbuf, userid);
stampfile(genbuf, &mhdr);
- strlcpy(mhdr.owner, cuser.userid, sizeof(mhdr.owner));
+ strlcpy(mhdr.owner, cuser->userid, sizeof(mhdr.owner));
strncpy(mhdr.title, save_title, TTLEN);
if (vedit(genbuf, YEA, NULL) == -1) {
unlink(genbuf);
@@ -298,10 +298,10 @@ do_send(char *userid, char *title)
}
clear();
sethomefile(fpath, userid, FN_OVERRIDES);
- i = belong(fpath, cuser.userid);
+ i = belong(fpath, cuser->userid);
sethomefile(fpath, userid, FN_REJECT);
- if (i || !belong(fpath, cuser.userid)) {/* Ptt: 用belong有點討厭 */
+ if (i || !belong(fpath, cuser->userid)) {/* Ptt: 用belong有點討厭 */
sethomedir(fpath, userid);
if (append_record_forward(fpath, &mhdr, sizeof(mhdr)) == -1)
return -1;
@@ -447,7 +447,7 @@ multi_send(char *title)
strtok(ptr = genbuf + 3, " \n\r");
do {
if (searchuser(ptr) && !InNameList(ptr) &&
- strcmp(cuser.userid, ptr)) {
+ strcmp(cuser->userid, ptr)) {
AddNameList(ptr);
reciper++;
}
@@ -525,7 +525,7 @@ multi_send(char *title)
unlink(genbuf);
Link(fpath, genbuf);
- strlcpy(mymail.owner, cuser.userid, sizeof(mymail.owner));
+ strlcpy(mymail.owner, cuser->userid, sizeof(mymail.owner));
strlcpy(mymail.title, save_title, sizeof(mymail.title));
mymail.filemode |= FILE_MULTI; /* multi-send flag */
sethomedir(genbuf, p->word);
@@ -602,17 +602,17 @@ mail_all()
setutmpmode(MAILALL);
stand_title("寄信中...");
- sethomepath(genbuf, cuser.userid);
+ sethomepath(genbuf, cuser->userid);
stampfile(genbuf, &mymail);
unlink(genbuf);
Link(fpath, genbuf);
unlink(fpath);
strcpy(fpath, genbuf);
- strlcpy(mymail.owner, cuser.userid, sizeof(mymail.owner)); /* 站長 ID */
+ strlcpy(mymail.owner, cuser->userid, sizeof(mymail.owner)); /* 站長 ID */
strlcpy(mymail.title, save_title, sizeof(mymail.title));
- sethomedir(genbuf, cuser.userid);
+ sethomedir(genbuf, cuser->userid);
if (append_record_forward(genbuf, &mymail, sizeof(mymail)) == -1)
outs(err_uid);
@@ -622,13 +622,13 @@ mail_all()
userid = SHM->userid[i];
if (strcmp(userid, STR_GUEST) && strcmp(userid, "new") &&
- strcmp(userid, cuser.userid)) {
+ strcmp(userid, cuser->userid)) {
sethomepath(genbuf, userid);
stampfile(genbuf, &mymail);
unlink(genbuf);
Link(fpath, genbuf);
- strlcpy(mymail.owner, cuser.userid, sizeof(mymail.owner));
+ strlcpy(mymail.owner, cuser->userid, sizeof(mymail.owner));
strlcpy(mymail.title, save_title, sizeof(mymail.title));
/* mymail.filemode |= FILE_MARKED; Ptt 公告改成不會mark */
sethomedir(genbuf, userid);
@@ -649,8 +649,8 @@ mail_mbox()
char cmd[100];
fileheader_t fhdr;
- snprintf(cmd, sizeof(cmd), "/tmp/%s.uu", cuser.userid);
- snprintf(fhdr.title, sizeof(fhdr.title), "%s 私人資料", cuser.userid);
+ snprintf(cmd, sizeof(cmd), "/tmp/%s.uu", cuser->userid);
+ snprintf(fhdr.title, sizeof(fhdr.title), "%s 私人資料", cuser->userid);
doforward(cmd, &fhdr, 'Z');
return 0;
}
@@ -851,12 +851,6 @@ maildoent(int num, fileheader_t * ent)
ent->date, ent->owner, color, mark, title);
}
-static int
-m_idle(int ent, fileheader_t * fhdr, char *direct)
-{
- t_idle();
- return FULLUPDATE;
-}
static int
mail_del(int ent, fileheader_t * fhdr, char *direct)
@@ -874,14 +868,14 @@ mail_del(int ent, fileheader_t * fhdr, char *direct)
unlink(genbuf);
if ((currmode & MODE_SELECT)) {
int index;
- sethomedir(genbuf, cuser.userid);
+ sethomedir(genbuf, cuser->userid);
index = getindex(genbuf, fhdr->filename, sizeof(fileheader_t));
delete_record(genbuf, sizeof(fileheader_t), index);
}
return DIRCHANGED;
}
}
- return FULLUPDATE;
+ return TITLE_REDRAW;
}
static int
@@ -1032,7 +1026,7 @@ mail_edit(int ent, fileheader_t * fhdr, char *direct)
char genbuf[200];
if (!HAS_PERM(PERM_SYSOP) &&
- strcmp(cuser.userid, fhdr->owner) &&
+ strcmp(cuser->userid, fhdr->owner) &&
strcmp("[備.忘.錄]", fhdr->owner))
return DONOTHING;
@@ -1044,9 +1038,9 @@ mail_edit(int ent, fileheader_t * fhdr, char *direct)
static int
mail_nooutmail(int ent, fileheader_t * fhdr, char *direct)
{
- cuser.userlevel ^= PERM_NOOUTMAIL;
- passwd_update(usernum, &cuser);
- return FULLUPDATE;
+ cuser->userlevel ^= PERM_NOOUTMAIL;
+ passwd_update(usernum, cuser);
+ return TITLE_REDRAW;
}
@@ -1111,8 +1105,6 @@ mail_cross_post(int ent, fileheader_t * fhdr, char *direct)
move(2, 0);
clrtoeol();
- move(3, 0);
- clrtoeol();
move(1, 0);
generalnamecomplete("轉錄本文章於看板:", xboard, sizeof(xboard),
SHM->Bnumber,
@@ -1120,10 +1112,10 @@ mail_cross_post(int ent, fileheader_t * fhdr, char *direct)
completeboard_permission,
completeboard_getname);
if (*xboard == '\0' || !haspostperm(xboard))
- return FULLUPDATE;
+ return TITLE_REDRAW;
ent = 1;
- if (HAS_PERM(PERM_SYSOP) || !strcmp(fhdr->owner, cuser.userid)) {
+ if (HAS_PERM(PERM_SYSOP) || !strcmp(fhdr->owner, cuser->userid)) {
getdata(2, 0, "(1)原文轉載 (2)舊轉錄格式?[1] ",
genbuf, 3, DOECHO);
if (genbuf[0] != '2') {
@@ -1154,7 +1146,7 @@ mail_cross_post(int ent, fileheader_t * fhdr, char *direct)
if (author)
strlcpy(xfile.owner, fhdr->owner, sizeof(xfile.owner));
else
- strlcpy(xfile.owner, cuser.userid, sizeof(xfile.owner));
+ strlcpy(xfile.owner, cuser->userid, sizeof(xfile.owner));
strlcpy(xfile.title, xtitle, sizeof(xfile.title));
if (genbuf[0] == 'l') {
xfile.filemode = FILE_LOCAL;
@@ -1170,7 +1162,7 @@ mail_cross_post(int ent, fileheader_t * fhdr, char *direct)
write_header(xptr);
strlcpy(currboard, xfpath, sizeof(currboard));
- fprintf(xptr, "※ [本文轉錄自 %s 信箱]\n\n", cuser.userid);
+ fprintf(xptr, "※ [本文轉錄自 %s 信箱]\n\n", cuser->userid);
b_suckinfile(xptr, fname);
addsignature(xptr, 0);
@@ -1185,9 +1177,8 @@ mail_cross_post(int ent, fileheader_t * fhdr, char *direct)
setbtotal(getbnum(xboard));
if (!xfile.filemode)
outgo_post(&xfile, xboard);
- cuser.numposts++;
- passwd_update(usernum, &cuser);
- outs("文章轉錄完成");
+ cuser->numposts++;
+ outmsg("文章轉錄完成");
pressanykey();
currmode = currmode0;
}
@@ -1202,8 +1193,8 @@ mail_man()
int mode0 = currutmp->mode;
int stat0 = currstat;
- sethomeman(buf, cuser.userid);
- snprintf(buf1, sizeof(buf1), "%s 的信件夾", cuser.userid);
+ sethomeman(buf, cuser->userid);
+ snprintf(buf1, sizeof(buf1), "%s 的信件夾", cuser->userid);
a_menu(buf1, buf, 1);
currutmp->mode = mode0;
currstat = stat0;
@@ -1227,7 +1218,7 @@ mail_cite(int ent, fileheader_t * fhdr, char *direct)
title[TTLEN] = '\0';
a_copyitem(fpath, title, 0, 1);
- if (cuser.userlevel >= PERM_BM) {
+ if (cuser->userlevel >= PERM_BM) {
move(2, 0);
clrtoeol();
move(3, 0);
@@ -1269,8 +1260,8 @@ mail_save(int ent, fileheader_t * fhdr, char *direct)
strncpy(title + 3, fhdr->title, TTLEN - 3);
title[TTLEN] = '\0';
a_copyitem(fpath, title, fhdr->owner, 1);
- sethomeman(fpath, cuser.userid);
- a_menu(cuser.userid, fpath, 1);
+ sethomeman(fpath, cuser->userid);
+ a_menu(cuser->userid, fpath, 1);
return FULLUPDATE;
}
return DONOTHING;
@@ -1289,7 +1280,7 @@ mail_waterball(int ent, fileheader_t * fhdr, char *direct)
return 1;
}
if (!address[0])
- strlcpy(address, cuser.email, sizeof(address));
+ strlcpy(address, cuser->email, sizeof(address));
move(b_lines - 8, 0);
outs("水球整理程式:\n"
"系統將會按照和不同人丟的水球各自獨立\n"
@@ -1337,16 +1328,16 @@ mail_waterball(int ent, fileheader_t * fhdr, char *direct)
cmode = (fname[0] != '0' && fname[0] != '1') ? 1 : fname[0] - '0';
snprintf(fname, sizeof(fname), BBSHOME "/jobspool/water.src.%s-%d",
- cuser.userid, (int)now);
+ cuser->userid, (int)now);
snprintf(genbuf, sizeof(genbuf), "cp " BBSHOME "/home/%c/%s/%s %s",
- cuser.userid[0], cuser.userid, fhdr->filename, fname);
+ cuser->userid[0], cuser->userid, fhdr->filename, fname);
system(genbuf);
/* dirty code ;x */
snprintf(fname, sizeof(fname), BBSHOME "/jobspool/water.des.%s-%d",
- cuser.userid, (int)now);
+ cuser->userid, (int)now);
fp = fopen(fname, "wt");
assert(fp);
- fprintf(fp, "%s\n%s\n%d\n", cuser.userid, address, cmode);
+ fprintf(fp, "%s\n%s\n%d\n", cuser->userid, address, cmode);
fclose(fp);
vmsg("設定完成, 系統將在下一個整點(尖峰時段除外)將資料寄給您");
return FULLUPDATE;
@@ -1361,7 +1352,7 @@ static onekey_t mail_comms[] = {
NULL, // Ctrl('F')
built_mail_index, // Ctrl('G')
NULL, // Ctrl('H')
- m_idle, // Ctrl('I') KEY_TAB 9
+ NULL, // Ctrl('I')
NULL, // Ctrl('J')
NULL, // Ctrl('K')
NULL, // Ctrl('L')
@@ -1454,7 +1445,7 @@ m_read()
i_read(RMAIL, currmaildir, mailtitle, maildoent, mail_comms, -1);
currbid = back_bid;
curredit = 0;
- currutmp->mailalert = load_mailalert(cuser.userid);
+ currutmp->mailalert = load_mailalert(cuser->userid);
return 0;
} else {
outs("您沒有來信");
@@ -1473,11 +1464,11 @@ send_inner_mail(char *fpath, char *title, char *receiver)
return -2;
sethomepath(genbuf, receiver);
stampfile(genbuf, &mymail);
- if (!strcmp(receiver, cuser.userid)) {
+ if (!strcmp(receiver, cuser->userid)) {
strlcpy(mymail.owner, "[" BBSNAME "]", sizeof(mymail.owner));
mymail.filemode = FILE_READ;
} else
- strlcpy(mymail.owner, cuser.userid, sizeof(mymail.owner));
+ strlcpy(mymail.owner, cuser->userid, sizeof(mymail.owner));
strncpy(mymail.title, title, TTLEN);
unlink(genbuf);
Link(fpath, genbuf);
@@ -1521,7 +1512,7 @@ bbs_sendmail(char *fpath, char *title, char *receiver)
} else {
snprintf(genbuf, sizeof(genbuf),
"/usr/sbin/sendmail -f %s%s %s > /dev/null",
- cuser.userid, str_mail_address, receiver);
+ cuser->userid, str_mail_address, receiver);
fin = fopen(fpath, "r");
}
fout = popen(genbuf, "w");
@@ -1530,9 +1521,9 @@ bbs_sendmail(char *fpath, char *title, char *receiver)
if (fpath)
fprintf(fout, "Reply-To: %s%s\nFrom: %s <%s%s>\n",
- cuser.userid, str_mail_address,
- cuser.username,
- cuser.userid, str_mail_address);
+ cuser->userid, str_mail_address,
+ cuser->username,
+ cuser->userid, str_mail_address);
fprintf(fout,"To: %s\nSubject: %s\n"
"Mime-Version: 1.0\r\n"
"Content-Type: text/plain; charset=\"big5\"\r\n"
@@ -1593,8 +1584,8 @@ bsmtp(char *fpath, char *title, char *rcpt, int method)
/* setup mail queue */
mqueue.mailtime = chrono;
mqueue.method = method;
- strlcpy(mqueue.sender, cuser.userid, sizeof(mqueue.sender));
- strlcpy(mqueue.username, cuser.username, sizeof(mqueue.username));
+ strlcpy(mqueue.sender, cuser->userid, sizeof(mqueue.sender));
+ strlcpy(mqueue.username, cuser->username, sizeof(mqueue.username));
strlcpy(mqueue.rcpt, rcpt, sizeof(mqueue.rcpt));
if (append_record("out/.DIR", (fileheader_t *) & mqueue, sizeof(mqueue)) < 0)
return 0;
@@ -1611,17 +1602,17 @@ doforward(char *direct, fileheader_t * fh, int mode)
char genbuf[200];
if (!address[0])
- strlcpy(address, cuser.email, sizeof(address));
+ strlcpy(address, cuser->email, sizeof(address));
if( mode == 'U' ){
- move(b_lines - 2, 0);
+ move(b_lines, 0);
prints("將進行 uuencode 。若您不清楚什麼是 uuencode 請改用 F轉寄。");
}
if (address[0]) {
snprintf(genbuf, sizeof(genbuf),
"確定轉寄給 [%s] 嗎(Y/N/Q)?[Y] ", address);
- getdata(b_lines - 1, 0, genbuf, fname, 3, LCECHO);
+ getdata(b_lines, 0, genbuf, fname, 3, LCECHO);
if (fname[0] == 'q') {
outmsg("取消轉寄");
@@ -1650,7 +1641,7 @@ doforward(char *direct, fileheader_t * fh, int mode)
snprintf(fname, sizeof(fname), "正轉寄給 %s, 請稍候...", address);
outmsg(fname);
- move(b_lines - 1, 0);
+ move(b_lines, 0);
refresh();
/* 追蹤使用者 */
@@ -1658,7 +1649,7 @@ doforward(char *direct, fileheader_t * fh, int mode)
char msg[200];
snprintf(msg, sizeof(msg), "%s mailforward to %s at %s",
- cuser.userid, address, Cdate(&now));
+ cuser->userid, address, Cdate(&now));
log_user(msg);
}
if (mode == 'Z') {
@@ -1666,13 +1657,13 @@ doforward(char *direct, fileheader_t * fh, int mode)
TAR_PATH " cfz /tmp/home.%s.tgz home/%c/%s; "
MUTT_PATH " -a /tmp/home.%s.tgz -s 'home.%s.tgz' '%s' </dev/null;"
"rm /tmp/home.%s.tgz",
- cuser.userid, cuser.userid[0], cuser.userid,
- cuser.userid, cuser.userid, address, cuser.userid);
+ cuser->userid, cuser->userid[0], cuser->userid,
+ cuser->userid, cuser->userid, address, cuser->userid);
system(fname);
return 0;
snprintf(fname, sizeof(fname), TAR_PATH " cfz - home/%c/%s | "
"/usr/bin/uuencode %s.tgz > %s",
- cuser.userid[0], cuser.userid, cuser.userid, direct);
+ cuser->userid[0], cuser->userid, cuser->userid, direct);
system(fname);
strlcpy(fname, direct, sizeof(fname));
} else if (mode == 'U') {
@@ -1748,7 +1739,7 @@ mail_justify(userec_t muser)
sethomepath(buf1, muser.userid);
stampfile(buf1, &mhdr);
unlink(buf1);
- strlcpy(mhdr.owner, cuser.userid, sizeof(mhdr.owner));
+ strlcpy(mhdr.owner, cuser->userid, sizeof(mhdr.owner));
strncpy(mhdr.title, "[審核通過]", TTLEN);
mhdr.filemode = 0;
diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c
index 5af63c29..64795836 100644
--- a/mbbsd/mbbsd.c
+++ b/mbbsd/mbbsd.c
@@ -102,7 +102,7 @@ log_user(char *msg)
char filename[200], buf[200];
snprintf(filename, sizeof(filename), BBSHOME "/home/%c/%s/USERLOG",
- cuser.userid[0], cuser.userid);
+ cuser->userid[0], cuser->userid);
snprintf(buf, sizeof(buf), "%s\n", msg);
log_file(filename, msg, 1);
}
@@ -113,30 +113,31 @@ log_usies(char *mode, char *mesg)
{
char genbuf[200];
- if (!mesg)
- snprintf(genbuf, sizeof(genbuf),
- cuser.userid[0] ? "%s %s %-12s Stay:%d (%s)\n" :
- "%s %s %s Stay:%d (%s)\n",
- Cdate(&now), mode, cuser.userid,
- (int)(now - login_start_time) / 60, cuser.username);
- else
- snprintf(genbuf, sizeof(genbuf),
- cuser.userid[0] ? "%s %s %-12s %s\n" : "%s %s %s%s\n",
- Cdate(&now), mode, cuser.userid, mesg);
+
+ sprintf(genbuf, "%-10.10s %-10.10s Stay:%-10d", Cdate(&now), mode,
+ (int)(now - login_start_time) / 60);
+
+ if(cuser && cuser->userid[0])
+ sprintf(genbuf+38, "%s %s ", cuser->userid, cuser->username);
+
+ if(mesg)
+ strcat(genbuf, mesg);
+
log_file(FN_USIES, genbuf, 1);
/* 追蹤使用者 */
- if (HAS_PERM(PERM_LOGUSER))
- log_user(genbuf);
+ if (cuser && HAS_PERM(PERM_LOGUSER))
+ log_user(genbuf);
}
+
static void
setflags(int mask, int value)
{
if (value)
- cuser.uflag |= mask;
+ cuser->uflag |= mask;
else
- cuser.uflag &= ~mask;
+ cuser->uflag &= ~mask;
}
void
@@ -157,27 +158,28 @@ u_exit(char *mode)
brc_finalize();
#ifdef ASSESS
- cuser.goodpost = currutmp->goodpost;
- cuser.badpost = currutmp->badpost;
- cuser.goodsale = currutmp->goodsale;
- cuser.badsale = currutmp->badsale;
+ cuser->goodpost = currutmp->goodpost;
+ cuser->badpost = currutmp->badpost;
+ cuser->goodsale = currutmp->goodsale;
+ cuser->badsale = currutmp->badsale;
#endif
- cuser.invisible = currutmp->invisible;
- cuser.pager = currutmp->pager;
- memcpy(cuser.mind, currutmp->mind, 4);
+ cuser->invisible = currutmp->invisible;
+ cuser->pager = currutmp->pager;
+ memcpy(cuser->mind, currutmp->mind, 4);
setutmpbid(0);
if (!(HAS_PERM(PERM_SYSOP) && HAS_PERM(PERM_DENYPOST)) &&
!currutmp->invisible)
do_aloha("<<下站通知>> -- 我走囉!");
purge_utmp(currutmp);
- if ((cuser.uflag != enter_uflag) || (currmode & MODE_DIRTY) || diff) {
- if (!diff && cuser.numlogins)
- cuser.numlogins = --cuser.numlogins;
+ if ((cuser->uflag != enter_uflag) || (currmode & MODE_DIRTY) || diff) {
+ if (!diff && cuser->numlogins)
+ cuser->numlogins = --cuser->numlogins;
/* Leeym 上站停留時間限制式 */
}
- passwd_update(usernum, &cuser);
+ passwd_index_update(usernum, cuser);
+ passwd_update(usernum, cuser);
log_usies(mode, NULL);
}
@@ -215,7 +217,7 @@ abort_bbs_debug(int sig)
reentrant = 1;
if (currmode)
u_exit("AXXED");
- setproctitle("debug me!(%d)(%s,%d)", sig, cuser.userid, currstat);
+ setproctitle("debug me!(%d)(%s,%d)", sig, cuser->userid, currstat);
sleep(3600); /* wait 60 mins for debug */
}
#endif
@@ -229,16 +231,6 @@ mysrand()
srand(time(NULL) + getpid()); /* 時間跟 pid 當 rand 的 seed */
}
-int
-dosearchuser(char *userid)
-{
- if ((usernum = getuser(userid)))
- memcpy(&cuser, &xuser, sizeof(cuser));
- else
- memset(&cuser, 0, sizeof(cuser));
- return usernum;
-}
-
void
talk_request(int sig)
{
@@ -287,7 +279,7 @@ show_call_in(int save, int which)
char genbuf[200];
time_t now;
if (!fp_writelog) {
- sethomefile(genbuf, cuser.userid, fn_writelog);
+ sethomefile(genbuf, cuser->userid, fn_writelog);
fp_writelog = fopen(genbuf, "a");
}
if (fp_writelog) {
@@ -402,7 +394,7 @@ write_request(int sig)
} else {
if (currutmp->mode != 0 &&
currutmp->pager != 0 &&
- cuser.userlevel != 0 &&
+ cuser->userlevel != 0 &&
currutmp->msgcount != 0 &&
currutmp->mode != TALK &&
currutmp->mode != EDITING &&
@@ -465,7 +457,7 @@ multi_user_check()
if (HAS_PERM(PERM_SYSOP))
return; /* don't check sysops */
- if (cuser.userlevel) {
+ if (cuser->userlevel) {
if (!(ui = (userinfo_t *) search_ulist(usernum)))
return; /* user isn't logged in */
@@ -479,7 +471,7 @@ multi_user_check()
if (genbuf[0] != 'n') {
if (pid > 0)
kill(pid, SIGHUP);
- log_usies("KICK ", cuser.username);
+ log_usies("KICK ", cuser->username);
} else {
if (search_ulistn(usernum, 3) != NULL)
system_abort(); /* Goodbye(); */
@@ -555,7 +547,6 @@ login_query()
#endif
output("1", 1);
- /* hint */
attempts = 0;
while (1) {
@@ -570,7 +561,6 @@ login_query()
#endif
getdata(20, 0, "請輸入代號,或以[guest]參觀,以[new]註冊:",
uid, sizeof(uid), DOECHO);
-
#ifdef CONVERT
/* switch to gb mode if uid end with '.' */
len = strlen(uid);
@@ -589,43 +579,44 @@ login_query()
if (strcasecmp(uid, str_new) == 0) {
#ifdef LOGINASNEW
new_register();
- mkuserdir(cuser.userid);
+ mkuserdir(cuser->userid);
break;
#else
outs("本系統目前無法以 new 註冊, 請用 guest 進入\n");
continue;
#endif
- } else if (uid[0] == '\0' || !dosearchuser(uid)) {
+ } else if (uid[0] == '\0'){
outs(err_uid);
} else if (strcmp(uid, STR_GUEST)) {
getdata(21, 0, MSG_PASSWD,
passbuf, sizeof(passbuf), NOECHO);
passbuf[8] = '\0';
- if (!checkpasswd(cuser.passwd, passbuf)
- /* || (HAS_PERM(PERM_SYSOP) && !use_shell_login_mode) */ ) {
- logattempt(cuser.userid, '-');
+ if( initcuser(uid) < 1 || cuser == NULL ||
+ !checkpasswd(cuser->passwd, passbuf) ){
+ logattempt(cuser ? cuser->userid : "", '-');
outs(ERR_PASSWD);
} else {
- logattempt(cuser.userid, ' ');
- if (strcasecmp("SYSOP", cuser.userid) == 0){
+ logattempt(cuser->userid, ' ');
+ if (strcasecmp("SYSOP", cuser->userid) == 0){
#ifdef NO_SYSOP_ACCOUNT
exit(0);
#else /* 自動加上各個主要權限 */
- cuser.userlevel = PERM_BASIC | PERM_CHAT | PERM_PAGE |
+ cuser->userlevel = PERM_BASIC | PERM_CHAT | PERM_PAGE |
PERM_POST | PERM_LOGINOK | PERM_MAILLIMIT |
PERM_CLOAK | PERM_SEECLOAK | PERM_XEMPT |
PERM_DENYPOST | PERM_BM | PERM_ACCOUNTS |
PERM_CHATROOM | PERM_BOARD | PERM_SYSOP | PERM_BBSADM;
- mkuserdir(cuser.userid);
+ mkuserdir(cuser->userid);
#endif
}
break;
}
} else { /* guest */
- cuser.userlevel = 0;
- cuser.uflag = COLOR_FLAG | PAGER_FLAG | BRDSORT_FLAG | MOVIE_FLAG;
- mkuserdir(cuser.userid);
+ if (initcuser(uid)< 1) exit (0) ;
+ cuser->userlevel = 0;
+ cuser->uflag = COLOR_FLAG | PAGER_FLAG | BRDSORT_FLAG | MOVIE_FLAG;
+ mkuserdir(cuser->userid);
break;
}
}
@@ -751,7 +742,7 @@ check_BM(void)
/* XXX: -_- */
int i;
- cuser.userlevel &= ~PERM_BM;
+ cuser->userlevel &= ~PERM_BM;
for( i = 0 ; i < numboards ; ++i )
if( is_BM_cache(i + 1) ) /* XXXbid */
return;
@@ -766,31 +757,31 @@ setup_utmp(int mode)
uinfo.pid = currpid = getpid();
uinfo.uid = usernum;
uinfo.mode = currstat = mode;
- uinfo.mailalert = load_mailalert(cuser.userid);
+ uinfo.mailalert = load_mailalert(cuser->userid);
#ifdef ASSESS
- uinfo.goodpost = cuser.goodpost;
- uinfo.badpost = cuser.badpost;
- uinfo.goodsale = cuser.goodsale;
- uinfo.badsale = cuser.badsale;
+ uinfo.goodpost = cuser->goodpost;
+ uinfo.badpost = cuser->badpost;
+ uinfo.goodsale = cuser->goodsale;
+ uinfo.badsale = cuser->badsale;
#endif
- uinfo.userlevel = cuser.userlevel;
- uinfo.sex = cuser.sex % 8;
+ uinfo.userlevel = cuser->userlevel;
+ uinfo.sex = cuser->sex % 8;
uinfo.lastact = time(NULL);
- strlcpy(uinfo.userid, cuser.userid, sizeof(uinfo.userid));
- //strlcpy(uinfo.realname, cuser.realname, sizeof(uinfo.realname));
- strlcpy(uinfo.username, cuser.username, sizeof(uinfo.username));
+ strlcpy(uinfo.userid, cuser->userid, sizeof(uinfo.userid));
+ //strlcpy(uinfo.realname, cuser->realname, sizeof(uinfo.realname));
+ strlcpy(uinfo.username, cuser->username, sizeof(uinfo.username));
strlcpy(uinfo.from, fromhost, sizeof(uinfo.from));
- uinfo.five_win = cuser.five_win;
- uinfo.five_lose = cuser.five_lose;
- uinfo.five_tie = cuser.five_tie;
- uinfo.chc_win = cuser.chc_win;
- uinfo.chc_lose = cuser.chc_lose;
- uinfo.chc_tie = cuser.chc_tie;
- uinfo.invisible = cuser.invisible % 2;
- uinfo.pager = cuser.pager % 5;
- memcpy(uinfo.mind, cuser.mind, 4);
+ uinfo.five_win = cuser->five_win;
+ uinfo.five_lose = cuser->five_lose;
+ uinfo.five_tie = cuser->five_tie;
+ uinfo.chc_win = cuser->chc_win;
+ uinfo.chc_lose = cuser->chc_lose;
+ uinfo.chc_tie = cuser->chc_tie;
+ uinfo.invisible = cuser->invisible % 2;
+ uinfo.pager = cuser->pager % 5;
+ memcpy(uinfo.mind, cuser->mind, 4);
#ifdef WHERE
uinfo.from_alias = where(fromhost);
#endif
@@ -806,7 +797,7 @@ setup_utmp(int mode)
uinfo.invisible = YEA;
getnewutmpent(&uinfo);
SHM->UTMPneedsort = 1;
- if (!(cuser.numlogins % 20) && cuser.userlevel & PERM_BM)
+ if (!(cuser->numlogins % 20) && cuser->userlevel & PERM_BM)
check_BM(); /* Ptt 自動取下離職板主權力 */
#ifndef _BBS_UTIL_C_
friend_load(0);
@@ -818,7 +809,7 @@ inline static void welcome_msg(void) {
prints("\033[m 歡迎您第 \033[1;33m%d\033[0;37m 度拜訪本站,"
"上次您是從 \033[1;33m%s\033[0;37m 連往本站,\n"
" 我記得那天是 \033[1;33m%s\033[0;37m。\n",
- ++cuser.numlogins, cuser.lasthost, Cdate(&cuser.lastlogin));
+ ++cuser->numlogins, cuser->lasthost, Cdate(&(cuser->lastlogin)));
pressanykey();
}
@@ -845,8 +836,8 @@ inline static void birthday_make_a_wish(struct tm *ptime, struct tm *tmp){
}
inline static void record_lasthost(char *fromhost, int len){
- strncpy(cuser.lasthost, fromhost, len);
- cuser.lasthost[len - 1] = '\0';
+ strncpy(cuser->lasthost, fromhost, len);
+ cuser->lasthost[len - 1] = '\0';
}
inline static void check_mailbox_quota(void){
@@ -873,25 +864,24 @@ static void init_guest_info(void)
"愛之味", "天上", "藍色珊瑚礁"
};
i = login_start_time % 13;
- snprintf(cuser.username, sizeof(cuser.username),
+ snprintf(cuser->username, sizeof(cuser->username),
"海邊漂來的%s", nick[(int)i]);
- strlcpy(currutmp->username, cuser.username,
+ strlcpy(currutmp->username, cuser->username,
sizeof(currutmp->username));
- strlcpy(cuser.realname, name[(int)i], sizeof(cuser.realname));
- //strlcpy(currutmp->realname, cuser.realname, sizeof(currutmp->realname));
- strlcpy(cuser.address, addr[(int)i], sizeof(cuser.address));
- cuser.sex = i % 8;
+ strlcpy(cuser->realname, name[(int)i], sizeof(cuser->realname));
+ strlcpy(cuser->address, addr[(int)i], sizeof(cuser->address));
+ cuser->sex = i % 8;
currutmp->pager = 2;
}
#ifdef FOREIGN_REG
inline static void foreign_warning(void){
- if ((cuser.uflag2 & FOREIGN) && !(cuser.uflag2 & LIVERIGHT)){
- if (login_start_time - cuser.firstlogin > (FOREIGN_REG_DAY - 5) * 24 * 3600){
- mail_muser(cuser, "[出入境管理局]", "etc/foreign_expired_warn");
+ if ((cuser->uflag2 & FOREIGN) && !(cuser->uflag2 & LIVERIGHT)){
+ if (login_start_time - cuser->firstlogin > (FOREIGN_REG_DAY - 5) * 24 * 3600){
+ mail_muser(*cuser, "[出入境管理局]", "etc/foreign_expired_warn");
}
- else if (login_start_time - cuser.firstlogin > FOREIGN_REG_DAY * 24 * 3600){
- cuser.userlevel &= ~(PERM_LOGINOK | PERM_POST);
+ else if (login_start_time - cuser->firstlogin > FOREIGN_REG_DAY * 24 * 3600){
+ cuser->userlevel &= ~(PERM_LOGINOK | PERM_POST);
vmsg("警告:請至出入境管理局申請永久居留");
}
}
@@ -915,8 +905,8 @@ user_login()
mysrand();
/* show welcome_login */
- ifbirth = (ptime->tm_mday == cuser.day &&
- ptime->tm_mon + 1 == cuser.month);
+ ifbirth = (ptime->tm_mday == cuser->day &&
+ ptime->tm_mon + 1 == cuser->month);
if (ifbirth)
more("etc/Welcome_birth", NA);
else {
@@ -933,7 +923,7 @@ user_login()
}
log_usies("ENTER", fromhost);
- setproctitle("%s: %s", margs, cuser.userid);
+ setproctitle("%s: %s", margs, cuser->userid);
resolve_fcache();
resolve_boards();
memset(&water[0], 0, sizeof(water_t) * 6);
@@ -951,10 +941,10 @@ user_login()
/* 初始化 uinfo、flag、mode */
setup_utmp(LOGIN);
currmode = MODE_STARTED;
- enter_uflag = cuser.uflag;
+ enter_uflag = cuser->uflag;
currutmp->birth = ifbirth;
- tmp = localtime(&cuser.lastlogin);
+ tmp = localtime(&(cuser->lastlogin));
if ((a = SHM->UTMPnumber) > SHM->max_user) {
SHM->max_user = a;
SHM->max_time = now;
@@ -971,7 +961,7 @@ user_login()
else
SHM->loginmsg.pid=0;
}
- if (cuser.userlevel) { /* not guest */
+ if (cuser->userlevel) { /* not guest */
move(t_lines - 4, 0);
welcome_msg();
@@ -981,7 +971,7 @@ user_login()
check_register();
record_lasthost(fromhost, 16);
restore_backup();
- } else if (!strcmp(cuser.userid, STR_GUEST)) {
+ } else if (!strcmp(cuser->userid, STR_GUEST)) {
init_guest_info();
pressanykey();
} else {
@@ -990,15 +980,20 @@ user_login()
}
if (!PERM_HIDE(currutmp))
- cuser.lastlogin = login_start_time;
+ cuser->lastlogin = login_start_time;
#ifdef FOREIGN_REG
foreign_warning();
#endif
- passwd_update(usernum, &cuser);
+ passwd_update(usernum, cuser);
+
+ fav_load();
+ /* subscribe new fav (deprecated) */
+ if (get_fav_root() != NULL)
+ updatenewfav(1);
for (i = 0; i < NUMVIEWFILE; i++)
- if ((cuser.loginview >> i) & 1)
+ if ((cuser->loginview >> i) & 1)
more(loginview_file[(int)i][0], YEA);
}
@@ -1082,7 +1077,7 @@ start_client()
b_closepolls();
SHM->close_vote_time = now;
}
- if (!(cuser.uflag & COLOR_FLAG))
+ if (!(cuser->uflag & COLOR_FLAG))
showansi = 0;
signal(SIGALRM, SIG_IGN);
diff --git a/mbbsd/menu.c b/mbbsd/menu.c
index 870b9572..1b8a5e5b 100644
--- a/mbbsd/menu.c
+++ b/mbbsd/menu.c
@@ -24,7 +24,6 @@ egetch()
}
}
-extern userec_t cuser;
extern char *fn_board;
extern char board_hidden_status;
@@ -113,14 +112,14 @@ show_status(void)
ptime->tm_mon + 1, ptime->tm_mday, myweek[i], myweek[i + 1],
ptime->tm_hour, ptime->tm_min, currutmp->birth ?
"生日要請客唷" : SHM->today_is,
- SHM->UTMPnumber, cuser.userid, msgs[currutmp->pager]);
+ SHM->UTMPnumber, cuser->userid, msgs[currutmp->pager]);
outmsg(mystatus);
}
static int
u_movie()
{
- cuser.uflag ^= MOVIE_FLAG;
+ cuser->uflag ^= MOVIE_FLAG;
return 0;
}
@@ -130,7 +129,7 @@ movie(int i)
static short history[MAX_HISTORY];
int j;
- if ((currstat != CLASS) && (cuser.uflag & MOVIE_FLAG) &&
+ if ((currstat != CLASS) && (cuser->uflag & MOVIE_FLAG) &&
!SHM->Pbusystate && SHM->max_film > 0) {
if (currstat == PSALE) {
i = PSALE;
@@ -177,7 +176,7 @@ show_menu(commands_t * p)
move(menu_row, 0);
while ((s = p[n].desc)) {
if (HAS_PERM(p[n].level)) {
- snprintf(buf, sizeof(buf), s + 2, state[cuser.proverb % 4]);
+ snprintf(buf, sizeof(buf), s + 2, state[cuser->proverb % 4]);
prints("%*s (\033[1;36m%c\033[0m)%s\n", menu_column, "", s[1],
buf);
}
diff --git a/mbbsd/more.c b/mbbsd/more.c
index 0bdb361c..ace229ee 100644
--- a/mbbsd/more.c
+++ b/mbbsd/more.c
@@ -54,10 +54,10 @@ more_readln(int fd, unsigned char *buf)
int ch;
unsigned char *data, *tail, *cc;
- int len, bytes, in_ansi;
+ int len, bytes, in_ansi, in_big5;
int size, head, ansilen;
- len = bytes = in_ansi = ansilen = 0;
+ len = bytes = in_ansi = in_big5 = ansilen = 0;
tail = buf + ANSILINELEN - 1;
size = more_size;
head = more_head;
@@ -102,12 +102,27 @@ more_readln(int fd, unsigned char *buf)
*buf++ = ch;
if (!strchr(STR_ANSICODE, ch))
in_ansi = 0;
+ } else if (in_big5) {
+ ++len;
+ *buf++ = ch;
+ in_big5 = 0;
} else if (isprint2(ch)) {
len++;
*buf++ = ch;
+ if (ch >= 0xa1 && ch <= 0xf9) /* first byte of big5 encoding */
+ in_big5 = 1;
}
} while (len < t_columns && buf < tail);
- if(len==t_columns && head<size && *data=='\n') {
+
+ if (in_big5) {
+ strcpy(buf - 1, "\033[1;34m>\033[m");
+ buf += 10;
+ --head;
+ --data;
+ --bytes;
+ }
+
+ if (len == t_columns && head < size && *data == '\n') {
/* XXX: not handle head==size, should read data */
/* no extra newline dirty hack for exact 80byte line */
data++; bytes++; head++;
diff --git a/mbbsd/othello.c b/mbbsd/othello.c
index 96fea2e2..b4625a58 100644
--- a/mbbsd/othello.c
+++ b/mbbsd/othello.c
@@ -95,7 +95,7 @@ printboard()
print_chess(4, 5, BLACK);
print_chess(5, 4, BLACK);
move(3, 56);
- prints("(黑)%s", cuser.userid);
+ prints("(黑)%s", cuser->userid);
move(3, 72);
prints(": 02");
move(4, 56);
@@ -229,7 +229,7 @@ end_of_game(int quit)
fp1 = fopen(SECRET, "a");
if (fp1) {
fprintf(fp1, "%d,%d,%s,%02d,%02d\n", think, which_table,
- cuser.userid, number[0], number[1]);
+ cuser->userid, number[0], number[1]);
fclose(fp1);
}
}
@@ -239,7 +239,7 @@ end_of_game(int quit)
fclose(fp);
return;
}
- fprintf(fp, "在%s級中, %s臨陣脫逃\n", opponent[think], cuser.userid);
+ fprintf(fp, "在%s級中, %s臨陣脫逃\n", opponent[think], cuser->userid);
if (fp)
fclose(fp);
return;
@@ -252,7 +252,7 @@ end_of_game(int quit)
demoney(200);
if (fp)
fprintf(fp, "在%s級中, %s以 %02d:%02d 贏了電腦%02d子\n",
- opponent[think], cuser.userid, number[0], number[1],
+ opponent[think], cuser->userid, number[0], number[1],
number[0] - number[1]);
} else if (number[1] > number[0]) {
prints("電腦贏了你%02d子", number[1] - number[0]);
@@ -260,16 +260,16 @@ end_of_game(int quit)
fprintf(fp, "在%s級中, ", opponent[think]);
if (number[1] - number[0] > 20)
fprintf(fp, "電腦以 %02d:%02d 慘電%s %02d子\n", number[1],
- number[0], cuser.userid, number[1] - number[0]);
+ number[0], cuser->userid, number[1] - number[0]);
else
fprintf(fp, "電腦以 %02d:%02d 贏了%s %02d子\n", number[1],
- number[0], cuser.userid, number[1] - number[0]);
+ number[0], cuser->userid, number[1] - number[0]);
}
} else {
prints("你和電腦打成平手!!");
if (fp)
fprintf(fp, "在%s級中, %s和電腦以 %02d:%02d 打成了平手\n",
- opponent[think], cuser.userid, number[1], number[0]);
+ opponent[think], cuser->userid, number[1], number[0]);
}
if (fp)
fclose(fp);
@@ -394,7 +394,7 @@ report()
else if (nowboard[i][j] == WHITE)
number[1]++;
move(3, 60);
- prints("%s", cuser.userid);
+ prints("%s", cuser->userid);
move(3, 72);
prints(": %02d", number[0]);
move(4, 60);
diff --git a/mbbsd/page.c b/mbbsd/page.c
index 1757412f..78e9ce0f 100644
--- a/mbbsd/page.c
+++ b/mbbsd/page.c
@@ -136,7 +136,7 @@ main_railway()
break;
line++;
- sethomepath(genbuf, cuser.userid);
+ sethomepath(genbuf, cuser->userid);
stampfile(genbuf, &mhdr);
strlcpy(mhdr.owner, "Ptt搜尋器", sizeof(mhdr.owner));
strncpy(mhdr.title, "火車時刻搜尋結果", TTLEN);
@@ -148,7 +148,7 @@ main_railway()
(type[0] == '1') ? "fast" : "slow", date, genbuf);
system(command);
- sethomedir(genbuf, cuser.userid);
+ sethomedir(genbuf, cuser->userid);
if (append_record(genbuf, &mhdr, sizeof(mhdr)) == -1)
return -1;
hpressanykey("\033[1;31m我們會把搜尋結果很快地寄給你唷 ^_^\033[m");
diff --git a/mbbsd/passwd.c b/mbbsd/passwd.c
index 7686e566..0f46f65f 100644
--- a/mbbsd/passwd.c
+++ b/mbbsd/passwd.c
@@ -49,26 +49,41 @@ passwd_init()
}
int
-passwd_update_money(int num)
+passwd_update_money(int num) /* update money only */
{
- userec_t user;
- if (num < 1 || num > MAX_USERS)
+ userec_t user;
+ int pwdfd, money = moneyof(num);
+ char path[256];
+
+ if (num < 1 || num > MAX_USERS)
return -1;
- passwd_query(num, &user);
- if (SHM->loaded)
- user.money = moneyof(num);
- passwd_update(num, &user);
- return 0;
+
+ sethomefile(path, getuserid(num), ".passwd");
+
+ if ((pwdfd = open(path, O_WRONLY)) < 0)
+ {
+ if(passwd_index_query(num, &user)<0) // tempory code, will be removed
+ exit(1);
+ user.money=money;
+ passwd_update(num, &user);
+ return 0;
+ }
+
+ if(lseek(pwdfd, (off_t)((int)&user.money - (int)&user), SEEK_SET) >= 0)
+ write(pwdfd, &money, sizeof(int));
+
+ close(pwdfd);
+ return 0;
}
int
-passwd_update(int num, userec_t * buf)
+passwd_index_update(int num, userec_t * buf)
{
- int pwdfd;
+ int pwdfd;
if (num < 1 || num > MAX_USERS)
return -1;
buf->money = moneyof(num);
- if ((pwdfd = open(fn_passwd, O_RDWR)) < 0)
+ if ((pwdfd = open(fn_passwd, O_WRONLY)) < 0)
exit(1);
lseek(pwdfd, sizeof(userec_t) * (num - 1), SEEK_SET);
write(pwdfd, buf, sizeof(userec_t));
@@ -77,7 +92,24 @@ passwd_update(int num, userec_t * buf)
}
int
-passwd_query(int num, userec_t * buf)
+passwd_update(int num, userec_t * buf)
+{
+ int pwdfd;
+ char path[256];
+
+ if(!buf->userid[0]) return -1;
+
+ sethomefile(path, buf->userid, ".passwd");
+ buf->money = moneyof(num);
+ if ((pwdfd = open(path, O_WRONLY|O_CREAT, 0600)) < 0)
+ return -1;
+ write(pwdfd, buf, sizeof(userec_t));
+ close(pwdfd);
+ return 0;
+}
+
+int
+passwd_index_query(int num, userec_t * buf)
{
int pwdfd;
if (num < 1 || num > MAX_USERS)
@@ -90,27 +122,51 @@ passwd_query(int num, userec_t * buf)
return 0;
}
+userec_t userecbuf;
+int initcuser(char *userid)
+{
+ // Ptt: setup cuser and usernum here
+ cuser = &userecbuf;
+ if(userid[0]=='\0' ||
+ !(usernum = searchuser(userid)) || usernum > MAX_USERS)
+ return -1;
+ passwd_query(usernum, &userecbuf);
+ return usernum;
+}
+
int
-passwd_apply(int (*fptr) (userec_t *))
+passwd_query(int num, userec_t * buf)
{
- int i;
- userec_t user;
- for (i = 0; i < MAX_USERS; i++) {
- passwd_query(i + 1, &user);
- if ((*fptr) (&user) == QUIT)
- return QUIT;
- }
- return 0;
+ int pwdfd;
+ char path[256], *userid;
+
+ if (num < 1 || num > MAX_USERS)
+ return -1;
+ userid = getuserid(num);
+
+ if(userid[0]=='\0') return -1;
+
+ sethomefile(path, userid, ".passwd");
+ if((pwdfd = open(path, O_RDONLY)) < 0)
+ { // copy from index // tempory code, will be removed
+ if(passwd_index_query(num, buf)<0)
+ exit(1);
+ passwd_update(num, buf);
+ return 0;
+ }
+ read(pwdfd, buf, sizeof(userec_t));
+ close(pwdfd);
+ return 0;
}
int
-passwd_apply2(int (*fptr)(int, userec_t *))
+passwd_apply(int (*fptr) (int, userec_t *))
{
- int i;
+ int i;
userec_t user;
- for(i = 0; i < MAX_USERS; i++){
+ for (i = 0; i < MAX_USERS; i++) {
passwd_query(i + 1, &user);
- if((*fptr)(i, &user) == QUIT)
+ if ((*fptr) (i, &user) == QUIT)
return QUIT;
}
return 0;
diff --git a/mbbsd/read.c b/mbbsd/read.c
index 8074c71b..f6b64313 100644
--- a/mbbsd/read.c
+++ b/mbbsd/read.c
@@ -170,7 +170,7 @@ TagPruner(int bid)
}
if (TagNum && ((currstat != READING) || (currmode & MODE_BOARD))) {
if (tolower(getans("刪除所有標記[N]?")) != 'y')
- return FULLUPDATE;
+ return READ_REDRAW;
delete_range(currdirect, 0, 0);
TagNum = 0;
if (bid)
@@ -498,9 +498,9 @@ select_read(keeploc_t * locmem, int sr_mode)
}
if ((fd = open(currdirect, O_RDONLY, 0)) != -1) {
- snprintf(genbuf, sizeof(genbuf), "SR.%s", cuser.userid);
+ snprintf(genbuf, sizeof(genbuf), "SR.%s", cuser->userid);
if (currstat == RMAIL)
- sethomefile(fpath, cuser.userid, genbuf);
+ sethomefile(fpath, cuser->userid, genbuf);
else
setbfile(fpath, currboard, genbuf);
if (((fr = open(fpath, O_WRONLY | O_CREAT | O_TRUNC, 0600)) != -1)) {
@@ -613,12 +613,6 @@ i_read_key(onekey_t * rcmdlist, keeploc_t * locmem, int ch, int bid)
case Ctrl('L'):
redoscr();
break;
- case KEY_ESC:
- if (KEY_ESC_arg == 'i') {
- t_idle();
- return FULLUPDATE;
- }
- break;
case Ctrl('H'):
if (select_read(locmem, RS_NEWPOST))
return NEWDIRECT;
@@ -723,7 +717,7 @@ i_read_key(onekey_t * rcmdlist, keeploc_t * locmem, int ch, int bid)
mail_forward(&headers[locmem->crs_ln - locmem->top_ln],
currdirect, ch /* == 'U' */ );
/* by CharlieL */
- return FULLUPDATE;
+ return READ_REDRAW;
}
break;
case Ctrl('Q'):
@@ -923,6 +917,9 @@ i_read(int cmdmode, char *direct, void (*dotitle) (), void (*doentry) (), onekey
"\033[44m 私人收藏 \033[30;47m 繼續? \033[m" :
curredit & EDIT_MAIL ? msg_mailer : MSG_POSTER);
break;
+ case TITLE_REDRAW:
+ (*dotitle) ();
+ break;
case READ_PREV:
case READ_NEXT:
case RELATE_PREV:
diff --git a/mbbsd/record.c b/mbbsd/record.c
index dd543f77..e6d88fda 100644
--- a/mbbsd/record.c
+++ b/mbbsd/record.c
@@ -416,66 +416,6 @@ safe_article_delete_range(char *direct, int from, int to)
return 0;
}
-int
-delete_file(char *dirname, int size, int ent, int (*filecheck) ())
-{
- char abuf[BUFSIZE];
- int fd;
- struct stat st;
- long numents;
-
- if (ent < 1 || (fd = open(dirname, O_RDWR)) == -1)
- return -1;
- flock(fd, LOCK_EX);
- fstat(fd, &st);
- numents = ((long)st.st_size) / size;
- if (((long)st.st_size) % size)
- fprintf(stderr, "align err\n");
- if (lseek(fd, (off_t) size * (ent - 1), SEEK_SET) != -1) {
- if (read(fd, abuf, size) == size) {
- if ((*filecheck) (abuf)) {
- int i;
-
- for (i = ent; i < numents; i++) {
- if (lseek(fd, (off_t) ((i) * size), SEEK_SET) == -1 ||
- read(fd, abuf, size) != size ||
- lseek(fd, (off_t) (i - 1) * size, SEEK_SET) == -1)
- break;
- if (safewrite(fd, abuf, size) != size)
- break;
- }
- ftruncate(fd, (off_t) size * (numents - 1));
- flock(fd, LOCK_UN);
- close(fd);
- return 0;
- }
- }
- }
- lseek(fd, 0, SEEK_SET);
- ent = 1;
- while (read(fd, abuf, size) == size) {
- if ((*filecheck) (abuf)) {
- int i;
-
- for (i = ent; i < numents; i++) {
- if (lseek(fd, (off_t) (i + 1) * size, SEEK_SET) == -1 ||
- read(fd, abuf, size) != size ||
- lseek(fd, (off_t) (i) * size, SEEK_SET) == -1 ||
- safewrite(fd, abuf, size) != size)
- break;
- }
- ftruncate(fd, (off_t) size * (numents - 1));
- flock(fd, LOCK_UN);
- close(fd);
- return 0;
- }
- ent++;
- }
- flock(fd, LOCK_UN);
- close(fd);
- return -1;
-}
-
#endif
#endif /* !defined(_BBS_UTIL_C_) */
@@ -503,19 +443,19 @@ stampfile(char *fpath, fileheader_t * fh)
register char *ip = fpath;
time_t dtime = COMMON_TIME;
struct tm *ptime;
- int fp = 0;
+// int fp = 0; //Ptt: don't need to check
if (access(fpath, X_OK | R_OK | W_OK))
mkdir(fpath, 0755);
while (*(++ip));
*ip++ = '/';
- do {
+// do {
sprintf(ip, "M.%d.A.%3.3X", (int)++dtime, rand() & 0xFFF);
- if (fp == -1 && errno != EEXIST)
- return -1;
- } while ((fp = open(fpath, O_CREAT | O_EXCL | O_WRONLY, 0644)) == -1);
- close(fp);
+// if (fp == -1 && errno != EEXIST)
+// return -1;
+// } while ((fp = open(fpath, O_CREAT | O_EXCL | O_WRONLY, 0644)) == -1);
+// close(fp);
memset(fh, 0, sizeof(fileheader_t));
strlcpy(fh->filename, ip, sizeof(fh->filename));
ptime = localtime(&dtime);
diff --git a/mbbsd/register.c b/mbbsd/register.c
index 58694c3d..04da1f05 100644
--- a/mbbsd/register.c
+++ b/mbbsd/register.c
@@ -1,5 +1,6 @@
/* $Id$ */
#define _XOPEN_SOURCE
+#define _ISOC99_SOURCE
#include "bbs.h"
@@ -107,7 +108,6 @@ compute_user_value(userec_t * urec, time_t clock)
int
check_and_expire_account(int uid, userec_t * urec)
{
- userec_t zerorec;
char genbuf[200], genbuf2[200];
int val;
if ((val = compute_user_value(urec, now)) < 0) {
@@ -115,7 +115,6 @@ check_and_expire_account(int uid, userec_t * urec)
uid, urec->userid, ctime(&(urec->lastlogin)) + 4,
urec->numlogins, urec->numposts, val);
if (val > -1 * 60 * 24 * 365) {
- memset(&zerorec, 0, sizeof(zerorec));
log_usies("CLEAN", genbuf);
snprintf(genbuf, sizeof(genbuf), "home/%c/%s", urec->userid[0],
urec->userid);
@@ -126,9 +125,7 @@ check_and_expire_account(int uid, userec_t * urec)
urec->userid[0], urec->userid);
system(genbuf);
}
- passwd_update(uid, &zerorec);
- remove_from_uhash(uid - 1);
- add_to_uhash(uid - 1, "");
+ kill_user(uid);
} else {
val = 0;
log_usies("DATED", genbuf);
@@ -143,12 +140,11 @@ getnewuserid()
{
char genbuf[50];
char *fn_fresh = ".fresh";
- userec_t utmp, zerorec;
+ userec_t utmp;
time_t clock;
struct stat st;
int fd, i;
- memset(&zerorec, 0, sizeof(zerorec));
clock = now;
/* Lazy method : 先找尋已經清除的過期帳號 */
@@ -185,10 +181,7 @@ getnewuserid()
snprintf(genbuf, sizeof(genbuf), "uid %d", i);
log_usies("APPLY", genbuf);
- strlcpy(zerorec.userid, str_new, sizeof(zerorec.userid));
- zerorec.lastlogin = clock;
- passwd_update(i, &zerorec);
- setuserid(i, zerorec.userid);
+ kill_user(i);
passwd_unlock();
return i;
}
@@ -281,12 +274,12 @@ new_register()
fprintf(stderr, "本站人口已達飽和!\n");
exit(1);
}
- if (passwd_update(allocid, &newuser) == -1) {
+ if (passwd_index_update(allocid, &newuser) == -1) {
fprintf(stderr, "客滿了,再見!\n");
exit(1);
}
setuserid(allocid, newuser.userid);
- if( (uid = dosearchuser(newuser.userid)) )
+ if( (uid = initcuser(newuser.userid)) )
setumoney(uid, 0);
else{
fprintf(stderr, "無法建立帳號\n");
@@ -312,33 +305,33 @@ check_register()
stand_title("請詳細填寫個人資料");
- while (strlen(cuser.username) < 2)
- getdata(2, 0, "綽號暱稱:", cuser.username,
- sizeof(cuser.username), DOECHO);
+ while (strlen(cuser->username) < 2)
+ getdata(2, 0, "綽號暱稱:", cuser->username,
+ sizeof(cuser->username), DOECHO);
- for (ptr = cuser.username; *ptr; ptr++) {
+ for (ptr = cuser->username; *ptr; ptr++) {
if (*ptr == 9) /* TAB convert */
*ptr = ' ';
}
- while (strlen(cuser.realname) < 4)
- getdata(4, 0, "真實姓名:", cuser.realname,
- sizeof(cuser.realname), DOECHO);
+ while (strlen(cuser->realname) < 4)
+ getdata(4, 0, "真實姓名:", cuser->realname,
+ sizeof(cuser->realname), DOECHO);
- while (strlen(cuser.address) < 8)
- getdata(6, 0, "聯絡地址:", cuser.address,
- sizeof(cuser.address), DOECHO);
+ while (strlen(cuser->address) < 8)
+ getdata(6, 0, "聯絡地址:", cuser->address,
+ sizeof(cuser->address), DOECHO);
/*
- * if(!strchr(cuser.email, '@')) { bell(); move(t_lines - 4, 0); prints("
+ * if(!strchr(cuser->email, '@')) { bell(); move(t_lines - 4, 0); prints("
* 您的權益,請填寫真實的 E-mail address," "以資確認閣下身份,\n" "
* 033[44muser@domain_name\033[0m 或 \033[44muser"
* "@\\[ip_number\\]\033[0m。\n\n" "※ 如果您真的沒有 E-mail, turn]
* 即可。");
*
- * do { getdata(8, 0, "電子信箱:", cuser.email, sizeof(cuser.email),
- * DOECHO); if(!cuser.email[0]) sprintf(cuser.email, "%s%s",
- * cuser.userid, str_mail_address); } while(!strchr(cuser.email, '@'));
+ * do { getdata(8, 0, "電子信箱:", cuser->email, sizeof(cuser->email),
+ * DOECHO); if(!cuser->email[0]) sprintf(cuser->email, "%s%s",
+ * cuser->userid, str_mail_address); } while(!strchr(cuser->email, '@'));
*
* } */
if (!HAS_PERM(PERM_SYSOP)) {
@@ -350,8 +343,8 @@ check_register()
u_register();
#ifdef NEWUSER_LIMIT
- if (cuser.lastlogin - cuser.firstlogin < 3 * 86400)
- cuser.userlevel &= ~PERM_POST;
+ if (cuser->lastlogin - cuser->firstlogin < 3 * 86400)
+ cuser->userlevel &= ~PERM_POST;
more("etc/newuser", YEA);
#endif
}
diff --git a/mbbsd/screen.c b/mbbsd/screen.c
index 825fb3b7..43df3757 100644
--- a/mbbsd/screen.c
+++ b/mbbsd/screen.c
@@ -429,7 +429,7 @@ outmsg(char *msg)
{
move(b_lines, 0);
clrtoeol();
- outs(msg);
+ prints(msg);
}
void
diff --git a/mbbsd/stuff.c b/mbbsd/stuff.c
index 6e3e5e00..767fdca1 100644
--- a/mbbsd/stuff.c
+++ b/mbbsd/stuff.c
@@ -35,6 +35,7 @@ sethomeman(char *buf, char *userid)
sprintf(buf, str_home_file, userid[0], userid, "man");
}
+
void
sethomefile(char *buf, char *userid, char *fname)
{
@@ -44,7 +45,7 @@ sethomefile(char *buf, char *userid, char *fname)
void
setuserfile(char *buf, char *fname)
{
- sprintf(buf, str_home_file, cuser.userid[0], cuser.userid, fname);
+ sprintf(buf, str_home_file, cuser->userid[0], cuser->userid, fname);
}
void
@@ -242,8 +243,8 @@ is_uBM(char *list, char *id)
int
is_BM(char *list)
{
- if (is_uBM(list, cuser.userid)) {
- cuser.userlevel |= PERM_BM; /* Ptt 自動加上BM的權利 */
+ if (is_uBM(list, cuser->userid)) {
+ cuser->userlevel |= PERM_BM; /* Ptt 自動加上BM的權利 */
return 1;
}
return 0;
diff --git a/mbbsd/syspost.c b/mbbsd/syspost.c
index 8fdc361c..1e4e25af 100644
--- a/mbbsd/syspost.c
+++ b/mbbsd/syspost.c
@@ -1,4 +1,4 @@
-/* $Id: syspost.c,v 1.18 2003/01/19 16:06:06 kcwu Exp $ */
+/* $Id$ */
#include "bbs.h"
int
@@ -86,12 +86,12 @@ post_change_perm(int oldperm, int newperm, char *sysopid, char *userid)
while (!getdata_str(5, 0, "請輸入理由以示負責:",
reason, sizeof(reason), DOECHO, "看板板主:"));
fprintf(fp, "\n \033[1;37m站長%s修改權限理由是:%s\033[m",
- cuser.userid, reason);
+ cuser->userid, reason);
fclose(fp);
snprintf(fhdr.title, sizeof(fhdr.title),
"[公安報告] 站長%s修改%s權限報告",
- cuser.userid, userid);
+ cuser->userid, userid);
strlcpy(fhdr.owner, "[系統安全局]", sizeof(fhdr.owner));
append_record("boards/S/Security/.DIR", &fhdr, sizeof(fhdr));
} else
@@ -148,7 +148,7 @@ post_newboard(char *bgroup, char *bname, char *bms)
snprintf(title, sizeof(title), "[新板成立] %s", bname);
snprintf(genbuf, sizeof(genbuf),
"%s 開了一個新板 %s : %s\n\n新任板主為 %s\n\n恭喜*^_^*\n",
- cuser.userid, bname, bgroup, bms);
+ cuser->userid, bname, bgroup, bms);
post_msg("Record", title, genbuf, "[系統]");
}
@@ -166,15 +166,15 @@ give_money_post(char *userid, int money)
return;
fprintf(fp, "作者: [系統安全局] 看板: Security\n"
"標題: [公安報告] 站長%s使用紅包機報告\n"
- "時間: %s\n", cuser.userid, ctime(&now));
+ "時間: %s\n", cuser->userid, ctime(&now));
clrtobot();
clear();
fprintf(fp, "\n 站長\033[1;32m%s\033[m給\033[1;33m%s %d 元\033[m",
- cuser.userid, userid, money);
+ cuser->userid, userid, money);
fclose(fp);
snprintf(fhdr.title, sizeof(fhdr.title), "[公安報告] 站長%s使用紅包機報告",
- cuser.userid);
+ cuser->userid);
strlcpy(fhdr.owner, "[系統安全局]", sizeof(fhdr.owner));
append_record("boards/S/Security/.DIR", &fhdr, sizeof(fhdr));
}
diff --git a/mbbsd/talk.c b/mbbsd/talk.c
index 7822e665..8052ae5a 100644
--- a/mbbsd/talk.c
+++ b/mbbsd/talk.c
@@ -363,7 +363,7 @@ my_query(char *uident)
muser.username,
26 - strlen(muser.userid) - strlen(muser.username), "",
money[i]);
- if (uentp && ((fri_stat & HFM && !uentp->invisible) || strcmp(muser.userid,cuser.userid) == 0))
+ if (uentp && ((fri_stat & HFM && !uentp->invisible) || strcmp(muser.userid,cuser->userid) == 0))
prints(" ($%d)", muser.money);
prints("\n");
@@ -393,7 +393,7 @@ my_query(char *uident)
prints("《競標評比》 優 %d / 劣 %d", muser.goodsale, muser.badsale);
move(6, 40);
#endif
- if ((uentp && ((fri_stat & HFM) || strcmp(muser.userid,cuser.userid) == 0) && !uentp->invisible))
+ if ((uentp && ((fri_stat & HFM) || strcmp(muser.userid,cuser->userid) == 0) && !uentp->invisible))
prints("《 性 別 》%-28.28s\n", sex[muser.sex % 8]);
showplans(uident);
@@ -640,7 +640,7 @@ my_write(pid_t pid, char *prompt, char *id, int flag, userinfo_t * puin)
if (flag != 2) { /* aloha 的水球不用存下來 */
/* 存到自己的水球檔 */
if (!fp_writelog) {
- sethomefile(genbuf, cuser.userid, fn_writelog);
+ sethomefile(genbuf, cuser->userid, fn_writelog);
fp_writelog = fopen(genbuf, "a");
}
if (fp_writelog) {
@@ -670,7 +670,7 @@ my_write(pid_t pid, char *prompt, char *id, int flag, userinfo_t * puin)
uin->msgcount = write_pos + 1;
uin->pager = 2;
uin->msgs[write_pos].pid = currpid;
- strlcpy(uin->msgs[write_pos].userid, cuser.userid,
+ strlcpy(uin->msgs[write_pos].userid, cuser->userid,
sizeof(uin->msgs[write_pos].userid));
strlcpy(uin->msgs[write_pos].last_call_in, msg,
sizeof(uin->msgs[write_pos].last_call_in));
@@ -820,13 +820,13 @@ t_display(void)
fileheader_t mymail;
char title[128], buf[80];
- sethomepath(buf, cuser.userid);
+ sethomepath(buf, cuser->userid);
stampfile(buf, &mymail);
mymail.filemode = FILE_READ ;
strlcpy(mymail.owner, "[備.忘.錄]", sizeof(mymail.owner));
strlcpy(mymail.title, "熱線記錄", sizeof(mymail.title));
- sethomedir(title, cuser.userid);
+ sethomedir(title, cuser->userid);
Rename(genbuf, buf);
append_record(title, &mymail, sizeof(mymail));
} else if (*ans == 'c')
@@ -976,7 +976,7 @@ do_talk_char(talkwin_t * twin, int ch, FILE *flog)
fprintf(flog, "%s%s: %s%s\n",
(twin->eline == b_lines - 1) ? "\033[1;35m" : "",
(twin->eline == b_lines - 1) ?
- getuserid(currutmp->destuid) : cuser.userid, buf,
+ getuserid(currutmp->destuid) : cuser->userid, buf,
(ch == Ctrl('P')) ? "\033[37;45m(Up)\033[m" : "\033[m");
}
@@ -993,9 +993,8 @@ do_talk(int fd)
ptime = localtime(&now);
- sethomepath(fpath, cuser.userid);
- strlcpy(fpath, tempnam(fpath, "talk_"), sizeof(fpath));
- flog = fopen(fpath, "w");
+ setuserfile(fpath, "talk_XXXXXX");
+ flog = fdopen(mkstemp(fpath), "w");
setuserfile(genbuf, fn_talklog);
@@ -1006,7 +1005,7 @@ do_talk(int fd)
setutmpmode(TALK);
ch = 58 - strlen(save_page_requestor);
- snprintf(genbuf, sizeof(genbuf), "%s【%s", cuser.userid, cuser.username);
+ snprintf(genbuf, sizeof(genbuf), "%s【%s", cuser->userid, cuser->username);
i = ch - strlen(genbuf);
if (i >= 0)
i = (i >> 1) + 1;
@@ -1103,14 +1102,14 @@ do_talk(int fd)
fileheader_t mymail;
char title[128];
- sethomepath(genbuf, cuser.userid);
+ sethomepath(genbuf, cuser->userid);
stampfile(genbuf, &mymail);
mymail.filemode = FILE_READ ;
strlcpy(mymail.owner, "[備.忘.錄]", sizeof(mymail.owner));
snprintf(mymail.title, sizeof(mymail.title),
"對話記錄 \033[1;36m(%s)\033[m",
getuserid(currutmp->destuid));
- sethomedir(title, cuser.userid);
+ sethomedir(title, cuser->userid);
Rename(fpath, genbuf);
append_record(title, &mymail, sizeof(mymail));
} else
@@ -1287,7 +1286,7 @@ my_talk(userinfo_t * uin, int fri_stat, char defact)
getuser(uin->userid);
if (uin->lockmode == CHICKEN || currutmp->lockmode == CHICKEN)
error = 1;
- if (!cuser.mychicken.name[0] || !xuser.mychicken.name[0])
+ if (!cuser->mychicken.name[0] || !xuser.mychicken.name[0])
error = 2;
if (error) {
outmsg(error == 2 ? "並非兩人都養寵物" :
@@ -1576,7 +1575,7 @@ int
pickup_maxpages(int pickupway, int nfriends)
{
int number;
- if (cuser.uflag & FRIEND_FLAG)
+ if (cuser->uflag & FRIEND_FLAG)
number = nfriends;
else
number = SHM->UTMPnumber +
@@ -1656,7 +1655,7 @@ pickup(pickup_t * currpickup, int pickup_way, int *page,
/* 產生好友區 */
which = *page * nPickups;
- if( (cuser.uflag & FRIEND_FLAG) || /* 只顯示好友模式 */
+ if( (cuser->uflag & FRIEND_FLAG) || /* 只顯示好友模式 */
((pickup_way == 0) && /* [嗨! 朋友] mode */
(
/* 含板友, 好友區最多只會有 (friendtotal + 板友) 個*/
@@ -1687,7 +1686,7 @@ pickup(pickup_t * currpickup, int pickup_way, int *page,
} else
*nfriend = 0;
- if (!(cuser.uflag & FRIEND_FLAG) && size < nPickups) {
+ if (!(cuser->uflag & FRIEND_FLAG) && size < nPickups) {
sorted_way = ((pickup_way == 0) ? 0 : (pickup_way - 1));
utmp = SHM->sorted[currsorted][sorted_way];
which = *page * nPickups - *nfriend;
@@ -1730,7 +1729,7 @@ draw_pickup(int drawall, pickup_t * pickup, int pickup_way,
#endif
if (drawall) {
- showtitle((cuser.uflag & FRIEND_FLAG) ? "好友列表" : "休閒聊天",
+ showtitle((cuser->uflag & FRIEND_FLAG) ? "好友列表" : "休閒聊天",
BBSName);
prints("\n"
"\033[7m %s P%c代號 %-17s%-17s%-13s%-10s\033[m\n",
@@ -1965,7 +1964,7 @@ userlist(void)
"代號 [%s]:", currutmp->userid);
if (!getdata(1, 0, buf, currutmp->userid,
sizeof(buf), DOECHO))
- strlcpy(currutmp->userid, cuser.userid, sizeof(currutmp->userid));
+ strlcpy(currutmp->userid, cuser->userid, sizeof(currutmp->userid));
redrawall = redraw = 1;
}
break;
@@ -2042,7 +2041,7 @@ userlist(void)
break;
case 's':
- if (!(cuser.uflag & FRIEND_FLAG)) {
+ if (!(cuser->uflag & FRIEND_FLAG)) {
int si; /* utmpshm->sorted[X][0][si] */
int fi; /* allpickuplist[fi] */
char swid[IDLEN + 1];
@@ -2149,7 +2148,7 @@ userlist(void)
#endif
case 'b': /* broadcast */
- if (cuser.uflag & FRIEND_FLAG || HAS_PERM(PERM_SYSOP)) {
+ if (cuser->uflag & FRIEND_FLAG || HAS_PERM(PERM_SYSOP)) {
char genbuf[60];
char ans[4];
@@ -2159,7 +2158,7 @@ userlist(void)
ans, sizeof(ans), LCECHO) &&
*ans == 'n')
break;
- if (!(cuser.uflag & FRIEND_FLAG) && HAS_PERM(PERM_SYSOP)) {
+ if (!(cuser->uflag & FRIEND_FLAG) && HAS_PERM(PERM_SYSOP)) {
getdata(1, 0, "再次確定站長廣播? [N]",
ans, sizeof(ans), LCECHO);
if( *ans != 'y' && *ans != 'Y' ){
@@ -2240,7 +2239,7 @@ userlist(void)
case 't':
if (HAS_PERM(PERM_LOGINOK)) {
if (uentp->pid != currpid &&
- strcmp(uentp->userid, cuser.userid) != 0) {
+ strcmp(uentp->userid, cuser->userid) != 0) {
move(1, 0);
clrtobot();
move(3, 0);
@@ -2288,14 +2287,14 @@ userlist(void)
case 'f':
if (HAS_PERM(PERM_LOGINOK)) {
- cuser.uflag ^= FRIEND_FLAG;
+ cuser->uflag ^= FRIEND_FLAG;
redrawall = redraw = 1;
}
break;
case 'g':
if (HAS_PERM(PERM_LOGINOK) &&
- strcmp(uentp->userid, cuser.userid) != 0) {
+ strcmp(uentp->userid, cuser->userid) != 0) {
char genbuf[128];
move(b_lines - 2, 0);
prints("要給 %s 多少錢呢? ", uentp->userid);
@@ -2313,18 +2312,18 @@ userlist(void)
}
reload_money();
- if (ch > cuser.money) {
+ if (ch > cuser->money) {
outs("\033[41m 現金不足~~\033[m");
} else {
deumoney(uentp->uid, ch - give_tax(ch));
prints("\033[44m 嗯..還剩下 %d 錢.."
"\033[m", demoney(-ch));
snprintf(genbuf, sizeof(genbuf),
- "%s\t給%s\t%d\t%s\n", cuser.userid,
+ "%s\t給%s\t%d\t%s\n", cuser->userid,
uentp->userid, ch,
ctime(&currutmp->lastact));
log_file(FN_MONEY, genbuf, 1);
- mail_redenvelop(cuser.userid, uentp->userid,
+ mail_redenvelop(cuser->userid, uentp->userid,
ch - give_tax(ch), 'Y');
}
} else {
@@ -2382,10 +2381,10 @@ userlist(void)
if (HAS_PERM(PERM_LOGINOK)) {
int tmp;
char *wm[3] = {"一般", "進階", "未來"};
- tmp = cuser.uflag2 & WATER_MASK;
- cuser.uflag2 -= tmp;
+ tmp = cuser->uflag2 & WATER_MASK;
+ cuser->uflag2 -= tmp;
tmp = (tmp + 1) % 3;
- cuser.uflag2 |= tmp;
+ cuser->uflag2 |= tmp;
move(4, 0);
prints("系統提供 一般 進階 未來 三種模式\n"
"在切換後請正常下線再重新登入, 以確保結構正確\n"
@@ -2406,8 +2405,8 @@ userlist(void)
case 'N':
oldgetdata(1, 0, "新的暱稱: ",
- cuser.username, sizeof(cuser.username), DOECHO);
- strcpy(currutmp->username, cuser.username);
+ cuser->username, sizeof(cuser->username), DOECHO);
+ strcpy(currutmp->username, cuser->username);
redrawall = redraw = 1;
break;
@@ -2427,7 +2426,7 @@ t_users(void)
int mode0 = currutmp->mode;
int stat0 = currstat;
- if( cuser.userid[0] != currutmp->userid[0] ){
+ if( cuser->userid[0] != currutmp->userid[0] ){
if( HAS_PERM(PERM_SYSOP) )
vmsg("warning: currutmp userid is changed");
else
@@ -2470,7 +2469,7 @@ t_idle(void)
currutmp->destuid = 0;
if (currutmp->destuid == 6)
- if (!cuser.userlevel ||
+ if (!cuser->userlevel ||
!getdata(b_lines - 1, 0, "發呆的理由:",
currutmp->chatid, sizeof(currutmp->chatid), DOECHO))
currutmp->destuid = 0;
@@ -2483,8 +2482,8 @@ t_idle(void)
getdata(b_lines - 1, 0, MSG_PASSWD, passbuf, sizeof(passbuf), NOECHO);
passbuf[8] = '\0';
}
- while (!checkpasswd(cuser.passwd, passbuf) &&
- strcmp(STR_GUEST, cuser.userid));
+ while (!checkpasswd(cuser->passwd, passbuf) &&
+ strcmp(STR_GUEST, cuser->userid));
currutmp->mode = mode0;
currutmp->destuid = destuid0;
diff --git a/mbbsd/user.c b/mbbsd/user.c
index d5c1d167..eb71a4ea 100644
--- a/mbbsd/user.c
+++ b/mbbsd/user.c
@@ -1,16 +1,27 @@
/* $Id$ */
+#define _XOPEN_SOURCE
+#define _ISOC99_SOURCE
+
#include "bbs.h"
static char *sex[8] = {
MSG_BIG_BOY, MSG_BIG_GIRL, MSG_LITTLE_BOY, MSG_LITTLE_GIRL,
MSG_MAN, MSG_WOMAN, MSG_PLANT, MSG_MIME
};
-
+int
+kill_user(int num)
+{
+ userec_t u;
+ memset(&u, 0, sizeof(u));
+ setuserid(num, "");
+ passwd_index_update(num, &u);
+ return 0;
+}
int
u_loginview()
{
int i;
- unsigned int pbits = cuser.loginview;
+ unsigned int pbits = cuser->loginview;
char choice[5];
clear();
@@ -32,9 +43,9 @@ u_loginview()
}
}
- if (pbits != cuser.loginview) {
- cuser.loginview = pbits;
- passwd_update(usernum, &cuser);
+ if (pbits != cuser->loginview) {
+ cuser->loginview = pbits;
+ passwd_update(usernum, cuser);
}
return 0;
}
@@ -191,16 +202,15 @@ violate_law(userec_t * u, int unum)
snprintf(dst, sizeof(dst), "tmp/%s", u->userid);
Rename(src, dst);
log_usies("KILL", u->userid);
- post_violatelaw(u->userid, cuser.userid, reason, "砍除 ID");
- u->userid[0] = '\0';
- setuserid(unum, u->userid);
- passwd_update(unum, u);
+ post_violatelaw(u->userid, cuser->userid, reason, "砍除 ID");
+ kill_user(unum);
+
} else {
u->userlevel |= PERM_VIOLATELAW;
u->vl_count++;
passwd_update(unum, u);
- post_violatelaw(u->userid, cuser.userid, reason, "罰單處份");
- mail_violatelaw(u->userid, cuser.userid, reason, "罰單處份");
+ post_violatelaw(u->userid, cuser->userid, reason, "罰單處份");
+ mail_violatelaw(u->userid, cuser->userid, reason, "罰單處份");
}
pressanykey();
}
@@ -218,35 +228,35 @@ static void Customize(void)
prints("您目前的個人化設定: ");
move(4, 0);
prints("%-30s%10s\n", "A. 水球模式",
- wm[(cuser.uflag2 & WATER_MASK)]);
+ wm[(cuser->uflag2 & WATER_MASK)]);
prints("%-30s%10s\n", "B. 接受站外信",
- ((cuser.userlevel & PERM_NOOUTMAIL) ? "否" : "是"));
+ ((cuser->userlevel & PERM_NOOUTMAIL) ? "否" : "是"));
prints("%-30s%10s\n", "C. 新板自動進我的最愛",
- ((cuser.uflag2 & FAVNEW_FLAG) ? "是" : "否"));
+ ((cuser->uflag2 & FAVNEW_FLAG) ? "是" : "否"));
prints("%-30s%10s\n", "D. 目前的心情", mindbuf);
prints("%-30s%10s\n", "E. 高亮度顯示我的最愛",
- ((cuser.uflag2 & FAVNOHILIGHT) ? "否" : "是"));
+ ((cuser->uflag2 & FAVNOHILIGHT) ? "否" : "是"));
getdata(b_lines - 1, 0, "請按 [A-E] 切換設定,按 [Return] 結束:",
ans, sizeof(ans), DOECHO);
switch( ans[0] ){
case 'A':
case 'a':{
- int currentset = cuser.uflag2 & WATER_MASK;
+ int currentset = cuser->uflag2 & WATER_MASK;
currentset = (currentset + 1) % 3;
- cuser.uflag2 &= ~WATER_MASK;
- cuser.uflag2 |= currentset;
+ cuser->uflag2 &= ~WATER_MASK;
+ cuser->uflag2 |= currentset;
vmsg("修正水球模式後請正常離線再重新上線");
}
break;
case 'B':
case 'b':
- cuser.userlevel ^= PERM_NOOUTMAIL;
+ cuser->userlevel ^= PERM_NOOUTMAIL;
break;
case 'C':
case 'c':
- cuser.uflag2 ^= FAVNEW_FLAG;
- if (cuser.uflag2 & FAVNEW_FLAG)
+ cuser->uflag2 ^= FAVNEW_FLAG;
+ if (cuser->uflag2 & FAVNEW_FLAG)
subscribe_newfav();
break;
case 'D':
@@ -263,12 +273,12 @@ static void Customize(void)
break;
case 'E':
case 'e':
- cuser.uflag2 ^= FAVNOHILIGHT;
+ cuser->uflag2 ^= FAVNOHILIGHT;
break;
default:
done = 1;
}
- passwd_update(usernum, &cuser);
+ passwd_update(usernum, cuser);
}
pressanykey();
}
@@ -324,7 +334,7 @@ uinfo_query(userec_t * u, int real, int unum)
getdata_buf(i++, 0, "真實姓名:",
x.realname, sizeof(x.realname), DOECHO);
#ifdef FOREIGN_REG
- getdata_buf(i++, 0, cuser.uflag2 & FOREIGN ? "護照號碼" : "身分證號:", x.ident, sizeof(x.ident), DOECHO);
+ getdata_buf(i++, 0, cuser->uflag2 & FOREIGN ? "護照號碼" : "身分證號:", x.ident, sizeof(x.ident), DOECHO);
#else
getdata_buf(i++, 0, "身分證號:", x.ident, sizeof(x.ident), DOECHO);
#endif
@@ -581,7 +591,7 @@ uinfo_query(userec_t * u, int real, int unum)
getdata(b_lines - 1, 0, msg_sure_ny, ans, 3, LCECHO);
if (*ans == 'y') {
if (flag)
- post_change_perm(temp, i, cuser.userid, x.userid);
+ post_change_perm(temp, i, cuser->userid, x.userid);
if (strcmp(u->userid, x.userid)) {
char src[STRLEN], dst[STRLEN];
@@ -604,8 +614,7 @@ uinfo_query(userec_t * u, int real, int unum)
snprintf(dst, sizeof(dst), "tmp/%s", x.userid);
Rename(src, dst); /* do not remove user home */
log_usies("KILL", x.userid);
- x.userid[0] = '\0';
- setuserid(unum, x.userid);
+ kill_user(unum);
} else
log_usies("SetUser", x.userid);
if (money_change)
@@ -622,7 +631,7 @@ uinfo_query(userec_t * u, int real, int unum)
"時間: %s\n"
" 站長\033[1;32m%s\033[m把\033[1;32m%s\033[m"
"的錢從\033[1;35m%ld\033[m改成\033[1;35m%d\033[m",
- ctime(&now), cuser.userid, x.userid, money, x.money);
+ ctime(&now), cuser->userid, x.userid, money, x.money);
clrtobot();
clear();
@@ -630,10 +639,10 @@ uinfo_query(userec_t * u, int real, int unum)
reason, sizeof(reason), DOECHO));
fprintf(fp, "\n \033[1;37m站長%s修改錢理由是:%s\033[m",
- cuser.userid, reason);
+ cuser->userid, reason);
fclose(fp);
snprintf(fhdr.title, sizeof(fhdr.title),
- "[公安報告] 站長%s修改%s錢報告", cuser.userid,
+ "[公安報告] 站長%s修改%s錢報告", cuser->userid,
x.userid);
strlcpy(fhdr.owner, "[系統安全局]", sizeof(fhdr.owner));
append_record("boards/S/Security/.DIR", &fhdr, sizeof(fhdr));
@@ -645,10 +654,9 @@ int
u_info()
{
move(2, 0);
- user_display(&cuser, 0);
- uinfo_query(&cuser, 0, usernum);
- //strlcpy(currutmp->realname, cuser.realname, sizeof(currutmp->realname));
- strlcpy(currutmp->username, cuser.username, sizeof(currutmp->username));
+ user_display(cuser, 0);
+ uinfo_query(cuser, 0, usernum);
+ strlcpy(currutmp->username, cuser->username, sizeof(currutmp->username));
return 0;
}
@@ -656,7 +664,7 @@ int
u_ansi()
{
showansi ^= 1;
- cuser.uflag ^= COLOR_FLAG;
+ cuser->uflag ^= COLOR_FLAG;
outs(reset_color);
return 0;
}
@@ -674,16 +682,16 @@ u_switchproverb()
/* char *state[4]={"用功\型","安逸型","自定型","SHUTUP"}; */
char buf[100];
- cuser.proverb = (cuser.proverb + 1) % 4;
+ cuser->proverb = (cuser->proverb + 1) % 4;
setuserfile(buf, fn_proverb);
- if (cuser.proverb == 2 && dashd(buf)) {
+ if (cuser->proverb == 2 && dashd(buf)) {
FILE *fp = fopen(buf, "a");
assert(fp);
fprintf(fp, "座右銘狀態為[自定型]要記得設座右銘的內容唷!!");
fclose(fp);
}
- passwd_update(usernum, &cuser);
+ passwd_update(usernum, cuser);
return 0;
}
@@ -817,14 +825,14 @@ u_editcalendar()
int aborted;
setutmpmode(EDITPLAN);
- setcalfile(genbuf, cuser.userid);
+ setcalfile(genbuf, cuser->userid);
aborted = vedit(genbuf, NA, NULL);
if (aborted != -1)
outs("行事曆更新完畢");
pressanykey();
return 0;
} else if (genbuf[0] == 'd') {
- setcalfile(genbuf, cuser.userid);
+ setcalfile(genbuf, cuser->userid);
unlink(genbuf);
outmsg("行事曆刪除完畢");
}
@@ -899,7 +907,7 @@ ispersonalid(char *inid)
static char *
getregcode(char *buf)
{
- sprintf(buf, "%s", crypt(cuser.userid, "02"));
+ sprintf(buf, "%s", crypt(cuser->userid, "02"));
return buf;
}
@@ -938,7 +946,7 @@ toregister(char *email, char *genbuf, char *phone, char *career,
FILE *fn;
char buf[128];
- sethomefile(buf, cuser.userid, "justify.wait");
+ sethomefile(buf, cuser->userid, "justify.wait");
if (phone[0] != 0) {
fn = fopen(buf, "w");
assert(fn);
@@ -948,7 +956,7 @@ toregister(char *email, char *genbuf, char *phone, char *career,
}
clear();
stand_title("認證設定");
- if (cuser.userlevel & PERM_NOREGCODE){
+ if (cuser->userlevel & PERM_NOREGCODE){
strcpy(email, "x");
goto REGFORM2;
}
@@ -1005,12 +1013,12 @@ toregister(char *email, char *genbuf, char *phone, char *career,
"若您無 E-Mail 請輸入 x由站長手動認證");
}
}
- strncpy(cuser.email, email, sizeof(cuser.email));
+ strncpy(cuser->email, email, sizeof(cuser->email));
REGFORM2:
if (strcasecmp(email, "x") == 0) { /* 手動認證 */
if ((fn = fopen(fn_register, "a"))) {
fprintf(fn, "num: %d, %s", usernum, ctime(&now));
- fprintf(fn, "uid: %s\n", cuser.userid);
+ fprintf(fn, "uid: %s\n", cuser->userid);
fprintf(fn, "ident: %s\n", ident);
fprintf(fn, "name: %s\n", rname);
fprintf(fn, "career: %s\n", career);
@@ -1032,20 +1040,20 @@ toregister(char *email, char *genbuf, char *phone, char *career,
#endif
snprintf(genbuf, sizeof(genbuf),
"%s:%s:<Email>", phone, career);
- strncpy(cuser.justify, genbuf, REGLEN);
- sethomefile(buf, cuser.userid, "justify");
+ strncpy(cuser->justify, genbuf, REGLEN);
+ sethomefile(buf, cuser->userid, "justify");
}
snprintf(buf, sizeof(buf),
"您在 " BBSNAME " 的認證碼: %s", getregcode(genbuf));
- strlcpy(tmp, cuser.userid, sizeof(tmp));
- strlcpy(cuser.userid, "SYSOP", sizeof(cuser.userid));
+ strlcpy(tmp, cuser->userid, sizeof(tmp));
+ strlcpy(cuser->userid, "SYSOP", sizeof(cuser->userid));
#ifdef HAVEMOBILE
if (strcmp(email, "m") == 0 || strcmp(email, "M") == 0)
mobile_message(mobile, buf);
else
#endif
bsmtp("etc/registermail", buf, email, 0);
- strlcpy(cuser.userid, tmp, sizeof(cuser.userid));
+ strlcpy(cuser->userid, tmp, sizeof(cuser->userid));
outs("\n\n\n我們即將寄出認證信 (您應該會在 10 分鐘內收到)\n"
"收到後您可以跟據認證信標題的認證碼\n"
"輸入到 (U)ser -> (R)egister 後就可以完成註冊");
@@ -1168,7 +1176,7 @@ u_register(void)
char genbuf[200];
FILE *fn;
- if (cuser.userlevel & PERM_LOGINOK) {
+ if (cuser->userlevel & PERM_LOGINOK) {
outs("您的身份確認已經完成,不需填寫申請表");
return XEASY;
}
@@ -1177,7 +1185,7 @@ u_register(void)
if ((ptr = strchr(genbuf, '\n')))
*ptr = '\0';
if (strncmp(genbuf, "uid: ", 5) == 0 &&
- strcmp(genbuf + 5, cuser.userid) == 0) {
+ strcmp(genbuf + 5, cuser->userid) == 0) {
fclose(fn);
outs("您的註冊申請單尚在處理中,請耐心等候");
return XEASY;
@@ -1185,20 +1193,20 @@ u_register(void)
}
fclose(fn);
}
- strlcpy(ident, cuser.ident, sizeof(ident));
- strlcpy(rname, cuser.realname, sizeof(rname));
- strlcpy(addr, cuser.address, sizeof(addr));
- strlcpy(email, cuser.email, sizeof(email));
- snprintf(mobile, sizeof(mobile), "0%09d", cuser.mobile);
- if (cuser.month == 0 && cuser.day && cuser.year == 0)
+ strlcpy(ident, cuser->ident, sizeof(ident));
+ strlcpy(rname, cuser->realname, sizeof(rname));
+ strlcpy(addr, cuser->address, sizeof(addr));
+ strlcpy(email, cuser->email, sizeof(email));
+ snprintf(mobile, sizeof(mobile), "0%09d", cuser->mobile);
+ if (cuser->month == 0 && cuser->day && cuser->year == 0)
birthday[0] = 0;
else
snprintf(birthday, sizeof(birthday), "%02i/%02i/%02i",
- cuser.month, cuser.day, cuser.year % 100);
- sex_is[0] = (cuser.sex % 8) + '1';
+ cuser->month, cuser->day, cuser->year % 100);
+ sex_is[0] = (cuser->sex % 8) + '1';
sex_is[1] = 0;
career[0] = phone[0] = '\0';
- sethomefile(genbuf, cuser.userid, "justify.wait");
+ sethomefile(genbuf, cuser->userid, "justify.wait");
if ((fn = fopen(genbuf, "r"))) {
fgets(phone, 21, fn);
phone[strlen(phone) - 1] = 0;
@@ -1215,20 +1223,20 @@ u_register(void)
fclose(fn);
}
- if (cuser.userlevel & PERM_NOREGCODE) {
+ if (cuser->userlevel & PERM_NOREGCODE) {
vmsg("您不被允許\使用認證碼認證。請填寫註冊申請單");
goto REGFORM;
}
- if (cuser.year != 0 && /* 已經第一次填過了~ ^^" */
- strcmp(cuser.email, "x") != 0 && /* 上次手動認證失敗 */
- strcmp(cuser.email, "X") != 0) {
+ if (cuser->year != 0 && /* 已經第一次填過了~ ^^" */
+ strcmp(cuser->email, "x") != 0 && /* 上次手動認證失敗 */
+ strcmp(cuser->email, "X") != 0) {
clear();
stand_title("EMail認證");
move(2, 0);
prints("%s(%s) 您好,請輸入您的認證碼。\n"
"或您可以輸入 x來重新填寫 E-Mail 或改由站長手動認證\n",
- cuser.userid, cuser.username);
+ cuser->userid, cuser->username);
inregcode[0] = 0;
do{
getdata(10, 0, "您的輸入: ", inregcode, sizeof(inregcode), DOECHO);
@@ -1242,18 +1250,18 @@ u_register(void)
if (strcmp(inregcode, getregcode(regcode)) == 0) {
int unum;
- if ((unum = getuser(cuser.userid)) == 0) {
+ if ((unum = getuser(cuser->userid)) == 0) {
vmsg("系統錯誤,查無此人!");
u_exit("getuser error");
exit(0);
}
- mail_muser(cuser, "[註冊成功\囉]", "etc/registeredmail");
- if(cuser.uflag2 & FOREIGN)
- mail_muser(cuser, "[出入境管理局]", "etc/foreign_welcome");
- cuser.userlevel |= (PERM_LOGINOK | PERM_POST);
+ mail_muser(*cuser, "[註冊成功\囉]", "etc/registeredmail");
+ if(cuser->uflag2 & FOREIGN)
+ mail_muser(*cuser, "[出入境管理局]", "etc/foreign_welcome");
+ cuser->userlevel |= (PERM_LOGINOK | PERM_POST);
prints("\n註冊成功\, 重新上站後將取得完整權限\n"
"請按下任一鍵跳離後重新上站~ :)");
- sethomefile(genbuf, cuser.userid, "justify.wait");
+ sethomefile(genbuf, cuser->userid, "justify.wait");
unlink(genbuf);
pressanykey();
u_exit("registed");
@@ -1281,7 +1289,7 @@ u_register(void)
clear();
move(1, 0);
prints("%s(%s) 您好,請據實填寫以下的資料:",
- cuser.userid, cuser.username);
+ cuser->userid, cuser->username);
#ifdef FOREIGN_REG
fore[0] = 'y';
fore[1] = 0;
@@ -1368,10 +1376,10 @@ u_register(void)
len = strlen(birthday);
if (!len) {
snprintf(birthday, sizeof(birthday), "%02i/%02i/%02i",
- cuser.month, cuser.day, cuser.year % 100);
- mon = cuser.month;
- day = cuser.day;
- year = cuser.year;
+ cuser->month, cuser->day, cuser->year % 100);
+ mon = cuser->month;
+ day = cuser->day;
+ year = cuser->year;
} else if (len == 8) {
mon = (birthday[0] - '0') * 10 + (birthday[1] - '0');
day = (birthday[3] - '0') * 10 + (birthday[4] - '0');
@@ -1395,20 +1403,20 @@ u_register(void)
if (ans[0] == 'y')
break;
}
- strlcpy(cuser.ident, ident, sizeof(cuser.ident));
- strlcpy(cuser.realname, rname, sizeof(cuser.realname));
- strlcpy(cuser.address, addr, sizeof(cuser.address));
- strlcpy(cuser.email, email, sizeof(cuser.email));
- cuser.mobile = atoi(mobile);
- cuser.sex = (sex_is[0] - '1') % 8;
- cuser.month = mon;
- cuser.day = day;
- cuser.year = year;
+ strlcpy(cuser->ident, ident, sizeof(cuser->ident));
+ strlcpy(cuser->realname, rname, sizeof(cuser->realname));
+ strlcpy(cuser->address, addr, sizeof(cuser->address));
+ strlcpy(cuser->email, email, sizeof(cuser->email));
+ cuser->mobile = atoi(mobile);
+ cuser->sex = (sex_is[0] - '1') % 8;
+ cuser->month = mon;
+ cuser->day = day;
+ cuser->year = year;
#ifdef FOREIGN_REG
if (fore[0])
- cuser.uflag2 |= FOREIGN;
+ cuser->uflag2 |= FOREIGN;
else
- cuser.uflag2 &= ~FOREIGN;
+ cuser->uflag2 &= ~FOREIGN;
#endif
trim(career);
trim(addr);
@@ -1421,20 +1429,20 @@ u_register(void)
prints("最後Post一篇\033[32m自我介紹文章\033[m給大家吧,"
"告訴所有老骨頭\033[31m我來啦^$。\\n\n\n\n");
pressanykey();
- cuser.userlevel |= PERM_POST;
+ cuser->userlevel |= PERM_POST;
brc_initial_board("WhoAmI");
set_board();
do_post();
- cuser.userlevel &= ~PERM_POST;
+ cuser->userlevel &= ~PERM_POST;
return 0;
}
/* 列出所有註冊使用者 */
static int usercounter, totalusers;
-static ushort u_list_special;
+static unsigned short u_list_special;
static int
-u_list_CB(userec_t * uentp)
+u_list_CB(int num, userec_t * uentp)
{
static int i;
char permstr[8], *ptr;
@@ -1517,7 +1525,7 @@ u_list()
if (genbuf[0] != '2')
u_list_special = PERM_BASIC | PERM_CHAT | PERM_PAGE | PERM_POST | PERM_LOGINOK | PERM_BM;
}
- u_list_CB(NULL);
+ u_list_CB(0, NULL);
if (passwd_apply(u_list_CB) == -1) {
outs(msg_nobody);
return XEASY;
diff --git a/mbbsd/var.c b/mbbsd/var.c
index 89a88244..4c7a29dc 100644
--- a/mbbsd/var.c
+++ b/mbbsd/var.c
@@ -95,7 +95,7 @@ pid_t currpid; /* current process ID */
time_t login_start_time;
time_t start_time;
time_t paste_time;
-userec_t cuser; /* current user structure */
+userec_t *cuser = NULL; /* current user structure */
userec_t xuser; /* lookup user structure */
crosspost_t postrecord; /* anti cross post */
unsigned int currbrdattr;
diff --git a/mbbsd/vote.c b/mbbsd/vote.c
index fa2a52e6..305b9613 100644
--- a/mbbsd/vote.c
+++ b/mbbsd/vote.c
@@ -874,7 +874,7 @@ user_vote_one(char *bname, int ind)
setbfile(buf, bname, STR_new_limited); /* Ptt */
if (dashf(buf)) {
setbfile(buf, bname, FN_CANVOTE);
- if (!belong(buf, cuser.userid)) {
+ if (!belong(buf, cuser->userid)) {
fclose(cfp);
outs("\n\n對不起! 這是私人投票..你並沒有受邀唷!");
pressanykey();
@@ -1040,7 +1040,7 @@ user_vote_one(char *bname, int ind)
fprintf(fcm,
"\033[36m○使用者\033[1;36m %s "
"\033[;36m的建議:\033[m\n",
- cuser.userid);
+ cuser->userid);
for (i = 0; i < 3; i++)
fprintf(fcm, " %s\n", mycomments[i]);
fprintf(fcm, "\n");
diff --git a/mbbsd/voteboard.c b/mbbsd/voteboard.c
index fe4008d7..7714b14e 100644
--- a/mbbsd/voteboard.c
+++ b/mbbsd/voteboard.c
@@ -20,9 +20,9 @@ do_voteboardreply(fileheader_t * fhdr)
clear();
- if (!(currmode & MODE_POST)) {
+ if (!CheckPostPerm()) {
move(5, 10);
- outs("對不起,您目前無法在此發表文章!");
+ prints("對不起,您目前無法在此發表文章!");
pressanykey();
return;
}
@@ -62,7 +62,7 @@ do_voteboardreply(fileheader_t * fhdr)
if(yes>=0) continue;
strtok(genbuf+4," \n");
- if (!strncmp(genbuf + 4, cuser.userid, IDLEN)) {
+ if (!strncmp(genbuf + 4, cuser->userid, IDLEN)) {
move(5, 10);
prints("您已經連署過本篇了");
getdata(17, 0, "要修改您之前的連署嗎?(Y/N) [N]", opnion, 3, LCECHO);
@@ -111,27 +111,27 @@ do_voteboardreply(fileheader_t * fhdr)
now -= 14 * 24 * 60 * 60;
}
fprintf(fo, "%s", genbuf);
- len = strlen(cuser.userid);
+ len = strlen(cuser->userid);
for(yes=0; fgets(genbuf, sizeof(genbuf), fi);) {
if (!strncmp("----------", genbuf, 10))
break;
- if (strlen(genbuf)<30 || (genbuf[4+len]==' ' && !strncmp(genbuf + 4, cuser.userid, len)))
+ if (strlen(genbuf)<30 || (genbuf[4+len]==' ' && !strncmp(genbuf + 4, cuser->userid, len)))
continue;
fprintf(fo, "%3d.%s", ++yes, genbuf + 4);
}
if (opnion[0] == 'y')
- fprintf(fo, "%3d.%-15s%-34s 來源:%s\n", ++yes, cuser.userid, reason, cuser.lasthost);
+ fprintf(fo, "%3d.%-15s%-34s 來源:%s\n", ++yes, cuser->userid, reason, cuser->lasthost);
fprintf(fo, "%s", genbuf);
for(no=0; fgets(genbuf, sizeof(genbuf), fi);) {
if (!strncmp("----------", genbuf, 10))
break;
- if (strlen(genbuf)<30 || (genbuf[4+len]==' ' && !strncmp(genbuf + 4, cuser.userid, len)))
+ if (strlen(genbuf)<30 || (genbuf[4+len]==' ' && !strncmp(genbuf + 4, cuser->userid, len)))
continue;
fprintf(fo, "%3d.%s", ++no, genbuf + 4);
}
if (opnion[0] == 'n')
- fprintf(fo, "%3d.%-15s%-34s 來源:%s\n", ++no, cuser.userid, reason, cuser.lasthost);
+ fprintf(fo, "%3d.%-15s%-34s 來源:%s\n", ++no, cuser->userid, reason, cuser->lasthost);
fprintf(fo, "----------總計----------\n");
fprintf(fo, "支持人數:%-9d反對人數:%-9d\n", yes, no);
fprintf(fo, "\n--\n※ 發信站 :" BBSNAME "(" MYHOSTNAME
@@ -157,9 +157,9 @@ do_voteboard(int type)
int temp;
clear();
- if (!(currmode & MODE_POST)) {
+ if (!CheckPostPerm()) {
move(5, 10);
- outs("對不起,您目前無法在此發表文章!");
+ prints("對不起,您目前無法在此發表文章!");
pressanykey();
return FULLUPDATE;
}
@@ -246,7 +246,7 @@ do_voteboard(int type)
completeboard_permission,
completeboard_getname);
snprintf(title, sizeof(title), "[連署板主] %s", topic);
- snprintf(genbuf, sizeof(genbuf), "%s\n\n%s%s\n%s%s", "連署板主", "英文名稱: ", topic, "申請 ID : ", cuser.userid);
+ snprintf(genbuf, sizeof(genbuf), "%s\n\n%s%s\n%s%s", "連署板主", "英文名稱: ", topic, "申請 ID : ", cuser->userid);
strcat(genbuf, "\n申請政見: \n");
break;
case 6:
@@ -275,7 +275,7 @@ do_voteboard(int type)
snprintf(title, sizeof(title), "[連署小組長] %s", topic);
snprintf(genbuf, sizeof(genbuf),
"%s\n\n%s%s\n%s%s", "連署小組長", "小組名稱: ",
- topic, "申請 ID : ", cuser.userid);
+ topic, "申請 ID : ", cuser->userid);
strcat(genbuf, "\n申請政見: \n");
break;
case 8:
@@ -294,7 +294,7 @@ do_voteboard(int type)
return FULLUPDATE;
snprintf(title, sizeof(title), "[申請新群組] %s", topic);
snprintf(genbuf, sizeof(genbuf), "%s\n\n%s%s\n%s%s",
- "申請群組", "群組名稱: ", topic, "申請 ID : ", cuser.userid);
+ "申請群組", "群組名稱: ", topic, "申請 ID : ", cuser->userid);
strcat(genbuf, "\n申請政見: \n");
break;
default:
@@ -325,13 +325,13 @@ do_voteboard(int type)
outs("開檔失敗,請稍候重來一次");
return FULLUPDATE;
}
- fprintf(fp, "%s%s %s%s\n%s%s\n%s%s", "作者: ", cuser.userid,
+ fprintf(fp, "%s%s %s%s\n%s%s\n%s%s", "作者: ", cuser->userid,
"看板: ", currboard,
"標題: ", title,
"時間: ", ctime(&now));
fprintf(fp, "%s\n", genbuf);
fclose(fp);
- strlcpy(votefile.owner, cuser.userid, sizeof(votefile.owner));
+ strlcpy(votefile.owner, cuser->userid, sizeof(votefile.owner));
strlcpy(votefile.title, title, sizeof(votefile.title));
votefile.filemode |= FILE_VOTE;
setbdir(genbuf, currboard);
diff --git a/mbbsd/xyz.c b/mbbsd/xyz.c
index e0b850b5..1d83fd41 100644
--- a/mbbsd/xyz.c
+++ b/mbbsd/xyz.c
@@ -179,7 +179,7 @@ note()
} notedata_t;
notedata_t myitem;
- if (cuser.money < 5) {
+ if (cuser->money < 5) {
outmsg("\033[1;41m 哎呀! 要投五銀才能留言...沒錢耶..\033[m");
clrtoeol();
refresh();
@@ -201,8 +201,8 @@ note()
return 0;
} while (buf[0] == 'e');
demoney(-5);
- strcpy(myitem.userid, cuser.userid);
- strncpy(myitem.username, cuser.username, 18);
+ strcpy(myitem.userid, cuser->userid);
+ strncpy(myitem.username, cuser->username, 18);
myitem.username[18] = '\0';
myitem.date = now;
@@ -360,7 +360,7 @@ Goodbye()
return 0;
movie(999);
- if (cuser.userlevel) {
+ if (cuser->userlevel) {
getdata(b_lines - 1, 0,
"(G)隨風而逝 (M)托夢站長 (N)酸甜苦辣流言板?[G] ",
genbuf, 3, LCECHO);
@@ -373,8 +373,8 @@ Goodbye()
clear();
prints("\033[1;36m親愛的 \033[33m%s(%s)\033[36m,別忘了再度光臨\033[45;33m"
" %s \033[40;36m!\n以下是您在站內的註冊資料:\033[0m\n",
- cuser.userid, cuser.username, BBSName);
- user_display(&cuser, 0);
+ cuser->userid, cuser->username, BBSName);
+ user_display(cuser, 0);
pressanykey();
more("etc/Logout", NA);
diff --git a/util/birth.c b/util/birth.c
index 20bd65c0..4a4a6fd0 100644
--- a/util/birth.c
+++ b/util/birth.c
@@ -5,18 +5,18 @@
#define OUTFILE BBSHOME "/etc/birth.today"
-struct userec_t cuser;
+struct userec_t user;
int bad_user_id(char *userid) {
register char ch;
int j;
- if (strlen(cuser.userid) < 2 || !isalpha(cuser.userid[0]))
+ if (strlen(user.userid) < 2 || !isalpha(user.userid[0]))
return 1;
- if (cuser.numlogins == 0 || cuser.numlogins > 15000)
+ if (user.numlogins == 0 || user.numlogins > 15000)
return 1;
- if (cuser.numposts > 15000)
+ if (user.numposts > 15000)
return 1;
- for (j = 1; (ch = cuser.userid[j]); j++)
+ for (j = 1; (ch = user.userid[j]); j++)
{
if (!isalnum(ch))
return 1;
@@ -60,29 +60,29 @@ int main(argc, argv)
"★★★★★★ \n\n");
fprintf(fp1, "【本日壽星】 \n");
for(j = 1; j <= MAX_USERS; j++) {
- passwd_query(j, &cuser);
+ passwd_query(j, &user);
if (bad_user_id(NULL))
continue;
- if (cuser.month == ptime->tm_mon + 1)
+ if (user.month == ptime->tm_mon + 1)
{
- if (cuser.day == ptime->tm_mday)
+ if (user.day == ptime->tm_mday)
{
char genbuf[200];
- sprintf(genbuf, BBSHOME "/home/%c/%s", cuser.userid[0], cuser.userid);
+ sprintf(genbuf, BBSHOME "/home/%c/%s", user.userid[0], user.userid);
stampfile(genbuf, &mymail);
strcpy(mymail.owner, BBSNAME);
strcpy(mymail.title, "!! 生日快樂 !!");
unlink(genbuf);
Link(BBSHOME "/etc/Welcome_birth", genbuf);
- sprintf(genbuf, BBSHOME "/home/%c/%s/.DIR", cuser.userid[0], cuser.userid);
+ sprintf(genbuf, BBSHOME "/home/%c/%s/.DIR", user.userid[0], user.userid);
append_record(genbuf, &mymail, sizeof(mymail));
- if ((cuser.numlogins + cuser.numposts) < 20)
+ if ((user.numlogins + user.numposts) < 20)
continue;
fprintf(fp1,
" [%2d/%-2d] %-14s %-24s login:%-5d post:%-5d\n",
- ptime->tm_mon + 1, ptime->tm_mday, cuser.userid,
- cuser.username, cuser.numlogins, cuser.numposts);
+ ptime->tm_mon + 1, ptime->tm_mday, user.userid,
+ user.username, user.numlogins, user.numposts);
}
}
}
diff --git a/util/horoscope.c b/util/horoscope.c
index 04479108..936c2727 100644
--- a/util/horoscope.c
+++ b/util/horoscope.c
@@ -2,7 +2,7 @@
#define _UTIL_C_
#include "bbs.h"
-struct userec_t cuser;
+struct userec_t user;
int main() {
int i, j, k;
@@ -37,79 +37,79 @@ int main() {
if(passwd_init())
exit(1);
for(k = 1; k <= MAX_USERS; k++) {
- passwd_query(k, &cuser);
- if(!cuser.userid[0])
+ passwd_query(k, &user);
+ if(!user.userid[0])
continue;
- switch (cuser.month)
+ switch (user.month)
{
case 1:
- if (cuser.day <= 19)
+ if (user.day <= 19)
act[9]++;
else
act[10]++;
break;
case 2:
- if (cuser.day <= 18)
+ if (user.day <= 18)
act[10]++;
else
act[11]++;
break;
case 3:
- if (cuser.day <= 20)
+ if (user.day <= 20)
act[11]++;
else
act[0]++;
break;
case 4:
- if (cuser.day <= 19)
+ if (user.day <= 19)
act[0]++;
else
act[1]++;
break;
case 5:
- if (cuser.day <= 20)
+ if (user.day <= 20)
act[1]++;
else
act[2]++;
break;
case 6:
- if (cuser.day <= 21)
+ if (user.day <= 21)
act[2]++;
else
act[3]++;
break;
case 7:
- if (cuser.day <= 22)
+ if (user.day <= 22)
act[3]++;
else
act[4]++;
break;
case 8:
- if (cuser.day <= 22)
+ if (user.day <= 22)
act[4]++;
else
act[5]++;
break;
case 9:
- if (cuser.day <= 22)
+ if (user.day <= 22)
act[5]++;
else
act[6]++;
break;
case 10:
- if (cuser.day <= 23)
+ if (user.day <= 23)
act[6]++;
else
act[7]++;
break;
case 11:
- if (cuser.day <= 22)
+ if (user.day <= 22)
act[7]++;
else
act[8]++;
break;
case 12:
- if (cuser.day <= 21)
+ if (user.day <= 21)
act[8]++;
else
act[9]++;
diff --git a/util/reaper.c b/util/reaper.c
index 03f7a694..2fc587e0 100644
--- a/util/reaper.c
+++ b/util/reaper.c
@@ -55,7 +55,7 @@ int main(int argc, char **argv)
attach_SHM();
if(passwd_init())
exit(1);
- passwd_apply2(check);
+ passwd_apply(check);
return 0;
}
diff --git a/util/uhash_loader.c b/util/uhash_loader.c
index d5171d56..2ea80975 100644
--- a/util/uhash_loader.c
+++ b/util/uhash_loader.c
@@ -74,13 +74,13 @@ void fill_uhash(void)
for (fd = 0; fd < (1 << HASH_BITS); fd++)
SHM->hash_head[fd] = -1;
- if ((fd = open(FN_PASSWD, O_RDONLY)) > 0)
+ if ((fd = open(FN_PASSWD, O_RDWR)) > 0)
{
struct stat stbuf;
caddr_t fimage, mimage;
fstat(fd, &stbuf);
- fimage = mmap(NULL, stbuf.st_size, PROT_READ, MAP_SHARED, fd, 0);
+ fimage = mmap(NULL, stbuf.st_size, PROT_WRITE|PROT_READ, MAP_SHARED, fd, 0);
if (fimage == (char *) -1)
{
perror("mmap");
@@ -121,7 +121,8 @@ void add_to_uhash(int n, userec_t *user)
{
int *p, h = string_hash(user->userid);
strcpy(SHM->userid[n], user->userid);
- SHM->money[n] = user->money;
+ SHM->money[n] = user->money;
+
p = &(SHM->hash_head[h]);
while (*p != -1)
diff --git a/util/yearsold.c b/util/yearsold.c
index b4b0d176..83b43fa9 100644
--- a/util/yearsold.c
+++ b/util/yearsold.c
@@ -5,7 +5,7 @@
#define YEARSOLD_MAX_LINE 16
-struct userec_t cuser;
+struct userec_t user;
void
fouts(fp, buf, mode)
@@ -43,12 +43,12 @@ int main(int argc, char **argv)
memset(act, 0, sizeof(act));
for(k = 1; k <= MAX_USERS; k++) {
- passwd_query(k, &cuser);
- if (((ptime->tm_year - cuser.year) < 10) || ((ptime->tm_year - cuser.year) >
+ passwd_query(k, &user);
+ if (((ptime->tm_year - user.year) < 10) || ((ptime->tm_year - user.year) >
33))
continue;
- act[ptime->tm_year - cuser.year - 10]++;
+ act[ptime->tm_year - user.year - 10]++;
act[24]++;
}