From 93e84c9d6c3c5d95e21d0a30bd32e8c58f66e40e Mon Sep 17 00:00:00 2001 From: ptt Date: Sat, 30 Oct 2004 03:08:26 +0000 Subject: feature for SOB users to import account git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2285 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- include/fpg.h | 179 ++++++++++++++++++-------------------------------------- include/proto.h | 2 +- mbbsd/menu.c | 2 +- mbbsd/merge.c | 72 +++++++++-------------- 4 files changed, 86 insertions(+), 169 deletions(-) diff --git a/include/fpg.h b/include/fpg.h index 57ae46c3..0ceabd73 100644 --- a/include/fpg.h +++ b/include/fpg.h @@ -1,137 +1,72 @@ - - #define STRLEN 80 /* Length of most string data */ +#define BRC_STRLEN 15 /* Length of boardname */ #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 */ + /* Ptt 說這裡有bug*/ #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; - usint bank; - char left[36]; -} ACCT; +typedef unsigned char uschar; /* length = 1 */ +typedef unsigned int usint; /* length = 4 */ +typedef unsigned short int ushort; /* length = 4 */ -struct fileheader +/* ----------------------------------------------------- */ +/* .PASSWDS struct : 512 bytes */ +/* ----------------------------------------------------- */ +struct sobuserec { - 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 */ + char userid[IDLEN + 1]; /* 使用者名稱 13 bytes */ + char realname[20]; /* 真實姓名 20 bytes */ + char username[24]; /* 暱稱 24 bytes */ + char passwd[PASSLEN]; /* 密碼 14 bytes */ + uschar uflag; /* 使用者選項 1 byte */ + usint userlevel; /* 使用者權限 4 bytes */ + ushort numlogins; /* 上站次數 2 bytes */ + ushort numposts; /* POST次數 2 bytes */ + time_t firstlogin; /* 註冊時間 4 bytes */ + time_t lastlogin; /* 前次上站 4 bytes */ + char lasthost[24]; /* 上站地點 24 bytes */ + char vhost[24]; /* 虛擬網址 24 bytes */ + char email[50]; /* E-MAIL 50 bytes */ + char address[50]; /* 地址 50 bytes */ + char justify[REGLEN + 1]; /* 註冊資料 39 bytes */ + uschar month; /* 出生月份 1 byte */ + uschar day; /* 出生日期 1 byte */ + uschar year; /* 出生年份 1 byte */ + uschar sex; /* 性別 1 byte */ + uschar state; /* 狀態?? 1 byte */ + usint habit; /* 喜好設定 4 bytes */ + uschar pager; /* 心情顏色 1 bytes */ + uschar invisible; /* 隱身模式 1 bytes */ + usint exmailbox; /* 信箱封數 4 bytes */ + usint exmailboxk; /* 信箱K數 4 bytes */ + usint toquery; /* 好奇度 4 bytes */ + usint bequery; /* 人氣度 4 bytes */ + char toqid[IDLEN + 1]; /* 前次查誰 13 bytes */ + char beqid[IDLEN + 1]; /* 前次被誰查 13 bytes */ + unsigned long int totaltime; /* 上線總時數 8 bytes */ + usint sendmsg; /* 發訊息次數 4 bytes */ + usint receivemsg; /* 收訊息次數 4 bytes */ + unsigned long int goldmoney; /* 風塵金幣 8 bytes */ + unsigned long int silvermoney; /* 銀幣 8 bytes */ + unsigned long int exp; /* 經驗值 8 bytes */ + time_t dtime; /* 存款時間 4 bytes */ + int scoretimes; /* 評分次數 4 bytes */ + uschar rtimes; /* 填註冊單次數 1 bytes */ + int award; /* 獎懲判斷 4 bytes */ + int pagermode; /* 呼叫器門號 4 bytes */ + char pagernum[7]; /* 呼叫器號碼 7 bytes */ + char feeling[5]; /* 心情指數 5 bytes */ + char title[20]; /* 稱謂(封號) 20 bytes */ + usint five_win; + usint five_lost; + usint five_draw; + char pad[91]; /* 空著填滿至512用 */ }; -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; +typedef struct sobuserec sobuserec; diff --git a/include/proto.h b/include/proto.h index edfad702..ee39868e 100644 --- a/include/proto.h +++ b/include/proto.h @@ -358,7 +358,7 @@ int Name_Menu(void); #ifdef MERGEBBS /* merge */ -int m_fpg(void); +int m_sob(void); void m_sob_brd(char *bname,char *fromdir); #endif diff --git a/mbbsd/menu.c b/mbbsd/menu.c index 2dd14d4e..31589eff 100644 --- a/mbbsd/menu.c +++ b/mbbsd/menu.c @@ -395,7 +395,7 @@ const static commands_t userlist[] = { {u_register, PERM_BASIC, "RRegister 填寫《註冊申請單》"}, {u_list, PERM_SYSOP, "UUsers 列出註冊名單"}, #ifdef MERGEBBS - {m_fpg, PERM_SYSOP, "FFPG Import 花園變身術"}, + {m_sob, PERM_LOGINOK, "SSOB Import 沙灘變身術"}, #endif {NULL, 0, NULL} }; diff --git a/mbbsd/merge.c b/mbbsd/merge.c index 3423e91e..5958e268 100644 --- a/mbbsd/merge.c +++ b/mbbsd/merge.c @@ -6,21 +6,21 @@ #include "fpg.h" int -m_fpg() +m_sob() { char genbuf[256], buf[256], userid[25], passbuf[24], msg[2048]=""; int count=0, i, isimported=0; FILE *fp; - ACCT man; + sobuserec man; time_t d; clear(); move(1,0); outs( - " 小魚的紫色花園,\n" - " 讓花園的使用者轉移個人資產以及重要信用資料, 享有平等安全的環境.\n" - " 如果您不需要, 請直接按[Enter]離開.\n" + " 請注意 這是只給陽光沙灘使用者!\n" + " 讓沙灘的使用者轉移個人資產以及重要信用資料, 享有平等安全的環境.\n" + " 如果您不需要, 請直離開.\n" " -----------------------------------------------------------------\n" " 特別叮嚀:\n" " 為了帳號安全,您只有連續三次密碼錯誤的機會,請小心輸入.\n" @@ -28,12 +28,12 @@ m_fpg() " 請不要在變身過程中不正常斷線, 刻意斷線變半獸人站長不救唷.\n" ); - + if(getkey("是否要繼續?(y/N)")!='y') return 0; if(search_ulistn(usernum,2)) {vmsg("請登出其他視窗, 以免變身失敗"); return 0;} do { - if(!getdata(10,0, " 小魚的ID [英文大小寫要完全正確]:", userid, 20, + if(!getdata(10,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); @@ -53,16 +53,16 @@ m_fpg() }while(!count); count = 0; do{ - getdata(11,0, " 小魚的密碼:", passbuf, sizeof(passbuf), + getdata(11,0, " 沙灘的密碼:", passbuf, sizeof(passbuf), NOECHO); if(++count>=3) { cuser.userlevel |= PERM_VIOLATELAW; cuser.vl_count++; passwd_update(usernum, &cuser); - post_violatelaw(cuser.userid, "[PTT警察]", "測試小魚帳號錯誤三次", + post_violatelaw(cuser.userid, "[PTT警察]", "測試帳號錯誤三次", "違法觀察"); - mail_violatelaw(cuser.userid, "[PTT警察]", "測試小魚帳號錯誤三次", + mail_violatelaw(cuser.userid, "[PTT警察]", "測試帳號錯誤三次", "違法觀察"); return 0; @@ -81,30 +81,25 @@ m_fpg() sprintf(buf,"%s.done",genbuf); rename(genbuf,buf); #ifdef MERGEMONEY - int price[10] = {74, 21, 29, 48, 67, 11, 9, 43, 57, 72}; - unsigned lmarket=0; reload_money(); - for(i=0; i<10; i++) - lmarket += man.market[i]/(674 / price[i]); sprintf(buf, - "您的花園幣有 %10d 換算成 Ptt 幣為 %9d (優惠匯率 155:1), \n" - " 銀行有 %10d 換算為 Ptt 幣為 %9d (匯率為 674:1), \n" - " 花市價值 %10d 換算為 Ptt 幣為 %9d (匯率為 674:1), \n" + "您的沙灘銀幣有 %10d 換算成 Ptt 幣為 %9d (匯率 22:1), \n" + " 沙灘金幣有 %10d 換算為 Ptt 幣為 %9d (匯率 222105:1), \n" " 原有P幣 %10d 匯入後共有 %d\n", - man.money, man.money/155, - man.bank, man.bank/674, - lmarket*674, lmarket, - cuser.money, cuser.money + man.money/155 + man.bank/674 + lmarket); - demoney(man.money/155 + man.bank/674 + lmarket); + man.goldmoney, man.goldmoney/22, + man.silvermoney, man.silvermoney/222105, + cuser.money, cuser.money + man.goldmoney/22 + + man.silvermoney/222105); + demoney(man.goldmoney/22 + man.silvermoney/222105 + lmarket); strcat(msg, buf); #endif - i = cuser.exmailbox + man.mailk + man.keepmail; + i = cuser.exmailbox + man.exmailbox + man.exmailboxk/2000; if (i > MAX_EXKEEPMAIL) i = MAX_EXKEEPMAIL; - sprintf(buf, "您的花園信箱有 %d (%dk), 原有 %d 匯入後共有 %d\n", - man.keepmail, man.mailk, cuser.exmailbox, i); + sprintf(buf, "您的沙灘信箱有 %d (%dk), 原有 %d 匯入後共有 %d\n", + man.exmailbox, man.exmailboxk, cuser.exmailbox, i); strcat(msg, buf); cuser.exmailbox = i; @@ -117,25 +112,19 @@ m_fpg() if(cuser.firstlogin > man.firstlogin) d = man.firstlogin; else d = cuser.firstlogin; - sprintf(buf, "花園註冊日期 %s ", Cdatedate(&(man.firstlogin))); - strcat(msg,buf); - sprintf(buf, "此帳號註冊日期 %s 將取 ",Cdatedate(&(cuser.firstlogin))); - strcat(msg,buf); - sprintf(buf, "將取 %s\n", Cdatedate(&d) ); - strcat(msg,buf); cuser.firstlogin = d; if(cuser.numlogins < man.numlogins) i = man.numlogins; else i = cuser.numlogins; - sprintf(buf, "花園進站次數 %d 此帳號 %d 將取 %d \n", man.numlogins, + sprintf(buf, "沙灘進站次數 %d 此帳號 %d 將取 %d \n", man.numlogins, cuser.numlogins, i); strcat(msg,buf); cuser.numlogins = i; if(cuser.numposts < man.numposts ) i = man.numposts; else i = cuser.numposts; - sprintf(buf, "花園文章次數 %d 此帳號 %d 將取 %d\n", + sprintf(buf, "沙灘文章次數 %d 此帳號 %d 將取 %d\n", man.numposts,cuser.numposts,i); strcat(msg,buf); cuser.numposts = i; @@ -146,16 +135,16 @@ m_fpg() } sethomeman(genbuf, cuser.userid); mkdir(genbuf, 0600); - sprintf(buf, "tar zxvf home/%c/%s.tgz>/dev/null", + sprintf(buf, "tar zxvf %c/%s.tar.gz>/dev/null", userid[0], userid); - chdir("fpg"); + chdir("sob/home"); system(buf); chdir(BBSHOME); if (getans("是否匯入個人信箱? (Y/n)")!='n') { sethomedir(buf, cuser.userid); - sprintf(genbuf, "fpg/home/bbs/home/%c/%s/.DIR", + sprintf(genbuf, "sob/home/%c/%s/.DIR", userid[0], userid); merge_dir(buf, genbuf, 1); strcat(msg, "匯入個人信箱\n"); @@ -163,7 +152,7 @@ m_fpg() if(getans("是否匯入個人信箱精華區? (會覆蓋\現有設定) (y/N)")=='y') { sprintf(buf, - "rm -rd home/%c/%s/man>/dev/null ; mv fpg/home/bbs/home/%c/%s/man home/%c/%s", + "rm -rd home/%c/%s/man>/dev/null ; mv sob/home/%c/%s/man home/%c/%s", cuser.userid[0], cuser.userid, userid[0], userid, cuser.userid[0], cuser.userid); @@ -173,7 +162,7 @@ m_fpg() if(getans("是否匯入好友名單? (會覆蓋\現有設定, ID可能是不同人)? (y/N)")=='y') { sethomefile(genbuf, cuser.userid, "overrides"); - sprintf(buf, "fpg/home/bbs/home/%c/%s/overrides",userid[0],userid); + sprintf(buf, "sob/home/%c/%s/overrides",userid[0],userid); Copy(buf, genbuf); strcat(buf, genbuf); friend_load(FRIEND_OVERRIDE); @@ -181,13 +170,6 @@ m_fpg() } sprintf(buf, "帳號匯入報告 %s -> %s ", userid, cuser.userid); post_msg("Security", buf, msg, "[系統安全局]"); - sprintf(buf, "fpg/home/bbs/home/%c/%s/PttID", userid[0],userid); - if((fp = fopen(buf, "w"))) - { - fprintf(fp, "%s\n", cuser.userid); - fprintf(fp, "%s", msg); - fclose(fp); - } vmsg("恭喜您完成帳號變身.."); return 0; -- cgit v1.2.3