diff options
author | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2002-06-02 09:55:21 +0800 |
---|---|---|
committer | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2002-06-02 09:55:21 +0800 |
commit | 20a09fdf769533f7efc09990481e131f1e289874 (patch) | |
tree | 817f574143a5ad6382a8f216956f3c7e5bf7891e | |
parent | 1fcc5da29d40392d24c3dc5f9afd65290ab6ddbe (diff) | |
download | pttbbs-20a09fdf769533f7efc09990481e131f1e289874.tar pttbbs-20a09fdf769533f7efc09990481e131f1e289874.tar.gz pttbbs-20a09fdf769533f7efc09990481e131f1e289874.tar.bz2 pttbbs-20a09fdf769533f7efc09990481e131f1e289874.tar.lz pttbbs-20a09fdf769533f7efc09990481e131f1e289874.tar.xz pttbbs-20a09fdf769533f7efc09990481e131f1e289874.tar.zst pttbbs-20a09fdf769533f7efc09990481e131f1e289874.zip |
iswritable_stat, isvisible_stat
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@270 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | include/proto.h | 11 | ||||
-rw-r--r-- | mbbsd/bbs.c | 35 | ||||
-rw-r--r-- | mbbsd/board.c | 15 | ||||
-rw-r--r-- | mbbsd/syspost.c | 4 | ||||
-rw-r--r-- | mbbsd/talk.c | 63 |
5 files changed, 71 insertions, 57 deletions
diff --git a/include/proto.h b/include/proto.h index d80f0adc..97e8b970 100644 --- a/include/proto.h +++ b/include/proto.h @@ -1,4 +1,4 @@ -/* $Id: proto.h,v 1.18 2002/05/24 18:24:11 ptt Exp $ */ +/* $Id: proto.h,v 1.19 2002/06/02 01:55:19 in2 Exp $ */ #ifndef INCLUDE_PROTO_H #define INCLUDE_PROTO_H @@ -427,12 +427,18 @@ void post_change_perm(int oldperm, int newperm, char *sysopid, char *userid); void give_money_post(char *userid, int money); /* talk */ +#define iswritable(uentp) \ + (iswritable_stat(uentp, friend_stat(currutmp, uentp))) +#define isvisible(me, uentp) \ + (isvisible_stat(currutmp, uentp, friend_stat(me, uentp))) + +int iswritable_stat(userinfo_t *uentp, int fri_stat); +int isvisible_stat(userinfo_t * me, userinfo_t * uentp, int fri_stat); int cmpwatermtime(const void *a, const void *b); //void water_scr(water_t *tw, int which, char type); void my_write2(void); int t_idle(); char *modestring(userinfo_t * uentp, int simple); -int isvisible(userinfo_t * me, userinfo_t * uentp); int t_users(); int cmpuids(int uid, userinfo_t * urec); int my_write(pid_t pid, char *hint, char *id, int flag, userinfo_t *); @@ -449,6 +455,7 @@ int logout_friend_online(); int login_friend_online(); int isvisible_uid(int tuid); int friend_stat(userinfo_t *me, userinfo_t * ui); +int call_in(userinfo_t *uentp, int fri_stat); /* tmpjack */ int reg_barbq(); diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index 0191bada..9c5d864b 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -1,4 +1,4 @@ -/* $Id: bbs.c,v 1.46 2002/06/01 00:40:28 ptt Exp $ */ +/* $Id: bbs.c,v 1.47 2002/06/02 01:55:21 in2 Exp $ */ #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -15,6 +15,7 @@ #include "proto.h" extern struct bcache_t *brdshm; +extern userinfo_t *currutmp; extern userec_t cuser; extern void touchdircache(int bid); extern int TagNum; @@ -157,10 +158,11 @@ extern char currtitle[TTLEN + 1]; extern int Tagger(); -static void readdoent(int num, fileheader_t *ent) { - int type,uid; - char *mark, *title, color, - special=0, isonline=0; +static void readdoent(int num, fileheader_t *ent) +{ + int type,uid; + char *mark, *title, color, special=0, isonline=0; + userinfo_t *uentp; if(ent->recommend>9 || ent->recommend <0 ) ent->recommend=0; //Ptt:暫時 type = brc_unread(ent->filename,brc_num,brc_list) ? '+' : ' '; @@ -188,8 +190,7 @@ static void readdoent(int num, fileheader_t *ent) { if(!strncmp(title,"[公告]",6)) special=1; if(!strchr(ent->owner, '.') && (uid=searchuser(ent->owner)) && - search_ulist(uid) && - isvisible_uid(uid)) + (uentp = search_ulist(uid)) && isvisible(currutmp, uentp) ) isonline=1; if(strncmp(currtitle, title, TTLEN)) @@ -679,20 +680,20 @@ int invalid_brdname(char *brd) { return 1; } return 0; -} +} + static int b_call_in(int ent, fileheader_t *fhdr, char *direct) { - userinfo_t *u=search_ulist (searchuser(fhdr->owner)); - int fri_stat; - if(u ) - { - fri_stat= friend_stat(currutmp, u); - if(isvisible_stat(currutmp, u, fri_stat) && - call_in(u, fri_stat)) - return FULLUPDATE; - } + userinfo_t *u = search_ulist(searchuser(fhdr->owner)); + if( u ){ + int fri_stat; + fri_stat = friend_stat(currutmp, u); + if( isvisible_stat(currutmp, u, fri_stat) && call_in(u, fri_stat) ) + return FULLUPDATE; + } return DONOTHING; } + static void do_reply(fileheader_t *fhdr) { boardheader_t *bp; bp = getbcache(currbid); diff --git a/mbbsd/board.c b/mbbsd/board.c index 54237fa5..c0fed91c 100644 --- a/mbbsd/board.c +++ b/mbbsd/board.c @@ -1,4 +1,4 @@ -/* $Id: board.c,v 1.27 2002/06/01 22:08:53 ptt Exp $ */ +/* $Id: board.c,v 1.28 2002/06/02 01:55:21 in2 Exp $ */ #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -263,8 +263,8 @@ void init_brdbuf() { close(n); } - for(n = 0; n < size; n++) - favbuf[n] &= ~BRD_TAG; + for(n = 0; n < numboards; n++) + favbuf[n] &= ~BRD_TAG; brc_expire_time = login_start_time - 365 * 86400; } @@ -430,9 +430,10 @@ static boardstat_t * addnewbrdstat(int n, int state) return ptr; } -static int cmpboardname(boardstat_t *brd, boardstat_t *tmp) { - return tmp->bh->nuser - brd->bh->nuser; -} +static int cmpboardname(const void *brd, const void *tmp) +{ + return ((boardstat_t *)tmp)->bh->nuser - ((boardstat_t *)brd)->bh->nuser; +} static void load_boards(char *key) { boardheader_t *bptr = NULL; @@ -464,7 +465,7 @@ static void load_boards(char *key) { ) continue; addnewbrdstat(n, state); if(class_bid==-1) - qsort(nbrd, brdnum, sizeof(boardstat_t), cmpboardname); + qsort(nbrd, brdnum, sizeof(boardstat_t), cmpboardname); } } else diff --git a/mbbsd/syspost.c b/mbbsd/syspost.c index 8a30abff..f1a2e70e 100644 --- a/mbbsd/syspost.c +++ b/mbbsd/syspost.c @@ -1,4 +1,4 @@ -/* $Id: syspost.c,v 1.8 2002/05/21 05:08:44 lwms Exp $ */ +/* $Id: syspost.c,v 1.9 2002/06/02 01:55:21 in2 Exp $ */ #include <stdio.h> #include <string.h> #include <time.h> @@ -101,7 +101,7 @@ void give_money_post(char *userid, int money) { FILE *fp; fileheader_t fhdr; time_t now = time(0); - char genbuf[200], reason[30]; + char genbuf[200]; strcpy(genbuf, "boards/S/Security"); stampfile(genbuf, &fhdr); diff --git a/mbbsd/talk.c b/mbbsd/talk.c index 6f96a52f..77b8edf5 100644 --- a/mbbsd/talk.c +++ b/mbbsd/talk.c @@ -1,4 +1,4 @@ -/* $Id: talk.c,v 1.55 2002/06/01 03:51:36 ptt Exp $ */ +/* $Id: talk.c,v 1.56 2002/06/02 01:55:21 in2 Exp $ */ #include <stdio.h> #include <string.h> #include <errno.h> @@ -91,6 +91,36 @@ static char page_requestor[40]; static char description[30]; static FILE *flog; +int iswritable_stat(userinfo_t *uentp, int fri_stat) +{ + if( uentp == currutmp ) + return 0; + + if( HAS_PERM(PERM_SYSOP) ) + return 1; + + if( !HAS_PERM(PERM_LOGINOK) ) + return 0; + + return (uentp->pager != 3 && (fri_stat & HFM || uentp->pager != 4)); +} + +int isvisible_stat(userinfo_t * me, userinfo_t * uentp, int fri_stat) +{ + if (uentp->userid[0] == 0) + return 0; + + if (PERM_HIDE(uentp) && !(PERM_HIDE(me)))/* 對方紫色隱形而你沒有 */ + return 0; + else if ((me->userlevel & PERM_SYSOP) || + ((fri_stat & HRM) && (fri_stat & HFM))) + /* 站長看的見任何人 */ + return 1; + + if (uentp->invisible && !(me->userlevel & PERM_SEECLOAK)) return 0; + + return !(fri_stat & HRM); +} char *modestring(userinfo_t * uentp, int simple) { @@ -296,28 +326,6 @@ int friend_stat(userinfo_t *me, userinfo_t * ui) return hit; } -int isvisible_stat(userinfo_t * me, userinfo_t * uentp, int fri_stat) -{ - if (uentp->userid[0] == 0) - return 0; - - if (PERM_HIDE(uentp) && !(PERM_HIDE(me)))/* 對方紫色隱形而你沒有 */ - return 0; - else if ((me->userlevel & PERM_SYSOP) || - ((fri_stat & HRM) && (fri_stat & HFM))) - /* 站長看的見任何人 */ - return 1; - - if (uentp->invisible && !(me->userlevel & PERM_SEECLOAK)) return 0; - - return (fri_stat & HRM) ? 0 : 1; -} - -int isvisible(userinfo_t * me, userinfo_t * uentp) -{ - return isvisible_stat(currutmp, uentp, friend_stat(me, uentp)); -} - int isvisible_uid(int tuid) { userinfo_t *uentp; @@ -1752,18 +1760,15 @@ static void draw_pickup(int drawall, pickup_t *pickup, int pickup_way, int call_in(userinfo_t *uentp, int fri_stat) { - char genbuf[60]; - if( HAS_PERM(PERM_LOGINOK) && - uentp->pid != currpid && - (HAS_PERM(PERM_SYSOP) || - (uentp->pager != 3 && - (fri_stat & HFM || uentp->pager != 4))) ){ + if( iswritable_stat(uentp, fri_stat) ){ + char genbuf[60]; sprintf(genbuf, "Call-In %s :", uentp->userid); my_write(uentp->pid, genbuf, uentp->userid, 0, NULL); return 1; } return 0; } + static void userlist(void) { /* 使用者名單: |