Ejemplo n.º 1
0
        internal static ServerMessage SerializeTicketChatlog(SupportTicket Ticket, RoomData RoomData, double Timestamp)
        {
            ServerMessage result;

            using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
            {
                queryreactor.setQuery(string.Concat(new object[]
                {
                    "SELECT user_id,timestamp,message FROM chatlogs WHERE room_id = ",
                    RoomData.Id,
                    " AND (timestamp >= ",
                    Timestamp - 300.0,
                    " AND timestamp <= ",
                    Timestamp,
                    ") OR (timestamp >= ",
                    Timestamp - 300.0,
                    " AND timestamp = 0) ORDER BY timestamp DESC LIMIT 150"
                }));
                DataTable     table         = queryreactor.getTable();
                ServerMessage serverMessage = new ServerMessage(Outgoing.ModerationToolIssueChatlogMessageComposer);
                serverMessage.AppendUInt(Ticket.TicketId);
                serverMessage.AppendUInt(Ticket.SenderId);
                serverMessage.AppendUInt(Ticket.ReportedId);
                serverMessage.AppendUInt(RoomData.Id);
                serverMessage.AppendBoolean(false);
                serverMessage.AppendUInt(RoomData.Id);
                serverMessage.AppendString(RoomData.Name);
                if (table != null)
                {
                    serverMessage.AppendInt32(table.Rows.Count);
                    IEnumerator enumerator = table.Rows.GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            DataRow dataRow    = (DataRow)enumerator.Current;
                            Habbo   habboForId = CyberEnvironment.getHabboForId(Convert.ToUInt32(dataRow["user_id"]));
                            serverMessage.AppendInt32(CyberEnvironment.UnixToDateTime(Convert.ToDouble(dataRow["timestamp"])).Minute);
                            serverMessage.AppendUInt(habboForId.Id);
                            serverMessage.AppendString(habboForId.Username);
                            serverMessage.AppendString((string)dataRow["message"]);
                        }
                        goto IL_1B8;
                    }
                    finally
                    {
                        IDisposable disposable = enumerator as IDisposable;
                        if (disposable != null)
                        {
                            disposable.Dispose();
                        }
                    }
                }
                serverMessage.AppendInt32(0);
IL_1B8:
                result = serverMessage;
            }
            return(result);
        }
Ejemplo n.º 2
0
        internal static ServerMessage ComposeClubPurchasePage(GameClient Session, int WindowId)
        {
            // Coded by Finn for Cyber Emulator
            ServerMessage Message = new ServerMessage(Outgoing.CatalogueClubPageMessageComposer);

            var habboClubItems = CyberEnvironment.GetGame().GetCatalog().HabboClubItems;

            Message.AppendInt32(habboClubItems.Count);

            foreach (CatalogItem Item in habboClubItems)
            {
                Message.AppendUInt(Item.Id);
                Message.AppendString(Item.Name);
                Message.AppendBoolean(false);
                Message.AppendInt32(Item.CreditsCost);
                Message.AppendInt32(Item.DucketsCost);
                Message.AppendInt32(0);
                Message.AppendBoolean(true);

                string[] fuckingArray = Item.Name.Split('_');
                double   dayTime      = 31;

                if (Item.Name.Contains("DAY"))
                {
                    dayTime = int.Parse(fuckingArray[3]);
                }
                else if (Item.Name.Contains("MONTH"))
                {
                    int monthTime = int.Parse(fuckingArray[3]);
                    dayTime = monthTime * 31;
                }
                else if (Item.Name.Contains("YEAR"))
                {
                    int yearTimeOmg = int.Parse(fuckingArray[3]);
                    dayTime = yearTimeOmg * 31 * 12;
                }

                DateTime newExpiryDate = DateTime.Now.AddDays(dayTime);
                if (Session.GetHabbo().GetSubscriptionManager().HasSubscription)
                {
                    newExpiryDate = CyberEnvironment.UnixToDateTime((double)Session.GetHabbo().GetSubscriptionManager().GetSubscription().ExpireTime).AddDays(dayTime);
                }
                Message.AppendInt32((int)dayTime / 31);
                Message.AppendInt32((int)dayTime);
                Message.AppendBoolean(false);
                Message.AppendInt32((int)dayTime);
                Message.AppendInt32(newExpiryDate.Year);
                Message.AppendInt32(newExpiryDate.Month);
                Message.AppendInt32(newExpiryDate.Day);
            }
            Message.AppendInt32(WindowId);
            return(Message);
        }
