コード例 #1
0
ファイル: Post.aspx.cs プロジェクト: huwred/SnitzDotNet
        protected void PostMessage(object sender, EventArgs e)
        {
            btnSubmit.Enabled = false;

            switch (_action.ToLower())
            {
                case "topic":
                    Session.Add("LastPostMade", DateTime.UtcNow.ToForumDateStr());
                    int topicid = PostNewTopic();
                    if (_forum.AllowSubscriptions)
                    {
                        var ws = new CommonFunc();
                        ws.ProcessForumSubscriptions(topicid,HttpContext.Current);
                    }
                    Response.Redirect("/Content/Forums/topic.aspx?TOPIC=" + topicid);
                    break;
                case "reply":
                case "quote":
                    Session.Add("LastPostMade", DateTime.UtcNow.ToForumDateStr());

                    int replyid = PostNewReply();
                    var topic = Topics.GetTopic(TopicId.Value);
                    _forum = Forums.GetForum(topic.ForumId);
                    if (_forum.AllowSubscriptions)
                    {
                        var ws = new CommonFunc();
                        ws.ProcessForumSubscriptions(TopicId.Value, HttpContext.Current);
                    }
                    if (topic.AllowSubscriptions)
                    {
                        var ws = new CommonFunc();
                        ws.ProcessTopicSubscriptions(TopicId.Value, replyid, HttpContext.Current);
                    }
                    Response.Redirect("/Content/Forums/topic.aspx?TOPIC=" + TopicId + "&whichpage=-1#" + replyid);
                    break;
                case "edit":
                    switch (_type)
                    {
                        case "reply" :
                            EditReply();
                            break;
                        case "topics":
                            EditTopic();
                            break;
                    }
                    break;
            }
        }
コード例 #2
0
ファイル: QuickReply.ascx.cs プロジェクト: huwred/SnitzDotNet
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        DateTime newdate = DateTime.UtcNow;

        if (Session["LastPostMade"] != null)
        {
            if ((Config.FloodCheck)&& !(page.IsAdministrator || page.IsModerator))
            {
                TimeSpan diff1 = new TimeSpan(0, 0, 0, Config.FloodTimeout);
                DateTime dt = newdate - diff1;
                DateTime? lastpost = Session["LastPostMade"].ToString().ToDateTime();
                if (lastpost > dt)
                    throw new HttpException(403, "FloodCheck");
                    //Response.Redirect("error.aspx?msg=errFloodError");
            }
        }
        else
        {
            Session.Add("LastPostMade", DateTime.UtcNow.ToForumDateStr());
        }

        string MemberIP = Common.GetIP4Address();
        ReplyInfo reply = new ReplyInfo
                          {
                              TopicId = thisTopic.Id,
                              ForumId = thisTopic.ForumId,
                              CatId = thisTopic.CatId,
                              UseSignatures = cbxSig.Checked,
                              Message = qrMessage.Text,
                              PosterIp = MemberIP,
                              Status = thisTopic.Status,
                              AuthorId = page.Member.Id,
                              Date = newdate
                          };
        var forum = Forums.GetForum(thisTopic.ForumId);
        if(!(page.IsAdministrator || page.IsModerator))
        {
            if (forum.ModerationLevel == (int) Enumerators.Moderation.AllPosts ||
                forum.ModerationLevel == (int) Enumerators.Moderation.Replies)
            {
                reply.Status = (int) Enumerators.PostStatus.UnModerated;
                thisTopic.UnModeratedReplies += 1;
                Topics.Update(thisTopic);
            }
        }
        int replyid = Replies.AddReply(reply);
        if (forum.AllowSubscriptions)
        {
            var ws = new CommonFunc();
            ws.ProcessForumSubscriptions(reply.TopicId, HttpContext.Current);
        }
        if (thisTopic.AllowSubscriptions)
        {
            var ws = new CommonFunc();
            ws.ProcessTopicSubscriptions(reply.TopicId, replyid, HttpContext.Current);
        }
        if (Session["LastPostMade"] == null)
        {
            Session.Add("LastPostMade", newdate.ToForumDateStr());
        }
        else
        {
            Session["LastPostMade"] = newdate.ToForumDateStr();
        }
        InvalidateForumCache();
        Page.Response.Redirect(string.Format("/Content/Forums/topic.aspx?whichpage=-1&TOPIC_ID={0}&#{1}", thisTopic.Id, replyid));
    }