コード例 #1
0
        private void HandleTimeouts()
        {
            while (true)
            {
                try
                {
                    while (timedOutConnections.Count > 0)
                    {
                        GameClient client = null;
                        lock (timedOutConnections.SyncRoot)
                        {
                            if (timedOutConnections.Count > 0)
                            {
                                client = (GameClient)timedOutConnections.Dequeue();
                            }
                        }

                        if (client != null)
                        {
                            client.Disconnect();
                        }
                    }
                }
                catch (Exception e)
                {
                    Logging.LogThreadException(e.ToString(), "HandleTimeouts");
                }

                Thread.Sleep(5000);
            }
        }
コード例 #2
0
        internal void LogClonesOut(uint UserID)
        {
            GameClient client = GetClientByUserID(UserID);

            if (client != null)
            {
                client.Disconnect();
            }
        }
コード例 #3
0
        // PENDING REWRITE
        internal void BanUser(GameClient Client, string Moderator, Double LengthSeconds, string Reason, Boolean IpBan)
        {
            ModerationBanType Type = ModerationBanType.USERNAME;
            string Var = Client.GetHabbo().Username;
            string RawVar = "user";
            Double Expire = PiciEnvironment.GetUnixTimestamp() + LengthSeconds;

            if (Reason == null)
            {
                Client.SendNotif("Please fill in a reason to ban a user.");
                return;
            }

            if (IpBan)
            {
                Type = ModerationBanType.IP;
                Var = Client.GetConnection().getIp();
                RawVar = "ip";
            }

            ModerationBan ban = new ModerationBan(Type, Var, Reason, Expire);

            if (ban.Type == ModerationBanType.IP)
            {
                if (bannedIPs.ContainsKey(Var))
                    bannedIPs[Var] = ban;
                else
                    bannedIPs.Add(Var, ban);
            }
            else
            {
                if (bannedUsernames.ContainsKey(Var))
                    bannedUsernames[Var] = ban;
                else
                    bannedUsernames.Add(Var, ban);
            }

            using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("INSERT 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", Moderator);
                dbClient.runQuery();
            }

            if (IpBan)
            {
                DataTable UsersAffected = null;

                using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.setQuery("SELECT id FROM users WHERE ip_last = @var");
                    dbClient.addParameter("var", Var);
                    UsersAffected = dbClient.getTable();
                }

                if (UsersAffected != null)
                {
                    using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        foreach (DataRow Row in UsersAffected.Rows)
                        {
                            dbClient.runFastQuery("UPDATE user_info SET bans = bans + 1 WHERE user_id = " + Convert.ToUInt32(Row["id"]));
                        }
                    }
                }

                BanUser(Client, Moderator, LengthSeconds, Reason, false);
            }
            else
            {
                using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.runFastQuery("UPDATE user_info SET bans = bans + 1 WHERE user_id = " + Client.GetHabbo().Id);
                }

                Client.SendBanMessage(LanguageLocale.GetValue("moderation.banned") + " " + Reason);
                Client.Disconnect();
            }
        }