private static void smethod_2(Session session_0, ClientMessage clientMessage_0) { string str = clientMessage_0.ReadString(); string s = clientMessage_0.ReadString(); uint num = clientMessage_0.ReadUnsignedInteger(); string str3 = clientMessage_0.ReadString(); int num2 = clientMessage_0.ReadInteger(); string str4 = clientMessage_0.ReadString(); string str5 = string.Empty; string str6 = string.Empty; SHA1 sha = SHA1.Create(); if ((((str.Length >= 1) && (s.Length >= 4)) && ((num2 >= 0) || (num2 <= 0x41))) && (str4.Length >= 4)) { str5 = Convert.ToBase64String(sha.ComputeHash(Constants.DefaultEncoding.GetBytes(s))); using (SqlDatabaseClient client = SqlDatabaseManager.GetClient()) { client.SetParameter("Username", str); client.SetParameter("Password", str5); client.SetParameter("Avatar", num); client.SetParameter("Colors", str3); client.SetParameter("Age", num2); client.SetParameter("Email", str4); client.SetParameter("CurrentTimestamp", UnixTimestamp.GetCurrent()); client.SetParameter("RemoteAddress", session_0.RemoteAddress); client.SetParameter("Null", 0); str6 = client.ExecuteScalar("INSERT INTO usuarios (`usuario`, `password`, `email`, `edad`, `tiempo_registrado`, `ip_registro`, `ip_actual`, `ultimo_login`, `tipo_avatar`, `colores_avatar`, `timestamp_monedas`) VALUES (@Username, @Password, @Email, @Age, @Null, @RemoteAddress, @RemoteAddress, @CurrentTimestamp, @Avatar, @Colors, @CurrentTimestamp); SELECT LAST_INSERT_ID();").ToString(); client.SetParameter("Id", (str6 == string.Empty) ? ((object)0) : ((object)uint.Parse(str6))); client.ExecuteNonQuery("INSERT INTO rankings (`usuario`) VALUES (@Id)"); } session_0.TryAuthenticate(str, str5, session_0.RemoteAddress, true); } }
public static uint GetUidFromName(string Name) { lock (dictionary_0) { foreach (KeyValuePair <uint, string> pair in dictionary_0) { if (pair.Value.ToLower() == Name.ToLower()) { return(pair.Key); } } using (SqlDatabaseClient client = SqlDatabaseManager.GetClient()) { client.SetParameter("username", Name); object obj2 = client.ExecuteScalar("SELECT id FROM usuarios WHERE usuario = @username LIMIT 1"); if (obj2 != null) { uint key = (uint)obj2; dictionary_0.Add(key, Name); return(key); } } } return(0); }
private static void Register(Session Session, ClientMessage Message) { if (Session.Authenticated) { return; } //±x³ƒ³²Test23432³²contrasea2³²11³²FFCC669933001A0000FF0000009999996666000000³²15³²[email protected]³²³²³²³²° string[] GetParameter = Regex.Split(Message.ToString(), "³²"); string User = GetParameter[1]; string Password = GetParameter[2]; int Avatar = int.Parse(GetParameter[3]); string Colors = GetParameter[4]; string Age = GetParameter[5]; string Email = GetParameter[6]; string str5 = string.Empty; string str6 = string.Empty; using (SqlDatabaseClient client = SqlDatabaseManager.GetClient()) { client.SetParameter("Username", User); client.SetParameter("Password", Password); client.SetParameter("Avatar", Avatar); client.SetParameter("Colors", Colors); client.SetParameter("Age", Age); client.SetParameter("Email", Email); client.SetParameter("CurrentTimestamp", UnixTimestamp.GetCurrent()); client.SetParameter("RemoteAddress", Session.RemoteAddress); client.SetParameter("Null", 0); str6 = client.ExecuteScalar("INSERT INTO usuarios (`usuario`, `password`, `email`, `edad`, `tiempo_registrado`, `ip_registro`, `ip_actual`, `ultimo_login`, `tipo_avatar`, `colores_avatar`, `timestamp_monedas`) VALUES (@Username, @Password, @Email, @Age, @Null, @RemoteAddress, @RemoteAddress, @CurrentTimestamp, @Avatar, @Colors, @CurrentTimestamp); SELECT LAST_INSERT_ID();").ToString(); client.SetParameter("Id", (str6 == string.Empty) ? ((object)0) : ((object)uint.Parse(str6))); } Session.SendData(RegisterComposer.Compose()); }
public void AddOrExtend(int Level, double ExtensionTime) { using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { if (!IsActive) { mTimestampCreated = UnixTimestamp.GetCurrent(); mTimestampExpire = UnixTimestamp.GetCurrent(); } mTimestampExpire += ExtensionTime; mBaseLevel = (ClubSubscriptionLevel)Level; MySqlClient.SetParameter("userid", mUserId); bool CreateNewRecord = (MySqlClient.ExecuteScalar("SELECT null FROM user_subscriptions WHERE user_id = @userid LIMIT 1") == null); MySqlClient.SetParameter("userid", mUserId); MySqlClient.SetParameter("expirestamp", mTimestampExpire); MySqlClient.SetParameter("level", ((int)mBaseLevel).ToString()); if (CreateNewRecord) { MySqlClient.SetParameter("createstamp", UnixTimestamp.GetCurrent()); MySqlClient.ExecuteNonQuery("INSERT INTO user_subscriptions (user_id,subscription_level,timestamp_created,timestamp_expire) VALUES (@userid,@level,@createstamp,@expirestamp)"); } else { MySqlClient.ExecuteNonQuery("UPDATE user_subscriptions SET subscription_level = @level, timestamp_expire = @expirestamp WHERE user_id = @userid LIMIT 1"); } } }
public static uint GetUidFromName(string Name) { lock (mNameCache) { foreach (KeyValuePair <uint, string> CachedName in mNameCache) { if (CachedName.Value.ToLower() == Name.ToLower()) { return(CachedName.Key); } } using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { MySqlClient.SetParameter("username", Name); object Result = MySqlClient.ExecuteScalar("SELECT id FROM characters WHERE username = @username LIMIT 1"); if (Result != null) { uint Id = (uint)Result; mNameCache.Add(Id, Name); return(Id); } } } return(0); }
private static void smethod_2(Session session_0, ClientMessage clientMessage_0) { string str = clientMessage_0.ReadString(); string s = clientMessage_0.ReadString(); uint num = clientMessage_0.ReadUnsignedInteger(); string str3 = clientMessage_0.ReadString(); int num2 = clientMessage_0.ReadInteger(); string str4 = clientMessage_0.ReadString(); string str5 = string.Empty; string str6 = string.Empty; if ((((str.Length >= 1) && (s.Length >= 4)) && ((num2 >= 0) || (num2 <= 65))) && (str4.Length >= 4)) { using (SqlDatabaseClient client = SqlDatabaseManager.GetClient()) { client.SetParameter("Username", str); client.SetParameter("Password", s); client.SetParameter("Avatar", num); client.SetParameter("Colors", str3); client.SetParameter("Age", num2); client.SetParameter("Email", str4); client.SetParameter("CurrentTimestamp", UnixTimestamp.GetCurrent()); client.SetParameter("CurrentTimestamp1", UnixTimestamp.GetCurrent()); client.SetParameter("RemoteAddress", session_0.RemoteAddress); client.SetParameter("RemoteAddress1", session_0.RemoteAddress); client.SetParameter("Null", 0); str6 = client.ExecuteScalar("INSERT INTO usuarios (`usuario`, `password`, `email`, `edad`, `tiempo_registrado`, `ip_registro`, `ip_actual`, `ultimo_login`, `tipo_avatar`, `colores_avatar`, `timestamp_monedas`) VALUES (@Username, @Password, @Email, @Age, @Null, @RemoteAddress, @RemoteAddress, @CurrentTimestamp, @Avatar, @Colors, @CurrentTimestamp); SELECT LAST_INSERT_ID();").ToString(); } session_0.TryAuthenticate(str, s, session_0.RemoteAddress, true); } }
public int GetRoomCount() { using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { MySqlClient.SetParameter("ownerid", mId); return(int.Parse(MySqlClient.ExecuteScalar("SELECT COUNT(*) FROM rooms WHERE owner_id = @ownerid LIMIT 1").ToString())); } }
private static void HandleIncomingTicket(Session Session, ClientMessage Message) { if (GetPendingTicketForUser(Session.CharacterId) != null) { Session.SendData(HelpSubmitCfhResultComposer.Compose(CfhErrorCode.AlreadyHaveCall)); return; } if (Session.CharacterInfo.ModerationTicketsCooldownSeconds > 0) { Session.SendData(HelpSubmitCfhResultComposer.Compose(CfhErrorCode.AbusiveCooldown)); return; } string TicketBody = UserInputFilter.FilterString(Message.PopString()); uint Unknown = Message.PopWiredUInt32(); uint Category = Message.PopWiredUInt32(); uint ReportedUser = Message.PopWiredUInt32(); uint RoomId = Session.CurrentRoomId; double Timestamp = UnixTimestamp.GetCurrent(); lock (mSyncRoot) { uint GeneratedId = 0; using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { MySqlClient.SetParameter("category", Category); MySqlClient.SetParameter("reporteduid", ReportedUser); MySqlClient.SetParameter("reporteeuid", Session.CharacterId); MySqlClient.SetParameter("roomid", RoomId); MySqlClient.SetParameter("timestamp", Timestamp); MySqlClient.SetParameter("message", TicketBody); string GeneratedResult = MySqlClient.ExecuteScalar("INSERT INTO moderation_tickets (category,reported_user_id,reportee_user_id,room_id,timestamp,message) VALUES (@category,@reporteduid,@reporteeuid,@roomid,@timestamp,@message); SELECT LAST_INSERT_ID();").ToString(); uint.TryParse(GeneratedResult, out GeneratedId); } if (GeneratedId > 0) { ModerationTicket NewTicket = new ModerationTicket(GeneratedId, Category, ModerationTicketStatus.OpenTicket, ReportedUser, Session.CharacterId, 0, RoomId, Timestamp, TicketBody); mTickets.Add(GeneratedId, NewTicket); ServerMessage TicketMessage = ModerationTicketComposer.Compose(NewTicket); SendDataToAllModerators(TicketMessage); Session.CharacterInfo.ModerationTickets++; } } Session.SendData(HelpSubmitCfhResultComposer.Compose(CfhErrorCode.Ok)); }
public static uint CreateRoom(uint OwnerId, string Name, string Model) { string Result = string.Empty; using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { MySqlClient.SetParameter("type", "flat"); MySqlClient.SetParameter("ownerid", OwnerId); MySqlClient.SetParameter("name", Name); MySqlClient.SetParameter("model", Model); Result = MySqlClient.ExecuteScalar("INSERT INTO rooms (type,owner_id,name,model) VALUES (@type,@ownerid,@name,@model); SELECT LAST_INSERT_ID();").ToString(); } return(Result == string.Empty ? 0 : uint.Parse(Result)); }
public static uint CreateIsland(uint OwnerId, string Name, string Model) { string s = string.Empty; using (SqlDatabaseClient client = SqlDatabaseManager.GetClient()) { client.SetParameter("type", "flat"); client.SetParameter("ownerid", OwnerId); client.SetParameter("name", Name); client.SetParameter("model", Model); s = client.ExecuteScalar("INSERT INTO escenarios (tipo_area,id_usuario,nombre,modelo) VALUES (@type,@ownerid,@name,@model); SELECT LAST_INSERT_ID();").ToString(); } if (!(s == string.Empty)) { return(uint.Parse(s)); } return(0); }
public static AvatarEffect CreateEffect(SqlDatabaseClient MySqlClient, uint UserId, int SpriteId, double Duration) { MySqlClient.SetParameter("userid", UserId); MySqlClient.SetParameter("spriteid", SpriteId); MySqlClient.SetParameter("duration", Duration); string RawId = MySqlClient.ExecuteScalar("INSERT INTO avatar_effects (user_id,sprite_id,duration) VALUES (@userid,@spriteid,@duration); SELECT LAST_INSERT_ID();").ToString(); uint Id = 0; uint.TryParse(RawId, out Id); if (Id == 0) { return(null); } return(new AvatarEffect(Id, SpriteId, Duration, 1, false, 0.0)); }
public static Pet CreatePet(SqlDatabaseClient MySqlClient, uint UserId, int Type, string Name, int Race) { MySqlClient.SetParameter("userid", UserId); MySqlClient.SetParameter("type", Type); MySqlClient.SetParameter("name", Name); MySqlClient.SetParameter("race", Race); MySqlClient.SetParameter("timestamp", UnixTimestamp.GetCurrent()); string RawId = MySqlClient.ExecuteScalar("INSERT INTO pets (user_id,type,name,race,timestamp) VALUES (@userid,@type,@name,@race,@timestamp); SELECT LAST_INSERT_ID();").ToString(); uint Id = 0; uint.TryParse(RawId, out Id); if (Id == 0) { return(null); } return(new Pet(Id, Name, Type, Race, UserId, 0, new Vector3(0, 0, 0), UnixTimestamp.GetCurrent(), 0, 120, 100, 0)); }
public static string GetNameFromUid(uint UserId) { lock (dictionary_0) { if (dictionary_0.ContainsKey(UserId)) { return(dictionary_0[UserId]); } using (SqlDatabaseClient client = SqlDatabaseManager.GetClient()) { client.SetParameter("id", UserId); string str = (string)client.ExecuteScalar("SELECT usuario FROM usuarios WHERE id = @id LIMIT 1"); if ((str != null) && (str.Length > 0)) { dictionary_0.Add(UserId, str); return(str); } } } return("Usuario desconocido"); }
public static void FillCache(SqlDatabaseClient MySqlClient, uint LinkedItemId) { if (mCache.ContainsKey(LinkedItemId)) { mCache.Remove(LinkedItemId); } uint IdValue = 0; MySqlClient.SetParameter("id", LinkedItemId); object Result = MySqlClient.ExecuteScalar("SELECT room_id FROM items WHERE id = @id LIMIT 1"); if (Result != null) { IdValue = (uint)Result; } if (IdValue > 0) { mCache.Add(LinkedItemId, IdValue); } }
public static Item CreateItem(SqlDatabaseClient MySqlClient, uint DefinitionId, uint UserId, string Flags, string FlagsDisplay, double ExpireTimestamp, bool Untradable = false) { MySqlClient.SetParameter("definitionid", DefinitionId); MySqlClient.SetParameter("userid", UserId); MySqlClient.SetParameter("flags", Flags); MySqlClient.SetParameter("flagsd", FlagsDisplay); MySqlClient.SetParameter("untradable", Untradable ? "1" : "0"); MySqlClient.SetParameter("expiretimestamp", ExpireTimestamp); string RawId = MySqlClient.ExecuteScalar("INSERT INTO items (definition_id,user_id,flags,flags_display,untradable,expire_timestamp) VALUES (@definitionid,@userid,@flags,@flagsd,@untradable,@expiretimestamp); SELECT LAST_INSERT_ID();").ToString(); uint Id = 0; uint.TryParse(RawId, out Id); if (Id == 0) { return(null); } return(new Item(Id, DefinitionId, UserId, 0, new Vector3(), string.Empty, 0, Flags, Flags, Untradable, 0, 0, ExpireTimestamp)); }
public static string GetNameFromUid(uint UserId) { lock (mNameCache) { if (mNameCache.ContainsKey(UserId)) { return(mNameCache[UserId]); } using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient()) { MySqlClient.SetParameter("id", UserId); string Username = (string)MySqlClient.ExecuteScalar("SELECT username FROM characters WHERE id = @id LIMIT 1"); if (Username != null && Username.Length > 0) { mNameCache.Add(UserId, Username); return(Username); } } } return("Unknown User"); }