コード例 #1
0
ファイル: Groups.cs プロジェクト: BjkGkh/Azure2
 /// <summary>
 /// Alters the state of the forum thread.
 /// </summary>
 internal void AlterForumThreadState()
 {
     int GroupId = Request.GetInteger();
     uint ThreadId = Request.GetUInteger();
     int StateToSet = Request.GetInteger();
     using (IQueryAdapter dbClient = AzureEmulator.GetDatabaseManager().GetQueryReactor())
     {
         dbClient.SetQuery(string.Format("SELECT * FROM groups_forums_posts WHERE group_id = '{0}' AND id = '{1}' LIMIT 1;", GroupId, ThreadId));
         DataRow Row = dbClient.GetRow();
         Guild Group = AzureEmulator.GetGame().GetGroupManager().GetGroup(GroupId);
         if (Row != null)
         {
             if ((uint)Row["poster_id"] == Session.GetHabbo().Id || Group.Admins.ContainsKey(Session.GetHabbo().Id))
             {
                 dbClient.SetQuery(string.Format("UPDATE groups_forums_posts SET hidden = @hid WHERE id = {0};", ThreadId));
                 dbClient.AddParameter("hid", (StateToSet == 10) ? "1" : "0");
                 dbClient.RunQuery();
             }
         }
         var Thread = new GroupForumPost(Row);
         var Notif = new ServerMessage(LibraryParser.OutgoingRequest("SuperNotificationMessageComposer"));
         Notif.AppendString((StateToSet == 10) ? "forums.thread.hidden" : "forums.thread.restored");
         Notif.AppendInteger(0);
         Session.SendMessage(Notif);
         if (Thread.ParentId != 0)
             return;
         var Message = new ServerMessage(LibraryParser.OutgoingRequest("GroupForumThreadUpdateMessageComposer"));
         Message.AppendInteger(GroupId);
         Message.AppendInteger(Thread.Id);
         Message.AppendInteger(Thread.PosterId);
         Message.AppendString(Thread.PosterName);
         Message.AppendString(Thread.Subject);
         Message.AppendBool(Thread.Pinned);
         Message.AppendBool(Thread.Locked);
         Message.AppendInteger((AzureEmulator.GetUnixTimeStamp() - Thread.Timestamp));
         Message.AppendInteger(Thread.MessageCount + 1);
         Message.AppendInteger(0);
         Message.AppendInteger(0);
         Message.AppendInteger(0);
         Message.AppendString("");
         Message.AppendInteger((AzureEmulator.GetUnixTimeStamp() - Thread.Timestamp));
         Message.AppendByte(StateToSet);
         Message.AppendInteger(0);
         Message.AppendString(Thread.Hider);
         Message.AppendInteger(0);
         Session.SendMessage(Message);
     }
 }
コード例 #2
0
ファイル: Groups.cs プロジェクト: BjkGkh/Azure2
        /// <summary>
        /// Reads the forum thread.
        /// </summary>
        internal void ReadForumThread()
        {
            int GroupId = Request.GetInteger();
            uint ThreadId = Request.GetUInteger();
            int StartIndex = Request.GetInteger();
            int EndIndex = Request.GetInteger();
            Guild Group = AzureEmulator.GetGame().GetGroupManager().GetGroup(GroupId);
            if (Group == null || !Group.HasForum)
                return;
            using (IQueryAdapter dbClient = AzureEmulator.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery(string.Format("SELECT * FROM groups_forums_posts WHERE group_id = '{0}' AND parent_id = '{1}' OR id = '{2}' ORDER BY timestamp ASC;", GroupId, ThreadId, ThreadId));
                DataTable Table = dbClient.GetTable();
                if (Table == null)
                    return;
                int b = (Table.Rows.Count <= 20) ? Table.Rows.Count : 20;
                var posts = new List<GroupForumPost>();
                int i = 1;
                while (i <= b)
                {
                    DataRow Row = Table.Rows[i - 1];
                    if (Row == null)
                    {
                        b--;
                        continue;
                    }
                    var thread = new GroupForumPost(Row);
                    if (thread.ParentId == 0 && thread.Hidden)
                        return;
                    posts.Add(thread);
                    i++;
                }

                var Message = new ServerMessage(LibraryParser.OutgoingRequest("GroupForumReadThreadMessageComposer"));
                Message.AppendInteger(GroupId);
                Message.AppendInteger(ThreadId);
                Message.AppendInteger(StartIndex);
                Message.AppendInteger(b);
                int indx = 0;
                foreach (GroupForumPost Post in posts)
                {
                    Message.AppendInteger(indx++ - 1);
                    Message.AppendInteger(indx - 1);
                    Message.AppendInteger(Post.PosterId);
                    Message.AppendString(Post.PosterName);
                    Message.AppendString(Post.PosterLook);
                    Message.AppendInteger((AzureEmulator.GetUnixTimeStamp() - Post.Timestamp));
                    Message.AppendString(Post.PostContent);
                    Message.AppendByte(0);
                    Message.AppendInteger(0);
                    Message.AppendString(Post.Hider);
                    Message.AppendInteger(0);
                }
                Session.SendMessage(Message);
            }
        }
