예제 #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);
        }
예제 #2
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);
        }
예제 #3
0
        internal void CloseTicket(GameClient Session, uint TicketId, int Result)
        {
            SupportTicket ticket = this.GetTicket(TicketId);

            if (ticket == null || ticket.Status != TicketStatus.PICKED || ticket.ModeratorId != Session.GetHabbo().Id)
            {
                return;
            }
            GameClient   clientByUserID = CyberEnvironment.GetGame().GetClientManager().GetClientByUserID(ticket.SenderId);
            int          i = 0;
            TicketStatus newStatus;

            switch (Result)
            {
            case 1:
                i         = 1;
                newStatus = TicketStatus.INVALID;
                goto IL_9E;

            case 2:
                i         = 2;
                newStatus = TicketStatus.ABUSIVE;
                using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
                {
                    queryreactor.runFastQuery("UPDATE user_info SET cfhs_abusive = cfhs_abusive + 1 WHERE user_id = " + ticket.SenderId);
                    goto IL_9E;
                }
            }
            i         = 0;
            newStatus = TicketStatus.RESOLVED;
IL_9E:
            if (clientByUserID != null && (ticket.Type != 3 && ticket.Type != 4))
            {
                clientByUserID.GetMessageHandler().GetResponse().Init(Outgoing.ModerationToolUpdateIssueMessageComposer);
                clientByUserID.GetMessageHandler().GetResponse().AppendInt32(1);
                clientByUserID.GetMessageHandler().GetResponse().AppendUInt(ticket.TicketId);
                clientByUserID.GetMessageHandler().GetResponse().AppendUInt(ticket.ModeratorId);
                clientByUserID.GetMessageHandler().GetResponse().AppendString((CyberEnvironment.getHabboForId(ticket.ModeratorId) != null) ? CyberEnvironment.getHabboForId(ticket.ModeratorId).Username : "******");
                clientByUserID.GetMessageHandler().GetResponse().AppendBoolean(false);
                clientByUserID.GetMessageHandler().GetResponse().AppendInt32(0);
                clientByUserID.GetMessageHandler().GetResponse().Init(Outgoing.ModerationTicketResponseMessageComposer);
                clientByUserID.GetMessageHandler().GetResponse().AppendInt32(i);
                clientByUserID.GetMessageHandler().SendResponse();
            }
            using (IQueryAdapter queryreactor2 = CyberEnvironment.GetDatabaseManager().getQueryReactor())
            {
                queryreactor2.runFastQuery("UPDATE user_stats SET tickets_answered = tickets_answered+1 WHERE id=" + Session.GetHabbo().Id + " LIMIT 1");
            }
            ticket.Close(newStatus, true);
            ModerationTool.SendTicketToModerators(ticket);
        }
예제 #4
0
        internal void SerializeGroupInfo(Guild Group, ServerMessage Response, GameClient Session, Room Room, bool NewWindow = false)
        {
            if (Room == null)
            {
                return;
            }
            DateTime dateTime  = new DateTime(1970, 1, 1, 0, 0, 0, 0);
            DateTime dateTime2 = dateTime.AddSeconds((double)Group.CreateTime);

            Response.Init(Outgoing.GroupDataMessageComposer);
            Response.AppendUInt(Group.Id);
            Response.AppendBoolean(true);
            Response.AppendUInt(Group.State);
            Response.AppendString(Group.Name);
            Response.AppendString(Group.Description);
            Response.AppendString(Group.Badge);
            Response.AppendUInt(Group.RoomId);
            Response.AppendString((CyberEnvironment.GetGame().GetRoomManager().GenerateRoomData(Group.RoomId) == null) ? "No room found.." : CyberEnvironment.GetGame().GetRoomManager().GenerateRoomData(Group.RoomId).Name);
            Response.AppendInt32((Group.CreatorId == Session.GetHabbo().Id) ? 3 : (Group.Requests.Contains(Session.GetHabbo().Id) ? 2 : (Group.Members.ContainsKey(Session.GetHabbo().Id) ? 1 : 0)));
            Response.AppendInt32(Group.Members.Count);
            Response.AppendBoolean(Session.GetHabbo().FavouriteGroup == Group.Id);
            Response.AppendString(string.Concat(new object[]
            {
                dateTime2.Day,
                "-",
                dateTime2.Month,
                "-",
                dateTime2.Year
            }));
            Response.AppendBoolean(Group.CreatorId == Session.GetHabbo().Id);
            Response.AppendBoolean(Group.Admins.ContainsKey(Session.GetHabbo().Id));
            Response.AppendString((CyberEnvironment.getHabboForId(Group.CreatorId) == null) ? "" : CyberEnvironment.getHabboForId(Group.CreatorId).Username);
            Response.AppendBoolean(NewWindow);
            Response.AppendBoolean(Group.AdminOnlyDeco == 0u);
            Response.AppendInt32(Group.Requests.Count);
            Response.AppendBoolean(Group.HasForum);
            if (Room != null)
            {
                Room.SendMessage(Response);
                return;
            }
            if (Session != null)
            {
                Session.SendMessage(Response);
            }
        }
