Exemplo n.º 1
0
 public Row(MySQL.Result store, IntPtr value)
 {
     this.Record = new Dictionary <string, MySQL.Record>();
     for (int i = 0; i < store.Field.Count; i++)
     {
         this.Record.Add(store.Field[i].Name, new MySQL.Record(store.Field[i], this.GetRecord(value, i)));
     }
 }
Exemplo n.º 2
0
 public static bool LoadAsDatabaseSQL()
 {
     MySQL.Result result = MySQL.Query("SELECT * FROM `db_users_banned`;", false);
     if (result != null)
     {
         foreach (MySQL.Row current in result.Row)
         {
             ulong asUInt = current.Get("steam_id").AsUInt64;
             if (!Banned.Database.ContainsKey(asUInt))
             {
                 Banned.Database.Add(asUInt, new UserBanned(current.Get("ip_address").AsString, current.Get("date").AsDateTime, current.Get("period").AsDateTime, current.Get("reason").AsString, ""));
             }
         }
     }
     return(true);
 }
Exemplo n.º 3
0
 public static bool LoadAsDatabaseSQL()
 {
     MySQL.Result result = MySQL.Query("SELECT * FROM `db_users_banned`;", false);
     if (result != null)
     {
         foreach (MySQL.Row row in result.Row)
         {
             ulong key = row.Get("steam_id").AsUInt64;
             if (!Database.ContainsKey(key))
             {
                 Database.Add(key, new UserBanned(row.Get("ip_address").AsString, row.Get("date").AsDateTime, row.Get("period").AsDateTime, row.Get("reason").AsString, ""));
             }
         }
     }
     return(true);
 }
Exemplo n.º 4
0
 public static bool LoadAsDatabaseSQL()
 {
     MySQL.Result result = MySQL.Query("SELECT * FROM `db_blocked_ip`;", false);
     if (result != null)
     {
         foreach (MySQL.Row row in result.Row)
         {
             string asString = row.Get("ip_address").AsString;
             if (!list_0.Contains(asString))
             {
                 list_0.Add(asString);
             }
         }
     }
     return(true);
 }
Exemplo n.º 5
0
 public static void SQL_UpdateServer()
 {
     MySQL.Result result = MySQL.Query("SELECT * FROM `db_server`;", true);
     if (result != null)
     {
         foreach (MySQL.Row row in result.Row)
         {
             if (row.Get("name").AsString.Equals("rcon_command", StringComparison.OrdinalIgnoreCase) && !row.Get("value").IsNull)
             {
                 ConsoleSystem.Arg arg = new ConsoleSystem.Arg(row.Get("value").AsString);
                 if (!ConsoleSystem.RunCommand(ref arg, true))
                 {
                     ConsoleSystem.PrintError(arg.Reply, false);
                 }
                 MySQL.Update(string.Format(SQL_SERVER_SET, row.Get("name").AsString, "NULL"));
             }
         }
     }
     MySQL.Update(string.Format(SQL_SERVER_SET, "time_update", MySQL.QuoteString(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))));
 }
Exemplo n.º 6
0
 public SQLQuery(MySQL.Result result, string query)
 {
     this.Query  = query;
     this.Result = result;
 }