コード例 #3
0
ファイル: Groups.cs プロジェクト: BjkGkh/Azure2
 /// <summary>
 /// Publishes the forum thread.
 /// </summary>
 internal void PublishForumThread()
 {
     if ((AzureEmulator.GetUnixTimeStamp() - Session.GetHabbo().LastSqlQuery) < 20)
         return;
     int groupId = Request.GetInteger();
     uint threadId = Request.GetUInteger();
     string subject = Request.GetString();
     string content = Request.GetString();
     Guild group = AzureEmulator.GetGame().GetGroupManager().GetGroup(groupId);
     if (group == null || !group.HasForum)
         return;
     int timestamp = AzureEmulator.GetUnixTimeStamp();
     using (IQueryAdapter dbClient = AzureEmulator.GetDatabaseManager().GetQueryReactor())
     {
         if (threadId != 0)
         {
             dbClient.SetQuery(string.Format("SELECT * FROM groups_forums_posts WHERE id = {0}", threadId));
             DataRow Row = dbClient.GetRow();
             var Post = new GroupForumPost(Row);
             if (Post.Locked || Post.Hidden)
             {
                 Session.SendNotif(TextManager.GetText("forums_cancel"));
                 return;
             }
         }
         Session.GetHabbo().LastSqlQuery = AzureEmulator.GetUnixTimeStamp();
         dbClient.SetQuery("INSERT INTO groups_forums_posts (group_id, parent_id, timestamp, poster_id, poster_name, poster_look, subject, post_content) VALUES (@gid, @pard, @ts, @pid, @pnm, @plk, @subjc, @content)");
         dbClient.AddParameter("gid", groupId);
         dbClient.AddParameter("pard", threadId);
         dbClient.AddParameter("ts", timestamp);
         dbClient.AddParameter("pid", Session.GetHabbo().Id);
         dbClient.AddParameter("pnm", Session.GetHabbo().UserName);
         dbClient.AddParameter("plk", Session.GetHabbo().Look);
         dbClient.AddParameter("subjc", subject);
         dbClient.AddParameter("content", content);
         threadId = (uint)dbClient.GetInteger();
     }
     group.ForumScore += 0.25;
     group.ForumLastPosterName = Session.GetHabbo().UserName;
     group.ForumLastPosterId = Session.GetHabbo().Id;
     group.ForumLastPosterTimestamp = timestamp;
     group.ForumMessagesCount++;
     group.UpdateForum();
     if (threadId == 0)
     {
         var Message = new ServerMessage(LibraryParser.OutgoingRequest("GroupForumNewThreadMessageComposer"));
         Message.AppendInteger(groupId);
         Message.AppendInteger(threadId);
         Message.AppendInteger(Session.GetHabbo().Id);
         Message.AppendString(subject);
         Message.AppendString(content);
         Message.AppendBool(false);
         Message.AppendBool(false);
         Message.AppendInteger((AzureEmulator.GetUnixTimeStamp() - timestamp));
         Message.AppendInteger(1);
         Message.AppendInteger(0);
         Message.AppendInteger(0);
         Message.AppendInteger(1);
         Message.AppendString("");
         Message.AppendInteger((AzureEmulator.GetUnixTimeStamp() - timestamp));
         Message.AppendByte(1);
         Message.AppendInteger(1);
         Message.AppendString("");
         Message.AppendInteger(42);//useless
         Session.SendMessage(Message);
     }
     else
     {
         var Message = new ServerMessage(LibraryParser.OutgoingRequest("GroupForumNewResponseMessageComposer"));
         Message.AppendInteger(groupId);
         Message.AppendInteger(threadId);
         Message.AppendInteger(group.ForumMessagesCount);
         Message.AppendInteger(0);
         Message.AppendInteger(Session.GetHabbo().Id);
         Message.AppendString(Session.GetHabbo().UserName);
         Message.AppendString(Session.GetHabbo().Look);
         Message.AppendInteger((AzureEmulator.GetUnixTimeStamp() - timestamp));
         Message.AppendString(content);
         Message.AppendByte(0);
         Message.AppendInteger(0);
         Message.AppendString("");
         Message.AppendInteger(0);
         Session.SendMessage(Message);
     }
 }
