internal static bool TestConnection() { int?Result = (int?)SQLCommand.FetchScalar("select 1"); if (Result == 1) { return(true); } return(false); }
internal static Account FetchAccount(string Username, string Password, bool CreateAccount) { Account FoundAccount = new Account(); MySqlDataReader AccountFinder = SQLCommand.Fetch($"select * from useraccount where Username = '******'"); if (!AccountFinder.Read()) { //NoSuchAccount AccountFinder.Close(); if (CreateAccount) { FoundAccount.Status = Account.AccountStatus.Success; var Bogus = new MySqlCommand($"insert into useraccount (Username, Password) values ('{ Username }', '{ Password }')") { Connection = Connection }.ExecuteNonQuery(); } else { FoundAccount.Status = Account.AccountStatus.NoSuchAccount; } } else { //Debug.Log($"Ordinal For 'UserAccountID': { AccountFinder.GetOrdinal("UserAccountID") }"); //Thread.Sleep(2000); FoundAccount.UserAccountID = AccountFinder.GetInt32(0); if (!AccountFinder.IsDBNull(1)) { FoundAccount.SteamID = AccountFinder.GetString(1); //System.DBNull } FoundAccount.Username = AccountFinder.GetString(2); FoundAccount.Password = AccountFinder.GetString(3); FoundAccount.PrivlegeLevel = AccountFinder.GetInt32(4); FoundAccount.AccountCreated = AccountFinder.GetDateTime(5); FoundAccount.Banned = AccountFinder.GetBoolean(6); if (!AccountFinder.IsDBNull(7)) { FoundAccount.BanReason = AccountFinder.GetString(7); } FoundAccount.BannedUntil = AccountFinder.GetDateTime(8); FoundAccount.Logins = AccountFinder.GetInt32(9); FoundAccount.LastLogin = AccountFinder.GetDateTime(10); AccountFinder.Close(); if (FoundAccount.Password == Password) { if (FoundAccount.Banned) { FoundAccount.Status = Account.AccountStatus.Banned; } else { FoundAccount.Status = Account.AccountStatus.Success; } } else { FoundAccount.Status = Account.AccountStatus.PasscodeIncorrect; } } SQLCommand.Update($"update useraccount set Logins=Logins+1 where Username='******'"); return(FoundAccount); }