namespace Holo.Managers { using Holo; using Holo.Virtual.Users; using System; using System.Collections; using System.Runtime.InteropServices; using System.Text; using System.Threading; public static class eventManager { private static Hashtable[] ᙅ; private static Thread 4AAAA; private static int 5AAA1; internal static int categoryAmount; private static void ᙄ() { while (true) { for (int i = 0; i < categoryAmount; i++) { foreach (eventManager.ᙃ ᙃ in ((Hashtable) ᙅ[i].Clone()).Values) { if (!userManager.containsUser(ᙃ.userID)) { DB.runQuery("DELETE FROM events WHERE roomid = '" + ᙃ.roomID + "'"); ᙅ[i].Remove(ᙃ.roomID); } else { virtualUser user = userManager.getUser(ᙃ.userID); if (user._roomID != ᙃ.roomID) { DB.runQuery("DELETE FROM events WHERE roomid = '" + ᙃ.roomID + "'"); ᙅ[i].Remove(ᙃ.roomID); user._hostsEvent = false; } } } } Thread.Sleep(5AAA1); } } public static bool categoryOK(int categoryID) { return ((categoryID > 0) && (categoryID <= categoryAmount)); } public static void createEvent(int categoryID, int userID, int roomID, string Name, string Description) { if (!ᙅ[categoryID - 1].Contains(roomID)) { eventManager.ᙃ ᙃ = new eventManager.ᙃ(roomID, userID, Name, Description); DB.runQuery(string.Concat(new object[] { "INSERT INTO events (name,description,userid,roomid,category,date) VALUES ('", DB.Stripslash(Name), "','", DB.Stripslash(Description), "','", userID, "','", roomID, "','", categoryID, "','", DateTime.Now.TimeOfDay.ToString(), "')" })); ᙅ[categoryID - 1].Add(roomID, ᙃ); } } public static void editEvent(int categoryID, int roomID, string Name, string Description) { if (ᙅ[categoryID - 1].Contains(roomID)) { eventManager.ᙃ ᙃ = (eventManager.ᙃ) ᙅ[categoryID - 1][roomID]; ᙃ.Name = Name; ᙃ.Description = Description; DB.runQuery(string.Concat(new object[] { "UPDATE events SET name = '", Name, "',description = '", Description, "',category = '", categoryID, "',date = '", DateTime.Now.TimeOfDay.ToString(), "' WHERE roomid = '", roomID, "'" })); ᙅ[categoryID - 1].Remove(roomID); ᙅ[categoryID - 1].Add(roomID, ᙃ); } } public static string getEvent(int roomID) { try { for (int i = 0; i < categoryAmount; i++) { if (ᙅ[i].ContainsKey(roomID)) { eventManager.ᙃ ᙃ = (eventManager.ᙃ) ᙅ[i][roomID]; return string.Concat(new object[] { ᙃ.userID, Convert.ToChar(2).ToString(), userManager.getUser(ᙃ.userID)._Username, Convert.ToChar(2).ToString(), ᙃ.roomID, Convert.ToChar(2).ToString(), Holo.Encoding.encodeVL64(i + 1), ᙃ.Name, Convert.ToChar(2).ToString(), ᙃ.Description, Convert.ToChar(2).ToString(), ᙃ.Started, Convert.ToChar(2).ToString() }); } } return "-1"; } catch { return "-1"; } } public static string getEvents(int categoryID) { try { int i = 0; StringBuilder builder = new StringBuilder(); foreach (eventManager.ᙃ ᙃ in ᙅ[categoryID - 1].Values) { if (userManager.containsUser(ᙃ.userID)) { builder.Append(string.Concat(new object[] { ᙃ.roomID, Convert.ToChar(2).ToString(), userManager.getUser(ᙃ.userID)._Username, Convert.ToChar(2), ᙃ.Name, Convert.ToChar(2), ᙃ.Description, Convert.ToChar(2), ᙃ.Started, Convert.ToChar(2) })); i++; } } return (Holo.Encoding.encodeVL64(i) + builder.ToString()); } catch { return "H"; } } public static void Init() { try { 4AAAA.Abort(); } catch { } categoryAmount = int.Parse(Config.getTableEntry("events_categorycount")); ᙅ = new Hashtable[categoryAmount]; for (int i = 0; i < categoryAmount; i++) { ᙅ[i] = new Hashtable(); } 5AAA1 = int.Parse(Config.getTableEntry("events_deadevents_removeinterval")) * 0x3e8; 4AAAA = new Thread(new ThreadStart(eventManager.ᙄ)); 4AAAA.Priority = ThreadPriority.BelowNormal; 4AAAA.Start(); } public static void removeEvent(int roomID) { for (int i = 0; i < categoryAmount; i++) { if (ᙅ[i].ContainsKey(roomID)) { DB.runQuery("DELETE FROM events WHERE roomid = '" + roomID + "'"); ᙅ[i].Remove(roomID); return; } } } [StructLayout(LayoutKind.Sequential)] private struct ᙃ { internal int roomID; internal int userID; internal string Name; internal string Description; internal string Started; internal ᙃ(int roomID, int userID, string Name, string Description) { this.roomID = roomID; this.userID = userID; this.Name = Name; this.Description = Description; this.Started = DateTime.Now.ToShortTimeString(); } } } }