コード例 #4
0
ファイル: Groups.cs プロジェクト: BjkGkh/Azure2
 /// <summary>
 /// Gets the group forum thread root.
 /// </summary>
 internal void GetGroupForumThreadRoot()
 {
     int GroupId = Request.GetInteger();
     int StartIndex = Request.GetInteger();
     int EndIndex = Request.GetInteger();
     Guild Group = AzureEmulator.GetGame().GetGroupManager().GetGroup(GroupId);
     if (Group == null || !Group.HasForum)
         return;
     using (IQueryAdapter dbClient = AzureEmulator.GetDatabaseManager().GetQueryReactor())
     {
         dbClient.SetQuery(string.Format("SELECT * FROM groups_forums_posts WHERE group_id = '{0}' AND parent_id = 0 ORDER BY timestamp DESC;", GroupId));
         DataTable Table = dbClient.GetTable();
         if (Table == null)
         {
             var Messages = new ServerMessage(LibraryParser.OutgoingRequest("GroupForumThreadRootMessageComposer"));
             Messages.AppendInteger(GroupId);
             Messages.AppendInteger(0);
             Messages.AppendInteger(0);
             Session.SendMessage(Messages);
             return;
         }
         int b = (Table.Rows.Count <= 20) ? Table.Rows.Count : 20;
         var Threads = new List<GroupForumPost>();
         int i = 1;
         while (i <= b)
         {
             DataRow Row = Table.Rows[i - 1];
             if (Row == null)
             {
                 b--;
                 continue;
             }
             var thread = new GroupForumPost(Row);
             Threads.Add(thread);
             i++;
         }
         Threads = Threads.OrderByDescending(x => x.Pinned).ToList();
         var Message = new ServerMessage(LibraryParser.OutgoingRequest("GroupForumThreadRootMessageComposer"));
         Message.AppendInteger(GroupId);
         Message.AppendInteger(StartIndex);
         Message.AppendInteger(b);
         foreach (GroupForumPost Thread in Threads)
         {
             Message.AppendInteger(Thread.Id);
             Message.AppendInteger(Thread.PosterId);
             Message.AppendString(Thread.PosterName);
             Message.AppendString(Thread.Subject);
             Message.AppendBool(Thread.Pinned);
             Message.AppendBool(Thread.Locked);
             Message.AppendInteger((AzureEmulator.GetUnixTimeStamp() - Thread.Timestamp));
             Message.AppendInteger(Thread.MessageCount + 1);
             Message.AppendInteger(0);
             Message.AppendInteger(0);
             Message.AppendInteger(0);
             Message.AppendString("");
             Message.AppendInteger((AzureEmulator.GetUnixTimeStamp() - Thread.Timestamp));
             Message.AppendByte((Thread.Hidden) ? 10 : 1);
             Message.AppendInteger(0);
             Message.AppendString(Thread.Hider);
             Message.AppendInteger(0);
         }
         Session.SendMessage(Message);
     }
 }