Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Text;
- using System.Data;
- using System.Collections.Generic;
- using Plus.Database.Interfaces;
- using Plus.HabboHotel.Rooms;
- using Plus.HabboHotel.Users;
- using Plus.Utilities;
- using Plus.HabboHotel.Cache;
- namespace Plus.Communication.Packets.Outgoing.Moderation
- {
- class ModeratorRoomChatlogComposer : ServerPacket
- {
- public ModeratorRoomChatlogComposer(Room Room)
- : base(ServerPacketHeader.ModeratorRoomChatlogMessageComposer)
- {
- base.WriteByte(1);
- base.WriteShort(2); //Count
- base.WriteString("roomName");
- base.WriteByte(2);
- base.WriteString(Room.Name);
- base.WriteString("roomId");
- base.WriteByte(1);
- base.WriteInteger(Room.Id);
- DataTable table;
- using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
- {
- dbClient.SetQuery("SELECT * FROM `chatlogs` WHERE `room_id` = @rid ORDER BY `id` DESC LIMIT 250");
- dbClient.AddParameter("rid", Room.Id);
- table = dbClient.getTable();
- }
- if (table != null)
- {
- base.WriteShort(table.Rows.Count);
- foreach (DataRow row in table.Rows)
- {
- int timestamp;
- try
- {
- timestamp = ((int) PlusEnvironment.GetUnixTimestamp() - Convert.ToInt32(row["timestamp"])) *
- 1000;
- }
- catch
- {
- timestamp = 0; // For whatever reason, the maths failed
- }
- UserCache habbo =
- PlusEnvironment.GetGame().GetCacheManager().GenerateUser(Convert.ToInt32(row["user_id"]));
- base.WriteInteger(timestamp);
- if (habbo != null)
- {
- base.WriteInteger(habbo.Id);
- base.WriteString(habbo.Username);
- }
- else
- {
- base.WriteInteger(-1);
- base.WriteString("Unknown User");
- }
- base.WriteString(
- string.IsNullOrWhiteSpace(Convert.ToString(row["message"]))
- ? "*user sent a blank message*"
- : Convert.ToString(row["message"]));
- base.WriteBoolean(false);
- }
- }
- }
- }
- }
- using System;
- using System.Linq;
- using System.Text;
- using System.Data;
- using System.Collections.Generic;
- using Plus.HabboHotel.Users;
- using Plus.Database.Interfaces;
- using Plus.HabboHotel.Rooms;
- using Plus.HabboHotel.Cache;
- namespace Plus.Communication.Packets.Outgoing.Moderation
- {
- class ModeratorUserChatlogComposer : ServerPacket
- {
- public ModeratorUserChatlogComposer(int UserId)
- : base(ServerPacketHeader.ModeratorUserChatlogMessageComposer)
- {
- base.WriteInteger(UserId);
- base.WriteString(PlusEnvironment.GetGame().GetClientManager().GetNameById(UserId));
- using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
- {
- dbClient.SetQuery(
- "SELECT room_id,entry_timestamp,exit_timestamp FROM user_roomvisits WHERE `user_id` = " + UserId +
- " ORDER BY entry_timestamp DESC LIMIT 5");
- DataTable visits = dbClient.getTable();
- if (visits != null)
- {
- base.WriteInteger(visits.Rows.Count);
- foreach (DataRow visit in visits.Rows)
- {
- string roomName = "Unknown";
- Room room =
- PlusEnvironment.GetGame().GetRoomManager().LoadRoom(Convert.ToInt32(visit["room_id"]));
- if (room != null)
- roomName = room.Name;
- base.WriteByte(1);
- base.WriteShort(2); //Count
- base.WriteString("roomName");
- base.WriteByte(2);
- base.WriteString(roomName); // room name
- base.WriteString("roomId");
- base.WriteByte(1);
- base.WriteInteger(Convert.ToInt32(visit["room_id"]));
- DataTable chatlogs = null;
- if ((Double) visit["exit_timestamp"] <= 0)
- {
- visit["exit_timestamp"] = PlusEnvironment.GetUnixTimestamp();
- }
- dbClient.SetQuery("SELECT user_id,timestamp,message FROM `chatlogs` WHERE room_id = " +
- Convert.ToInt32(visit["room_id"]) + " AND timestamp > " +
- (Double) visit["entry_timestamp"] + " AND timestamp < " +
- (Double) visit["exit_timestamp"] + " ORDER BY timestamp DESC LIMIT 150");
- chatlogs = dbClient.getTable();
- if (chatlogs != null)
- {
- base.WriteShort(chatlogs.Rows.Count);
- foreach (DataRow log in chatlogs.Rows)
- {
- UserCache habbo =
- PlusEnvironment.GetGame()
- .GetCacheManager()
- .GenerateUser(Convert.ToInt32(log["user_id"]));
- if (habbo == null)
- continue;
- int timestamp;
- try
- {
- timestamp = ((int) PlusEnvironment.GetUnixTimestamp() -
- Convert.ToInt32(log["timestamp"])) * 1000;
- }
- catch
- {
- timestamp = 0;
- }
- base.WriteInteger(timestamp);
- base.WriteInteger(habbo.Id);
- base.WriteString(habbo.Username);
- base.WriteString(string.IsNullOrWhiteSpace(Convert.ToString(log["message"]))
- ? "*user sent a blank message*"
- : Convert.ToString(log["message"]));
- base.WriteBoolean(false);
- }
- }
- else
- base.WriteInteger(0);
- }
- }
- else
- base.WriteInteger(0);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement