summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2010-06-12 13:17:59 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2010-06-12 13:17:59 +0800
commitff2631f4fd85aa5f2c9fc385637bc37ad0a35c1e (patch)
tree6f51572554aa76571998fab97a31f121cc7f6c41
parentd1ebd36df1aaa15a296da08fd64dbb4aa6d32b74 (diff)
downloadpttbbs.vice_log.tar
pttbbs.vice_log.tar.gz
pttbbs.vice_log.tar.bz2
pttbbs.vice_log.tar.lz
pttbbs.vice_log.tar.xz
pttbbs.vice_log.tar.zst
pttbbs.vice_log.zip
* experimental money-related changes in vice_log branch (not in trunk yet)pttbbs.vice_log
* free ordersong (with other restriction) * free changing from * add money transactio log * remove notes_ans git-svn-id: http://opensvn.csie.org/pttbbs/branches/pttbbs.vice_log@5063 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--pttbbs/include/common.h5
-rw-r--r--pttbbs/include/proto.h11
-rw-r--r--pttbbs/mbbsd/Makefile2
-rw-r--r--pttbbs/mbbsd/admin.c6
-rw-r--r--pttbbs/mbbsd/bbs.c33
-rw-r--r--pttbbs/mbbsd/cal.c106
-rw-r--r--pttbbs/mbbsd/chicken.c15
-rw-r--r--pttbbs/mbbsd/gamble.c18
-rw-r--r--pttbbs/mbbsd/mbbsd.c2
-rw-r--r--pttbbs/mbbsd/menu.c36
-rw-r--r--pttbbs/mbbsd/ordersong.c33
-rw-r--r--pttbbs/mbbsd/record.c56
-rw-r--r--pttbbs/mbbsd/user.c9
-rw-r--r--pttbbs/mbbsd/var.c4
-rw-r--r--pttbbs/mbbsd/vice.c153
-rw-r--r--pttbbs/mbbsd/xyz.c131
16 files changed, 242 insertions, 378 deletions
diff --git a/pttbbs/include/common.h b/pttbbs/include/common.h
index 6e3c8540..d7d3b9a6 100644
--- a/pttbbs/include/common.h
+++ b/pttbbs/include/common.h
@@ -28,7 +28,6 @@
#define FN_DIR ".DIR"
#define FN_BOARD ".BRD" /* board list */
#define FN_USEBOARD "usboard" /* ¬ÝªO²Î­p */
-#define FN_NOTE_ANS "note.ans"
#define FN_TOPSONG "etc/topsong"
#define FN_OVERRIDES "overrides"
#define FN_TICKET "ticket"
@@ -47,6 +46,10 @@
#ifndef SZ_RECENTLOGIN
#define SZ_RECENTLOGIN (16000) // size of max recent log before rotation
#endif
+#define FN_RECENTVICE "vice.recent" // in user directory
+#ifndef SZ_RECENTVICE
+#define SZ_RECENTVICE (16000) // size of max recent log before rotation
+#endif
// ¦Û­q§R°£¤å³¹®É¥X²{ªº¼ÐÃD»PÀÉ®×
diff --git a/pttbbs/include/proto.h b/pttbbs/include/proto.h
index b8d38728..1823c17d 100644
--- a/pttbbs/include/proto.h
+++ b/pttbbs/include/proto.h
@@ -123,13 +123,14 @@ const char * postperm_msg(const char *bname);
/* cal */
const char* money_level(int money);
-int vice(int money, const char* item);
+int vice(int money, const char* item, ...) GCC_CHECK_FORMAT(2,3);
+int vice_to(int money, int uid, const char* item, ...) GCC_CHECK_FORMAT(3, 4);
int lockutmpmode(int unmode, int state);
int unlockutmpmode(void);
int x_file(void);
int give_money(void);
int p_sysinfo(void);
-int do_give_money(char *id, int uid, int money);
+int do_give_money(char *id, int uid, int money, const char *myid);
int give_money_ui(const char *userid);
int p_give(void);
int p_cloak(void);
@@ -477,6 +478,9 @@ int get_sum_records(const char* fpath, int size);
int substitute_ref_record(const char* direct, fileheader_t *fhdr, int ent);
inline
int getindex(const char *fpath, fileheader_t *fh, int start);
+int rotate_bin_logfile(const char *filename, off_t record_size,
+ off_t max_size, float keep_ratio);
+int rotate_text_logfile(const char *filename, off_t max_size, float keep_ratio);
/* register */
int u_register(void);
@@ -665,9 +669,6 @@ int b_vote(void);
int b_vote_maintain(void);
void auto_close_polls(void);
-/* vice */
-int vice_main(void);
-
/* voteboard */
int do_voteboard(int);
void do_voteboardreply(const fileheader_t *fhdr);
diff --git a/pttbbs/mbbsd/Makefile b/pttbbs/mbbsd/Makefile
index 7726635a..6b7b0beb 100644
--- a/pttbbs/mbbsd/Makefile
+++ b/pttbbs/mbbsd/Makefile
@@ -14,7 +14,7 @@ NETOBJS = mbbsd.o io.o term.o telnet.o
TALKOBJS = friend.o talk.o ccw.o
UTILOBJS = stuff.o kaede.o convert.o name.o syspost.o
PAGEROBJS= more.o pmore.o
-PLUGOBJS = calendar.o ordersong.o gamble.o vice.o angel.o
+PLUGOBJS = calendar.o ordersong.o gamble.o angel.o
CHESSOBJS= chess.o chc.o chc_tab.o ch_go.o ch_gomo.o ch_dark.o ch_reversi.o
GAMEOBJS = card.o chicken.o
OBJS:= admin.o assess.o edit.o menu.o xyz.o var.o vtuikit.o \
diff --git a/pttbbs/mbbsd/admin.c b/pttbbs/mbbsd/admin.c
index 8e434d4e..c322a21f 100644
--- a/pttbbs/mbbsd/admin.c
+++ b/pttbbs/mbbsd/admin.c
@@ -1100,9 +1100,11 @@ int make_symbolic_link_interactively(int gid)
static void
give_id_money(const char *user_id, int money, const char *mail_title)
{
- char tt[TTLEN + 1] = {0};
+ char tt[TTLEN + 1] = {0};
+ int unum = searchuser(user_id, NULL);
- if (deumoney(searchuser(user_id, NULL), money) < 0) { // TODO if searchuser() return 0
+ if (unum <= 0 ||
+ vice_to(unum, -money, "¯¸ªøµo¬õ¥]") < 1) {
move(12, 0);
clrtoeol();
prints("id:%s money:%d ¤£¹ï§a!!", user_id, money);
diff --git a/pttbbs/mbbsd/bbs.c b/pttbbs/mbbsd/bbs.c
index 6ee44c7a..71cb09ce 100644
--- a/pttbbs/mbbsd/bbs.c
+++ b/pttbbs/mbbsd/bbs.c
@@ -236,7 +236,7 @@ save_violatelaw(void)
return 0;
}
- demoney(-1000 * cuser.vl_count);
+ vice(1000 * cuser.vl_count, "ú¥I»@³æ (#%d)", cuser.vl_count);
pwcuSaveViolateLaw();
log_filef("log/violation", LOG_CREAT,
"%s %s pay-violation: $%d complete.\n",
@@ -1222,7 +1222,7 @@ do_general(int garbage)
{
if (money > 0)
{
- demoney(money);
+ vice(-money, "%s ¬ÝªOµo¤å½Z¹S: %s", currboard, postfile.title);
pwcuIncNumPost();
addPost = 1;
prints("³o¬O±zªº²Ä %d ½g¦³®Ä¤å³¹¡AÀò±o½Z¹S %d ¤¸\n",
@@ -3017,11 +3017,9 @@ del_range(int ent, const fileheader_t *fhdr, const char *direct)
static int
del_post(int ent, fileheader_t * fhdr, char *direct)
{
-#ifdef SAFE_ARTICLE_DELETE
- char reason[PROPER_TITLE_LEN];
-#endif
+ char reason[PROPER_TITLE_LEN] = "";
char genbuf[100], newpath[PATHLEN];
- int not_owned, is_anon, tusernum, del_ok = 0;
+ int not_owned, is_anon, tusernum, del_ok = 0, as_badpost = 0;
boardheader_t *bp;
assert(0<=currbid-1 && currbid-1<MAX_BOARD);
@@ -3067,7 +3065,6 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
if (fhdr->filename[0]=='L') fhdr->filename[0]='M';
#ifdef SAFE_ARTICLE_DELETE
- reason[0] = 0;
// query if user really wants to delete it
if (not_owned && !is_anon && fhdr->owner[0])
{
@@ -3157,6 +3154,7 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
if (genbuf[0]=='y') {
assign_badpost(getuserid(tusernum), fhdr, newpath, NULL);
+ as_badpost = 1;
}
}
#endif // ASSESS
@@ -3192,7 +3190,12 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
xuser.numposts--;
passwd_sync_update(tusernum, &xuser);
}
- deumoney(tusernum, -fhdr->multi.money);
+ vice_to(tusernum, fhdr->multi.money,
+ "%s ¬ÝªO ¤å³¹¡u%s¡v³Q%s¡A¦©°£½Z¹S%s %s",
+ currboard,
+ fhdr->title,
+ as_badpost ? "¦H°h" : "§R°£",
+ reason[0] ? "¡C­ì¦]:" : "", reason);
sendalert_uid(tusernum, ALERT_PWD_PERM);
#ifdef USE_COOLDOWN
if (bp->brdattr & BRD_COOLDOWN)
@@ -3204,7 +3207,8 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
{
// owner case
pwcuDecNumPost();
- demoney(-fhdr->multi.money);
+ vice(fhdr->multi.money, "%s ¬ÝªO ¤å³¹¦Û§R²M¼ä¶O: %s",
+ currboard, fhdr->title);
sendalert(cuser.userid, ALERT_PWD_PERM);
vmsgf("±zªº¤å³¹´î¬° %d ½g¡A¤ä¥I²M¼ä¶O %d ¤¸",
cuser.numposts, fhdr->multi.money);
@@ -3663,7 +3667,11 @@ good_post(int ent, fileheader_t * fhdr, const char *direct)
!strcmp(currboard, BN_LAW)
)
{
- deumoney(searchuser(fhdr->owner, NULL), -1000); // TODO if searchuser() return 0
+ int unum = searchuser(fhdr->owner, NULL);
+ if (unum > 0) {
+ vice_to(unum, 1000, "¨ú®ø %s ¬ÝªO¤åºK", currboard);
+ }
+
if (!(currmode & MODE_SELECT))
fhdr->multi.money -= 1000;
else
@@ -3709,7 +3717,10 @@ good_post(int ent, fileheader_t * fhdr, const char *direct)
!strcmp(currboard, BN_LAW)
)
{
- deumoney(searchuser(fhdr->owner, NULL), 1000); // TODO if searchuser() return 0
+ int unum = searchuser(fhdr->owner, NULL);
+ if (unum > 0) {
+ vice_to(unum, -1000, "³Q¿ï¤J %s ¬ÝªO¤åºK", currboard);
+ }
if (!(currmode & MODE_SELECT))
fhdr->multi.money += 1000;
else
diff --git a/pttbbs/mbbsd/cal.c b/pttbbs/mbbsd/cal.c
index ecf03bd7..73bbc5cd 100644
--- a/pttbbs/mbbsd/cal.c
+++ b/pttbbs/mbbsd/cal.c
@@ -57,28 +57,74 @@ unlockutmpmode(void)
return 0;
}
-/* ¨Ï¥Î¿úªº¨ç¼Æ */
-#define VICE_NEW "vice.new"
+static int
+do_vice(int uid, int money, const char *item, const char *reason)
+{
+ char buf[PATHLEN];
+ int oldm, newm;
+ const char *userid;
+
+ assert(money != 0);
+ userid = getuserid(uid);
+ assert(userid);
+ assert(reason);
+
+ // if we cannot find user, abort
+ if (!userid)
+ return -1;
+
+ oldm = moneyof(uid);
+ newm = deumoney(uid, -money);
+ if (uid == usernum)
+ reload_money();
+
+ sethomefile(buf, userid, FN_RECENTVICE);
+ rotate_text_logfile(buf, SZ_RECENTVICE, 0.2);
+ syncnow();
+
+
+ log_filef(buf, LOG_CREAT, "%s %s $%d ($%d => $%d) %s\n",
+ Cdatelite(&now),
+ money >= 0 ? "¤ä¥X" : "¦¬¤J",
+ money >= 0 ? money : -money,
+ oldm, newm, reason);
+ return newm;
+}
-/* Heat:µo²¼ */
int
-vice(int money, const char *item)
+vice_to(int uid, int money, const char *item, ...)
{
- char buf[128];
- unsigned int viceserial = (currutmp->lastact % 10000) * 10000 +
- random() % 10000;
+ va_list ap;
+ char reason[STRLEN*3] ="";
- // new logic: do not send useless vice tickets
- demoney(-money);
- if (money < VICE_MIN)
- return 0;
+ if (!money)
+ return 0;
- setuserfile(buf, VICE_NEW);
- log_filef(buf, LOG_CREAT, "%8.8d\n", viceserial);
- snprintf(buf, sizeof(buf),
- "%s ªá¤F$%d ½s¸¹[%08d]", item, money, viceserial);
- mail_id(cuser.userid, buf, "etc/vice.txt", BBSMNAME "¸gÀÙ³¡");
- return 0;
+ if (item) {
+ va_start(ap, item);
+ vsnprintf(reason, sizeof(reason)-1, item, ap);
+ va_end(ap);
+ }
+
+ return do_vice(uid, money, item, reason);
+}
+
+int
+vice(int money, const char *item, ...)
+{
+ va_list ap;
+ char reason[STRLEN*3] ="";
+
+ if (!money)
+ return 0;
+
+ if (item) {
+ va_start(ap, item);
+ vsnprintf(reason, sizeof(reason)-1, item, ap);
+ va_end(ap);
+ }
+
+ return do_vice(usernum, money, item, reason);
}
static int
@@ -88,21 +134,15 @@ inmailbox(int m)
return cuser.exmailbox;
}
-
int
p_from(void)
{
char tmp_from[sizeof(currutmp->from)];
- if (vans("½T©w­n§ï¬G¶m?[y/N]") != 'y')
- return 0;
- reload_money();
- if (cuser.money < 49)
- return 0;
+ strlcpy(tmp_from, currutmp->from, sizeof(tmp_from));
if (getdata(b_lines - 1, 0, "½Ð¿é¤J·s¬G¶m:",
tmp_from, sizeof(tmp_from), DOECHO) &&
strcmp(tmp_from, currutmp->from) != 0)
{
- vice(49, "§ó§ï¬G¶m");
strlcpy(currutmp->from, tmp_from, sizeof(currutmp->from));
}
return 0;
@@ -253,7 +293,7 @@ give_money_vget_peekcb(int key, VGET_RUNTIME *prt, void *instance)
return VGETCB_NEXT;
}
-int do_give_money(char *id, int uid, int money)
+int do_give_money(char *id, int uid, int money, const char *myid)
{
int tax;
@@ -266,11 +306,18 @@ int do_give_money(char *id, int uid, int money)
return -1; /* ú§¹µ|´N¨S¿úµ¹¤F */
// ¹ê»Úµ¹¤©ª÷¿ú¡C
- deumoney(uid, money - tax);
- demoney(-money);
log_filef(FN_MONEY, LOG_CREAT, "%-12s µ¹ %-12s %d\t(µ|«á %d)\t%s\n",
cuser.userid, id, money, money - tax, Cdate(&now));
+ if (strcmp(myid, cuser.userid) != 0)
+ vice(money, "¥H %s ªº¦W¸qÂà±bµ¹ %s (µ|«á $%d)",
+ myid, id, money - tax);
+ else
+ vice(money, "Âà±bµ¹ %s (µ|«á $%d)", id, money - tax);
+
+ vice_to(uid, -(money - tax), "¨Ó¦Û %s ªºÂà±b (µ|«e $%d)",
+ myid, money);
+
// penalty
if (money < 50) {
usleep(2000000); // 2 sec
@@ -418,7 +465,7 @@ give_money_ui(const char *userid)
outs("\n¥æ©ö¥¿¦b¶i¦æ¤¤¡A½Ðµy­Ô...\n");
refresh();
- if(do_give_money(id, uid, m) < 0)
+ if(do_give_money(id, uid, m, myid) < 0)
{
outs(ANSI_COLOR(1;31) "¥æ©ö¥¢±Ñ¡I" ANSI_RESET "\n");
vmsg("¥æ©ö¥¢±Ñ¡C");
@@ -426,6 +473,9 @@ give_money_ui(const char *userid)
}
outs(ANSI_COLOR(1;33) "¥æ©ö§¹¦¨¡I" ANSI_RESET "\n");
+ outs("±z¥i¥H©ó¤U¦C¦ì¸m§ä¨ì³Ìªñªº¥æ©ö°O¿ý:\n"
+ "¥D¿ï³æ => (U)ser­Ó¤H³]©w => (L)MyLogs ­Ó¤H°O¿ý => "
+ "(V)RecentVice ³Ìªñ¥æ©ö°O¿ý\n");
// transaction complete.
{
diff --git a/pttbbs/mbbsd/chicken.c b/pttbbs/mbbsd/chicken.c
index e5d74b06..88db83f1 100644
--- a/pttbbs/mbbsd/chicken.c
+++ b/pttbbs/mbbsd/chicken.c
@@ -455,7 +455,7 @@ ch_hit(chicken_t *mychicken)
//static
void
-ch_buyitem(int money, const char *picture, int *item, int haveticket)
+ch_buyitem(int money, const char *picture, int *item)
{
int num = 0;
char buf[5];
@@ -468,11 +468,8 @@ ch_buyitem(int money, const char *picture, int *item, int haveticket)
reload_money();
if (cuser.money/money >= num) {
*item += num;
- if( haveticket )
- vice(money * num, "ÁʶRÃdª«");
- else
- demoney(-money * num);
- show_chicken_picture(picture);
+ vice(money * num, "Ãdª«");
+ show_chicken_picture(picture);
pressanykey();
} else {
vmsg("²{ª÷¤£°÷ !!!");
@@ -817,7 +814,7 @@ select_menu(int age GCC_UNUSED, chicken_t *mychicken)
break;
case '7':
ch_buyitem(food_price[(int)mychicken->type], CHICKEN_PIC "/food",
- &mychicken->food, 1);
+ &mychicken->food);
break;
case '8':
ch_eatoo(mychicken);
@@ -827,11 +824,11 @@ select_menu(int age GCC_UNUSED, chicken_t *mychicken)
break;
case 'O':
case 'o':
- ch_buyitem(100, CHICKEN_PIC "/buyoo", &mychicken->oo, 1);
+ ch_buyitem(100, CHICKEN_PIC "/buyoo", &mychicken->oo);
break;
case 'M':
case 'm':
- ch_buyitem(10, CHICKEN_PIC "/buymedicine", &mychicken->medicine, 1);
+ ch_buyitem(10, CHICKEN_PIC "/buymedicine", &mychicken->medicine);
break;
case 'N':
case 'n':
diff --git a/pttbbs/mbbsd/gamble.c b/pttbbs/mbbsd/gamble.c
index 87848f5a..6409a134 100644
--- a/pttbbs/mbbsd/gamble.c
+++ b/pttbbs/mbbsd/gamble.c
@@ -138,7 +138,8 @@ append_ticket_record(const char *direct, int ch, int n, int count)
}
void
-buy_ticket_ui(int money, const char *picture, int *item, int haveticket)
+buy_ticket_ui(int money, const char *picture, int *item, int type,
+ const char *title)
{
int num = 0;
char buf[5];
@@ -157,10 +158,7 @@ buy_ticket_ui(int money, const char *picture, int *item, int haveticket)
}
*item += num;
- if( haveticket )
- vice(money * num, "½ä½L¶µ¥Ø");
- else
- demoney(-money * num);
+ vice(money * num, "%s½ä½L[ºØÃþ%d,±i¼Æ%d]", title, type+1, num);
// XXX magic numbers 5, 14...
show_file(picture, 5, 14, SHOWFILE_ALLOW_ALL);
pressanykey();
@@ -213,7 +211,8 @@ ticket(int bid)
continue;
n = 0;
- buy_ticket_ui(price, "etc/buyticket", &n, 0);
+ buy_ticket_ui(price, "etc/buyticket", &n, ch,
+ bh ? bh->brdname : BBSMNAME);
if (bid && !dashf(fn_ticket))
goto doesnt_catch_up;
@@ -229,8 +228,9 @@ ticket(int bid)
doesnt_catch_up:
price = price * n;
+ // XXX ³o¬O¦]¬°°±¤î¤Uª`©Ò¥H°h¿ú¡H ·Pı¦n¦MÀI+race condition
if (price > 0)
- deumoney(currutmp->uid, price);
+ vice_to(currutmp->uid, -price, "¤Uª`¥¢±Ñ°h¶O");
vmsg("ªO¥D¤w¸g°±¤î¤Uª`¤F ¤£¯à½äÂP");
unlockutmpmode();
return -1;
@@ -328,7 +328,7 @@ openticket(int bid)
forBM = money * 0.0005;
if(forBM > 500) forBM = 500;
- demoney(forBM);
+ vice(-forBM, "%s ½ä³õ©âÀY", bh->brdname);
mail_redenvelop("[½ä³õ©âÀY]", cuser.userid, forBM, NULL);
money = ticket[bet] ? money * 0.95 / ticket[bet] : 9999999;
} else {
@@ -395,7 +395,7 @@ openticket(int bid)
continue;
if ((uid = searchuser(userid, userid)) == 0)
continue;
- deumoney(uid, money * i);
+ vice_to(uid, -(money * i), BBSMNAME "½ä³õ - ±m²¼[%s]", betname[mybet]);
mail_id(userid, buf, "etc/ticket.win", BBSMNAME "½ä³õ");
}
fclose(fp1);
diff --git a/pttbbs/mbbsd/mbbsd.c b/pttbbs/mbbsd/mbbsd.c
index 0aa6c3fa..794dcd4e 100644
--- a/pttbbs/mbbsd/mbbsd.c
+++ b/pttbbs/mbbsd/mbbsd.c
@@ -1335,7 +1335,7 @@ user_login(void)
// since only one special now, let's write directly...
if (strcmp(fn, "@calendar") == 0)
calendar();
- } else {
+ } else if (*fn) {
// use NA+pause or YEA?
more(fn, YEA);
}
diff --git a/pttbbs/mbbsd/menu.c b/pttbbs/mbbsd/menu.c
index 183cf7ed..49216be2 100644
--- a/pttbbs/mbbsd/menu.c
+++ b/pttbbs/mbbsd/menu.c
@@ -634,6 +634,22 @@ static int u_view_recentlogin()
return more(fn, YEA);
}
+static int u_view_recentvice()
+{
+ char fn[PATHLEN];
+ clear();
+ move(10, 0);
+
+ outs("\t½Ðª`·N - ¦¹¸ê®Æ¤´¦b¹êÅ礤¡A¶È¨Ñ°Ñ¦Ò¡C\n\n"
+ "\t³¡¥÷ª÷¿ú¥æ©öºØÃþ(¦p¨t²Î½ä½L¶}¼ú)¥i¯à¼È®É¤£·|¥X²{¦b¦Cªí¤º¡C\n"
+ "\t¤]´N¬O»¡±z¤â¤Wªºª÷¿ú¼Æ¥Ø¦³¥i¯à»P³Ì«á¦C¥X¼Æ¦r¤£¦X¡C\n\n"
+ );
+ pressanykey();
+
+ setuserfile(fn, FN_RECENTVICE);
+ return more(fn, YEA);
+}
+
static const commands_t myfilelist[] = {
{u_editplan, PERM_LOGINOK, "QQueryEdit ½s¿è¦W¤ùÀÉ"},
{u_editsig, PERM_LOGINOK, "SSignature ½s¿èñ¦WÀÉ"},
@@ -641,7 +657,8 @@ static const commands_t myfilelist[] = {
};
static const commands_t myuserlog[] = {
- {u_view_recentlogin, 0, "LLRecent Login ³Ìªñ¤W¯¸°O¿ý"},
+ {u_view_recentlogin, 0, "LLRecent Login ³Ìªñ¤W¯¸°O¿ý"},
+ {u_view_recentvice, 0, "VVRecent Vice ³Ìªñ¥æ©ö°O¿ý"},
{NULL, 0, NULL}
};
@@ -676,7 +693,7 @@ static const commands_t userlist[] = {
{calendar, PERM_LOGINOK, "CCalendar ¦æ¨Æ¾ä"},
{u_loginview, PERM_BASIC, "VVLogin View ¿ï¾Ü¶i¯¸µe­±"},
{u_myfiles, PERM_LOGINOK, "MMy Files ¡i­Ó¤HÀɮסj (¦W¤ù,ñ¦WÀÉ...)"},
- {u_mylogs, PERM_LOGINOK, "LLMy Logs ¡i­Ó¤H°O¿ý¡j (³Ìªñ¤W½u...)"},
+ {u_mylogs, PERM_LOGINOK, "LLMy Logs ¡i­Ó¤H°O¿ý¡j (³Ìªñ¤W½u,ª÷¿ú...)"},
{u_cloak, PERM_LOGINOK, "KKCloak Áô¨­³N"},
{u_register, MENU_UNREGONLY, "RRegister ¶ñ¼g¡mµù¥U¥Ó½Ð³æ¡n"},
#ifdef ASSESS
@@ -788,7 +805,6 @@ static const commands_t xyzlist[] = {
{x_program, 0, "PProgram ¥»µ{¦¡¤§ª©¥»»Pª©Åv«Å§i"},
#endif
{x_history, 0, "HHistory ¡m§Ú­Ìªº¦¨ªø¡n"},
- {x_note, 0, "NNote ¡m»Ä²¢­W»¶¬y¨¥ªO¡n"},
{x_login,0, "SSystem ¡m¨t²Î­«­n¤½§i¡n"},
#ifdef HAVE_SYSUPDATES
{x_sys_updates,0,"LLUpdates ¡m¥»¯¸¨t²Îµ{¦¡§ó·s¬ö¿ý¡n"},
@@ -807,9 +823,9 @@ static const commands_t xyzlist[] = {
static const commands_t moneylist[] = {
{p_give, 0, "00Give µ¹¨ä¥L¤H¿ú"},
{save_violatelaw, 0,"11ViolateLaw ú»@³æ"},
- {p_from, 0, "33From ¼È®É­×§ï¬G¶m $49 /¦¸"},
- {ordersong,0, "44OSong ¼Ú®á°ÊºAÂIºq¾÷ $200 /¦¸"},
- {p_exmail, 0, "55Exmail ÁʶR«H½c $1000/«Ê"},
+ {p_from, 0, "33From ¼È®É­×§ï¬G¶m "},
+ {ordersong,0, "44OSong ¼Ú®á°ÊºAÂIºq¾÷"},
+ {p_exmail, 0, "55Exmail ÁʶR«H½c $1000/«Ê"},
{NULL, 0, NULL}
};
@@ -852,7 +868,6 @@ static int chessroom();
/* Ptt Play menu */
static const commands_t playlist[] = {
- {note, PERM_LOGINOK, "NNote ¡i ¨è¨è¬y¨¥ªO ¡j"},
{p_money,PERM_LOGINOK, "PPay ¡i" ANSI_COLOR(1;31)
" " BBSMNAME2 "¶q³c©± " ANSI_RESET "¡j"},
{chicken_main,PERM_LOGINOK,
@@ -886,10 +901,9 @@ static int chessroom() {
static const commands_t plist[] = {
{ticket_main, PERM_LOGINOK, "11Gamble ¡i " BBSMNAME2 "½ä³õ ¡j"},
- {vice_main, PERM_LOGINOK, "22Vice ¡i µo²¼¹ï¼ú ¡j"},
- {g_card_jack, PERM_LOGINOK, "33Jack ¡i ¶Â³Ç§J ¡j"},
- {g_ten_helf, PERM_LOGINOK, "44Tenhalf ¡i ¤QÂI¥b ¡j"},
- {card_99, PERM_LOGINOK, "55Nine ¡i ¤E¤Q¤E ¡j"},
+ {g_card_jack, PERM_LOGINOK, "22Jack ¡i ¶Â³Ç§J ¡j"},
+ {g_ten_helf, PERM_LOGINOK, "33Tenhalf ¡i ¤QÂI¥b ¡j"},
+ {card_99, PERM_LOGINOK, "44Nine ¡i ¤E¤Q¤E ¡j"},
{NULL, 0, NULL}
};
diff --git a/pttbbs/mbbsd/ordersong.c b/pttbbs/mbbsd/ordersong.c
index e55f769c..57b6473c 100644
--- a/pttbbs/mbbsd/ordersong.c
+++ b/pttbbs/mbbsd/ordersong.c
@@ -6,7 +6,13 @@
#define lockbreak(unmode, state) if(lockutmpmode(unmode, state)) break
#define SONGBOOK "etc/SONGBOOK"
#define OSONGPATH "etc/SONGO"
-#define ORDER_SONG_COST (200) // how much to order a song
+
+#ifndef ORDERSONG_MIN_NUMPOST
+#define ORDERSONG_MIN_NUMPOST (3)
+#endif
+#ifndef ORDERSONG_MAX_BADPOST
+#define ORDERSONG_MAX_BADPOST (2)
+#endif
#define MAX_SONGS (MAX_ADBANNER-100) // (400) XXX MAX_SONGS should be fewer than MAX_ADBANNER.
@@ -24,8 +30,22 @@ do_order_song(void)
int nsongs;
char save_title[STRLEN];
+ // ¥Ñ©óÅܧK¶O¤F¡A§ï¦¨­n¤å³¹¼Æ§a
+#ifdef ORDERSONG_MIN_NUMPOST
+ if (cuser.numposts < ORDERSONG_MIN_NUMPOST) {
+ vmsgf("¬°ÁקKÀݥΡAÂIºq«e½Ð¥ýÀò±o %d ½g¦³®Ä¤å³¹°O¿ý",
+ ORDERSONG_MIN_NUMPOST);
+ return 0;
+ }
+#endif
+#ifdef ORDERSONG_MAX_BADPOST
+ if (cuser.badpost > ORDERSONG_MAX_BADPOST) {
+ vmsgf("¬°ÁקKÀݥΡAÂIºq«e½Ð¥ý®ø°£¦H¤å°O¿ý¦Ü %d ½g¥H¤U",
+ ORDERSONG_MAX_BADPOST);
+ return 0;
+ }
+#endif
strlcpy(buf, Cdatedate(&now), sizeof(buf));
-
lockreturn0(OSONG, LOCK_MULTI);
pwcuReload();
@@ -65,14 +85,6 @@ do_order_song(void)
}
}
- reload_money();
- if (cuser.money < ORDER_SONG_COST) {
- move(22, 0);
- vmsgf("ÂIºq­n %d ¤¸­ò!....", ORDER_SONG_COST);
- unlockutmpmode();
- return 0;
- }
-
getdata_str(19, 0, "ÂIºqªÌ(¥i°Î¦W): ", sender, sizeof(sender), DOECHO, cuser.userid);
getdata(20, 0, "ÂIµ¹(¥i°Î¦W): ", receiver, sizeof(receiver), DOECHO);
@@ -167,7 +179,6 @@ do_order_song(void)
snprintf(genbuf, sizeof(genbuf), "%s says \"%s\" to %s.",
sender, say, receiver);
log_usies("OSONG", genbuf);
- vice(ORDER_SONG_COST, "ÂIºq");
}
snprintf(save_title, sizeof(save_title), "%s:%s", sender, say);
hold_mail(filename, receiver, save_title);
diff --git a/pttbbs/mbbsd/record.c b/pttbbs/mbbsd/record.c
index fadb9c1e..506640e9 100644
--- a/pttbbs/mbbsd/record.c
+++ b/pttbbs/mbbsd/record.c
@@ -438,6 +438,62 @@ append_record_forward(char *fpath, fileheader_t * record, int size, const char *
return 0;
}
+// return 1 if rotated, otherwise 0
+int
+rotate_bin_logfile(const char *filename, off_t record_size,
+ off_t max_size, float keep_ratio)
+{
+ off_t sz = dashs(filename);
+ assert(keep_ratio >= 0 && keep_ratio <= 1.0f);
+
+ if (sz < max_size)
+ return 0;
+
+ // delete from head
+ delete_records(filename, record_size, 1,
+ (1 - keep_ratio) * max_size / record_size );
+ return 1;
+}
+
+int
+rotate_text_logfile(const char *filename, off_t max_size, float keep_ratio)
+{
+ off_t sz = dashs(filename), newsz;
+ char *buf, *newent;
+ FILE *fp;
+ assert(keep_ratio >= 0 && keep_ratio <= 1.0f);
+
+ if (sz < max_size)
+ return 0;
+
+ // FIXME we sould lock the file here.
+ // however since these log are just for reference...
+ // let's pretend there's no race condition with it.
+
+ // now, calculate a starting seek point
+ fp = fopen(filename, "r+b");
+ fseek(fp, - keep_ratio * max_size, SEEK_END);
+ newsz = sz - ftell(fp);
+ buf = (char*)malloc(newsz);
+ memset(buf, 0, newsz);
+ assert(buf);
+ fread(buf, newsz, 1, fp);
+ fclose(fp);
+
+ // find a newline or \0
+ newent = buf;
+ while (*newent && *newent++ != '\n') ;
+
+ // replace file with new content
+ fp = fopen(filename, "wb");
+ fwrite(newent, 1, newsz - (newent - buf), fp);
+ fclose(fp);
+
+ free(buf);
+ return 1;
+}
+
+
void
setaidfile(char *buf, const char *bn, aidu_t aidu)
{
diff --git a/pttbbs/mbbsd/user.c b/pttbbs/mbbsd/user.c
index ea0fed33..27e20e92 100644
--- a/pttbbs/mbbsd/user.c
+++ b/pttbbs/mbbsd/user.c
@@ -62,9 +62,14 @@ u_loginview(void)
clear();
move(4, 0);
- for (i = 0; i < NUMVIEWFILE && loginview_file[i][0]; i++)
+ for (i = 0; i < NUMVIEWFILE && loginview_file[i][0]; i++) {
+ // skip deprecated items
+ const char *desc = loginview_file[i][1];
+ if (!desc || !*desc)
+ desc = "(«O¯d)";
prints(" %c. %-20s %-15s \n", 'A' + i,
- loginview_file[i][1], ((pbits >> i) & 1 ? "£¾" : "¢æ"));
+ desc, ((pbits >> i) & 1 ? "£¾" : "¢æ"));
+ }
in = i;
clrtobot();
diff --git a/pttbbs/mbbsd/var.c b/pttbbs/mbbsd/var.c
index 39197a46..0d73132e 100644
--- a/pttbbs/mbbsd/var.c
+++ b/pttbbs/mbbsd/var.c
@@ -118,7 +118,6 @@ unsigned int currstat;
char * const fn_passwd = FN_PASSWD;
char * const fn_board = FN_BOARD;
-char * const fn_note_ans = FN_NOTE_ANS;
const char * const fn_plans = "plans";
const char * const fn_writelog = "writelog";
const char * const fn_talklog = "talklog";
@@ -134,7 +133,7 @@ const char * const fn_boardhelp = FN_BOARDHELP;
/* are descript in userec.loginview */
char * const loginview_file[NUMVIEWFILE][2] = {
- {FN_NOTE_ANS, "»Ä²¢­W»¶¬y¨¥ªO"},
+ {"", NULL}, // NOTE_ANS, deprecated
{FN_TOPSONG, "ÂIºq±Æ¦æº]"},
{"etc/topusr", "¤Q¤j±Æ¦æº]"},
{"etc/topusr100", "¦Ê¤j±Æ¦æº]"},
@@ -148,7 +147,6 @@ char * const loginview_file[NUMVIEWFILE][2] = {
{"etc/topboardman", "ºëµØ°Ï±Æ¦æº]"},
{"etc/topboard.tmp", "¬ÝªO¤H®ð±Æ¦æº]"},
{"@calendar", "­Ó¤H¦æ¨Æ¾ä"},
- {NULL, NULL}
};
/* message */
diff --git a/pttbbs/mbbsd/vice.c b/pttbbs/mbbsd/vice.c
deleted file mode 100644
index 14e4e8f4..00000000
--- a/pttbbs/mbbsd/vice.c
+++ /dev/null
@@ -1,153 +0,0 @@
-/* $Id$ */
-#include "bbs.h"
-
-#define VICE_PLAY BBSHOME "/etc/vice/vice.play"
-#define VICE_DATA "vice.new"
-#define VICE_BINGO BBSHOME "/etc/vice.bingo"
-#define VICE_SHOW BBSHOME "/etc/vice.show"
-#define VICE_LOST BBSHOME "/etc/vice/vice.lost"
-#define VICE_WIN BBSHOME "/etc/vice/vice.win"
-#define VICE_END BBSHOME "/etc/vice/vice.end"
-#define VICE_NO BBSHOME "/etc/vice/vice.no"
-#define MAX_NO_PICTURE 2
-#define MAX_WIN_PICTURE 2
-#define MAX_LOST_PICTURE 3
-#define MAX_END_PICTURE 5
-
-static int
-vice_load(char tbingo[6][15])
-{
- FILE *fb = fopen(VICE_BINGO, "r");
- char buf[16], *ptr;
- int i = 0;
- if (!fb)
- return -1;
- bzero((char *)tbingo, 6*15);
- while (i < 6 && fgets(buf, 15, fb)) {
- if ((ptr = strchr(buf, '\n')))
- *ptr = 0;
- strcpy(tbingo[i++], buf);
- }
- fclose(fb);
- return 0;
-}
-
-static int
-check(char tbingo[6][15], const char *data)
-{
- int i = 0, j;
-
- if (!strcmp(data, tbingo[0]))
- return 8;
-
- for (j = 8; j > 0; j--)
- for (i = 1; i < 6; i++)
- if (!strncmp(data + 8 - j, tbingo[i] + 8 - j, j))
- return j - 1;
- return 0;
-}
-/* TODO Ptt:showfile ran_showfile more ¤TªÌ­n¦X */
-static int
-ran_showfile(int y, int x, const char *filename, int maxnum)
-{
- FILE *fs;
- char buf[512];
-
- bzero(buf, sizeof(buf));
- snprintf(buf, sizeof(buf), "%s%d", filename, (int)(random() % maxnum + 1));
- if (!(fs = fopen(buf, "r"))) {
- move(10, 10);
- prints("can't open file: %s", buf);
- return 0;
- }
- move(y, x);
-
- while (fgets(buf, sizeof(buf), fs))
- outs(buf);
-
- fclose(fs);
- return 1;
-}
-
-static int
-ran_showmfile(const char *filename, int maxnum)
-{
- char buf[256];
-
- snprintf(buf, sizeof(buf), "%s%d", filename, (int)(random() % maxnum + 1));
- return more(buf, YEA);
-}
-
-
-int
-vice_main(void)
-{
- FILE *fd;
- char tbingo[6][15];
- char buf_data[256],
- serial[16], ch[2], *ptr;
- int TABLE[] = {0, 10, 200, 1000, 4000, 10000, 40000, 100000, 200000};
- int total = 0, money, i = 4, j = 0;
-
- setuserfile(buf_data, VICE_DATA);
- if (!dashf(buf_data)) {
- ran_showmfile(VICE_NO, MAX_NO_PICTURE);
- return 0;
- }
- if (vice_load(tbingo) < 0)
- return -1;
- clear();
- ran_showfile(0, 0, VICE_PLAY, 1);
- ran_showfile(10, 0, VICE_SHOW, 1);
-
- if (!(fd = fopen(buf_data, "r")))
- return 0;
- j = 0;
- i = 0;
- move(10, 24);
- clrtoeol();
- outs("³o¤@´Áªºµo²¼¸¹½X");
- // FIXME ·íµo²¼¦h©ó¤@¦æ, ¶}¼úªº¸¹½X´N·|³Q»\±¼
- while (fgets(serial, 15, fd)) {
- if ((ptr = strchr(serial, '\r')))
- *ptr = 0;
- if (j == 0)
- i++;
- if( i >= 14 )
- break;
- move(10 + i, 24 + j);
- outs(serial);
- j += 9;
- j %= 45;
- }
- getdata(8, 0, "«ö'c'¶}©l¹ï¼ú¤F(©Î¬O¥ô·NÁäÂ÷¶})): ",
- ch, sizeof(ch), LCECHO);
- if (ch[0] != 'c' || lockutmpmode(VICE, LOCK_MULTI)) {
- fclose(fd);
- return 0;
- }
- showtitle("µo²¼¹ï¼ú", BBSNAME);
- rewind(fd);
- while (fgets(serial, 15, fd)) {
- if ((ptr = strchr(serial, '\n')))
- *ptr = 0;
- money = TABLE[check(tbingo, serial)];
- total += money;
- prints("%s ¤¤¤F %d\n", serial, money);
- }
- pressanykey();
- if (total > 0) {
- ran_showmfile(VICE_WIN, MAX_WIN_PICTURE);
- move(22, 0);
- clrtoeol();
- prints("¥þ³¡ªºµo²¼¤¤¤F %d ¶ô¿ú\n", total);
- demoney(total);
- } else
- ran_showmfile(VICE_LOST, MAX_LOST_PICTURE);
-
- fclose(fd);
- unlink(buf_data);
- pressanykey();
- unlockutmpmode();
- return 0;
-}
diff --git a/pttbbs/mbbsd/xyz.c b/pttbbs/mbbsd/xyz.c
index 4523536a..96fd55d7 100644
--- a/pttbbs/mbbsd/xyz.c
+++ b/pttbbs/mbbsd/xyz.c
@@ -32,13 +32,6 @@ x_boards(void)
#endif
int
-x_note(void)
-{
- more(fn_note_ans, YEA);
- return 0;
-}
-
-int
x_issue(void)
{
more("etc/day", YEA);
@@ -73,121 +66,6 @@ x_login(void)
return 0;
}
-int
-note(void)
-{
- char *fn_note_tmp = "note.tmp";
- char *fn_note_dat = "note.dat";
- int total = 0, i, collect, len;
- struct stat st;
- char buf[256], buf2[80];
- int fd, fx;
- FILE *fp, *foo;
-
- typedef struct notedata_t {
- time4_t date;
- char userid[IDLEN + 1];
- char nickname[19];
- char buf[3][80];
- } notedata_t;
- notedata_t myitem;
-
- if (cuser.money < 5) {
- vmsg(ANSI_COLOR(1;41) " «u§r! ­n§ë¤­¤¸¤~¯à¯d¨¥...¨S¿ú­C.." ANSI_RESET);
- return 0;
- }
- setutmpmode(EDNOTE);
- do {
- myitem.buf[0][0] = myitem.buf[1][0] = myitem.buf[2][0] = '\0';
- move(12, 0);
- clrtobot();
- outs("\n§ë¤­¤¸... ¹Í... ½Ð¯d¨¥ (¦Ü¦h¤T¦æ)¡A«ö[Enter]µ²§ô");
- for (i = 0; (i < 3) && getdata(16 + i, 0, "¡G", myitem.buf[i],
- sizeof(myitem.buf[i]) - 5, DOECHO)
- && *myitem.buf[i]; i++);
- getdata(b_lines - 1, 0, "(S)Àx¦s (E)­«·s¨Ó¹L (Q)¨ú®ø¡H[S] ",
- buf, 3, LCECHO);
-
- if (buf[0] == 'q' || (i == 0 && *buf != 'e'))
- return 0;
- } while (buf[0] == 'e');
- demoney(-5);
- strcpy(myitem.userid, cuser.userid);
- strlcpy(myitem.nickname, cuser.nickname, sizeof(myitem.nickname));
- myitem.date = now;
-
- /* begin load file */
- if ((foo = fopen(".note", "a")) == NULL)
- return 0;
-
- unlink(fn_note_ans); // remove first to prevent mmap(pmore) crash
- if ((fp = fopen(fn_note_ans, "w")) == NULL) {
- fclose(fp);
- return 0;
- }
-
- if ((fx = open(fn_note_tmp, O_WRONLY | O_CREAT, 0644)) <= 0) {
- fclose(foo);
- fclose(fp);
- return 0;
- }
-
- if ((fd = open(fn_note_dat, O_RDONLY)) == -1)
- total = 1;
- else if (fstat(fd, &st) != -1) {
- total = st.st_size / sizeof(notedata_t) + 1;
- if (total > MAX_NOTE)
- total = MAX_NOTE;
- }
- fputs(ANSI_COLOR(1;31;44) "¡ó¢s¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢t"
- ANSI_COLOR(37) "»Ä²¢­W»¶ªO" ANSI_COLOR(31) "¢u¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢s¡ó"
- ANSI_RESET "\n", fp);
- collect = 1;
-
- while (total) {
- snprintf(buf, sizeof(buf), ANSI_COLOR(1;31) "ùÝ¢t" ANSI_COLOR(32) " %s " ANSI_COLOR(37) "(%s)",
- myitem.userid, myitem.nickname);
- len = strlen(buf);
-
- for (i = len; i < 71; i++)
- strcat(buf, " ");
- snprintf(buf2, sizeof(buf2), " " ANSI_COLOR(1;36) "%.16s" ANSI_COLOR(31) " ¢uùß" ANSI_RESET "\n",
- Cdate(&(myitem.date)));
- strcat(buf, buf2);
- fputs(buf, fp);
- if (collect)
- fputs(buf, foo);
- for (i = 0; i < 3 && *myitem.buf[i]; i++) {
- fprintf(fp, ANSI_COLOR(1;31) "¢x" ANSI_RESET "%-74.74s" ANSI_COLOR(1;31) "¢x" ANSI_RESET "\n",
- myitem.buf[i]);
- if (collect)
- fprintf(foo, ANSI_COLOR(1;31) "¢x" ANSI_RESET "%-74.74s" ANSI_COLOR(1;31) "¢x" ANSI_RESET "\n",
- myitem.buf[i]);
- }
- fputs(ANSI_COLOR(1;31) "ùã¢s¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w"
- "¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢sùå" ANSI_RESET "\n", fp);
-
- if (collect) {
- fputs(ANSI_COLOR(1;31) "ùã¢s¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w"
- "¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢sùå" ANSI_RESET "\n", foo);
- fclose(foo);
- collect = 0;
- }
- write(fx, &myitem, sizeof(myitem));
-
- if (--total)
- read(fd, (char *)&myitem, sizeof(myitem));
- }
- fputs(ANSI_COLOR(1;31;44) "¡ó¢r¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w"
- "¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢r¡ó" ANSI_RESET "\n", fp);
- fclose(fp);
- close(fd);
- close(fx);
- Rename(fn_note_tmp, fn_note_dat);
- more(fn_note_ans, YEA);
- return 0;
-}
-
static void
mail_sysop(void)
{
@@ -264,15 +142,6 @@ Goodbye(void)
return 0;
adbanner_goodbye();
- if (cuser.userlevel) {
- getdata(b_lines - 1, 0,
- "(G)ÀH­·¦Ó³u (M)¦«¹Ú¯¸ªø (N)»Ä²¢­W»¶¬y¨¥ªO¡H[G] ",
- genbuf, 3, LCECHO);
- if (genbuf[0] == 'm')
- mail_sysop();
- else if (genbuf[0] == 'n')
- note();
- }
show_80x24_screen("etc/Logout");
{
int diff = (now - login_start_time) / 60;