/// <summary> /// Adds the subscription. /// </summary> /// <param name="dayLength">Length of the day.</param> internal void AddSubscription(double dayLength) { var num = ((int)Math.Round(dayLength)); var clientByUserId = Plus.GetGame().GetClientManager().GetClientByUserId(_userId); DateTime target; Int64 num2; Int64 num3; if (_subscription != null) { target = Plus.UnixToDateTime(_subscription.ExpireTime).AddDays(num); num2 = _subscription.ActivateTime; num3 = _subscription.LastGiftTime; } else { target = DateTime.Now.AddDays(num); num2 = Plus.GetUnixTimeStamp(); num3 = Plus.GetUnixTimeStamp(); } var num4 = Plus.DateTimeToUnix(target); _subscription = new Subscription(2, num2, num4, num3); using (var queryReactor = Plus.GetDatabaseManager().GetQueryReactor()) queryReactor.RunFastQuery( string.Concat(new object[] { "REPLACE INTO users_subscriptions VALUES (", _userId, ", 2, ", num2, ", ", num4, ", ", num3, ");" })); clientByUserId.GetHabbo().SerializeClub(); Plus.GetGame().GetAchievementManager().TryProgressHabboClubAchievements(clientByUserId); }
/// <summary> /// Composes the club purchase page. /// </summary> /// <param name="session">The session.</param> /// <param name="windowId">The window identifier.</param> /// <returns>ServerMessage.</returns> internal static ServerMessage ComposeClubPurchasePage(GameClient session, int windowId) { var message = new ServerMessage(LibraryParser.OutgoingRequest("CatalogueClubPageMessageComposer")); var habboClubItems = Plus.GetGame().GetCatalog().HabboClubItems; message.AppendInteger(habboClubItems.Count); foreach (var item in habboClubItems) { message.AppendInteger(item.Id); message.AppendString(item.Name); message.AppendBool(false); message.AppendInteger(item.CreditsCost); message.AppendInteger(item.DucketsCost); message.AppendInteger(0); message.AppendBool(true); var fuckingArray = item.Name.Split('_'); double dayTime = 31; if (item.Name.Contains("DAY")) { dayTime = int.Parse(fuckingArray[3]); } else if (item.Name.Contains("MONTH")) { var monthTime = int.Parse(fuckingArray[3]); dayTime = monthTime * 31; } else if (item.Name.Contains("YEAR")) { var yearTimeOmg = int.Parse(fuckingArray[3]); dayTime = yearTimeOmg * 31 * 12; } var newExpiryDate = DateTime.Now.AddDays(dayTime); if (session.GetHabbo().GetSubscriptionManager().HasSubscription) { newExpiryDate = Plus.UnixToDateTime(session.GetHabbo().GetSubscriptionManager().GetSubscription().ExpireTime) .AddDays(dayTime); } message.AppendInteger((int)dayTime / 31); message.AppendInteger((int)dayTime); message.AppendBool(false); message.AppendInteger((int)dayTime); message.AppendInteger(newExpiryDate.Year); message.AppendInteger(newExpiryDate.Month); message.AppendInteger(newExpiryDate.Day); } message.AppendInteger(windowId); return(message); }
/// <summary> /// Serializes the user chatlog. /// </summary> /// <param name="userId">The user identifier.</param> /// <returns>ServerMessage.</returns> internal static ServerMessage SerializeUserChatlog(uint userId) { ServerMessage result; using (IQueryAdapter queryReactor = Plus.GetDatabaseManager().GetQueryReactor()) { queryReactor.SetQuery(string.Format("SELECT room_id FROM users_chatlogs WHERE user_id = {0} ORDER BY timestamp DESC LIMIT 1", userId)); DataTable table = queryReactor.GetTable(); var serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("ModerationToolUserChatlogMessageComposer")); serverMessage.AppendInteger(userId); serverMessage.AppendString(Plus.GetGame().GetClientManager().GetNameById(userId)); if (table != null) { serverMessage.AppendInteger(table.Rows.Count); IEnumerator enumerator = table.Rows.GetEnumerator(); try { while (enumerator.MoveNext()) { var dataRow = (DataRow)enumerator.Current; queryReactor.SetQuery(string.Concat(new object[] { "SELECT user_id,timestamp,message FROM users_chatlogs WHERE room_id = ", (uint)dataRow["room_id"], " AND user_id = ", userId, " ORDER BY timestamp DESC LIMIT 500" })); DataTable table2 = queryReactor.GetTable(); RoomData roomData = Plus.GetGame().GetRoomManager().GenerateRoomData((uint)dataRow["room_id"]); if (table2 != null) { serverMessage.AppendByte(1); serverMessage.AppendShort(2); serverMessage.AppendString("roomName"); serverMessage.AppendByte(2); serverMessage.AppendString(roomData == null ? "This room was deleted" : roomData.Name); serverMessage.AppendString("roomId"); serverMessage.AppendByte(1); serverMessage.AppendInteger((uint)dataRow["room_id"]); serverMessage.AppendShort(table2.Rows.Count); IEnumerator enumerator2 = table2.Rows.GetEnumerator(); try { while (enumerator2.MoveNext()) { var dataRow2 = (DataRow)enumerator2.Current; Habbo habboForId = Plus.GetHabboById((uint)dataRow2["user_id"]); Plus.UnixToDateTime((double)dataRow2["timestamp"]); if (habboForId == null) { return(null); } serverMessage.AppendInteger(((int)(Plus.GetUnixTimeStamp() - (double)dataRow2["timestamp"]))); serverMessage.AppendInteger(habboForId.Id); serverMessage.AppendString(habboForId.UserName); serverMessage.AppendString(dataRow2["message"].ToString()); serverMessage.AppendBool(false); } continue; } finally { var disposable = enumerator2 as IDisposable; if (disposable != null) { disposable.Dispose(); } } } serverMessage.AppendByte(1); serverMessage.AppendShort(0); serverMessage.AppendShort(0); } goto IL_29B; } finally { var disposable2 = enumerator as IDisposable; if (disposable2 != null) { disposable2.Dispose(); } } } serverMessage.AppendInteger(0); IL_29B: result = serverMessage; } return(result); }
/// <summary> /// Serializes the user information. /// </summary> /// <param name="userId">The user identifier.</param> /// <returns>ServerMessage.</returns> /// <exception cref="System.NullReferenceException">User not found in database.</exception> internal static ServerMessage SerializeUserInfo(uint userId) { { ServerMessage result; using (IQueryAdapter queryReactor = Plus.GetDatabaseManager().GetQueryReactor()) { queryReactor.SetQuery("SELECT id, username, online, mail, ip_last, look , rank , trade_lock , trade_lock_expire FROM users WHERE id = " + userId); DataRow row = queryReactor.GetRow(); queryReactor.SetQuery("SELECT reg_timestamp, login_timestamp, cfhs, cfhs_abusive, cautions, bans FROM users_info WHERE user_id = " + userId); DataRow row2 = queryReactor.GetRow(); if (row == null) { throw new NullReferenceException("User not found in database."); } var serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("ModerationToolUserToolMessageComposer")); serverMessage.AppendInteger(Convert.ToUInt32(row["id"])); serverMessage.AppendString((string)row["username"]); serverMessage.AppendString((string)row["look"]); if (row2 != null) { serverMessage.AppendInteger((int)Math.Ceiling((Plus.GetUnixTimeStamp() - (double)row2["reg_timestamp"]) / 60.0)); serverMessage.AppendInteger((int)Math.Ceiling((Plus.GetUnixTimeStamp() - (double)row2["login_timestamp"]) / 60.0)); } else { serverMessage.AppendInteger(0); serverMessage.AppendInteger(0); } serverMessage.AppendBool(Plus.GetGame().GetClientManager().GetClientByUserId(Convert.ToUInt32(row["id"])) != null); if (row2 != null) { serverMessage.AppendInteger((int)row2["cfhs"]); serverMessage.AppendInteger((int)row2["cfhs_abusive"]); serverMessage.AppendInteger((int)row2["cautions"]); serverMessage.AppendInteger((int)row2["bans"]); } else { serverMessage.AppendInteger(0); serverMessage.AppendInteger(0); serverMessage.AppendInteger(0); serverMessage.AppendInteger(0); } serverMessage.AppendInteger(0); serverMessage.AppendString((row["trade_lock"].ToString() == "1") ? Plus.UnixToDateTime(int.Parse(row["trade_lock_expire"].ToString())).ToLongDateString() : "Not trade-locked"); Random _random = new Random(); string fakeip = string.Format("{0}.{1}.{2}.{3}", _random.Next(0, 255), _random.Next(0, 255), _random.Next(0, 255), _random.Next(0, 255)); serverMessage.AppendString(((uint)row["rank"] < 6u) ? ((string)row["ip_last"]) : fakeip); serverMessage.AppendInteger(Convert.ToUInt32(row["id"])); serverMessage.AppendInteger(0); serverMessage.AppendString(string.Format("E-Mail: {0}", row["mail"])); uint Rank = (uint)row["rank"]; serverMessage.AppendString((Rank == 12 ? string.Format("Rank ID: {0}", 1) : string.Format("Rank ID: {0}", Rank))); result = serverMessage; } return(result); } }