private string ValidatePhone_Function(HttpContext context, string tel) { string result = "ok"; if (tel != "") { int t = 0; try { string sql = "select top 1 userid from THINK_SNS_DB.dbo.HRENH_THINK_USER where tel=@tel order by userid desc"; SqlParameter[] para = { new SqlParameter("@tel", SqlDbType.NVarChar, 50) }; para[0].Value = tel; t = Convert.ToInt32(DbHelperSQL.GetSingle(sql, para).ToString()); } catch (Exception ex) { } if (t <= 0) { result = "nouser"; } else { CookieManage_HongRenHui.AddCookie("FINDRED_HREN_USERID", t.ToString(), 1, false); } } else { result = "notel"; } return(result); }
/// <summary> /// 验证是否登录成功 /// </summary> /// <param name="context"></param> private void Login_States(NVelocity.VelocityContext context) { int login_type = String_Manage.Return_Request_Int("logintype", 0); string urls = String_Manage.Return_Request_Str("urls"); CookieManage_HongRenHui.AddCookie("RED_HREN_Login_Type", login_type.ToString(), 7, false); if (urls != "" && urls != "0") { CookieManage_HongRenHui.AddCookie("RED_HREN_Login_Urls", urls, 7, false); } else { CookieManage_HongRenHui.AddCookie("RED_HREN_Login_Urls", CheckIsLogin_HongRenHui.Get_User_CenterUrl_HongRenHui(), 7, false); } if (CheckIsLogin_HongRenHui.IsLogin("RED_HREN_USERID")) { if (urls != "") { context.Put("redirecturl", urls); } else { context.Put("redirecturl", CheckIsLogin_HongRenHui.Get_User_CenterUrl_HongRenHui()); } } }
public override void Page_Load(ref NVelocity.VelocityContext context) { base.Page_Load(ref context); int t = 0; t = String_Manage.Return_Request_Int("t", 0); context.Put("t", t); int logintype = 0; int third_logintype = 1; try { if (CookieManage_HongRenHui.IsHaveCookie("RED_HREN_USERID")) { logintype = Convert.ToInt32(CookieManage_HongRenHui.GetCookieValue("RED_HREN_Login_Type")); third_logintype = Convert.ToInt32(CookieManage_HongRenHui.GetCookieValue("RED_HREN_Third_Login")); CookieManage_HongRenHui.AddCookie("RED_HREN_USERID", CookieManage_HongRenHui.GetCookieValue("RED_HREN_USERID"), -1, true); CookieManage_HongRenHui.AddCookie("FINDRED_HREN_USERID", CookieManage_HongRenHui.GetCookieValue("FINDRED_HREN_USERID"), -1, true); CookieManage_HongRenHui.AddCookie("FINDTEL_HREN_STATE", CookieManage_HongRenHui.GetCookieValue("FINDTEL_HREN_STATE"), -1, true); CookieManage_HongRenHui.AddCookie("RED_HREN_Login_Type", CookieManage_HongRenHui.GetCookieValue("RED_HREN_Login_Type"), -1, true); CookieManage_HongRenHui.AddCookie("RED_HREN_Third_Login", CookieManage_HongRenHui.GetCookieValue("RED_HREN_Third_Login"), -1, true); CookieManage_HongRenHui.AddCookie("RED_HREN_Login_Urls", CookieManage_HongRenHui.GetCookieValue("RED_HREN_Login_Urls"), -1, true); CookieManage_HongRenHui.ClearCookie("RED_HREN_USERID"); CookieManage_HongRenHui.ClearCookie("FINDRED_HREN_USERID"); CookieManage_HongRenHui.ClearCookie("FINDTEL_HREN_STATE"); CookieManage_HongRenHui.ClearCookie("RED_HREN_Login_Type"); CookieManage_HongRenHui.ClearCookie("RED_HREN_Third_Login"); CookieManage_HongRenHui.ClearCookie("RED_HREN_Login_Urls"); HttpCookie aCookie; string cookieName; int limit = HttpContext.Current.Request.Cookies.Count; for (int i = 0; i < limit; i++) { cookieName = HttpContext.Current.Request.Cookies[i].Name; if (!cookieName.ToLower().Contains("redparty")) { aCookie = new HttpCookie(cookieName); aCookie.Expires = DateTime.Now.AddDays(-1); HttpContext.Current.Response.Cookies.Add(aCookie); } } } } catch (Exception ex) { } context.Put("logintype", logintype); context.Put("third_logintype", third_logintype); }
/// <summary> /// 执行微信登录,并注册信息操作 /// </summary> /// <param name="uname">用户名称或昵称</param> /// <param name="sex_val">性别值</param> /// <param name="user_head">用户头像地址</param> /// <param name="third_logintype">第三方登录类型,0:默认,1:QQ,2:Sina,3:微信</param> /// <param name="third_uopenid">第三方登录账号的唯一标识ID</param> /// <returns></returns> private string Is_Register_Wchat(string uname, string sex_val, string user_head, int third_logintype, string third_uopenid) { string result = "ok"; string tel = "123456"; string pwd = "123456"; int sex = 1; //登录途径,0:红人汇PC端,1:红人汇wap端,2:微吧PC端,3:微吧wap端 int login_type = Convert.ToInt32(CookieManage_HongRenHui.GetCookieValue("RED_HREN_Login_Type")); pwd = NewXzc.Common.DEncrypt.DESEncrypt.Encrypt(pwd);//给密码加密 if (sex_val == "1" || sex_val == "man" || sex_val == "男") { sex = 1; } else { sex = 2; } //int third_old_logintype = Convert.ToInt32(CookieManage_HongRenHui.GetCookieValue("RED_HREN_Third_Login")); if (user_bll.GetRecordCount(" third_openid='" + third_uopenid + "' ") <= 0) { if (third_uopenid != "")// && uname != "qzuser" 未授权(uname == "qzuser") { //string[] uhead = user_head.Split(';'); //if (third_logintype == 1) //{ // //大头像 // user_head = Save_Img_Http.Save_Img_WebRequest(uhead[0].ToString(), "jpg", 1); // ////小头像 // //Save_Img_Http.Save_Img_WebRequest(uhead[1].ToString(), "jpg", 3); //} //else //{ // //大头像 // user_head = Save_Img_Http.Save_Img_WebRequest(user_head, "jpg", 1); //} //大头像 int imgpre = 0; if (third_logintype < 3) { imgpre = 1; } user_head = Save_Img_Http.Save_Img_WebRequest(user_head, "jpg", imgpre); user_head = user_head.Replace("large_", "").Replace(ImgHelper.GetCofigShowUrl(), ""); int userguid = user_bll.GetMaxId(); string empty = ""; int cnt_0 = 0; int utype = login_type + 1;//用户注册途径,0:红人议会,1:红人汇,2:红人汇手机端,3:微吧,4:微吧手机端,5:红人爱品 user_model.USERID = userguid; user_model.USERNAME = uname; user_model.PWD = pwd; user_model.TEL = tel; user_model.TEL_STATE = cnt_0; user_model.USER_HEAD = user_head; user_model.SEX = sex; user_model.EMAIL = empty; user_model.USER_TYPE = utype; user_model.ISCOMPLETE = cnt_0; user_model.PROVINCE = empty; user_model.CITY = empty; user_model.AREA = empty; user_model.PEOPLE_IDENTITY = empty; user_model.OCCUPATION = empty; user_model.PERSONALITY = empty; user_model.INTRODUCE = empty; user_model.IDENTIFICATION_STATE = cnt_0; user_model.SAME_HOBBY_PEOPLE = empty; user_model.EXP = cnt_0; user_model.SCORE = cnt_0; user_model.REALM_NAME = empty; user_model.ADDTIME = DateTime.Now; user_model.IS_RED = cnt_0; user_model.STATE = cnt_0; user_model.REMARK = empty; user_model.Person_Desc = empty; user_model.Person_NickName = empty; user_model.Porder = cnt_0; user_model.UpdateTime = DateTime.Now; user_model.PLAT_VAL = empty; user_model.SPECIALTY_VAL = empty; user_model.IPURL = empty; if (!user_bll.Add(user_model)) { result = "no"; } else { try { DbHelperSQL.ExecuteSql("update THINK_SNS_DB.dbo.hrenh_think_user set third_utype=" + third_logintype + ",third_openid='" + third_uopenid + "' where userid=" + userguid + " "); } catch (Exception ex) { } CookieManage_HongRenHui.AddCookie("RED_HREN_USERID", userguid.ToString(), 7, false); CookieManage_HongRenHui.AddCookie("RED_HREN_Third_Login", third_logintype.ToString(), 7, false); } } else { result = "noautho"; } } else { #region 更新用户信息 ////大头像 //int imgpre = 0; //if (third_logintype < 3) //{ // imgpre = 1; //} //user_head = Save_Img_Http.Save_Img_WebRequest(user_head, "jpg", imgpre); //user_head = user_head.Replace("large_", "").Replace(ImgHelper.GetCofigShowUrl(), ""); //try //{ // DbHelperSQL.ExecuteSql("update THINK_SNS_DB.dbo.hrenh_think_user set username='******',USER_HEAD='" + user_head + "' where third_openid='" + third_uopenid + "' "); //} //catch (Exception ex) //{ //} #endregion CookieManage_HongRenHui.AddCookie("RED_HREN_USERID", DbHelperSQL.GetSingle("select top 1 userid from THINK_SNS_DB.dbo.hrenh_think_user where third_openid='" + third_uopenid + "' ").ToString(), 7, false); CookieManage_HongRenHui.AddCookie("RED_HREN_Third_Login", third_logintype.ToString(), 7, false); } if (result == "ok") { ////登录途径,0:红人汇PC端,1:红人汇wap端,2:微吧PC端,3:微吧wap端 //switch (login_type) //{ // case 0: // result = "http://www.ypindapei.com"; // break; // case 1: // result = "http://m.ypindapei.com"; // break; // case 2: // result = "http://weiba.ypindapei.com"; // break; // case 3: // result = "http://w.ypindapei.com"; // break; // default: // result = "http://www.ypindapei.com"; // break; //} //result = "/UserLogin/Login_Third.aspx"; string urls = CookieManage_HongRenHui.GetCookieValue("RED_HREN_Login_Urls"); if (urls != "" && urls != "0") { result = urls; } else { result = CheckIsLogin_HongRenHui.Get_User_CenterUrl_HongRenHui(); } //登录微吧 //Get_Http_Url_Content.GetPostContent("http://weiba.ypindapei.com/login?uid=" + NewXzc.Common.DEncrypt.DESEncrypt.Encrypt(CookieManage_HongRenHui.GetCookieValue("RED_HREN_USERID"))); } return(result); }
private void Is_Register(HttpContext context) { string result = "ok"; string tel = String_Manage.Return_Request_Str("tel"); string pwd = String_Manage.Return_Request_Str("upwd"); string uname = String_Manage.Return_Request_Str("uname"); var istel = ValidatePhone_Function(context, tel); if (istel != "ok") { result = istel; } else { if (pwd == "") { result = "nopwd"; } else if (uname == "") { result = "nouser"; } else { pwd = NewXzc.Common.DEncrypt.DESEncrypt.Encrypt(pwd);//给密码加密 int userguid = user_bll.GetMaxId(); //user_model.USERID = user_bll.GetMaxId(); //user_model.TEL = tel; //user_model.TEL_STATE = 1; //user_model.USER_HEAD = "default.jpg"; //user_model.PWD = pwd; //user_model.NICKNAME = uname; //user_model.IP = RequestHelper.GetIP(); //user_model.ADDTIME = DateTime.Now; //user_model.REMARK = ""; string empty = ""; int cnt_0 = 0; int cnt_1 = 1; int utype = 1; user_model.USERID = userguid; user_model.USERNAME = uname; user_model.PWD = pwd; user_model.TEL = tel; user_model.TEL_STATE = cnt_1; user_model.USER_HEAD = "default.jpg"; user_model.SEX = cnt_1; user_model.EMAIL = empty; user_model.USER_TYPE = utype; user_model.ISCOMPLETE = cnt_0; user_model.PROVINCE = empty; user_model.CITY = empty; user_model.AREA = empty; user_model.PEOPLE_IDENTITY = empty; user_model.OCCUPATION = empty; user_model.PERSONALITY = empty; user_model.INTRODUCE = empty; user_model.IDENTIFICATION_STATE = cnt_0; user_model.SAME_HOBBY_PEOPLE = empty; user_model.EXP = cnt_0; user_model.SCORE = cnt_0; user_model.REALM_NAME = empty; user_model.ADDTIME = DateTime.Now; user_model.IS_RED = cnt_0; user_model.STATE = cnt_0; user_model.REMARK = empty; user_model.Person_Desc = empty; user_model.Person_NickName = empty; user_model.Porder = cnt_0; user_model.UpdateTime = DateTime.Now; user_model.PLAT_VAL = empty; user_model.SPECIALTY_VAL = empty; user_model.IPURL = empty; if (user_bll.GetRecordCount(" USERNAME='******' and userid<>" + userguid + " ") <= 0) { if (!user_bll.Add(user_model)) { result = "no"; } else { CookieManage_HongRenHui.AddCookie("RED_HREN_USERID", userguid.ToString(), 1, false); } } else { result = "repname"; } } } context.Response.Write(result); }
private void VerifyCodeIsExists(HttpContext context) { int uid = CheckIsLogin_HongRenHui.GetUserID("FINDRED_HREN_USERID"); string phone = ""; user_model = user_bll.GetModel(uid); if (user_model != null) { phone = user_model.TEL; } if (phone != "") { try { string verifycode = context.Request["Vc"]; string phone2 = "", verifycode2 = ""; string[] items = null; if (HttpContext.Current.Session["PhoneVerifyCode"] != null) { string PhoneVerifyCode = ""; PhoneVerifyCode = HttpContext.Current.Session["PhoneVerifyCode"].ToString(); if (PhoneVerifyCode.IndexOf(',') != -1)//有多个手机号和验证码,因为短信有可能延迟用户就会收到多个验证码,应该保证每个验证码是正确的。 { items = PhoneVerifyCode.Split(','); } else { items = new string[1]; items[0] = PhoneVerifyCode; } } bool isOk = false; for (int i = 0; i < items.Length; i++) { if (!string.IsNullOrEmpty(items[i])) { phone2 = items[i].Split('-')[1]; verifycode2 = items[i].Split('-')[0]; if (phone == phone2 && verifycode == verifycode2) { isOk = true; break; } } } if (isOk) { CookieManage_HongRenHui.AddCookie("FINDTEL_HREN_STATE", "1", 1, false); context.Response.Write("1"); } else { context.Response.Write("0"); } } catch (Exception ex) { context.Response.Write("0"); } } else { context.Response.Write("nologin"); } context.Response.End(); }
private void Is_Login(HttpContext context) { string result = "ok"; string tel = String_Manage.Return_Request_Str("tel"); string pwd = String_Manage.Return_Request_Str("upwd"); pwd = NewXzc.Common.DEncrypt.DESEncrypt.Encrypt(pwd);//给密码加密 int remmber = String_Manage.Return_Request_Int("remmber", 0); var istel = ValidatePhone_Function(context, tel); if (istel != "ok") { result = istel; } else { //前台生成的验证码,用于点击发送验证码前验证用 string send_code_yzm = String_Manage.Return_Request_Str("send_code_yzm"); if (send_code_yzm != "") { try { if (HttpContext.Current.Session["code"] != null) { if (!string.IsNullOrEmpty(HttpContext.Current.Session["code"].ToString())) { string str_yzm = HttpContext.Current.Session["code"].ToString(); if (send_code_yzm != str_yzm) { result = "error_yzm"; } } } } catch (Exception ex) { } } if (result == "ok") { string sql = "select top 1 userid from THINK_SNS_DB.dbo.HRENH_THINK_USER where tel=@tel and pwd=@pwd order by userid asc"; SqlParameter[] para = { new SqlParameter("@tel", SqlDbType.NVarChar, 50), new SqlParameter("@pwd", SqlDbType.NVarChar, 50) }; para[0].Value = tel; para[1].Value = pwd; int t = 0; try { t = Convert.ToInt32(DbHelperSQL.GetSingle(sql, para).ToString()); } catch (Exception ex) { } if (t <= 0) { result = "no"; } else { result = CheckIsLogin_HongRenHui.Get_User_CenterUrl_HongRenHui(); if (remmber == 0) { CookieManage_HongRenHui.AddCookie("RED_HREN_USERID", t.ToString(), 1, false); } else { CookieManage_HongRenHui.AddCookie("RED_HREN_USERID", t.ToString(), 7, false); } } } } context.Response.Write(result); }