diff options
author | victor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2007-04-16 10:59:01 +0800 |
---|---|---|
committer | victor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2007-04-16 10:59:01 +0800 |
commit | 48049f58fca08253facdfa66371b48ea046abcc9 (patch) | |
tree | ae91c8ca340b4ccfdf355291472ca97fd74d7f73 | |
parent | 54ab3b0886feb9faa8ead846c2bd1e2b688023e5 (diff) | |
download | pttbbs-48049f58fca08253facdfa66371b48ea046abcc9.tar pttbbs-48049f58fca08253facdfa66371b48ea046abcc9.tar.gz pttbbs-48049f58fca08253facdfa66371b48ea046abcc9.tar.bz2 pttbbs-48049f58fca08253facdfa66371b48ea046abcc9.tar.lz pttbbs-48049f58fca08253facdfa66371b48ea046abcc9.tar.xz pttbbs-48049f58fca08253facdfa66371b48ea046abcc9.tar.zst pttbbs-48049f58fca08253facdfa66371b48ea046abcc9.zip |
horoscope flavor birthday card
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3503 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-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.���l"); + mouts(b_lines - 2, 0, "7.���� 8.��l 9.�B�k 10.�ѯ� 11.���� 12.�g��"); + 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) +{ + // ���~ ���~ ���� �զ� ���� ���l ���� ��l �B�k �ѯ� ���� �g�� + 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 �جP�j�[ " "[40m��[32m��[33m��[34m��[35m��[1m��[m \n\n"); fprintf(fp1, "[33m�i[1;45m����جP[40;33m�j[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); |