Exemplo n.º 7
0
 public static MySQL.Result Query(string query, bool skip = false)
 {
     MySQL.Result result = null;
     MySQL.Result result3;
     try
     {
         if (!MySQL.IsReady && skip)
         {
             MySQL.Result result2 = result;
             result3 = result2;
             return(result3);
         }
         MySQL.IsReady = false;
         int num;
         if (Core.MySQL_UTF8)
         {
             num = MySQL.mysql_query(MySQL.SQL, query);
         }
         else
         {
             num = MySQL.mysql_real_query(MySQL.SQL, query, query.Length);
         }
         if (num != 0 || MySQL.ErrorCode != 0u)
         {
             if (MySQL.LogLevel > MySQL.LogLevelType.NONE)
             {
                 Helper.LogSQLError(MySQL.Error(), true);
             }
             MySQL.mysql_ping(MySQL.SQL);
             MySQL.IsReady = true;
             MySQL.Result result2 = null;
             result3 = result2;
             return(result3);
         }
         if (MySQL.LogLevel > MySQL.LogLevelType.ERRORS)
         {
             Helper.LogSQL(query, false);
         }
         IntPtr intPtr = MySQL.mysql_store_result(MySQL.SQL);
         if (MySQL.ErrorCode == 0u && !(intPtr == IntPtr.Zero))
         {
             result        = new MySQL.Result();
             result.Fields = MySQL.mysql_num_fields(intPtr);
             result.Rows   = MySQL.mysql_num_rows(intPtr);
             int num2 = 0;
             while ((long)num2 < (long)((ulong)result.Fields))
             {
                 result.Field.Add((MySQL.Field)Marshal.PtrToStructure(MySQL.mysql_fetch_field(intPtr), typeof(MySQL.Field)));
                 num2++;
             }
             IntPtr value;
             while ((value = MySQL.mysql_fetch_row(intPtr)) != IntPtr.Zero)
             {
                 result.Row.Add(new MySQL.Row(result, value));
             }
             MySQL.mysql_free_result(intPtr);
         }
         else
         {
             result = null;
         }
     }
     catch (Exception ex)
     {
         result = null;
         Helper.LogSQLError(query, false);
         Helper.LogSQLError(ex.Message.ToString(), true);
     }
     MySQL.IsReady = true;
     result3       = result;
     return(result3);
 }
Exemplo n.º 8
0
 public static void SQL_SynchronizeClans()
 {
     if (Core.DatabaseType.Equals("MYSQL"))
     {
         MySQL.Result result = MySQL.Query("SELECT * FROM `db_clans`;", true);
         if (result != null)
         {
             using (List <MySQL.Row> .Enumerator enumerator = result.Row.GetEnumerator())
             {
                 while (enumerator.MoveNext())
                 {
                     Predicate <ClanLevel> predicate = null;
                     Clans.Class3          @class    = new Clans.Class3();
                     @class.row_0 = enumerator.Current;
                     uint     asUInt = @class.row_0.Get("id").AsUInt;
                     ClanData clanData;
                     if (Clans.Database.ContainsKey(asUInt))
                     {
                         clanData = Clans.Get(asUInt);
                     }
                     else
                     {
                         Clans.Database.Add(asUInt, clanData = new ClanData(asUInt, null, null, 0uL, default(DateTime)));
                     }
                     if (!Clans.dictionary_0.ContainsKey(asUInt))
                     {
                         Clans.dictionary_0.Add(asUInt, 0uL);
                     }
                     if (Clans.Database[clanData.ID].Hash == Clans.dictionary_0[clanData.ID])
                     {
                         clanData.Name     = @class.row_0.Get("name").AsString;
                         clanData.Abbr     = @class.row_0.Get("abbrev").AsString;
                         clanData.LeaderID = @class.row_0.Get("leader_id").AsUInt64;
                         clanData.Created  = @class.row_0.Get("created").AsDateTime;
                         clanData.Flags    = @class.row_0.Get("flags").AsEnum <ClanFlags>();
                         clanData.Balance  = @class.row_0.Get("balance").AsUInt64;
                         clanData.Tax      = @class.row_0.Get("tax").AsUInt;
                         ClanData         clanData2 = clanData;
                         List <ClanLevel> levels    = Clans.Levels;
                         if (predicate == null)
                         {
                             predicate = new Predicate <ClanLevel>(@class.method_0);
                         }
                         clanData2.SetLevel(levels.Find(predicate));
                         clanData.Experience = @class.row_0.Get("experience").AsUInt64;
                         string[] array = @class.row_0.Get("location").AsString.Replace(", ", ",").Split(new char[]
                         {
                             ','
                         });
                         if (array.Length > 0)
                         {
                             float.TryParse(array[0].Trim(), out clanData.Location.x);
                         }
                         if (array.Length > 1)
                         {
                             float.TryParse(array[1].Trim(), out clanData.Location.y);
                         }
                         if (array.Length > 2)
                         {
                             float.TryParse(array[2].Trim(), out clanData.Location.z);
                         }
                         clanData.MOTD    = @class.row_0.Get("motd").AsString;
                         clanData.Penalty = @class.row_0.Get("penalty").AsDateTime;
                     }
                     else
                     {
                         Clans.SQL_Update(clanData, false);
                     }
                     Clans.dictionary_0[asUInt] = Clans.Database[asUInt].Hash;
                 }
             }
         }
     }
 }