Ejemplo n.º 3
0
        internal static ServerMessage SerializeRoomChatlog(uint roomID)
        {
            // NEW CHATLOGS [March 2014] Coded by Finn
            // Please don't remove credits, this took me some time to do... :(
            // Credits to Itachi for the structure's "context" enigma :D

            ServerMessage Message = new ServerMessage();
            RoomData      Room    = CyberEnvironment.GetGame().GetRoomManager().GenerateRoomData(roomID);

            if (Room == null)
            {
                throw new NullReferenceException("No room found.");
            }

            Message.Init(Outgoing.ModerationToolRoomChatlogMessageComposer);
            Message.AppendByte(1);
            Message.AppendShort(2);
            Message.AppendString("roomName");
            Message.AppendByte(2);
            Message.AppendString(Room.Name);
            Message.AppendString("roomId");
            Message.AppendByte(1);
            Message.AppendUInt(Room.Id);


            var TempChatlogs = Room.RoomChat.Reverse().Take(60);

            Message.AppendShort(TempChatlogs.Count());
            foreach (Chatlog current in TempChatlogs)
            {
                Habbo    Habbo = CyberEnvironment.getHabboForId(current.UserId);
                DateTime Date  = CyberEnvironment.UnixToDateTime(current.Timestamp);
                if (Habbo == null)
                {
                    Message.AppendInt32((DateTime.Now - Date).Seconds);
                    Message.AppendUInt(current.UserId);
                    Message.AppendString("*User not found*");
                    Message.AppendString(current.Message);
                    Message.AppendBoolean(true);
                }
                else
                {
                    Message.AppendInt32((DateTime.Now - Date).Seconds);
                    Message.AppendUInt(Habbo.Id);
                    Message.AppendString(Habbo.Username);
                    Message.AppendString(current.Message);
                    Message.AppendBoolean(false); // Text is bold
                }
            }
            TempChatlogs = null;

            return(Message);
        }
Ejemplo n.º 4
0
        internal void AddSubscription(double DayLength)
        {
            int        num            = checked ((int)Math.Round(DayLength));
            GameClient clientByUserID = CyberEnvironment.GetGame().GetClientManager().GetClientByUserID(this.UserId);
            DateTime   target;
            int        num2;
            int        num3;

            if (this.Subscription != null)
            {
                target = CyberEnvironment.UnixToDateTime((double)this.Subscription.ExpireTime).AddDays((double)num);
                num2   = this.Subscription.ActivateTime;
                num3   = this.Subscription.LastGiftTime;
            }
            else
            {
                target = DateTime.Now.AddDays((double)num);
                num2   = CyberEnvironment.GetUnixTimestamp();
                num3   = CyberEnvironment.GetUnixTimestamp();
            }
            int num4 = CyberEnvironment.DateTimeToUnix(target);

            this.Subscription = new Subscription(2, num2, num4, num3);
            using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
            {
                queryreactor.runFastQuery(string.Concat(new object[]
                {
                    "REPLACE INTO user_subscriptions VALUES (",
                    this.UserId,
                    ", 2, ",
                    num2,
                    ", ",
                    num4,
                    ", ",
                    num3,
                    ");"
                }));
            }
            clientByUserID.GetHabbo().SerializeClub();
        }
