Example #1
0
        private int PostNewReply()
        {
            string ipaddress = Common.GetIP4Address();

            var poll = new Regex(@"(?<poll>\[poll=(?<question>.+?)](?<answers>.+?)\[\/poll])", RegexOptions.Singleline);

            if (poll.IsMatch(Message.Text))
            {
                //Polls not allowed in replies
                Message.Text = poll.Replace(Message.Text, "");
            }

            var reply = new ReplyInfo
            {
                Message       = Message.Text,
                PosterIp      = ipaddress,
                Status        = (int)Enumerators.PostStatus.Open,
                UseSignatures = cbxSig.Checked,
                AuthorId      = Member.Id,
                Date          = DateTime.UtcNow
            };

            if (!_inModeratedList)
            {
                if (_thisTopic.Forum.ModerationLevel == (int)Enumerators.Moderation.AllPosts ||
                    _thisTopic.Forum.ModerationLevel == (int)Enumerators.Moderation.Replies)
                {
                    reply.Status = (int)Enumerators.PostStatus.UnModerated;
                    _thisTopic.UnModeratedReplies += 1;
                }
            }

            reply.TopicId = _thisTopic.Id;
            reply.CatId   = _thisTopic.CatId;
            reply.ForumId = _thisTopic.ForumId;
            reply.Id      = Replies.AddReply(reply);

            if (cbxLock.Checked && _inModeratedList)
            {
                _thisTopic.Status = (int)Enumerators.PostStatus.Closed;
            }
            Topics.Update(_thisTopic);
            if (pingSiteMap)
            {
                Ping("");
            }
            InvalidateForumCache();
            return(reply.Id);
        }
Example #2
0
    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));
    }