Exemplo n.º 9
0
        public static bool LoadAsDatabaseSQL()
        {
            Predicate <ClanLevel> predicate = null;

            Clans.Class1 @class = new Clans.Class1();
            Clans.Loaded = 0;
            ClanData clanData = null;
            UserData userData = null;

            @class.row_0 = null;
            MySQL.Result result  = MySQL.Query("SELECT * FROM `db_clans`;", false);
            MySQL.Result result2 = MySQL.Query("SELECT * FROM `db_clans_members`;", false);
            MySQL.Result result3 = MySQL.Query("SELECT * FROM `db_clans_hostile`;", false);
            if (result2 != null && result != null)
            {
                foreach (MySQL.Row current in result2.Row)
                {
                    Clans.Class2 class2 = new Clans.Class2();
                    class2.class1_0 = @class;
                    ulong asUInt = current.Get("user_id").AsUInt64;
                    class2.uint_0 = current.Get("clan_id").AsUInt;
                    userData      = Users.GetBySteamID(asUInt);
                    if (userData != null && class2.uint_0 != 0u)
                    {
                        if (@class.row_0 == null || @class.row_0.Get("id").AsUInt != class2.uint_0)
                        {
                            @class.row_0 = result.Row.Find(new Predicate <MySQL.Row>(class2.method_0));
                        }
                        if (@class.row_0 == null)
                        {
                            MySQL.Query(string.Format(Clans.SQL_DELETE_MEMBER, asUInt), false);
                        }
                        else
                        {
                            ClanMemberFlags value = current.Get("privileges").AsEnum <ClanMemberFlags>();
                            if (clanData == null || clanData.ID != class2.uint_0)
                            {
                                clanData = Clans.Get(class2.uint_0);
                            }
                            if (clanData == null)
                            {
                                clanData          = new ClanData(class2.uint_0, null, null, 0uL, default(DateTime));
                                clanData.Name     = @class.row_0.Get("name").AsString;
                                clanData.Abbr     = @class.row_0.Get("abbrev").AsString;
                                clanData.LeaderID = @class.row_0.Get("leader_id").AsUInt64;
                                clanData.Created  = @class.row_0.Get("created").AsDateTime;
                                clanData.Flags    = @class.row_0.Get("flags").AsEnum <ClanFlags>();
                                clanData.Balance  = @class.row_0.Get("balance").AsUInt64;
                                clanData.Tax      = @class.row_0.Get("tax").AsUInt;
                                ClanData         clanData2 = clanData;
                                List <ClanLevel> levels    = Clans.Levels;
                                if (predicate == null)
                                {
                                    predicate = new Predicate <ClanLevel>(@class.method_0);
                                }
                                clanData2.SetLevel(levels.Find(predicate));
                                clanData.Experience = @class.row_0.Get("experience").AsUInt64;
                                string[] array = @class.row_0.Get("location").AsString.Split(new char[]
                                {
                                    ','
                                });
                                if (array.Length > 0)
                                {
                                    float.TryParse(array[0], out clanData.Location.x);
                                }
                                if (array.Length > 1)
                                {
                                    float.TryParse(array[1], out clanData.Location.y);
                                }
                                if (array.Length > 2)
                                {
                                    float.TryParse(array[2], out clanData.Location.z);
                                }
                                clanData.MOTD    = @class.row_0.Get("motd").AsString;
                                clanData.Penalty = @class.row_0.Get("penalty").AsDateTime;
                                if (result3 != null)
                                {
                                    foreach (MySQL.Row current2 in result3.Row)
                                    {
                                        if (current2.Get("clan_id").AsUInt == class2.uint_0)
                                        {
                                            clanData.Hostile.Add(current2.Get("hostile_id").AsUInt, current2.Get("ending").AsDateTime);
                                        }
                                    }
                                }
                                Clans.Database.Add(clanData.ID, clanData);
                                Clans.Loaded++;
                            }
                            clanData.Members.Add(userData, value);
                            userData.Clan = clanData;
                        }
                    }
                    else
                    {
                        MySQL.Query(string.Format(Clans.SQL_DELETE_MEMBER, asUInt), false);
                    }
                }
            }
            Clans.dictionary_0.Clear();
            foreach (uint current3 in Clans.Database.Keys)
            {
                Clans.dictionary_0.Add(current3, Clans.Database[current3].Hash);
            }
            return(true);
        }
