From d7dd7919a06864cffb048458575a46e49ac79424 Mon Sep 17 00:00:00 2001 From: ptt Date: Wed, 23 Jun 2004 16:51:24 +0000 Subject: merge tools for fpg git-svn-id: http://opensvn.csie.org/pttbbs/branches/Ptt.merge@2077 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- include/fpg.h | 136 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/proto.h | 5 +++ mbbsd/Makefile | 6 +++ mbbsd/menu.c | 3 ++ mbbsd/merge.c | 128 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 278 insertions(+) create mode 100644 include/fpg.h create mode 100644 mbbsd/merge.c diff --git a/include/fpg.h b/include/fpg.h new file mode 100644 index 00000000..8014c5b4 --- /dev/null +++ b/include/fpg.h @@ -0,0 +1,136 @@ + + +#define STRLEN 80 /* Length of most string data */ +#define BTLEN 48 /* Length of board title */ +#define FTTLEN 72 /* Length of title */ +#define NAMELEN 40 /* Length of username/realname */ +#define FNLEN 33 /* Length of filename */ +#define IDLEN 12 /* Length of bid/uid */ +#define PASSLEN 14 /* Length of encrypted passwd field */ +#define REGLEN 38 /* Length of registration data */ + +typedef unsigned char uschar; /* length = 1 */ +typedef unsigned int usint; /* length = 4 */ + + +typedef struct +{ + uschar id; + char broken; +} WEAPONARMOR; + +typedef struct +{ + char id; + char name[IDLEN + 1]; + char lv; + short lp; + ushort mlp; + short hp; + ushort mhp; + uschar po; + uschar st; + uschar ag; + uschar lu; + int ex; + char emotion; + char moral; + char wisdom; + char will; + char charm; + WEAPONARMOR weapon; + WEAPONARMOR armor[4]; + uschar flag; + char hungry; + char sick; + char angry; +} PET; + +typedef struct +{ + char userid[IDLEN + 1]; + char realname[20]; + char username[24]; + char passwd[PASSLEN]; + ushort uflag; + usint userlevel; + ushort numlogins; + ushort numposts; + time_t firstlogin; + time_t lastlogin; + char lasthost[16]; + char email[50]; + char address[50]; + char justify[REGLEN + 1]; + uschar month; + uschar day; + uschar year; + uschar sex; + uschar state; + ushort mailk; + ushort keepmail; + int money; + ushort totalday; + uschar totalhour; + uschar totalmin; + int market[10]; + short locate; + char action; + char direct; + char speed; + char count; + uschar landnum; + uschar tool[10]; + char NAME[IDLEN + 1]; + char LV; + short HP; + short MHP; + short MP; + short MMP; + short WC; + short AC; + short PO; + short ST; + short AG; + short LU; + int EX; + char EVENT; + uschar WA[6]; + uschar USE[10]; + uschar MAGIC[5]; + uschar NOWOCCUPATION; + short OCCUPATION[4]; + uschar cardfightnum; + uschar cardfight[20]; + uschar dragon[5]; + PET pet; + char left[40]; +} ACCT; + +struct fileheader +{ + char filename[FNLEN]; /* M.9876543210.A */ + char savemode; /* file save mode */ + char owner[IDLEN + 2]; /* uid[.] */ + char date[6]; /* [02/02] or space(5) */ + char title[FTTLEN + 1]; + uschar filemode; /* must be last field @ boards.c */ +}; +typedef struct fileheader fileheader; + +struct boardheader +{ + char brdname[IDLEN + 1]; /* bid */ + char title[BTLEN + 1]; + char BM[IDLEN * 3 + 3]; /* BMs' uid, token '/' */ + char group[9]; /* 看板分類 */ + char type; /* 看板性質: 轉信?目錄? */ + char pad[1]; + time_t bupdate; /* note update time */ + char pad2[3]; + uschar bvote; /* Vote flags */ + time_t vtime; /* Vote close time */ + usint level; +}; +typedef struct boardheader boardheader; + diff --git a/include/proto.h b/include/proto.h index 13bbd834..2096eb29 100644 --- a/include/proto.h +++ b/include/proto.h @@ -338,6 +338,11 @@ int Xyz(void); int Play_Play(void); int Name_Menu(void); +#ifdef MERGEBBS +/* merge */ +int m_fpg(void); +#endif + /* more */ int more(char *fpath, int promptend); diff --git a/mbbsd/Makefile b/mbbsd/Makefile index 1a078380..c60550f3 100644 --- a/mbbsd/Makefile +++ b/mbbsd/Makefile @@ -7,6 +7,7 @@ CFLAGS+= -DBLOG LDFLAGS+= -L/usr/local/lib/mysql -lmysqlclient .endif + PROG= mbbsd OBJS= admin.o announce.o args.o assess.o bbs.o board.o cache.o cal.o card.o\ chat.o chc.o chicken.o convert.o dark.o edit.o fav.o friend.o gamble.o\ @@ -15,6 +16,11 @@ OBJS= admin.o announce.o args.o assess.o bbs.o board.o cache.o cal.o card.o\ register.o screen.o stuff.o talk.o term.o topsong.o user.o brc.o\ vice.o vote.o xyz.o voteboard.o syspost.o var.o passwd.o calendar.o +.if defined(MERGEBBS) +CFLAGS+= -DMERGEBBS +OBJS+= merge.o +.endif + .SUFFIXES: .c .o .c.o: ../include/var.h $(CCACHE) $(CC) $(CFLAGS) -c $*.c diff --git a/mbbsd/menu.c b/mbbsd/menu.c index b1c45f4b..71b63718 100644 --- a/mbbsd/menu.c +++ b/mbbsd/menu.c @@ -393,6 +393,9 @@ const static commands_t userlist[] = { #endif {u_register, PERM_BASIC, "RRegister 填寫《註冊申請單》"}, {u_list, PERM_SYSOP, "UUsers 列出註冊名單"}, +#ifdef MERGEBBS + {m_fpg, PERM_LOGINOK, "FFPG import 花園變身術"}, +#endif {NULL, 0, NULL} }; diff --git a/mbbsd/merge.c b/mbbsd/merge.c new file mode 100644 index 00000000..5494e3df --- /dev/null +++ b/mbbsd/merge.c @@ -0,0 +1,128 @@ +/* $Id: merge.c 2060 2004-06-11 17:18:06Z Ptt $ */ +#define _XOPEN_SOURCE +#define _ISOC99_SOURCE +/* this is a interface provided when we merge BBS */ +#include "bbs.h" +#include "fpg.h" + +int +m_fpg() +{ + char genbuf[256], buf[1024], userid[25], passbuf[24]; + int count=0, i; + FILE *fp; + ACCT man; + time_t d; + + clear(); + move(1,0); + + outs( + "此功\能是專門給各位資深花園使用者,\n" + "把自己的變為資深Ptt使用者,讓花園的使用者享有平等安全的環境.\n" + "直接按[Enter]離開.\n\n" + "特別叮嚀: \n" + " 為了帳號安全,您只有連續三次密碼錯誤的機會,請小心輸入.\n" + " 連續三次錯誤您的變身功\能就會被開罰單並直接通知站長.\n" + " 請不要在變身過程中不正常斷線, 刻意斷線變半獸人站長不負責唷."); + + if(search_ulistn(usernum,2)) + {vmsg("請不要multi-login時使用, 以免變身失敗"); return 0;} + do + { + if(!getdata(8,0, "請小心輸入小魚的ID [英文大小寫要完全正確]:", userid, 20, + DOECHO)) return 0; + if(bad_user_id(userid)) continue; + sprintf(genbuf, "/home/bbs/fpg/home/%c/%s.ACT",userid[0], userid); + if(!(fp=fopen(genbuf, "r"))) + { + vmsg("查無此人或已經匯入過..請注意大小寫 "); + continue; + } + count = fread(&man, sizeof(man), 1, fp); + fclose(fp); + }while(!count); + count = 0; + do{ + getdata(9,0, "請小心輸入您在小魚的密碼:", passbuf, sizeof(passbuf), + NOECHO); + if(++count>=3) + { + cuser.userlevel |= PERM_VIOLATELAW; + cuser.vl_count++; + passwd_update(usernum, &cuser); + post_violatelaw(cuser.userid, "[PTT警察]", "測試小魚帳號錯誤三次", + "違法觀察"); + mail_violatelaw(cuser.userid, "[PTT警察]", "測試小魚帳號錯誤三次", + "違法觀察"); + + return 0; + } + } while(!checkpasswd(man.passwd, passbuf)); + if(!dashf(genbuf)) // avoid multi-login + { + vmsg("查無此人或已經匯入過..請注意大小寫 "); + return 0; + } + sprintf(buf,"%s.done",genbuf); + rename(genbuf,buf); + move(10,0); + reload_money(); + + prints("您的花園幣有 %d 換算成 Ptt 幣為 %d (匯率 155:1), 匯入後共有 %d\n", + man.money, man.money/155, cuser.money + man.money/155); + demoney(man.money/155); + + cuser.exmailbox += man.mailk; + prints("您的花園信相有 %d , 匯入後共有 %d\n", + man.mailk, cuser.exmailbox ); + + if(cuser.firstlogin>man.firstlogin) d = man.firstlogin; + else d = cuser.firstlogin; + prints("花園註冊日期 %s 與此帳號 %s 比 將取 %s", + Cdate(&man.firstlogin), Cdate(&cuser.firstlogin), + Cdate(&d) ); + cuser.firstlogin = d; + + if(cuser.numlogins < man.numlogins) i = man.numlogins; + else i = cuser.numlogins; + + prints("花園進站次數 %d 與此帳號 %d 比 將取 %d", man.numlogins, + cuser.numlogins, i); + cuser.numlogins = i; + + if(cuser.numposts < man.numposts ) i = man.numposts; + else i = cuser.numposts; + prints("花園文章次數 %d 與此帳號 %d 比 將取 %d", man.numposts,cuser.numposts, + i); + cuser.numposts = i; + while(search_ulistn(usernum,2)) + {vmsg("請將重覆上站其他線關閉! 再繼續");} + passwd_update(usernum, &cuser); + sethomeman(genbuf, cuser.userid); + mkdir(genbuf, 0600); + sprintf(buf, "cd home/bbs/fpg/tmp; tar zxvf ../home/%c/%s.tgz" + "cd home/bbs/home/%c; mv %s ../../../..;" + "cd ../../../../%s; ", + userid[0], userid, userid[0], userid, userid); + i = 0; + if (getans("是否匯入個人信箱以及信箱精華區? (Y/n)")!='n') + { + sprintf(genbuf, + "mv M.* /home/bbs/home/%c/%s;" + "mv man/* /home/bbs/home/%c/%s/man;", cuser.userid[0], cuser.userid, + cuser.userid[0], cuser.userid); + strcat(buf,genbuf); + i++; + } + if (getans("是否匯入好友名單? (會覆蓋\現有設定, ID可能是不同人)? (y/N)")=='y') + { + sprintf(genbuf,"mv overrides /home/bbs/home/%c/%s; ", + cuser.userid[0], cuser.userid); + strcat(buf, genbuf); + i++; + } + if(i) system(buf); + vmsg("恭喜您完成帳號變身.."); + return 0; +} -- cgit v1.2.3