diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2010-10-10 17:22:09 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2010-10-10 17:22:09 +0800 |
commit | 5b66d9bc4e9353db61d35a8f2769321362df5206 (patch) | |
tree | ea8b5c7fd9b792a24547f1574ccfdc267d76ecb2 | |
parent | bd60f1b3de49e7a65eb0ec7442d0f0a04adbe97a (diff) | |
download | pttbbs-5b66d9bc4e9353db61d35a8f2769321362df5206.tar pttbbs-5b66d9bc4e9353db61d35a8f2769321362df5206.tar.gz pttbbs-5b66d9bc4e9353db61d35a8f2769321362df5206.tar.bz2 pttbbs-5b66d9bc4e9353db61d35a8f2769321362df5206.tar.lz pttbbs-5b66d9bc4e9353db61d35a8f2769321362df5206.tar.xz pttbbs-5b66d9bc4e9353db61d35a8f2769321362df5206.tar.zst pttbbs-5b66d9bc4e9353db61d35a8f2769321362df5206.zip |
make users' 'sex' property an optional field for privacy
git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5114 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | pttbbs/include/proto.h | 2 | ||||
-rw-r--r-- | pttbbs/include/pttstruct.h | 8 | ||||
-rw-r--r-- | pttbbs/mbbsd/mbbsd.c | 5 | ||||
-rw-r--r-- | pttbbs/mbbsd/passwd.c | 8 | ||||
-rw-r--r-- | pttbbs/mbbsd/register.c | 14 | ||||
-rw-r--r-- | pttbbs/mbbsd/talk.c | 11 | ||||
-rw-r--r-- | pttbbs/mbbsd/user.c | 7 | ||||
-rw-r--r-- | pttbbs/util/shmctl.c | 8 |
8 files changed, 50 insertions, 13 deletions
diff --git a/pttbbs/include/proto.h b/pttbbs/include/proto.h index 0a59702e..d586829c 100644 --- a/pttbbs/include/proto.h +++ b/pttbbs/include/proto.h @@ -737,7 +737,9 @@ int pwcuRegisterSetInfo (const char *rname, const char *phone, const char *email, int mobile, +#ifdef USE_USER_SEX uint8_t sex, +#endif uint8_t year, uint8_t month, uint8_t day, diff --git a/pttbbs/include/pttstruct.h b/pttbbs/include/pttstruct.h index 588a0280..9a4d4cf6 100644 --- a/pttbbs/include/pttstruct.h +++ b/pttbbs/include/pttstruct.h @@ -79,7 +79,11 @@ typedef struct userec_t { uint8_t month; /* ¥Í¤é ¤ë */ uint8_t day; /* ¥Í¤é ¤é */ uint8_t year; /* ¥Í¤é ¦~ */ +#ifdef USE_USER_SEX uint8_t sex; /* ©Ê§O */ +#else + uint8_t nonuse_sex; /* ©Ê§O (¤w°±¥Î) */ +#endif uint8_t pager_ui_type; /* ©I¥s¾¹¬É±Ãþ§O (was: WATER_*) */ uint8_t pager; /* ©I¥s¾¹ª¬ºA */ @@ -339,7 +343,11 @@ typedef struct userinfo_t { char nickname[24]; char from[27]; /* machine name the user called in from */ in_addr_t from_ip; // was: int from_alias; +#ifdef USE_USER_SEX char sex; +#else + char nonuse_sex; // deprecated: sex info +#endif char nonuse[4]; /* unsigned char goodpost; diff --git a/pttbbs/mbbsd/mbbsd.c b/pttbbs/mbbsd/mbbsd.c index 4e161ca6..3f62a8f8 100644 --- a/pttbbs/mbbsd/mbbsd.c +++ b/pttbbs/mbbsd/mbbsd.c @@ -1008,9 +1008,12 @@ setup_utmp(int mode) uinfo.mode = currstat = mode; uinfo.userlevel = cuser.userlevel; - uinfo.sex = cuser.sex % 8; uinfo.lastact = time(NULL); +#ifdef USE_USER_SEX + uinfo.sex = cuser.sex % 8; +#endif + // only enable this after you've really changed talk.c to NOT use from_alias. uinfo.from_ip = inet_addr(fromhost); diff --git a/pttbbs/mbbsd/passwd.c b/pttbbs/mbbsd/passwd.c index 75a013fb..a3be31bd 100644 --- a/pttbbs/mbbsd/passwd.c +++ b/pttbbs/mbbsd/passwd.c @@ -255,7 +255,9 @@ int pwcuRegisterSetInfo (const char *rname, const char *phone, const char *email, int mobile, +#ifdef USE_USER_SEX uint8_t sex, +#endif uint8_t year, uint8_t month, uint8_t day, @@ -268,7 +270,9 @@ int pwcuRegisterSetInfo (const char *rname, strlcpy(u.phone, phone, sizeof(u.phone)); strlcpy(u.email, email, sizeof(u.email)); u.mobile = mobile; +#ifdef USE_USER_SEX u.sex = sex; +#endif u.year = year; u.month = month; u.day = day; @@ -282,7 +286,9 @@ int pwcuRegisterSetInfo (const char *rname, strlcpy(cuser.phone, phone, sizeof(cuser.phone)); strlcpy(cuser.email, email, sizeof(cuser.email)); cuser.mobile = mobile; +#ifdef USE_USER_SEX cuser.sex = sex; +#endif cuser.year = year; cuser.month = month; cuser.day = day; @@ -630,5 +636,7 @@ void pwcuInitGuestInfo () sizeof(currutmp->nickname)); strlcpy(cuser.realname, "guest", sizeof(cuser.realname)); memset (cuser.mind, 0, sizeof(cuser.mind)); +#ifdef USE_USER_SEX cuser.sex = i % 8; +#endif } diff --git a/pttbbs/mbbsd/register.c b/pttbbs/mbbsd/register.c index a7c96fa5..1686b2c9 100644 --- a/pttbbs/mbbsd/register.c +++ b/pttbbs/mbbsd/register.c @@ -1252,12 +1252,15 @@ int u_register(void) { char rname[20], addr[50], mobile[16]; - char phone[20], career[40], email[50], birthday[11], sex_is[2]; + char phone[20], career[40], email[50], birthday[11]; unsigned char year, mon, day; char inregcode[14], regcode[50]; char ans[3], *errcode; int i = 0; int isForeign = (HasUserFlag(UF_FOREIGN)) ? 1 : 0; +#ifdef USE_USER_SEX + char sex_is[2]; +#endif if (cuser.userlevel & PERM_LOGINOK) { outs("±zªº¨¥÷½T»{¤w¸g§¹¦¨¡A¤£»Ý¶ñ¼g¥Ó½Ðªí"); @@ -1301,8 +1304,10 @@ u_register(void) snprintf(birthday, sizeof(birthday), "%04i/%02i/%02i", 1900 + cuser.year, cuser.month, cuser.day); +#ifdef USE_USER_SEX sex_is[0] = (cuser.sex % 8) + '1'; sex_is[1] = 0; +#endif if (cuser.userlevel & PERM_NOREGCODE) { vmsg("±z¤£³Q¤¹³\\¨Ï¥Î»{ÃÒ½X»{ÃÒ¡C½Ð¶ñ¼gµù¥U¥Ó½Ð³æ"); @@ -1505,7 +1510,9 @@ u_register(void) } break; } +#ifdef USE_USER_SEX getfield(10, "1.¡ñ¨k 2.¡ð¤k ", REGNOTES_ROOT "sex", "©Ê§O", sex_is, 2); +#endif getdata(20, 0, "¥H¤W¸ê®Æ¬O§_¥¿½T(Y/N)¡H(Q)¨ú®øµù¥U [N] ", ans, 3, LCECHO); if (ans[0] == 'q') @@ -1519,7 +1526,10 @@ u_register(void) // copy values to cuser pwcuRegisterSetInfo(rname, addr, career, phone, email, - atoi(mobile), (sex_is[0] - '1') % 8, + atoi(mobile), +#ifdef USE_USER_SEX + (sex_is[0] - '1') % 8, +#endif year, mon, day, isForeign); // if reach here, email is apparently 'x'. diff --git a/pttbbs/mbbsd/talk.c b/pttbbs/mbbsd/talk.c index 4b58d8b1..d7a9854a 100644 --- a/pttbbs/mbbsd/talk.c +++ b/pttbbs/mbbsd/talk.c @@ -433,11 +433,12 @@ my_query(const char *uident) int tuid, fri_stat = 0; int is_self = 0; userinfo_t *uentp; - const char *sex[8] = - {MSG_BIG_BOY, MSG_BIG_GIRL, - MSG_LITTLE_BOY, MSG_LITTLE_GIRL, - MSG_MAN, MSG_WOMAN, MSG_PLANT, MSG_MIME}; static time_t last_query; +#ifdef USE_USER_SEX + const char *sex[8] = { + MSG_BIG_BOY, MSG_BIG_GIRL, MSG_LITTLE_BOY, MSG_LITTLE_GIRL, + MSG_MAN, MSG_WOMAN, MSG_PLANT, MSG_MIME}; +#endif STATINC(STAT_QUERY); if ((tuid = getuser(uident, &muser))) { @@ -512,8 +513,10 @@ my_query(const char *uident) muser.five_win, muser.five_lose, muser.five_tie, muser.chc_win, muser.chc_lose, muser.chc_tie); +#ifdef USE_USER_SEX if ((uentp && ((fri_stat & HFM) || is_self) && !uentp->invisible)) prints("¡m ©Ê §O ¡n%-28.28s\n", sex[muser.sex % 8]); +#endif showplans_userec(&muser); if(HasUserPerm(PERM_SYSOP|PERM_POLICE) ) diff --git a/pttbbs/mbbsd/user.c b/pttbbs/mbbsd/user.c index b3078169..44fa672c 100644 --- a/pttbbs/mbbsd/user.c +++ b/pttbbs/mbbsd/user.c @@ -2,10 +2,12 @@ #define PWCU_IMPL #include "bbs.h" +#ifdef USE_USER_SEX static char * const sex[8] = { MSG_BIG_BOY, MSG_BIG_GIRL, MSG_LITTLE_BOY, MSG_LITTLE_GIRL, MSG_MAN, MSG_WOMAN, MSG_PLANT, MSG_MIME }; +#endif #ifdef CHESSCOUNTRY static const char * const chess_photo_name[3] = { @@ -175,7 +177,9 @@ user_display(const userec_t * u, int adminmode) prints("\t¹q¤l«H½c: %s\n", u->email); prints("\t»È¦æ±b¤á: %d ¤¸\n", u->money); +#ifdef USE_USER_SEX prints("\t©Ê §O: %s\n", sex[u->sex%8]); +#endif prints("\t¥Í ¤é: %04i/%02i/%02i (%sº¡18·³)\n", u->year + 1900, u->month, u->day, resolve_over18_user(u) ? "¤w" : "¥¼"); @@ -727,6 +731,8 @@ uinfo_query(const char *orig_uid, int adminmode, int unum) snprintf(buf, sizeof(buf), "%010d", x.mobile); getdata_buf(y++, 0, "¤â¾÷¸¹½X¡G", buf, 11, NUMECHO); x.mobile = atoi(buf); + +#ifdef USE_USER_SEX snprintf(genbuf, sizeof(genbuf), "%d", (x.sex + 1) % 8); getdata_str(y++, 0, "©Ê§O (1)¸¯®æ (2)©j±µ (3)©³} (4)¬ü¬Ü (5)Á¦¨û " "(6)ªü«¼ (7)´Óª« (8)Äqª«¡G", @@ -735,6 +741,7 @@ uinfo_query(const char *orig_uid, int adminmode, int unum) x.sex = (buf[0] - '1') % 8; else x.sex = x.sex % 8; +#endif while (1) { snprintf(genbuf, sizeof(genbuf), "%04i/%02i/%02i", diff --git a/pttbbs/util/shmctl.c b/pttbbs/util/shmctl.c index 261f9a6e..58e04cb2 100644 --- a/pttbbs/util/shmctl.c +++ b/pttbbs/util/shmctl.c @@ -394,12 +394,8 @@ void utmpsort(int sortall) for (uentp = &SHM->uinfo[0], count = i = 0; i < USHM_SIZE; ++i, uentp = &SHM->uinfo[i]) { - if (uentp->pid) { - if (uentp->sex < 0 || uentp->sex > 7) - purge_utmp(uentp); - else - SHM->sorted[ns][0][count++] = i; - } + if (uentp->pid) + SHM->sorted[ns][0][count++] = i; } SHM->UTMPnumber = count; qsort(SHM->sorted[ns][0], count, sizeof(int), cmputmpuserid); |