Exemplo n.º 10
0
 public static void SQL_SynchronizeClans()
 {
     if (Core.DatabaseType.Equals("MYSQL"))
     {
         MySQL.Result result = MySQL.Query("SELECT * FROM `db_clans`;", true);
         if (result != null)
         {
             using (System.Collections.Generic.List <MySQL.Row> .Enumerator enumerator = result.Row.GetEnumerator())
             {
                 while (enumerator.MoveNext())
                 {
                     Predicate <ClanLevel> match = null;
                     Class3 class2 = new Class3 {
                         row_0 = enumerator.Current
                     };
                     ClanData clandata = null;
                     uint     asUInt   = class2.row_0.Get("id").AsUInt;
                     if (Database.ContainsKey(asUInt))
                     {
                         clandata = Get(asUInt);
                     }
                     else
                     {
                         DateTime created = new DateTime();
                         Database.Add(asUInt, clandata = new ClanData(asUInt, null, null, 0L, created));
                     }
                     if (!dictionary_0.ContainsKey(asUInt))
                     {
                         dictionary_0.Add(asUInt, 0L);
                     }
                     if (Database[clandata.ID].Hash == dictionary_0[clandata.ID])
                     {
                         clandata.Name     = class2.row_0.Get("name").AsString;
                         clandata.Abbr     = class2.row_0.Get("abbrev").AsString;
                         clandata.LeaderID = class2.row_0.Get("leader_id").AsUInt64;
                         clandata.Created  = class2.row_0.Get("created").AsDateTime;
                         clandata.Flags    = class2.row_0.Get("flags").AsEnum <ClanFlags>();
                         clandata.Balance  = class2.row_0.Get("balance").AsUInt64;
                         clandata.Tax      = class2.row_0.Get("tax").AsUInt;
                         if (match == null)
                         {
                             match = new Predicate <ClanLevel>(class2.method_0);
                         }
                         clandata.SetLevel(Levels.Find(match));
                         clandata.Experience = class2.row_0.Get("experience").AsUInt64;
                         string[] strArray = class2.row_0.Get("location").AsString.Replace(", ", ",").Split(new char[] { ',' });
                         if (strArray.Length > 0)
                         {
                             float.TryParse(strArray[0].Trim(), out clandata.Location.x);
                         }
                         if (strArray.Length > 1)
                         {
                             float.TryParse(strArray[1].Trim(), out clandata.Location.y);
                         }
                         if (strArray.Length > 2)
                         {
                             float.TryParse(strArray[2].Trim(), out clandata.Location.z);
                         }
                         clandata.MOTD    = class2.row_0.Get("motd").AsString;
                         clandata.Penalty = class2.row_0.Get("penalty").AsDateTime;
                     }
                     else
                     {
                         SQL_Update(clandata, false);
                     }
                     dictionary_0[asUInt] = Database[asUInt].Hash;
                 }
             }
         }
     }
 }
