summaryrefslogtreecommitdiffstats
path: root/mbbsd/bbs.c
diff options
context:
space:
mode:
Diffstat (limited to 'mbbsd/bbs.c')
-rw-r--r--mbbsd/bbs.c116
1 files changed, 57 insertions, 59 deletions
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index 1a455c75..1c75e1a6 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,16 @@ 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);
+ //passwd_update(usernum, &cuser);
+ u_exit("Cross Post");
exit(0);
}
@@ -58,16 +57,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 +84,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 +94,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;
}
@@ -341,7 +340,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 +376,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 +419,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");
@@ -529,7 +528,7 @@ do_general(int isbid)
if (!(currmode & MODE_POST)
#ifdef FOREIGN_REG
// 不是外籍使用者在 PttForeign 板
- && !((cuser.uflag2 & FOREIGN) && strcmp(bp->brdname, "PttForeign") == 0)
+ && !((cuser->uflag2 & FOREIGN) && strcmp(bp->brdname, "PttForeign") == 0)
#endif
) {
move(5, 10);
@@ -656,9 +655,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 +700,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 +710,7 @@ do_general(int isbid)
prints(" 稿酬 %d 銀。",aborted);
demoney(aborted);
}
- passwd_update(usernum, &cuser); /* post 數 */
+ // passwd_update(usernum, &cuser); /* post 數 */
} else
outs("測試信件不列入紀錄,敬請包涵。");
@@ -735,7 +734,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)
@@ -942,7 +941,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) )
+ (!(currmode & MODE_POST) || strcmp(fhdr->owner, cuser->userid) != 0) )
return DONOTHING;
if( currmode & MODE_SELECT )
@@ -1052,7 +1051,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 +1082,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 +1110,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();
@@ -1371,7 +1370,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 +1402,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 +1418,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 +1562,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 +1591,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 +1599,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 +1609,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);
@@ -1675,12 +1674,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 +1698,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 +1795,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 +1848,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 +1916,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 +1929,15 @@ 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 數 */
+ // passwd_update(usernum, &cuser); /* post 數 */
prints("%s,您的文章減為 %d 篇,支付清潔費 %d 銀", msg_del_ok,
- cuser.numposts, fhdr->money);
+ cuser->numposts, fhdr->money);
refresh();
pressanykey();
}
@@ -2015,7 +2013,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);
@@ -2257,11 +2255,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;
@@ -2673,7 +2671,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);
}
}