Ejemplo n.º 5
0
        internal static ServerMessage SerializeUserChatlog(uint UserId)
        {
            ServerMessage result;

            using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
            {
                queryreactor.setQuery("SELECT DISTINCT room_id FROM chatlogs WHERE user_id = " + UserId + " ORDER BY timestamp DESC LIMIT 4");
                DataTable     table         = queryreactor.getTable();
                ServerMessage serverMessage = new ServerMessage(Outgoing.ModerationToolUserChatlogMessageComposer);
                serverMessage.AppendUInt(UserId);
                serverMessage.AppendString(CyberEnvironment.GetGame().GetClientManager().GetNameById(UserId));
                if (table != null)
                {
                    serverMessage.AppendInt32(table.Rows.Count);
                    IEnumerator enumerator = table.Rows.GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            DataRow dataRow = (DataRow)enumerator.Current;
                            queryreactor.setQuery(string.Concat(new object[]
                            {
                                "SELECT user_id,timestamp,message FROM chatlogs WHERE room_id = ",
                                (uint)dataRow["room_id"],
                                " AND user_id = ",
                                UserId,
                                " ORDER BY timestamp DESC LIMIT 30"
                            }));
                            DataTable table2   = queryreactor.getTable();
                            RoomData  roomData = CyberEnvironment.GetGame().GetRoomManager().GenerateRoomData((uint)dataRow["room_id"]);
                            if (table2 != null)
                            {
                                serverMessage.AppendByte(1);
                                serverMessage.AppendShort(2);
                                serverMessage.AppendString("roomName");
                                serverMessage.AppendByte(2);
                                if (roomData == null)
                                {
                                    serverMessage.AppendString("This room was deleted");
                                }
                                else
                                {
                                    serverMessage.AppendString(roomData.Name);
                                }
                                serverMessage.AppendString("roomId");
                                serverMessage.AppendByte(1);
                                serverMessage.AppendUInt((uint)dataRow["room_id"]);
                                serverMessage.AppendShort(table2.Rows.Count);
                                IEnumerator enumerator2 = table2.Rows.GetEnumerator();
                                try
                                {
                                    while (enumerator2.MoveNext())
                                    {
                                        DataRow dataRow2   = (DataRow)enumerator2.Current;
                                        Habbo   habboForId = CyberEnvironment.getHabboForId((uint)dataRow2["user_id"]);
                                        CyberEnvironment.UnixToDateTime((double)dataRow2["timestamp"]);
                                        if (habboForId == null)
                                        {
                                            result = null;
                                            return(result);
                                        }
                                        serverMessage.AppendInt32(checked ((int)unchecked ((double)CyberEnvironment.GetUnixTimestamp() - (double)dataRow2["timestamp"])));
                                        serverMessage.AppendUInt(habboForId.Id);
                                        serverMessage.AppendString(habboForId.Username);
                                        serverMessage.AppendString(dataRow2["message"].ToString());
                                        serverMessage.AppendBoolean(false);
                                    }
                                    continue;
                                }
                                finally
                                {
                                    IDisposable disposable = enumerator2 as IDisposable;
                                    if (disposable != null)
                                    {
                                        disposable.Dispose();
                                    }
                                }
                            }
                            serverMessage.AppendByte(1);
                            serverMessage.AppendShort(0);
                            serverMessage.AppendShort(0);
                        }
                        goto IL_29B;
                    }
                    finally
                    {
                        IDisposable disposable2 = enumerator as IDisposable;
                        if (disposable2 != null)
                        {
                            disposable2.Dispose();
                        }
                    }
                }
                serverMessage.AppendInt32(0);
IL_29B:
                result = serverMessage;
            }
            return(result);
        }
Ejemplo n.º 6
0
 internal static ServerMessage SerializeUserInfo(uint UserId)
 {
     checked
     {
         ServerMessage result;
         using (IQueryAdapter queryreactor = CyberEnvironment.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 user_info WHERE user_id = " + UserId);
             DataRow row2 = queryreactor.getRow();
             if (row == null)
             {
                 throw new NullReferenceException("User not found in database.");
             }
             ServerMessage serverMessage = new ServerMessage(Outgoing.ModerationToolUserToolMessageComposer);
             serverMessage.AppendUInt(Convert.ToUInt32(row["id"]));
             serverMessage.AppendString((string)row["username"]);
             serverMessage.AppendString((string)row["look"]);
             if (row2 != null)
             {
                 serverMessage.AppendInt32((int)Math.Ceiling(unchecked ((double)CyberEnvironment.GetUnixTimestamp() - (double)row2["reg_timestamp"]) / 60.0));
                 serverMessage.AppendInt32((int)Math.Ceiling(unchecked ((double)CyberEnvironment.GetUnixTimestamp() - (double)row2["login_timestamp"]) / 60.0));
             }
             else
             {
                 serverMessage.AppendInt32(0);
                 serverMessage.AppendInt32(0);
             }
             serverMessage.AppendBoolean(CyberEnvironment.GetGame().GetClientManager().GetClientByUserID(Convert.ToUInt32(row["id"])) != null);
             if (row2 != null)
             {
                 serverMessage.AppendInt32((int)row2["cfhs"]);
                 serverMessage.AppendInt32((int)row2["cfhs_abusive"]);
                 serverMessage.AppendInt32((int)row2["cautions"]);
                 serverMessage.AppendInt32((int)row2["bans"]);
             }
             else
             {
                 serverMessage.AppendInt32(0);
                 serverMessage.AppendInt32(0);
                 serverMessage.AppendInt32(0);
                 serverMessage.AppendInt32(0);
             }
             serverMessage.AppendInt32(0);
             serverMessage.AppendString((row["trade_lock"].ToString() == "1") ? CyberEnvironment.UnixToDateTime((double)int.Parse(row["trade_lock_expire"].ToString())).ToLongDateString() : "Not trade-locked");
             serverMessage.AppendString(((uint)row["rank"] < 6u) ? ((string)row["ip_last"]) : "127.0.0.1");
             serverMessage.AppendUInt(Convert.ToUInt32(row["id"]));
             serverMessage.AppendInt32(0);
             serverMessage.AppendString("E-Mail:         " + row["mail"].ToString());
             serverMessage.AppendString("Rank ID:        " + (uint)row["rank"]);
             result = serverMessage;
         }
         return(result);
     }
 }