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 System.Data.SqlClient;
using System.Text;

public partial class Ajax_TopAjax : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {      

        //System.Text.Encoding GB2312 = System.Text.Encoding.GetEncoding("GB2312");
        //System.Text.Encoding UTF8 = System.Text.Encoding.UTF8;
        //byte[] data = GB2312.GetBytes(Request.QueryString["str"]);
        //string msg = UTF8.GetString(System.Text.Encoding.Convert(GB2312,UTF8,data));
        //Response.Write(Request.QueryString["str"]);
        string[] str = Request.QueryString["str"].Split('$');
        string a, b, c,d;
        a=str[0];
        b=str[1];
        c=str[2];
        string isusertrue;
        if (Session["Wtouser"] != "vipadmin")
        {
            isusertrue = "n";
        }
        else
        {
            isusertrue = "y";
            SqlConnection connzf=CDatabase.wtoconn();
            connzf.Open();
            SqlCommand smdzf = new SqlCommand("select bbsson from Integral", connzf);
            string bbsjf = Convert.ToString(smdzf.ExecuteScalar());
            connzf.Close();
            Doadmin.Execsql("update MemberVIP set Integral=Integral+"+Convert.ToInt32(bbsjf)+" where id="+Session["userid"].ToString());
        }
        string userip = "";
      if(Request.ServerVariables["HTTP_VIA"]!=null)
      {

          userip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();

　　  }
      else
      {

          userip = Request.ServerVariables["REMOTE_ADDR"].ToString();
 
　  　}
    SqlConnection conn = CDatabase.wtoconn();
    conn.Open();
    SqlCommand smd = new SqlCommand("select Products,ThumbnailsPic from ProductInfo where id="+Session["pid"], conn);
    SqlDataReader sdr = smd.ExecuteReader();
    sdr.Read();
    string pname = sdr.GetString(0);
    string pic = sdr.GetString(1);
    sdr.Close();


    SqlCommand smd2 = new SqlCommand("select ProcuctMSet from SystemBasicInformation", conn);
    string closeandopen = Convert.ToString(smd2.ExecuteScalar());
    conn.Close();


    string sql = "insert into comments(username,isfp,content,ip,pid,FBdate,Pf,isuser,userid,isusertrue,pname,pic,shefen,reContent) values ('" + a + "','" + closeandopen + "','" + b + "','" + userip + "','" + Session["pid"] + "','" + System.DateTime.Now.ToString() + "'," + Convert.ToInt32(Request.QueryString["pf"]) + ",'" + c + "'," + Session["userid"] + ",'" + isusertrue + "','" + pname + "','" + pic + "','客服回复','您好，这是系统自动回复，我们会尽快回复您；')";
        if (TOPdo.Execsql(sql))
        {

            Response.Write("发表成功，感谢您对我们的支持！");
        }
        else
        {
            Response.Write("发表失败，请您再次提交！\n感谢您对我们的支持！");
        }
    }
}