예제 #5
0
 internal void Pick(uint pModeratorId, bool UpdateInDb)
 {
     this.Status      = TicketStatus.PICKED;
     this.ModeratorId = pModeratorId;
     this.ModName     = CyberEnvironment.getHabboForId(pModeratorId).Username;
     if (UpdateInDb)
     {
         using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
         {
             queryreactor.runFastQuery(string.Concat(new object[]
             {
                 "UPDATE moderation_tickets SET status = 'picked', moderator_id = ",
                 pModeratorId,
                 ", timestamp = '",
                 CyberEnvironment.GetUnixTimestamp(),
                 "' WHERE id = ",
                 this.Id
             }));
         }
     }
 }
예제 #6
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);
        }
예제 #7
0
        internal ServerMessage SerializeGroupMembers(ServerMessage Response, Guild Group, uint ReqType, GameClient Session, string SearchVal = "", int Page = 0)
        {
            if (Group == null || Session == null)
            {
                return(null);
            }
            if (Page < 1)
            {
                Page = 0;
            }
            List <List <GroupUser> > list = GroupManager.Split(this.GetGroupUsersByString(Group, SearchVal, ReqType));

            Response.AppendUInt(Group.Id);
            Response.AppendString(Group.Name);
            Response.AppendUInt(Group.RoomId);
            Response.AppendString(Group.Badge);
            switch (ReqType)
            {
            case 0u:
                Response.AppendInt32(Group.Members.Count);
                Response.AppendInt32(list[Page].Count);
                using (List <GroupUser> .Enumerator enumerator = list[Page].GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        GroupUser current    = enumerator.Current;
                        Habbo     habboForId = CyberEnvironment.getHabboForId(current.Id);
                        if (habboForId == null)
                        {
                            Response.AppendInt32(0);
                            Response.AppendInt32(0);
                            Response.AppendString("");
                            Response.AppendString("");
                            Response.AppendString("");
                        }
                        else
                        {
                            Response.AppendInt32((current.Rank == 2) ? 0 : ((current.Rank == 1) ? 1 : 2));
                            Response.AppendUInt(habboForId.Id);
                            Response.AppendString(habboForId.Username);
                            Response.AppendString(habboForId.Look);
                            Response.AppendString("");
                        }
                    }
                    goto IL_367;
                }

            case 1u:
                break;

            case 2u:
            {
                List <List <uint> > list2 = GroupManager.Split(this.GetGroupRequestsByString(Group, SearchVal, ReqType));
                Response.AppendInt32(Group.Requests.Count);
                if (Group.Requests.Count > 0)
                {
                    Response.AppendInt32(list2[Page].Count);
                    using (List <uint> .Enumerator enumerator2 = list2[Page].GetEnumerator())
                    {
                        while (enumerator2.MoveNext())
                        {
                            uint  current2    = enumerator2.Current;
                            Habbo habboForId2 = CyberEnvironment.getHabboForId(current2);
                            if (habboForId2 == null)
                            {
                                Response.AppendInt32(0);
                                Response.AppendInt32(0);
                                Response.AppendString("");
                                Response.AppendString("");
                                Response.AppendString("");
                            }
                            else
                            {
                                Response.AppendInt32(3);
                                Response.AppendUInt(habboForId2.Id);
                                Response.AppendString(habboForId2.Username);
                                Response.AppendString(habboForId2.Look);
                                Response.AppendString("");
                            }
                        }
                        goto IL_367;
                    }
                }
                Response.AppendInt32(0);
                goto IL_367;
            }

            default:
                goto IL_367;
            }
            Response.AppendInt32(Group.Admins.Count);
            if (Group.Admins.Count > 0)
            {
                Response.AppendInt32(list[Page].Count);
                using (List <GroupUser> .Enumerator enumerator3 = list[Page].GetEnumerator())
                {
                    while (enumerator3.MoveNext())
                    {
                        GroupUser current3    = enumerator3.Current;
                        Habbo     habboForId3 = CyberEnvironment.getHabboForId(current3.Id);
                        if (habboForId3 == null)
                        {
                            Response.AppendInt32(0);
                            Response.AppendInt32(0);
                            Response.AppendString("");
                            Response.AppendString("");
                            Response.AppendString("");
                        }
                        else
                        {
                            Response.AppendInt32((current3.Rank == 2) ? 0 : ((current3.Rank == 1) ? 1 : 2));
                            Response.AppendUInt(habboForId3.Id);
                            Response.AppendString(habboForId3.Username);
                            Response.AppendString(habboForId3.Look);
                            Response.AppendString("");
                        }
                    }
                    goto IL_367;
                }
            }
            Response.AppendInt32(0);
IL_367:
            Response.AppendBoolean(Session.GetHabbo().Id == Group.CreatorId);
            Response.AppendInt32(14);
            Response.AppendInt32(Page);
            Response.AppendUInt(ReqType);
            Response.AppendString(SearchVal);
            return(Response);
        }