def CmdUnban(mob,args):
    if not len(args):
        return
    
    from mud.common.permission import BannedUser
    try:
        banned = BannedUser.byName(args[0])
        banned.destroySelf()
        mob.player.sendGameText(RPG_MSG_GAME_GAINED,"User %s has been unbanned.\\n"%args[0])
        return
    except:
        pass

    mob.player.sendGameText(RPG_MSG_GAME_DENIED,"User %s hasn't been banned.\\n"%args[0])
def CmdUnban(mob, args):
    if not len(args):
        return

    from mud.common.permission import BannedUser
    try:
        banned = BannedUser.byName(args[0])
        banned.destroySelf()
        mob.player.sendGameText(RPG_MSG_GAME_GAINED,
                                "User %s has been unbanned.\\n" % args[0])
        return
    except:
        pass

    mob.player.sendGameText(RPG_MSG_GAME_DENIED,
                            "User %s hasn't been banned.\\n" % args[0])
def CmdBan(mob, args):
    from mud.common.permission import User, Role, BannedUser
    from player import Player

    if not len(args):
        return

    try:
        player = Player.byPublicName(args[0])
    except:
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,
                                "Unknown player %s.\\n" % args[0])
        return

    if not IsUserSuperior(mob.player.publicName, player.publicName):
        mob.player.sendGameText(
            RPG_MSG_GAME_DENIED,
            "You do not have the required permission for this action.\\n")
        return

    try:
        banned = BannedUser.byName(args[0])
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,
                                "User %s already banned.\\n" % args[0])
        return
    except:
        pass

    try:
        user = User.byName(args[0])
    except:
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,
                                "Unknown user %s.\\n" % args[0])
        return

    #bye bye
    BannedUser(name=args[0])
    mob.player.sendGameText(RPG_MSG_GAME_GAINED,
                            "User %s has been banned.\\n" % args[0])

    world = mob.player.world
    world.kickPlayer(player)
def CmdBan(mob,args):
    from mud.common.permission import User,Role, BannedUser
    from player import Player
    
    if not len(args):
        return

    try:
        player = Player.byPublicName(args[0])
    except:
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Unknown player %s.\\n"%args[0])
        return
    
    if not IsUserSuperior(mob.player.publicName,player.publicName):
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,"You do not have the required permission for this action.\\n")
        return

    
    try:
        banned = BannedUser.byName(args[0])
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,"User %s already banned.\\n"%args[0])
        return
    except:
        pass
    
    try:
        user = User.byName(args[0])
    except:
        mob.player.sendGameText(RPG_MSG_GAME_DENIED,"Unknown user %s.\\n"%args[0])
        return
    
    #bye bye
    BannedUser(name=args[0])
    mob.player.sendGameText(RPG_MSG_GAME_GAINED,"User %s has been banned.\\n"%args[0])


    world = mob.player.world
    world.kickPlayer(player)
    def requestAvatarId(self, credentials):

        if len(credentials.username.split('-'))!=2:
            return failure.Failure(UnauthorizedError())
            
            
        username,role=credentials.username.split('-')
        
        try:
            banned = BannedUser.byName(username)
            return failure.Failure(BannedError())
        except:
            pass
        
        if THESERVER.roleLimits.has_key(role):
            limit = THESERVER.roleLimits[role]
            if not limit:
                return failure.Failure(ServerFullError())
            n = 0
            for x in MasterPerspective.users:
                
                if role == x[1]:
                    n+=1
                    if n == limit:
                        return failure.Failure(ServerFullError())
                        
        
        roles = ('Player','Immortal','Guardian','World')
        if role in roles:
            for r in roles:
                if (username,r) in MasterPerspective.users[:]:
                    for avatar in THESERVER.realm.avatars[:]:
                        if avatar.username == username and avatar.role.name == r:
                            #kick
                            try:
                                avatar.logout()
                            except:
                                traceback.print_exc()
                                

        
        try:
            user = User.byName(username)

        except SQLObjectNotFound:
            print "User not found",username
            return failure.Failure(UnauthorizedError())
        
        if self.useMD5:
            matched = credentials.checkPassword(md5(user.password).digest())
            if not matched:
                matched = credentials.checkPassword(md5(user.tempPassword).digest())
                
            #XXX REMOVE ME AT A LATER TIME, LEGACY non-md5 using CLIENTS!!! 9-10-06
            if not matched:
                matched = credentials.checkPassword(user.password)

        else:
            matched = credentials.checkPassword(user.password)
            if not matched:
                matched = credentials.checkPassword(user.tempPassword)
            
        if not matched:
            return failure.Failure(UnauthorizedError())
            
        r = user.getRole(role)
        if r:
            print r
            return credentials.username
                        
        #bad role
        
        return failure.Failure(UnauthorizedError())
Exemple #6
0
    def requestAvatarId(self, credentials):

        if len(credentials.username.split('-')) != 2:
            return failure.Failure(UnauthorizedError())

        username, role = credentials.username.split('-')

        try:
            banned = BannedUser.byName(username)
            return failure.Failure(BannedError())
        except:
            pass

        if THESERVER.roleLimits.has_key(role):
            limit = THESERVER.roleLimits[role]
            if not limit:
                return failure.Failure(ServerFullError())
            n = 0
            for x in MasterPerspective.users:

                if role == x[1]:
                    n += 1
                    if n == limit:
                        return failure.Failure(ServerFullError())

        roles = ('Player', 'Immortal', 'Guardian', 'World')
        if role in roles:
            for r in roles:
                if (username, r) in MasterPerspective.users[:]:
                    for avatar in THESERVER.realm.avatars[:]:
                        if avatar.username == username and avatar.role.name == r:
                            #kick
                            try:
                                avatar.logout()
                            except:
                                traceback.print_exc()

        try:
            user = User.byName(username)

        except SQLObjectNotFound:
            print "User not found", username
            return failure.Failure(UnauthorizedError())

        if self.useMD5:
            matched = credentials.checkPassword(md5(user.password).digest())
            if not matched:
                matched = credentials.checkPassword(
                    md5(user.tempPassword).digest())

            #XXX REMOVE ME AT A LATER TIME, LEGACY non-md5 using CLIENTS!!! 9-10-06
            if not matched:
                matched = credentials.checkPassword(user.password)

        else:
            matched = credentials.checkPassword(user.password)
            if not matched:
                matched = credentials.checkPassword(user.tempPassword)

        if not matched:
            return failure.Failure(UnauthorizedError())

        r = user.getRole(role)
        if r:
            print r
            return credentials.username

        #bad role

        return failure.Failure(UnauthorizedError())