using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using JuSNS.Home;
using JuSNS.Model;
using JuSNS.UI.Control;
using JuSNS.Common;

namespace JuSNS.Web.Inc.Ajax
{
    public partial class LeaveWord : JuSNS.UI.Page.UserPage
    {
        JuSNS.Home.Space sp = new JuSNS.Home.Space();
        JuSNS.Home.Movie movie = new JuSNS.Home.Movie();
        JuSNS.Home.Album ab = new JuSNS.Home.Album();
        JuSNS.Home.HomeIndex uHome = new JuSNS.Home.HomeIndex();
        JuSNS.Home.User us = new JuSNS.Home.User();
        JuSNS.Home.Friend frd = new JuSNS.Home.Friend();
        public int myid = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.Form["r"] != null && Request.Form["r"].Trim() != string.Empty)
                    myid = int.Parse(Request.Form["r"]);
                else
                    myid = this.UserID;

                try
                {
                    string type = Request.Form["Type"];
                    if (type == "DelMsg")
                    {
                        if (sp.DelInfo(int.Parse(Request.Form["ID"]), 2) == 1)//删除留言
                        {
                            //Response.Write(getLeaveWord(myid, this.UserID, int.Parse(Request.Form["IsFriend"]), Convert.ToBoolean(Request.Form["flag"])));
                            //Response.End();
                        }
                    }
                    else if (type == "Msg")//给好友留言
                    {
                        if (Request.Form["IsFriend"] == "2")
                        {
                            #region 过滤关键字
                            string content = Request.Form["Content"];
                            string res = JuSNS.Common.Public.CheckKey(content, true);
                            if (res != "")
                            {
                                content = content.Replace(res, "***");
                            }
                            #endregion
                            if (sp.LeaveWords(this.UserID,myid,content,JuSNS.Common.Public.GetClientIP()) == 1)
                            {
                                //Response.Write(getLeaveWord(myid, this.UserID, int.Parse(Request.Form["IsFriend"]), Convert.ToBoolean(Request.Form["flag"])));
                                //Response.End();
                            }
                        }
                        else
                        {
                            Response.Write("1");
                            Response.End();
                        }
                    }
                }
                catch { }
            }

        }

    }
}  