summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-07-01 10:51:12 +0800
committerptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-07-01 10:51:12 +0800
commit2846cb73dbb035197c88ec52d73e6267c2b6608a (patch)
treee8ce688ea5b871a2850bcb6742c5f4338e695ffc
parentbec9f21f48476db6e3c83f66f8eda67e4cc9d0d2 (diff)
downloadpttbbs-2846cb73dbb035197c88ec52d73e6267c2b6608a.tar
pttbbs-2846cb73dbb035197c88ec52d73e6267c2b6608a.tar.gz
pttbbs-2846cb73dbb035197c88ec52d73e6267c2b6608a.tar.bz2
pttbbs-2846cb73dbb035197c88ec52d73e6267c2b6608a.tar.lz
pttbbs-2846cb73dbb035197c88ec52d73e6267c2b6608a.tar.xz
pttbbs-2846cb73dbb035197c88ec52d73e6267c2b6608a.tar.zst
pttbbs-2846cb73dbb035197c88ec52d73e6267c2b6608a.zip
merge the branch from ptt.fpg
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2109 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/admin.c20
-rw-r--r--mbbsd/merge.c129
2 files changed, 93 insertions, 56 deletions
diff --git a/mbbsd/admin.c b/mbbsd/admin.c
index d9211c74..43c48995 100644
--- a/mbbsd/admin.c
+++ b/mbbsd/admin.c
@@ -271,7 +271,7 @@ int dir_cmp(const void *a, const void *b)
atoi( &((fileheader_t *)b)->filename[2] ));
}
-void merge_dir(char *dir1, char *dir2)
+void merge_dir(char *dir1, char *dir2, int isoutter)
{
int i, pn, sn;
fileheader_t *fh;
@@ -293,19 +293,25 @@ void merge_dir(char *dir1, char *dir2)
fh= (fileheader_t *)malloc( (pn+sn)*sizeof(fileheader_t));
get_records(dir1, fh, sizeof(fileheader_t), 1, pn);
get_records(dir2, fh+pn, sizeof(fileheader_t), 1, sn);
+ if(isoutter)
+ {
+ for(i=0; i<sn; i++)
+ if(fh[pn+i].owner[0])
+ strcat(fh[pn+i].owner, ".");
+ }
qsort(fh, pn+sn, sizeof(fileheader_t), dir_cmp);
sprintf(bakdir,"%s.bak", dir1);
Rename(dir1, bakdir);
- for(i=1; i<pn+sn; i++ )
+ for(i=1; i<=pn+sn; i++ )
{
- if(!fh[i].title[0] || !fh[i].filename[0]) continue;
- if( strcmp(fh[i-1].filename, fh[i].filename))
+ if(!fh[i-1].title[0] || !fh[i-1].filename[0]) continue;
+ if(i == pn+sn || strcmp(fh[i-1].filename, fh[i].filename))
{
fh[i-1].recommend =0;
fh[i-1].filemode |= 1;
append_record(dir1, &fh[i-1], sizeof(fileheader_t));
strcpy(p1, fh[i-1].filename);
- if(!dashd(file1))
+ if(!dashf(file1))
{
strcpy(p2, fh[i-1].filename);
Copy(file2, file1);
@@ -314,6 +320,7 @@ void merge_dir(char *dir1, char *dir2)
else
fh[i].filemode |= fh[i-1].filemode;
}
+
free(fh);
}
@@ -367,6 +374,7 @@ m_mod_board(char *bname)
setbdir(genbuf, bname);
m_fpg_brd(bname, fromdir);
if(!fromdir[0]) break;
+ merge_dir(genbuf, fromdir, 1);
}
else{
#endif
@@ -380,10 +388,10 @@ m_mod_board(char *bname)
break;
setbdir(genbuf, bname);
setbdir(fromdir, frombname);
+ merge_dir(genbuf, fromdir, 0);
#ifdef MERGEBBS
}
#endif
- merge_dir(genbuf, fromdir);
touchbtotal(bid);
}
break;
diff --git a/mbbsd/merge.c b/mbbsd/merge.c
index 6a75328c..93aafaf4 100644
--- a/mbbsd/merge.c
+++ b/mbbsd/merge.c
@@ -9,7 +9,7 @@ int
m_fpg()
{
char genbuf[256], buf[256], userid[25], passbuf[24], msg[2048]="";
- int count=0, i;
+ int count=0, i, isimported=0;
FILE *fp;
ACCT man;
time_t d;
@@ -38,10 +38,16 @@ m_fpg()
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;
- }
+ {
+ isimported = 1;
+ strcat(genbuf, ".done");
+ if(!(fp=fopen(genbuf, "r")))
+ {
+ vmsg("查無此人或已經匯入過..請注意大小寫 ");
+ isimported = 0;
+ continue;
+ }
+ }
count = fread(&man, sizeof(man), 1, fp);
fclose(fp);
}while(!count);
@@ -62,60 +68,82 @@ m_fpg()
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(12,0);
clrtobot();
+
+ if(!isimported)
+ {
+ if(!dashf(genbuf)) // avoid multi-login
+ {
+ vmsg("請不要嘗試多重id踹匯入");
+ return 0;
+ }
+ 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,
- "您的花園幣有 %d 換算成 Ptt 幣為 %d (匯率 155:1), \n"
- " 原有 %d 匯入後共有 %d\n",
- man.money, man.money/155, cuser.money, cuser.money + man.money/155);
- demoney(man.money/155);
+ "您的花園幣有 %10d 換算成 Ptt 幣為 %9d (優惠匯率 155:1), \n"
+ " 銀行有 %10d 換算為 Ptt 幣為 %9d (匯率為 674:1), \n"
+ " 花市價值 %10d 換算為 Ptt 幣為 %9d (匯率為 674: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);
strcat(msg, buf);
#endif
- i = cuser.exmailbox + man.mailk + man.keepmail;
- if (i > 1000) i = 1000;
- sprintf(buf, "您的花園信箱有 %d : %d, 原有 %d 匯入後共有 %d\n",
- man.mailk, man.keepmail, cuser.exmailbox, cuser.exmailbox );
- strcat(msg, buf);
- cuser.exmailbox = i;
-
- 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,
+ i = cuser.exmailbox + man.mailk + man.keepmail;
+ if (i > 1000) i = 1000;
+ sprintf(buf, "您的花園信箱有 %d (%dk), 原有 %d 匯入後共有 %d\n",
+ man.keepmail, man.mailk, cuser.exmailbox, i);
+ strcat(msg, buf);
+ cuser.exmailbox = i;
+
+ if(man.userlevel & PERM_MAILLIMIT)
+ {
+ sprintf(buf, "開啟信箱無上限\n");
+ strcat(msg, buf);
+ cuser.userlevel |= PERM_MAILLIMIT;
+ }
+
+ 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,
cuser.numlogins, i);
- strcat(msg,buf);
- 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",
+ if(cuser.numposts < man.numposts ) i = man.numposts;
+ else i = cuser.numposts;
+ sprintf(buf, "花園文章次數 %d 此帳號 %d 將取 %d\n",
man.numposts,cuser.numposts,i);
- strcat(msg,buf);
- cuser.numposts = i;
- outs(msg);
- while(search_ulistn(usernum,2))
+ strcat(msg,buf);
+ cuser.numposts = i;
+ outs(msg);
+ while(search_ulistn(usernum,2))
{vmsg("請將重覆上站其他線關閉! 再繼續");}
- passwd_update(usernum, &cuser);
+ passwd_update(usernum, &cuser);
+ }
sethomeman(genbuf, cuser.userid);
mkdir(genbuf, 0600);
sprintf(buf, "tar zxvf home/%c/%s.tgz>/dev/null",
@@ -129,13 +157,14 @@ m_fpg()
sethomedir(buf, cuser.userid);
sprintf(genbuf, "fpg/home/bbs/home/%c/%s/.DIR",
userid[0], userid);
- merge_dir(buf, genbuf);
+ merge_dir(buf, genbuf, 1);
strcat(msg, "匯入個人信箱\n");
}
- if(getans("是否匯入個人信箱精華區? (Y/n)")!='n')
+ if(getans("是否匯入個人信箱精華區? (會覆蓋\現有設定) (y/N)")=='y')
{
sprintf(buf,
- "mv fpg/home/bbs/home/%c/%s/man home/%c/%s/man",
+ "rm -rd home/%c/%s/man>/dev/null ; mv fpg/home/bbs/home/%c/%s/man home/%c/%s",
+ cuser.userid[0], cuser.userid,
userid[0], userid,
cuser.userid[0], cuser.userid);
system(buf);