Exemplo n.º 11
0
        public static bool LoadAsDatabaseSQL()
        {
            Predicate <ClanLevel> match = null;
            Class1 class3 = new Class1();

            Loaded = 0;
            ClanData data = null;
            UserData key  = null;

            class3.row_0 = null;
            MySQL.Result result  = MySQL.Query("SELECT * FROM `db_clans`;", false);
            MySQL.Result result2 = MySQL.Query("SELECT * FROM `db_clans_members`;", false);
            MySQL.Result result3 = MySQL.Query("SELECT * FROM `db_clans_hostile`;", false);
            if ((result2 != null) && (result != null))
            {
                foreach (MySQL.Row row in result2.Row)
                {
                    Class2 class2 = new Class2 {
                        class1_0 = class3
                    };
                    ulong num = row.Get("user_id").AsUInt64;
                    class2.uint_0 = row.Get("clan_id").AsUInt;
                    key           = Users.GetBySteamID(num);
                    if ((key != null) && (class2.uint_0 != 0))
                    {
                        if ((class3.row_0 == null) || (class3.row_0.Get("id").AsUInt != class2.uint_0))
                        {
                            class3.row_0 = result.Row.Find(new Predicate <MySQL.Row>(class2.method_0));
                        }
                        if (class3.row_0 == null)
                        {
                            MySQL.Query(string.Format(SQL_DELETE_MEMBER, num), false);
                        }
                        else
                        {
                            ClanMemberFlags flags = row.Get("privileges").AsEnum <ClanMemberFlags>();
                            if ((data == null) || (data.ID != class2.uint_0))
                            {
                                data = Get(class2.uint_0);
                            }
                            if (data == null)
                            {
                                DateTime created = new DateTime();
                                data = new ClanData(class2.uint_0, null, null, 0L, created)
                                {
                                    Name     = class3.row_0.Get("name").AsString,
                                    Abbr     = class3.row_0.Get("abbrev").AsString,
                                    LeaderID = class3.row_0.Get("leader_id").AsUInt64,
                                    Created  = class3.row_0.Get("created").AsDateTime,
                                    Flags    = class3.row_0.Get("flags").AsEnum <ClanFlags>(),
                                    Balance  = class3.row_0.Get("balance").AsUInt64,
                                    Tax      = class3.row_0.Get("tax").AsUInt
                                };
                                if (match == null)
                                {
                                    match = new Predicate <ClanLevel>(class3.method_0);
                                }
                                data.SetLevel(Levels.Find(match));
                                data.Experience = class3.row_0.Get("experience").AsUInt64;
                                string[] strArray = class3.row_0.Get("location").AsString.Split(new char[] { ',' });
                                if (strArray.Length > 0)
                                {
                                    float.TryParse(strArray[0], out data.Location.x);
                                }
                                if (strArray.Length > 1)
                                {
                                    float.TryParse(strArray[1], out data.Location.y);
                                }
                                if (strArray.Length > 2)
                                {
                                    float.TryParse(strArray[2], out data.Location.z);
                                }
                                data.MOTD    = class3.row_0.Get("motd").AsString;
                                data.Penalty = class3.row_0.Get("penalty").AsDateTime;
                                if (result3 != null)
                                {
                                    foreach (MySQL.Row row2 in result3.Row)
                                    {
                                        if (row2.Get("clan_id").AsUInt == class2.uint_0)
                                        {
                                            data.Hostile.Add(row2.Get("hostile_id").AsUInt, row2.Get("ending").AsDateTime);
                                        }
                                    }
                                }
                                Database.Add(data.ID, data);
                                Loaded++;
                            }
                            data.Members.Add(key, flags);
                            key.Clan = data;
                        }
                    }
                    else
                    {
                        MySQL.Query(string.Format(SQL_DELETE_MEMBER, num), false);
                    }
                }
            }
            dictionary_0.Clear();
            foreach (uint num2 in Database.Keys)
            {
                dictionary_0.Add(num2, Database[num2].Hash);
            }
            return(true);
        }