diff options
-rw-r--r-- | include/proto.h | 1 | ||||
-rw-r--r-- | mbbsd/admin.c | 13 | ||||
-rw-r--r-- | mbbsd/calendar.c | 16 | ||||
-rw-r--r-- | mbbsd/mbbsd.c | 4 | ||||
-rw-r--r-- | util/birth.c | 35 |
5 files changed, 46 insertions, 23 deletions
diff --git a/include/proto.h b/include/proto.h index b2dff6bc..12700e29 100644 --- a/include/proto.h +++ b/include/proto.h @@ -801,6 +801,7 @@ int freecuser(void); /* calendar */ int calendar(void); int ParseDate(const char *date, int *year, int *month, int *day); +int getHoroscope(int m, int d); /* util */ void touchbtotal(int bid); diff --git a/mbbsd/admin.c b/mbbsd/admin.c index 766ecab0..161dd851 100644 --- a/mbbsd/admin.c +++ b/mbbsd/admin.c @@ -679,8 +679,8 @@ m_board(void) int x_file(void) { - int aborted; - char ans[4], *fpath; + int aborted, num; + char ans[4], *fpath, buf[256]; move(b_lines - 7, 0); /* Ptt */ @@ -786,7 +786,14 @@ x_file(void) fpath = "etc/Logout"; break; case 'k': - fpath = "etc/Welcome_birth"; + mouts(b_lines - 3, 0, "1.摩羯 2.水瓶 3.雙魚 4.白羊 5.金牛 6.雙子"); + mouts(b_lines - 2, 0, "7.巨蟹 8.獅子 9.處女 10.天秤 11.天蠍 12.射手"); + getdata(b_lines - 1, 0, "請選擇 [1-12]", ans, sizeof(ans), LCECHO); + num = atoi(ans); + if (num <= 0 || num > 12) + return FULLUPDATE; + snprintf(buf, sizeof(buf), "etc/Welcome_birth.%d\n", num); + fpath = buf; break; case 'l': fpath = "etc/feast"; diff --git a/mbbsd/calendar.c b/mbbsd/calendar.c index ba0fb45a..2f2e5af6 100644 --- a/mbbsd/calendar.c +++ b/mbbsd/calendar.c @@ -323,3 +323,19 @@ calendar(void) pressanykey(); return 0; } + +int getHoroscope(int m, int d) +{ + // 摩羯 水瓶 雙魚 白羊 金牛 雙子 巨蟹 獅子 處女 天秤 天蠍 射手 + const int firstday[12] = { + /* Dec. */ 22, /* Jan. */ 20, 19, 21, 20, 21, 21, 23, 23, 23, 23, 22 + }; + if (d >= firstday[m]) { + if (m == 12) + return 1; + else + return m - 1; + } + else + return m; +} diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index eadcc622..979d76dc 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -1114,7 +1114,9 @@ user_login(void) /* show welcome_login */ if( (ifbirth = (ptime->tm_mday == cuser.day && ptime->tm_mon + 1 == cuser.month)) ){ - more("etc/Welcome_birth", NA); + char buf[PATHLEN]; + snprintf(buf, sizeof(buf), "etc/Welcome_birth.%d", getHoroscope(cuser.month, cuser.day)); + more(buf, NA); } else { #ifndef MULTI_WELCOME_LOGIN diff --git a/util/birth.c b/util/birth.c index f0d5626a..e9198ef5 100644 --- a/util/birth.c +++ b/util/birth.c @@ -59,31 +59,28 @@ int main(argc, argv) "[1m★[35m★[34m★[33m★[32m★[31m★[45;33m 壽星大觀 " "[40m★[32m★[33m★[34m★[35m★[1m★[m \n\n"); fprintf(fp1, "[33m【[1;45m本日壽星[40;33m】[m \n"); + int horoscope = getHoroscope(ptime->tm_mon + 1, ptime->tm_mday); for(j = 1; j <= MAX_USERS; j++) { passwd_query(j, &user); if (bad_user_id(NULL)) continue; - if (user.month == ptime->tm_mon + 1) - { - if (user.day == ptime->tm_mday) - { - char genbuf[200]; - sprintf(genbuf, BBSHOME "/home/%c/%s", user.userid[0], user.userid); - stampfile(genbuf, &mymail); - strcpy(mymail.owner, BBSNAME); - strcpy(mymail.title, "!! 生日快樂 !!"); - unlink(genbuf); - Link(BBSHOME "/etc/Welcome_birth", genbuf); - sprintf(genbuf, BBSHOME "/home/%c/%s/.DIR", user.userid[0], user.userid); - append_record(genbuf, &mymail, sizeof(mymail)); - if ((user.numlogins + user.numposts) < 20) - continue; + if (user.month == ptime->tm_mon + 1 && user.day == ptime->tm_mday) { + char genbuf[200]; + sprintf(genbuf, BBSHOME "/home/%c/%s", user.userid[0], user.userid); + stampfile(genbuf, &mymail); + strcpy(mymail.owner, BBSNAME); + strcpy(mymail.title, "!! 生日快樂 !!"); + unlink(genbuf); + Link(BBSHOME "/etc/Welcome_birth.%d", genbuf, horoscope); + sprintf(genbuf, BBSHOME "/home/%c/%s/.DIR", user.userid[0], user.userid); + append_record(genbuf, &mymail, sizeof(mymail)); + if ((user.numlogins + user.numposts) < 20) + continue; - fprintf(fp1, - " [33m[%2d/%-2d] %-14s[0m %-24s login:%-5d post:%-5d\n", + fprintf(fp1, + " [33m[%2d/%-2d] %-14s[0m %-24s login:%-5d post:%-5d\n", ptime->tm_mon + 1, ptime->tm_mday, user.userid, - user.nickname, user.numlogins, user.numposts); - } + user.nickname, user.numlogins, user.numposts); } } fclose(fp1); |