internal void BanUser(GameClient Client, string Username, string MachineId, string Reason, double LengthSeconds, GameClient Session)
        {
            string Var    = Username;
            string RawVar = "user";

            if (Username.Length > 0)
            {
                RawVar = "user";
                Var    = Username;
            }
            else if (MachineId.Length > 0)
            {
                RawVar = "machine";
                Var    = MachineId;
            }

            double Expire = OtanixEnvironment.GetUnixTimestamp() + LengthSeconds;

            if (RawVar == "user")
            {
                if (UsersCache.getIdByUsername(Username) == 0)
                {
                    Session.SendNotif(LanguageLocale.GetValue("input.usernotfound"));
                    return;
                }
            }

            using (IQueryAdapter dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("REPLACE INTO bans (bantype,value,reason,expire,added_by,added_date) VALUES (@rawvar,@var,@reason,'" + Expire + "',@mod,'" + DateTime.Now.ToLongDateString() + "')");
                dbClient.addParameter("rawvar", RawVar);
                dbClient.addParameter("var", Var);
                dbClient.addParameter("reason", Reason);
                dbClient.addParameter("mod", (Session == null) ? "Automatic-BAN" : Session.GetHabbo().Username);
                dbClient.runQuery();
            }

            switch (RawVar)
            {
            case "user":
            {
                Ban ban = new Ban(ModerationBanType.USERNAME, Var, Reason, Expire);
                if (!bannedUsernames.ContainsKey(Var))
                {
                    bannedUsernames.Add(Var, ban);
                }

                break;
            }

            case "machine":
            {
                Ban ban = new Ban(ModerationBanType.MACHINEID, Var, Reason, Expire);
                if (!bannedMachinedId.ContainsKey(Var))
                {
                    bannedMachinedId.Add(Var, ban);
                }

                break;
            }
            }

            if (Client != null && Client.GetConnection() != null)
            {
                Client.SendBanMessage(LanguageLocale.GetValue("moderation.banned") + " " + Reason);
                Client.Disconnect();
            }
        }
Exemple #2
0
        internal void Fill(DataRow Row, uint modelId = 0)
        {
            Id                   = modelId != 0 ? modelId : Convert.ToUInt32(Row["id"]);
            Name                 = (string)Row["caption"];
            Description          = (string)Row["description"];
            Type                 = (string)Row["roomtype"];
            Owner                = (string)Row["owner"];
            OwnerId              = UsersCache.getIdByUsername(Owner);
            State                = (int)Row["state"];
            Category             = (int)Row["category"];
            UsersNow             = 0;
            UsersMax             = Convert.ToUInt32(Row["users_max"]);
            ModelName            = (string)Row["model_name"];
            LastModelName        = ModelName;
            Score                = (int)Row["score"];
            Tags                 = new List <string>();
            TradeSettings        = (int)Row["trade_settings"];
            AllowPets            = OtanixEnvironment.EnumToBool(Row["allow_pets"].ToString());
            AllowPetsEating      = OtanixEnvironment.EnumToBool(Row["allow_pets_eat"].ToString());
            AllowWalkthrough     = OtanixEnvironment.EnumToBool(Row["allow_walkthrough"].ToString());
            AllowRightsOverride  = OtanixEnvironment.EnumToBool(Row["allow_rightsoverride"].ToString());
            AllowDiagonalEnabled = OtanixEnvironment.EnumToBool(Row["allow_diagonals"].ToString());
            AntiFloodSettings    = (int)Row["antiflood_settings"];
            ChatDistance         = (int)Row["chat_distance"];
            Hidewall             = OtanixEnvironment.EnumToBool(Row["allow_hidewall"].ToString());
            Password             = (string)Row["password"];
            Wallpaper            = (string)Row["wallpaper"];
            Floor                = (string)Row["floor"];
            Landscape            = (string)Row["landscape"];
            FloorThickness       = (int)Row["floorthickness"];
            WallThickness        = (int)Row["wallthickness"];
            MuteFuse             = Convert.ToInt32((string)Row["moderation_mute_fuse"]);
            KickFuse             = Convert.ToInt32((string)Row["moderation_kick_fuse"]);
            BanFuse              = Convert.ToInt32((string)Row["moderation_ban_fuse"]);
            GroupId              = Convert.ToUInt32(Row["groupId"]);
            BubbleMode           = Convert.ToInt32((string)Row["bubble_mode"]);
            BubbleType           = Convert.ToInt32((string)Row["bubble_type"]);
            BubbleScroll         = Convert.ToInt32((string)Row["bubble_scroll"]);
            WallHeight           = Convert.ToInt32(Row["wall_height"]);
            RollerSpeed          = Convert.ToUInt32(Row["roller_speed"]);
            temEmblema           = (string)Row["temEmblema"];

            DisabledCommands = new List <int>();
            foreach (string StrCommandId in Row["disable_commands"].ToString().Split(','))
            {
                int CommandId = -1;
                if (!int.TryParse(StrCommandId, out CommandId))
                {
                    continue;
                }

                if (!DisabledCommands.Contains(CommandId))
                {
                    DisabledCommands.Add(CommandId);
                }
            }

            foreach (var Tag in Row["tags"].ToString().Split(','))
            {
                Tags.Add(Tag);
            }

            mModel = OtanixEnvironment.GetGame().GetRoomManager().GetModel(ModelName, Id);
        }