荔园在线

荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀

[回到开始] [上一篇][下一篇]


发信人: fly (小火娃的心空了), 信区: sysop
标  题: [转载]bbs新增功能:查询某权限所属用户
发信站: 荔园晨风BBS站 (Wed Nov  7 07:36:41 2001), 转信

发信人: advertise (广告小生), 信区: BBSMan_Dev
标  题: BBS新增功能:查询某权限的所属用户
发信站: BBS 水木清华站 (Thu Jun 15 05:17:01 2000)

======================================================================
             查询某权限的所属用户.     Written By Casper of Swjtu
======================================================================

说明:
  只需改动list.c文件即可.
  1.在前面定义全局变量:  int pmode=0;
  2.然后将下面所有函数加入list.c文件里面.
  3.改动:commit_list.c文件,按它的格式把t_findper()加进去。
  3.改系统文件menu.ini.在"特别服务"选单内加入如下行:
    @FindPerm    0,0,  PERM_SYSOP, "FindPerm", "(F)indPerm   查询权限属
主"
    (注意大小写,空格具体长度请自己调节.)
  现在就可以使用了.您也可以设置些颜色使画面漂亮些!
void printptitle()
{
  print_title2();
  move(2,0);
  prints(" 编号  使用者代号    真实姓名  上站次数  发文章数  等级
上次联线;
  update_endline();
}
int countpusers(uentp)
struct userec *uentp;

{
  static int allpusers;
  char permstr[10];
  if( uentp == NULL ) {
      int c = allpusers;
      allpusers = 0;
      return c;
  }
  if(uentp->numlogins!=0&&uleveltochar(permstr,uentp->userlevel)!=0)
    if( (uentp->userlevel==PERM_BASIC&&pmode==1)||  /*未注册*/
        (uentp->userlevel&PERM_POST&&pmode==2)||    /*已注册*/
        (uentp->userlevel&PERM_CLOAK&&pmode==3)||   /*隐身权限*/
        (uentp->userlevel&PERM_XEMPT&&pmode==4)||   /*账号保留*/
        (uentp->userlevel&PERM_BOARDS&&pmode==5)||  /*板主权限*/
        (uentp->userlevel&PERM_ACCOUNTS&&pmode==6)||/*账号管励*/
        (uentp->userlevel&PERM_CHATCLOAK&&pmode==7)||/*智囊团 */
        (uentp->userlevel&PERM_OBOARDS&&pmode==8)|| /*讨论前总管*/
        (uentp->userlevel&PERM_SYSOP&&pmode==9) )  /*系统管励员*/
        allpusers++;
  return 0;
}

int apusers()
{
  countpusers((struct userec *)NULL);
  if(apply_record(PASSFILE,countpusers,sizeof(struct userec)) == -1)
      return 0;
  return countpusers((struct userec *)NULL);
}

int FindPerm(uentp)
struct userec *uentp;
{
     /* level:  pmode */
    static int i;
    char permstr[10];
    char addstr[18];
    int override;
    if( uentp == NULL )  { printptitle(); i = 0; return 0; }
    if( uentp->numlogins == 0 ||
        uleveltochar(permstr,uentp->userlevel)==0 )
        return 0;
    if(i<page||i>=page+BBS_PAGESIZE||i>=range)  {
        i++;
        if(i>=page+BBS_PAGESIZE||i>=range)
            return QUIT;
        else
            return 0;
    }

    if( (uentp->userlevel==PERM_BASIC&&pmode==1)||  /*未注册*/
        (uentp->userlevel&PERM_POST&&pmode==2)||    /*已注册*/
        (uentp->userlevel&PERM_CLOAK&&pmode==3)||   /*隐身权限*/
        (uentp->userlevel&PERM_XEMPT&&pmode==4)||   /*账号保留*/
        (uentp->userlevel&PERM_BOARDS&&pmode==5)||  /*板主权限*/
        (uentp->userlevel&PERM_ACCOUNTS&&pmode==6)||/*账号管理*/
        (uentp->userlevel&PERM_CHATCLOAK&&pmode==7)||/*智囊团 */
        (uentp->userlevel&PERM_OBOARDS&&pmode==8)|| /*讨论区总管*/
        (uentp->userlevel&PERM_SYSOP&&pmode==9) )  /*系统管理员*/
        {
           uleveltochar(&permstr,uentp->userlevel);
           sprintf(addstr,"%-.16s",uentp->lasthost);
           user_data[i-page]=*uentp;
           override=myfriend(searchuser(uentp->userid));
           move(i-page+3,0);
           prints("%5d%2s%s%-12s%s  %-8s  %5d     %5d     %-8s
%-16s\n",i+1,
             (override)?"□":"",
             (override)?"":"",uentp->userid,(override)?"":"",
             uentp->realname,
             uentp->numlogins,
             uentp->numposts,
             permstr,
             addstr);
           i++ ;
     }
     return 0;
}
int getperm()
{
  modify_user_mode( LAUSERS );
  FindPerm((struct userec *)NULL);
  if(apply_record(PASSFILE,FindPerm,sizeof(struct userec))==-1)
  {
     prints("没有此权限的用户!");
     pressreturn();
     return 0;
  }
  clrtobot();
  return 0;
}
int dealukey(ch,allnum,pagenum)
char ch;
int allnum,pagenum;
{
        char    buf[STRLEN];
        static  int   msgflag;
        if(msgflag==YEA)
        {
                show_message(NULL);
                msgflag=NA;
        }
        switch(ch)
        {
                case 'h': case 'H':
                        show_help( "help/usershelp" );
                        break;
                case 'm': case 'M':
                        if(!HAS_PERM(PERM_POST))
                                return 1;
                        m_send(user_data[allnum-pagenum].userid);
                        break;
                case 'o': case 'O':
                        if(!strcmp("guest",currentuser.userid))
                                return 0;
                        sprintf(buf,"确定要把 %s 加入好友名单吗",
                                user_data[allnum-pagenum].userid);
                        move(BBS_PAGESIZE+3,0);
                        if(askyn(buf,NA,NA)==NA)
                                break;
                        if(addtooverride(user_data[allnum-pagenum].
userid)
                           ==-1)
                        {
                                sprintf(buf,"%s 已在朋友名单",
                                user_data[allnum-pagenum].userid);
                                show_message(buf);
                        }
                        else
                        {
                                sprintf(buf,"%s 列入朋友名单",
                                user_data[allnum-pagenum].userid);
                                show_message(buf);
                        }
                        msgflag=YEA;
                        return 1;
                        break;
               case 'd': case 'D':
                        sprintf(buf,"确定要把 %s 从好友名单删除吗",
                                user_data[allnum-pagenum].userid);
                        move(BBS_PAGESIZE+3,0);
                        if(askyn(buf,NA,NA)==NA)
                                break;
                        if(deleteoverride(user_data[allnum-pagenum].
userid,"frin
ds")
                           ==-1)
                        {
                                sprintf(buf,"%s 本来就不在朋友名单中",
                                user_data[allnum-pagenum].userid);
                                show_message(buf);
                        }
                        else
                        {
                                sprintf(buf,"%s 已从朋友名单移除",
                                user_data[allnum-pagenum].userid);
                                show_message(buf);
                        }
                        msgflag=YEA;
                        return 1;
                        break;
                default:
                        return 0;
                 }
               modify_user_mode( LAUSERS );
               if(readplan==NA)
               {
                print_title2();
                move(3,0);
                clrtobot();
                if(getperm()==-1)
                        return -1;
                update_endline();
               }
                redoscr();
                return 1;
}
void t_findperm()
{
  char msg[4];
  clear();
  move(0,0);
  friendmode = NA;
  modify_user_mode( LAUSERS );
  prints("查询具有下列权限的用户:\n\n");
  prints("(0)  放弃\n");
  prints("(1)  未注册账号\n");
  prints("(2)  已注册账号\n");
  prints("(3)  隐身权限\n");
  prints("(4)  账号永久保留\n");
  prints("(5)  板主权限\n");
  prints("(6)  账号管理\n");
  prints("(7)  智囊团成员\n");
  prints("(8)  讨论区总管\n");
  prints("(9)  系统管理员权限\n");
  getdata( 13, 0,"请输入您要查询的权限 (0~9) [0]:", msg, 2, DOECHO,
NULL, YEA);
  if( msg[0]-'0' < 1 || msg[0]-'0' > 9 )
       return;
  pmode = msg[0]-'0';
  range = apusers();
  if( range == 0 ) {
     move(15,0);
     prints("没有此权限的用户!");
     pressanykey();
     return;
  }
  clear();
  user_data=(struct userec *)calloc(sizeof(struct userec),
BBS_PAGESIZE);
  choose(NA,0,print_title2,dealukey,getperm,do_query2);
  clear();
  free(user_data);
  return;
}


--
※ 来源:·BBS 水木清华站 smth.org·[FROM: 202.115.64.174]

--
※ 来源:·荔园晨风BBS站 bbs.szu.edu.cn·[FROM: 192.168.35.4]


[回到开始] [上一篇][下一篇]

荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店