protected void Page_Load(object sender, EventArgs e) { AjaxPro.Utility.RegisterTypeForAjax(typeof(Home_Room_TencentReceive), this.Page); if (this.Request.Form.AllKeys.Length < 1) { Shove._Web.JavaScript.Alert(this.Page, "接口调用失败,请重新登录。", "../../UserLogin.aspx"); return; } StringBuilder sb = new StringBuilder(); string input_charset = Request.Form["charset"] == null ? "" : Request.Form["charset"].ToString().Trim(); string tmstamp = Request.Form["tmstamp"] == null ? "" : Request.Form["tmstamp"].ToString().Trim(); string sign = Request.Form["sign"] == null ? "" : Request.Form["sign"].ToString().Trim(); string key =so["MemberSharing_Tencent_MD5"].ToString("").Trim(); string id = Request.Form["id"] == null ? "" : Request.Form["id"].ToString().Trim(); string email = "" ; if (id.IndexOf("@") > 0 && id.IndexOf(".") > 0) { email = id; } else { email = id + "@qq.com"; } if (!IsPostBack) { if (Shove._Convert.StrToLong(GetTmstamp(), 0) - Shove._Convert.StrToLong(tmstamp, 0) > 60 * 2) { Shove._Web.JavaScript.Alert(this.Page, "登陆超时,请重新登录。", "../../UserLogin.aspx"); return; } string[] allKeys = Request.Form.AllKeys; string TencentSign = GetSign(key, input_charset, allKeys); if (TencentSign != sign) { Shove._Web.JavaScript.Alert(this.Page, "您不是有效的腾讯用户不能登录本站,请您注册成为本站会员,再登录,谢谢!(-1001)。", "../../UserLogin.aspx"); return; } if (String.IsNullOrEmpty(id)) { Shove._Web.JavaScript.Alert(this.Page, "您不是有效的腾讯用户不能登录本站,请您注册成为本站会员,再登录,谢谢!(-1002)。", "../../UserLogin.aspx"); return; } } bool isUseCheckCode = _Site.SiteOptions["Opt_isUseCheckCode"].ToBoolean(true); CheckCode.Visible = isUseCheckCode; new Login().SetCheckCode(_Site, ShoveCheckCode1); Sites site = new Sites()[Shove._Web.Utility.GetUrlWithoutHttp()]; if (site == null) { Shove._Web.JavaScript.Alert(this.Page, "站点信息不存在。", "../../UserLogin.aspx"); return; } if (_User != null && Shove._Web.Cache.GetCache("UserQQBind_" + _User.ID.ToString()) != null) { if (Shove._Convert.StrToLong(id, 0) < 1) { Shove._Web.JavaScript.Alert(this.Page, "您输入的 QQ 号码不合法!", "TencentLogin.aspx"); return; } Shove._Web.Cache.ClearCache("UserQQBind_" + _User.ID.ToString()); System.Threading.Thread.Sleep(500); int ReturnValue = -1; string ReturnDescription = ""; _User.QQ = id; _User.isQQValided = true; ReturnValue = _User.EditByID(ref ReturnDescription); if (ReturnValue < 0) { Shove._Web.JavaScript.Alert(this.Page, ReturnDescription); return; } Shove._Web.JavaScript.Alert(this.Page, "QQ号码绑定成功!","UserQQBind.aspx"); } DAL.Tables.T_Users t_users = new DAL.Tables.T_Users(); DataTable dt = t_users.Open("[ID], [Name]", "SiteID = " + site.ID.ToString() + " and QQ = '" + Shove._Web.Utility.FilteSqlInfusion(id) + "' and IsQQValided = 1", "[ID]"); if (dt == null) { Shove._Web.JavaScript.Alert(this.Page, "数据库繁忙,请重试。", "../../UserLogin.aspx"); return; } if (!IsPostBack) { labAccount.Text = id; labAccount2.Text = id; if (dt.Rows.Count < 1) { // 不存在,注册为新会员 tbQQID.Text = id; tbName.Text = id; tbEmail.Text = email; btnSelect.Enabled = false; tableSelect.Visible = false; Script = "btn_CheckUserName('" + id + "')"; return; } else if (dt.Rows.Count == 1) { long UserID = Shove._Convert.StrToLong(dt.Rows[0]["ID"].ToString(), -1); if (UserID < 0) { Shove._Web.JavaScript.Alert(this.Page, "用户信息读取错误。", "../../UserLogin.aspx"); return; } Users user = new Users(site.ID)[site.ID, UserID]; if (user == null) { Shove._Web.JavaScript.Alert(this.Page, "用户信息不存在。", "../../UserLogin.aspx"); return; } string ReturnDescription = ""; if (user.LoginDirect(ref ReturnDescription) < 0) { PF.GoError(ErrorNumber.Unknow, ReturnDescription, this.GetType().FullName); return; } ResponseToDistination(user, id); return; } // 绑定了多个用户 tableRegister.Visible = false; btnOK.Enabled = false; tableSelect.Visible = true; btnSelect.Enabled = true; Shove.ControlExt.FillDropDownList(ddlName, dt, "Name", "ID"); ddlName.SelectedIndex = 0; } }
protected void Page_Load(object sender, EventArgs e) { AjaxPro.Utility.RegisterTypeForAjax(typeof(Home_Room_Receive), this.Page); if (this.Request.QueryString.Count < 1) { Shove._Web.JavaScript.Alert(this.Page, "接口调用失败,请重新登录。", "../../Default.aspx"); return; } string alipayNotifyURL = "http://notify.alipay.com/trade/notify_query.do?"; string partner = so["MemberSharing_Alipay_UserNumber"].ToString(""); //卖家商户号 alipayNotifyURL = alipayNotifyURL + "partner=" + partner + "¬ify_id=" + Request.QueryString["notify_id"]; //获取支付宝ATN返回结果,true是正确的订单信息,false 是无效的 string responseTxt = Get_Http(alipayNotifyURL, 120000); if (responseTxt == "false") { Shove._Web.JavaScript.Alert(this.Page, "接口调用失败,请重新登录。", "../../Default.aspx"); return; } bool isUseCheckCode = _Site.SiteOptions["Opt_isUseCheckCode"].ToBoolean(true); CheckCode.Visible = isUseCheckCode; new Login().SetCheckCode(_Site, ShoveCheckCode1); string key = so["MemberSharing_Alipay_MD5"].ToString(""); //partner 的对应交易安全校验码(必须填写)和alipay.cs文件中值是一样的 string _input_charset = "utf-8"; int i; String[] requestarr = Request.QueryString.AllKeys; //进行排序; string[] Sortedstr = Shove.Alipay.Alipay.BubbleSort(requestarr); //构造待md5摘要字符串 ; StringBuilder prestr = new StringBuilder(); for (i = 0; i < Sortedstr.Length; i++) { if (String.IsNullOrEmpty(Sortedstr[i])) { continue; } if (Request.QueryString[Sortedstr[i]] != "" && Sortedstr[i] != "sign" && Sortedstr[i] != "sign_type" && Sortedstr[i].ToLower() != "pn") { if (i == Sortedstr.Length - 1) { prestr.Append(Sortedstr[i] + "=" + Request.QueryString[Sortedstr[i]]); } else { prestr.Append(Sortedstr[i] + "=" + Request.QueryString[Sortedstr[i]] + "&"); } } } prestr.Append(key); //生成Md5摘要; string mysign = Shove.Alipay.Alipay.GetMD5(prestr.ToString(), _input_charset); string sign = (Request.QueryString["sign"] == null ? "" : Request.QueryString["sign"].ToString()); string Success = (Request.QueryString["is_success"] == null ? "" : Request.QueryString["is_success"].ToString().ToUpper()); string User_id = (Request.QueryString["user_id"] == null ? "" : Request.QueryString["user_id"].ToString()); string RealName = (Request.QueryString["real_name"] == null ? "" : Request.QueryString["real_name"].ToString()); string Email = (Request.QueryString["email"] == null ? "" : Request.QueryString["email"].ToString()); //****************************************************************************** if (mysign != sign) //验证支付发过来的消息,签名是否正确(防止有伪造消息) { //WriteLog PF.GoError(ErrorNumber.Unknow, "您不是有效的支付宝会员不能登录本站,请您注册成为本站会员,再登录,谢谢!(-1001)", this.GetType().FullName); return; } if (Success != "T") { PF.GoError(ErrorNumber.Unknow, "您不是有效的支付宝会员不能登录本站,请您注册成为本站会员,再登录,谢谢!(-1002)", this.GetType().FullName); return; } labAccount.Text = Email; //处理数据 if (String.IsNullOrEmpty(User_id)) { PF.GoError(ErrorNumber.Unknow, "您不是有效的支付宝会员不能登录本站,请您注册成为本站会员,再登录,谢谢!(-1003)", this.GetType().FullName); return; } Sites site = new Sites()[Shove._Web.Utility.GetUrlWithoutHttp()]; if (site == null) { PF.GoError(ErrorNumber.Unknow, "会员数据校验错误。", this.GetType().FullName); return; } if (_User != null && Shove._Web.Cache.GetCache("BindAlipay_" + _User.ID.ToString()) != null) { Shove._Web.Cache.ClearCache("BindAlipay_" + _User.ID.ToString()); System.Threading.Thread.Sleep(500); Users tu = new Users(_Site.ID); _User.Clone(tu); _User.AlipayID = User_id; _User.isAlipayNameValided = true; _User.AlipayName = Email; string ReturnDescription = ""; if (_User.EditByID(ref ReturnDescription) < 0) { tu.Clone(_User); Shove._Web.JavaScript.Alert(this.Page, ReturnDescription); return; } Shove._Web.JavaScript.Alert(this.Page, "支付宝绑定成功!", "BindAlipay.aspx"); } DAL.Tables.T_Users t_users = new DAL.Tables.T_Users(); DataTable dt = t_users.Open("[ID], [Name]", "SiteID = " + site.ID.ToString() + " and AlipayID = '" + User_id + "' and isAlipayNameValided = 1", "[ID]"); if (dt == null) { PF.GoError(ErrorNumber.DataReadWrite, "数据库繁忙,请重试", this.GetType().FullName); return; } if (!IsPostBack) { tbRealityName.Text = RealName; hidUserID.Value = User_id; if (dt.Rows.Count < 1) { // 不存在,注册为新会员 tbAlipayID.Text = User_id; Script = "btn_CheckUserName('" + tbName.Text + "')"; btnSelect.Enabled = false; tableSelect.Visible = false; return; } else if (dt.Rows.Count == 1) { long UserID = Shove._Convert.StrToLong(dt.Rows[0]["ID"].ToString(), -1); if (UserID < 0) { PF.GoError(ErrorNumber.Unknow, "会员数据校验错误。", this.GetType().FullName); return; } Users user = new Users(site.ID)[site.ID, UserID]; if (user == null) { PF.GoError(ErrorNumber.Unknow, "会员数据校验错误。", this.GetType().FullName); return; } string ReturnDescription = ""; if (user.LoginDirect(ref ReturnDescription) < 0) { PF.GoError(ErrorNumber.Unknow, ReturnDescription, this.GetType().FullName); return; } Response.Redirect("../../Default.aspx", true); return; } // 绑定了多个用户 tableRegister.Visible = false; btnOK.Enabled = false; tableSelect.Visible = true; btnSelect.Enabled = true; Shove.ControlExt.FillDropDownList(ddlName, dt, "Name", "ID"); ddlName.SelectedIndex = 0; } }