Ejemplo n.º 1
0
        public static bool IsIPBanned(string ip)
        {
            bool        yes = false;
            int         now = UnixTimestamp();
            IDataReader DBQuery;

            if (EBConfig.UseMysql)
            {
                DBQuery = EBData.DBMysql.QueryReader("SELECT IP FROM BannedIP WHERE IP = @0 AND (UnbanDate>@1 OR UnbanDate = 0)", ip, now).Reader;
            }
            else
            {
                DBQuery = EBData.DBSqlite.QueryReader("SELECT IP FROM BannedIP WHERE IP = @0 AND (UnbanDate>@1 OR UnbanDate = 0)", ip, now).Reader;
            }
            while (DBQuery.Read())
            {
                if (ip == DBQuery.Get <string>("IP"))
                {
                    yes = true;
                    break;
                }
            }
            if (!EBConfig.UseMysql)
            {
                EBData.DBSqlite.Dispose();
            }
            else
            {
                EBData.DBMysql.Close();
            }
            DBQuery.Dispose();
            return(yes);
        }
Ejemplo n.º 2
0
        public static bool IsPlayerMuted(string plName)
        {
            bool        yes = false;
            int         now = UnixTimestamp();
            IDataReader DBQuery;

            if (EBConfig.UseMysql)
            {
                DBQuery = EBData.DBMysql.QueryReader("SELECT Player FROM MutedPlayer WHERE LOWER(Player) = @0 AND (UnmuteDate>@1 OR UnmuteDate = 0)", plName.ToLower(), now).Reader;
            }
            else
            {
                DBQuery = EBData.DBSqlite.QueryReader("SELECT Player FROM MutedPlayer WHERE LOWER(Player) = @0 AND (UnmuteDate>@1 OR UnmuteDate = 0)", plName.ToLower(), now).Reader;
            }
            while (DBQuery.Read())
            {
                if (plName.ToLower() == DBQuery.Get <string>("Player").ToLower())
                {
                    yes = true;
                    break;
                }
            }
            if (!EBConfig.UseMysql)
            {
                EBData.DBSqlite.Dispose();
            }
            else
            {
                EBData.DBMysql.Close();
            }
            DBQuery.Dispose();
            return(yes);
        }
Ejemplo n.º 3
0
        public static string[] IPBanInfo(string ip)
        {
            string[] baninfo = new string[6];
            if (!IsValidIP(ip.Replace("*", "255")))
            {
                return(baninfo);
            }
            int now = UnixTimestamp();

            string[]    ipnets = ip.Split('.');
            IDataReader DBQuery;

            if (EBConfig.UseMysql)
            {
                DBQuery = EBData.DBMysql.QueryReader("SELECT * FROM BannedIP WHERE UnbanDate>@0 OR UnbanDate = 0", now).Reader;
            }
            else
            {
                DBQuery = EBData.DBSqlite.QueryReader("SELECT * FROM BannedIP WHERE UnbanDate>@0 OR UnbanDate = 0", now).Reader;
            }
            while (DBQuery.Read())
            {
                string   ipban = DBQuery.Get <string>("IP");
                string[] nets  = ipban.Split('.');
                if (nets[0] == ipnets[0] || nets[0] == "*")
                {
                    if (nets[1] == ipnets[1] || nets[1] == "*")
                    {
                        if (nets[2] == ipnets[2] || nets[2] == "*")
                        {
                            if (nets[3] == ipnets[3] || nets[3] == "*")
                            {
                                baninfo[0] = "banned";
                                baninfo[1] = DBQuery.Get <string>("IP");
                                baninfo[2] = DBQuery.Get <int>("BanDate").ToString();
                                baninfo[3] = DBQuery.Get <int>("UnbanDate").ToString();
                                baninfo[4] = DBQuery.Get <string>("BannedBy");
                                baninfo[5] = DBQuery.Get <string>("Reason");
                                break;
                            }
                        }
                    }
                }
            }
            if (!EBConfig.UseMysql)
            {
                EBData.DBSqlite.Dispose();
            }
            else
            {
                EBData.DBMysql.Close();
            }
            DBQuery.Dispose();
            return(baninfo);
        }
Ejemplo n.º 4
0
        public static string[] PlayerBanInfo(string plName)
        {
            string[]    baninfo = new string[6];
            int         now     = UnixTimestamp();
            IDataReader DBQuery;

            if (EBConfig.UseMysql)
            {
                DBQuery = EBData.DBMysql.QueryReader("SELECT * FROM BannedPlayer WHERE UnbanDate>@0 OR UnbanDate = 0", now).Reader;
            }
            else
            {
                DBQuery = EBData.DBSqlite.QueryReader("SELECT * FROM BannedPlayer WHERE UnbanDate>@0 OR UnbanDate = 0", now).Reader;
            }
            while (DBQuery.Read())
            {
                string plBanned = DBQuery.Get <string>("Player");
                if (plBanned.ToLower() == plName.ToLower())
                {
                    baninfo[0] = "banned";
                    baninfo[1] = DBQuery.Get <string>("Player");
                    baninfo[2] = DBQuery.Get <int>("BanDate").ToString();
                    baninfo[3] = DBQuery.Get <int>("UnbanDate").ToString();
                    baninfo[4] = DBQuery.Get <string>("BannedBy");
                    baninfo[5] = DBQuery.Get <string>("Reason");
                    break;
                }
            }
            if (!EBConfig.UseMysql)
            {
                EBData.DBSqlite.Dispose();
            }
            else
            {
                EBData.DBMysql.Close();
            }
            DBQuery.Dispose();
            return(baninfo);
        }