diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-08-06 17:02:50 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-08-06 17:02:50 +0800 |
commit | 243b8fa1bcadfb312cc334fdd83322a043d97a41 (patch) | |
tree | 695ef854c84e0e7abfc1c2b1b34881bd52e48fc8 | |
parent | 1f6dede4cd2f7f35a2a768ec4c1f75aba51b71dd (diff) | |
download | pttbbs-243b8fa1bcadfb312cc334fdd83322a043d97a41.tar pttbbs-243b8fa1bcadfb312cc334fdd83322a043d97a41.tar.gz pttbbs-243b8fa1bcadfb312cc334fdd83322a043d97a41.tar.bz2 pttbbs-243b8fa1bcadfb312cc334fdd83322a043d97a41.tar.lz pttbbs-243b8fa1bcadfb312cc334fdd83322a043d97a41.tar.xz pttbbs-243b8fa1bcadfb312cc334fdd83322a043d97a41.tar.zst pttbbs-243b8fa1bcadfb312cc334fdd83322a043d97a41.zip |
Revision 3000
- sync with ptt1 local modified source
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3000 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | include/fpg.h | 15 | ||||
-rw-r--r-- | innbbsd/receive_article.c | 8 | ||||
-rw-r--r-- | mbbsd/Makefile | 2 | ||||
-rw-r--r-- | mbbsd/bbs.c | 53 | ||||
-rw-r--r-- | sample/etc/board.help | 2 | ||||
-rw-r--r-- | util/Makefile | 10 | ||||
-rw-r--r-- | util/boardlist.c | 15 | ||||
-rw-r--r-- | util/mailangel.c | 143 | ||||
-rw-r--r-- | util/userlist.c | 23 |
9 files changed, 254 insertions, 17 deletions
diff --git a/include/fpg.h b/include/fpg.h index 199eab02..f237b967 100644 --- a/include/fpg.h +++ b/include/fpg.h @@ -10,9 +10,10 @@ -typedef unsigned char uschar; /* length = 1 */ -typedef unsigned int usint; /* length = 4 */ -typedef unsigned short int ushort; /* length = 4 */ +typedef unsigned char uschar; /* length = 1 */ +typedef unsigned short ushort; /* length = 2 */ +typedef unsigned long uslong; /* length = 4 */ +typedef unsigned int usint; /* length = 4 */ /* ----------------------------------------------------- */ /* .PASSWDS struct : 512 bytes */ @@ -48,12 +49,12 @@ struct sobuserec usint bequery; /* 人氣度 4 bytes */ char toqid[IDLEN + 1]; /* 前次查誰 13 bytes */ char beqid[IDLEN + 1]; /* 前次被誰查 13 bytes */ - unsigned long int totaltime; /* 上線總時數 8 bytes */ + uslong totaltime; /* 上線總時數 8 bytes */ usint sendmsg; /* 發訊息次數 4 bytes */ usint receivemsg; /* 收訊息次數 4 bytes */ - unsigned int goldmoney; /* 風塵金幣 8 bytes */ - unsigned int silvermoney; /* 銀幣 8 bytes */ - unsigned int exp; /* 經驗值 8 bytes */ + usint goldmoney; /* 風塵金幣 8 bytes */ + usint silvermoney; /* 銀幣 8 bytes */ + usint exp; /* 經驗值 8 bytes */ time4_t dtime; /* 存款時間 4 bytes */ int scoretimes; /* 評分次數 4 bytes */ uschar rtimes; /* 填註冊單次數 1 bytes */ diff --git a/innbbsd/receive_article.c b/innbbsd/receive_article.c index 92993aaf..6e2e754e 100644 --- a/innbbsd/receive_article.c +++ b/innbbsd/receive_article.c @@ -273,7 +273,15 @@ receive_article() "http://digi.hkgo.cc/mile", "http://love520.hk852.cc/mytw", "美容保養品公司USANA", "Robert G. Allen", "Multiple Streams of Income", "http://www.twstars.com", "36005081", "3123835", + ".hkgo.cc/", ".hk852.cc/", ".4hk.cc/", ".2hk.cc/", ".xdd.cc/", + ".hkoo.net/", ".nowgo.net/", "http://www.taconet.com.tw/jscha/", "www.ejiajia.net", "ufjt0356@ms9.hinet.net", "jt0356@yahoo.com.tw", + "http://www.IT-Test.Net", "http://uuu.to/", "greenhouse6688", + "http://www.s-bus.com", "http://goods.sytes.net/", + "http://www.1-care.com", "美商優莎納生技公司", "Http://www.It-Test.Net", + "http://home.pchome.com.tw/happy/eykk6767/", "http://www.agelopp.com/", + "http://www.togetrich.net", "http://www.newchance.ligsystem.com/", + "jimtist@yahoo.com", "http://fleamarket.mine.nu", "http://e-car.mine.nu", "http://www.whymsi.com", "http://www.msi-team.com/", NULL}; #endif diff --git a/mbbsd/Makefile b/mbbsd/Makefile index 8f2abc22..5f1d5ad8 100644 --- a/mbbsd/Makefile +++ b/mbbsd/Makefile @@ -16,10 +16,12 @@ OBJS= admin.o announce.o args.o assess.o bbs.o board.o cache.o cal.o card.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 go.o file.o \ pmore.o + .if defined(DIET) OBJS+= random.o time.o DIETCC= diet -Os .endif +#CFLAGS+=-g # reduce .bss align overhead .if !defined(DEBUG) diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index 89524b16..6a614bcb 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -2711,7 +2711,7 @@ b_config(int ent, const fileheader_t * fhdr, const char *direct) bp = getbcache(currbid); while(!finished) { - move(b_lines - 10, 0); clrtobot(); + move(b_lines - 12, 0); clrtobot(); outs(MSG_SEPERATOR); prints("\n目前 %s 看板設定:\n", bp->brdname); prints(" 中文敘述: %s\n", bp->title); @@ -2747,9 +2747,9 @@ b_config(int ent, const fileheader_t * fhdr, const char *direct) prints( " " ANSI_COLOR(1;36) "f" ANSI_RESET " - %s " ANSI_RESET "快速連推文章", d != 0 ? - ANSI_COLOR(1)"不可": "可以"); + ANSI_COLOR(1)"限制": "可以"); if(d > 0) - prints(", 限制: %d 秒", d); + prints(", 最低間隔時間: %d 秒", d); outs("\n"); } #ifdef USE_AUTOCPLOG @@ -2760,6 +2760,15 @@ b_config(int ent, const fileheader_t * fhdr, const char *direct) #else optCmds[1] = ""; #endif + prints( " " ANSI_COLOR(1;36) "o" ANSI_RESET + " - 若有轉信則發文時預設 %s " ANSI_RESET "\n", + (bp->brdattr & BRD_LOCALSAVE) ? + "站內存檔(不轉出)" : ANSI_COLOR(1)"站際存檔(轉出)" ); + + prints( " " ANSI_COLOR(1;36) "e" ANSI_RESET + " - 發文權限: %s" ANSI_RESET " (站長才可設定此項)\n", + (bp->brdattr & BRD_RESTRICTEDPOST) ? + ANSI_COLOR(1)"只有板友才可發文" : "無特別設定" ); if (!((currmode & MODE_BOARD) || HasUserPerm(PERM_SYSOP))) { @@ -2767,7 +2776,7 @@ b_config(int ent, const fileheader_t * fhdr, const char *direct) return FULLUPDATE; } - switch(tolower(getans("請按 h/r%s/f%s 改變設定,其它鍵結束: ", + switch(tolower(getans("請輸入 h/r%s/f%s/o 改變設定,其它鍵結束: ", optCmds[0], optCmds[1]))) { #ifdef USE_AUTOCPLOG @@ -2776,7 +2785,29 @@ b_config(int ent, const fileheader_t * fhdr, const char *direct) touched = 1; break; #endif + case 'o': + bp->brdattr ^= BRD_LOCALSAVE; + touched = 1; + break; + + case 'e': + if(HasUserPerm(PERM_SYSOP)) + { + bp->brdattr ^= BRD_RESTRICTEDPOST; + touched = 1; + } else { + vmsg("此項設定需要站長權限"); + } + break; + case 'h': +#ifndef BMCHS + if (!HasUserPerm(PERM_SYSOP)) + { + vmsg("此項設定需要站長權限"); + break; + } +#endif if(bp->brdattr & BRD_HIDE) { bp->brdattr &= ~BRD_HIDE; @@ -2787,10 +2818,12 @@ b_config(int ent, const fileheader_t * fhdr, const char *direct) } touched = 1; break; + case 'r': bp->brdattr ^= BRD_NORECOMMEND; touched = 1; break; + case 'f': bp->brdattr &= ~BRD_NORECOMMEND; bp->brdattr ^= BRD_NOFASTRECMD; @@ -2888,6 +2921,7 @@ change_counting(int ent, const fileheader_t * fhdr, const char *direct) boardheader_t *bp; if (!((currmode & MODE_BOARD) || HasUserPerm(PERM_SYSOP))) return DONOTHING; + bp = getbcache(currbid); if (!(bp->brdattr & BRD_HIDE && bp->brdattr & BRD_POSTMASK)) return FULLUPDATE; @@ -2916,6 +2950,9 @@ change_counting(int ent, const fileheader_t * fhdr, const char *direct) static int change_localsave(int ent, const fileheader_t * fhdr, const char *direct) { + vmsg("此功\能已整合進大寫 I 看板設定,請按 I 設定。"); + return FULLUPDATE; +#if 0 boardheader_t *bp; if (!((currmode & MODE_BOARD) || HasUserPerm(PERM_SYSOP))) return DONOTHING; @@ -2935,13 +2972,18 @@ change_localsave(int ent, const fileheader_t * fhdr, const char *direct) substitute_record(fn_board, bp, sizeof(boardheader_t), currbid); pressanykey(); return FULLUPDATE; +#endif } /** * 設定只有板友可 post 或全部人都可 post */ static int -change_restrictedpost(int ent, fileheader_t * fhdr, char *direct){ +change_restrictedpost(int ent, fileheader_t * fhdr, char *direct) +{ + vmsg("此功\能已整合進大寫 I 看板設定,請按 I 設定。"); + return FULLUPDATE; +#if 0 boardheader_t *bp; if (!HasUserPerm(PERM_SYSOP)) return DONOTHING; @@ -2961,6 +3003,7 @@ change_restrictedpost(int ent, fileheader_t * fhdr, char *direct){ substitute_record(fn_board, bp, sizeof(boardheader_t), currbid); pressanykey(); return FULLUPDATE; +#endif } #ifdef USE_COOLDOWN diff --git a/sample/etc/board.help b/sample/etc/board.help index d0dead13..41e04b35 100644 --- a/sample/etc/board.help +++ b/sample/etc/board.help @@ -19,4 +19,4 @@ (T/B) 重編文章標題/重編看板標題 (t/^D) 標記文章/砍除標記的文章 (O)/(i) 發表注意事項/文章類別 (W)/(K)/(v) 編進板畫面/水桶/可見名單 (^G) 舉辦賭盤/停止下注/開獎 (H) 切換看板隱藏 - (I) 看板設定(隱藏,推文,轉錄記錄) + (I) 看板設定(隱藏,推文,...) diff --git a/util/Makefile b/util/Makefile index 7ff2f3b6..4f7e19a4 100644 --- a/util/Makefile +++ b/util/Makefile @@ -23,7 +23,7 @@ CPROG_WITH_UTIL= \ expire mandex rmuid horoscope \ openvice parse_news openticket topusr \ yearsold toplazyBM toplazyBBM writemoney \ - reaper buildAnnounce inndBM shmctl \ + reaper buildAnnounce inndBM mailangel \ outmail chkhbf checkmoney merge_dir \ transman angel gamblegive checkdir \ chesscountry tunepasswd buildir xchatd @@ -37,6 +37,7 @@ CPROG_WITHOUT_UTIL= \ # 下面這些程式會被 install PROGS= ${CPROG_WITH_UTIL} ${CPROG_WITHOUT_UTIL} \ + shmctl \ BM_money.sh backpasswd.sh mailog.sh opendice.sh \ openticket.sh stock.sh topsong.sh weather.sh \ stock.perl weather.perl toplazyBM.sh toplazyBBM.sh \ @@ -58,6 +59,13 @@ util_${fn}.o: ${BBSBASE} ../mbbsd/${fn}.c $(CCACHE) ${CC} ${CFLAGS} -D_BBS_UTIL_C_ -c -o $@ ../mbbsd/${fn}.c .endfor +shmctl: ${BBSBASE} shmctl.c ${UTIL_OBJS} + $(CCACHE) ${CC} ${CFLAGS} ${LDFLAGS} -o shmctl ${UTIL_OBJS} shmctl.c +#shmctl: ${BBSBASE} shmctl.c ${UTIL_OBJS} +# $(CCACHE) gcc -g -DBBSHOME='"/home/bbs"' -I../include -D__OS_MAJOR_VERSION__="2" -D__OS_MINOR_VERSION__="6" -DPTTBBS_UTIL -O1 -o shmctl ${UTIL_OBJS} shmctl.c +#shmctl: ${BBSBASE} shmctl.cc ${UTIL_OBJS} +# $(CCACHE) g++ -g -DBBSHOME='"/home/bbs"' -I../include -D__OS_MAJOR_VERSION__="2" -D__OS_MINOR_VERSION__="6" -DPTTBBS_UTIL -O1 -o shmctl ${UTIL_OBJS} shmctl.cc + bbsmail: ${BBSBASE} bbsmail.c ../innbbsd/str_decode.c $(UTIL_OBJS) $(CCACHE) $(CC) $(CFLAGS) $(LDFLAGS) -o bbsmail -DUSE_ICONV \ bbsmail.c ../innbbsd/str_decode.c $(UTIL_OBJS) diff --git a/util/boardlist.c b/util/boardlist.c index e530ecfb..a6758f46 100644 --- a/util/boardlist.c +++ b/util/boardlist.c @@ -1,6 +1,19 @@ /* $Id$ */ /* 這是用來將樹狀分類輸出成 perl module (可以給像是 man/ 使用) */ #include "bbs.h" +/* 產生 hash 的內容如下: + + $db{'tobid.BRDNAME'} 把 BRDNAME(大小寫需正確) 查 bid + $db{'parent.BID'} 從 BID 查 parent 的 bid + $db{'tobrdname.BID'} 從 BID 查英文看板名稱 + $db{'look.SBRDNAME'} 從全部都是小寫的 SBRDNAME 查正確的看板大小寫 + $db{'BID.isboard'} 看 BID 是看板(1)或群組(0) + $db{'BID.brdname'} 從 BID 查 brdname + $db{'BID.title'} 查 BID 的中文板名 + $db{'BID.BM.0'} .. $db{'BID.BM.4'} + 該板板主 ID + */ +int parent[MAX_BOARD]; static void load_uidofgid(const int gid, const int type) @@ -68,6 +81,7 @@ void dumpdetail(void) bid = bptr - bcache + 1; printf("$db{'tobid.%s'} = %d;\n", bptr->brdname, bid); + printf("$db{'parent.%d'} = %d;\n", bid, parent[bid]); printf("$db{'tobrdname.%d'} = '%s';\n", bid, bptr->brdname); printf("$db{'look.%s'} = '%s';\n", smallbrdname, bptr->brdname); printf("$db{'%d.isboard'} = %d;\n", bid, @@ -100,6 +114,7 @@ void dumpclass(int gid) continue; printf("%5d,\t", bid); + parent[bid] = gid; } printf("]);\n"); diff --git a/util/mailangel.c b/util/mailangel.c new file mode 100644 index 00000000..f873188c --- /dev/null +++ b/util/mailangel.c @@ -0,0 +1,143 @@ +/* $Id$ */ +#include "bbs.h" + +#ifndef PLAY_ANGEL +int main(){ return 0; } +#else + +int total[MAX_USERS + 1]; +int *list; +int count; +char *mailto = NULL; +char *mailfile = NULL; + +int ListCmp(const void * a, const void * b){ + return *(int*)b - *(int*)a; +} + +int RejCmp(const void * a, const void * b){ + return strcasecmp(SHM->userid[*(int*)a - 1], SHM->userid[*(int*)b - 1]); +} + +void readData(); +void sendResult(); +void mailUser(char *userid); + +int main(int argc, char* argv[]){ + if (argc < 2) { + fprintf(stderr, "Usage: %s file [userid]\n", argv[0]); + exit(1); + } + mailfile = argv[1]; + + if (argc > 2) + mailto = argv[2]; + + readData(); + if (mailto) + mailUser(mailto); + else + sendResult(); + + return 0; +} + +int mailalertuser(char* userid) +{ + userinfo_t *uentp=NULL; + if (userid[0] && (uentp = search_ulist_userid(userid))) + uentp->mailalert=1; + return 0; +} + +void readData(){ + int i, j; + userec_t user; + FILE* fp; + + attach_SHM(); + + fp = fopen(BBSHOME "/.PASSWDS", "rb"); + j = count = 0; + while (fread(&user, sizeof(userec_t), 1, fp) == 1) { + ++j; /* j == uid */ + if (user.userlevel & PERM_ANGEL) { + ++count; + ++total[j]; /* make all angel have total > 0 */ + } else { /* don't have PERM_ANGEL */ + total[j] = INT_MIN; + } + } + fclose(fp); + + list = (int *) malloc(count * sizeof(int)); + j = 0; + for (i = 1; i <= MAX_USERS; ++i) + if (total[i] > 0) { + list[j] = i; + ++j; + } +} + +void sendResult(){ + int i; + for (i = 0; i < count; ++i) { + mailUser(SHM->userid[list[i] - 1]); +// printf("%s\n", SHM->userid[list[i] - 1]); + } +} + +void mailUser(char *userid) +{ + int count; + FILE *fp, *fp2; + time4_t t; + fileheader_t header; + struct stat st; + char filename[512]; + + fp2 = fopen(mailfile, "r"); + if (fp2 == NULL) { + fprintf(stderr, "Cannot open file %s\n", mailfile); + return; + } + + sprintf(filename, BBSHOME "/home/%c/%s", userid[0], userid); + if (stat(filename, &st) == -1) { + if (mkdir(filename, 0755) == -1) { + fprintf(stderr, "mail box create error %s \n", filename); + return; + } + } + else if (!(st.st_mode & S_IFDIR)) { + fprintf(stderr, "mail box error\n"); + return; + } + + stampfile(filename, &header); + fp = fopen(filename, "w"); + if (fp == NULL) { + fprintf(stderr, "Cannot open file %s\n", filename); + return; + } + + t = time(NULL); + fprintf(fp, "作者: 小天使系統\n" + "標題: 給小天使的一封信\n" + "時間: %s\n", + ctime4(&t)); + + while ((count = fread(filename, 1, sizeof(filename), fp2))) { + fwrite(filename, 1, count, fp); + } + fclose(fp); + fclose(fp2); + + strcpy(header.title, "給小天使的一封信"); + strcpy(header.owner, "小天使系統"); + sprintf(filename, BBSHOME "/home/%c/%s/.DIR", userid[0], userid); + append_record(filename, &header, sizeof(header)); + mailalertuser(userid); + printf("%s\n", userid); +} +#endif /* defined PLAY_ANGEL */ diff --git a/util/userlist.c b/util/userlist.c index 3faf5364..12f6b3d9 100644 --- a/util/userlist.c +++ b/util/userlist.c @@ -20,11 +20,28 @@ int main(int argc, char **argv) { perror("shmat"); exit(0); } - - if(argc > 1) { + + if(argc == 2) { + /* list specific id */ + for (i = 0; i < USHM_SIZE; i++) + { + userinfo_t *f = &SHM->uinfo[i]; + if(!f->pid) + continue; + if(strcmp(f->userid, argv[1]) != 0) + continue; + printf( + "id=%s money=%d\n", + f->userid, SHM->money[f->uid - 1]); + } + } + else if(argc > 1) + { for(i = 1; i < argc; i++) SHM->uinfo[atoi(argv[i])].pid = 0; - } else { + } + else + { for(i = counter = 0; i < USHM_SIZE; i++) if(SHM->uinfo[i].pid) { userinfo_t *f; |