Ejemplo n.º 1
0
        protected void btnSend_Click(object sender, EventArgs e)
        {
            string content = editor.GetContent();

            Page.Validate();

            if (!Page.IsValid || content.Replace(" ", "").Length == 0 || txtSubject.Text.Replace(" ", "").Length == 0)
            {
                lblResult.CssClass = "resulterror";
                lblResult.Text     = Properties.Messages.SubjectAndBodyNeeded;
                return;
            }

            Regex r = new Regex(@"\<script.*?\>", RegexOptions.Compiled | RegexOptions.IgnoreCase);

            if (r.Match(editor.GetContent()).Success)
            {
                lblResult.CssClass = "resulterror";
                lblResult.Text     = @"<span style=""color: #FF0000;"">" + Properties.Messages.ScriptDetected + "</span>";
                return;
            }

            string username = Request.UserHostAddress;

            if (SessionFacade.LoginKey != null)
            {
                username = SessionFacade.CurrentUsername;
            }

            if (Request["Edit"] == null)
            {
                int parent = -1;
                try
                {
                    parent = int.Parse(Request["Parent"]);
                }
                catch { }

                Pages.AddMessage(page, username, txtSubject.Text, DateTime.Now, content, parent);
            }
            else
            {
                var     messages = Pages.GetPageMessages(page);
                Message msg      = Pages.FindMessage(messages, int.Parse(Request["Edit"]));
                Pages.ModifyMessage(page, int.Parse(Request["Edit"]), msg.Username, txtSubject.Text, DateTime.Now, content);
            }
            UrlTools.Redirect(page.FullName + Settings.PageExtension + "?Discuss=1&NoRedirect=1");
        }