public IActionResult func_reg(RegModel regModel) { string acct = regModel.email; string pass = regModel.pass ?? string.Empty; string encrypt = regModel.encrypt ?? string.Empty; bool passisencrypt = regModel.encrypt == "True" || regModel.encrypt == "true"; string tname = regModel.tname ?? string.Empty; string mobile = regModel.mobile ?? string.Empty; string idcard = regModel.idcard ?? string.Empty; string gatesrc = regModel.gatesrc ?? "urs"; string pstype = regModel.pstype ?? "game"; int qq = regModel.qq; string ipstr = regModel.ip ?? string.Empty; string regip = ipstr; bool hasip = !string.IsNullOrWhiteSpace(ipstr) && ipstr.Length > 7; int ip = ip2long(ipstr); string ipkey = string.Format("check-reg-ip-{0}", ip); object obj = UrsHelper.Cache_GetObj(ipkey); List <DateTime> li_ipreglist = new List <DateTime>(); if (obj != null && obj is List <DateTime> ) { li_ipreglist = (List <DateTime>)obj; int regcount = 0; for (int i = li_ipreglist.Count - 1; i >= 0; i--) { DateTime d = li_ipreglist[i]; if (Math.Abs((DateTime.Now - d).TotalSeconds) > 900) { li_ipreglist.RemoveAt(i); } else { regcount++; } } if (regcount >= 101)//放得较宽,以防如3G网之类的可能有问题 { this.FuncResult(new APIReturn(10320, "注册频繁")); } } string vcode = regModel.vcode; if (regModel.ismodenopass) { pass = "******"; passisencrypt = true; } string passmd5 = passisencrypt ? pass : UrsHelper.MD5(pass); if (passmd5 == "0ab7dea79b1de3d0816f8b5cbbb36367") { //Operator.CHT_ExtData["ismodenopass"] = true; regModel.ismodenopass = true; } WebParams webParans = new WebParams(this.Request); var dicValues = webParans.Where(e => e.Key.StartsWith("extarg_")).ToDictionary(e => e.Key, e => e.Value); Hashtable cht_args = new Hashtable(dicValues); if (qq <= 0) { qq = 0; } string friendname = UrsHelper.Lib_Friend_GetName(acct); if (friendname.Length > 0) { this.FuncResult(new APIReturn(10350, string.Format("{0}帐号不能在这里进行注册操作", friendname))); } string[] acctspt = acct.Split('@'); string domain = acctspt[1].ToLower(); if (domain.EndsWith("2980.com") && domain != "2980.com" || domain == "2925.com" || acct.ToLower().IndexOf("@henhaoji.com") != -1 || acct.ToLower().IndexOf("@duoyi.com") != -1) { this.FuncResult(new APIReturn(10355, "该类邮箱不支持注册,请选用其他邮箱")); } if (friendname != string.Empty) { this.FuncResult(new APIReturn(10326, string.Format("{0}帐号无需注册,可直接登录", friendname))); } if (!isemail(acct)) { this.FuncResult(new APIReturn(10302, "帐号格式错误")); } if (!isvpass(pass, passisencrypt)) { this.FuncResult(new APIReturn(10305, "密码格式错误")); } if (!string.IsNullOrWhiteSpace(idcard) && idcard.Length > 0 && !isidcard(idcard)) { this.FuncResult(new APIReturn(10711, "身份证格式错误")); } if (!string.IsNullOrWhiteSpace(tname) && tname.Length > 0 && !isvname(tname)) { this.FuncResult(new APIReturn(10720, "姓名格式错误")); } if (!string.IsNullOrWhiteSpace(mobile) && mobile.Length >= 1 && !IsMobile(mobile)) { this.FuncResult(new APIReturn(10701, "手机号格式错误")); } if (regModel.qq.ToString().Length >= 5 && (qq <= 0)) { this.FuncResult(new APIReturn(10730, "QQ号格式错误")); } if (passisencrypt) { if (pass.Length != 32) { this.FuncResult(new APIReturn(10000, $"参数错误pass={pass}")); } pass = UrsHelper.MD5(pass.Substring(7, 16)).Substring(3, 16); } return(func_exec_reg(regModel, false, ip, acct, pass, passisencrypt, tname, idcard, mobile, qq, gatesrc, pstype, cht_args.ToJson(), regip)); }
public IActionResult func_getPwdByMobile(string account, string mobile, string newpass, string country) { if (string.IsNullOrWhiteSpace(mobile) || mobile.Length < 5) { return(this.FuncResult(new APIReturn(10205, "不合法的手机号长度"))); } int number = (Math.Abs(mobile.GetHashCode()) > 20000000 ? Math.Abs(mobile.GetHashCode()) : 200000000 + Math.Abs(mobile.GetHashCode())); string ipstr = this.IP; int ip = 0; if (!string.IsNullOrEmpty(ipstr)) { ip = this.ip2long(ipstr); } if (string.IsNullOrWhiteSpace(account) || !isemail(account)) { return(this.FuncResult(new APIReturn(10302, "不合法的邮箱帐号格式"))); } if (string.IsNullOrWhiteSpace(newpass) || newpass.Length != 32) { return(this.FuncResult(new APIReturn(10305, "不合法的密码长度"))); } string[] accountext = account.Split("@".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); string maildomain = accountext[1]; if (maildomain.ToLower() == "2980.com") { return(this.FuncResult(new APIReturn(10350, "2980帐号请到2980邮箱重设密码"))); } newpass = UrsHelper.mymd5(newpass); List <object> listobj = new List <object>(); listobj.AddRange(new object[] { "ip", ip, "number", account, "mobile", mobile, "newpass", newpass, "country", country ?? string.Empty }); DCResult dcr = DCInvoker.HttpInvoke(DCProdTypes.URS, DCMethodTypes.W, "acct_setpass_mobile", listobj.ToArray()); DicDCValue retMsg = dcr.GetDicDCValue(); if (retMsg.Code == 0 || retMsg.Code == 54) { Hashtable ht = new Hashtable(); ht.Add("email", account); //重置成功 return(this.FuncResult(new APIReturn(0, "", ht))); } else if (retMsg.Code == 68) { return(this.FuncResult(new APIReturn(10351, "手机号与通行证已关联但未生效"))); } else if (retMsg.Code == 69) { return(this.FuncResult(new APIReturn(10351, "手机号与帐号不匹配"))); } else if (retMsg.Code == 151) { return(this.FuncResult(new APIReturn(10350, "2980帐号请到2980邮箱重设密码"))); } else { return(this.FuncResult(new APIReturn(19804, $"重设密码失败({retMsg.Code}"))); } }
private IActionResult func_exec_reg(RegModel regModel, bool isfriend, int ip, string acct, string pass, bool passismyencrypt, string tname, string idcard, string mobile, int qq, string gatesrc, string pstype, string extinfo, string regip) { //配置控制,是否需要检查注册时的验证码,一段时间之后应去掉此项判断,否则非公司正常产品的gate就绕过此内容 if (DC2Conf.RegvcodeProducts.Contains(gatesrc) && DC2Conf.RegvcodeEnable) { //2016-1-20 对于163邮箱,没有传验证码的必须传验证码 if (acct.ToLower().EndsWith("163.com")) { if (string.IsNullOrEmpty(regModel.vcode) && string.IsNullOrEmpty(regModel.vregval)) { return(createVCode(regip)); } else { var retValue = decRegVal(regModel.vregval, regModel.vcode, regip); if (retValue != null) { return(retValue); } } } else { var retValue = checkRegRates(regModel.vcode, regModel.vregval, regip); if (retValue != null) { return(retValue); } } } UrsacctInfo userInfo = Ursacct.GetItem(acct); if (userInfo != null) { Hashtable htbData = new Hashtable(); htbData.Add("number", userInfo.AcctNumber.Value); return(this.FuncResult(new APIReturn(10303, "帐号已存在", htbData))); } DCClass dcc = new DCClass(); DicDCValue dcValue = dcc.Acct_Register(regModel, isfriend, ip, acct, pass, passismyencrypt, tname, idcard, mobile, qq, gatesrc, pstype); if (dcValue.Code == 0) { int number = dcValue["number"].ToInt(); Ursuser.CreateUser(number, acct, qq, mobile, idcard, extinfo); Hashtable cht_rcdata = new Hashtable(); cht_rcdata["number"] = number; //添加缓存 if (ip != 0 && ip != -1) { string ipkey = string.Format("check-reg-ip-{0}", ip); object obj = UrsHelper.Cache_GetObj(ipkey); List <DateTime> li_ipreglist = new List <DateTime>(); if (obj != null && obj is List <DateTime> ) { li_ipreglist = (List <DateTime>)obj; } li_ipreglist.Add(DateTime.Now); UrsHelper.Cache_SetObj(ipkey, li_ipreglist); } addRegSuc(regip); cht_rcdata["email"] = regModel.email; cht_rcdata["mailhost"] = "http://mail" + regModel.email.Substring(regModel.email.IndexOf('@'), regModel.email.Length - regModel.email.IndexOf('@')); return(this.FuncResult(new APIReturn(0, "注册成功", cht_rcdata))); } else if (dcValue.Code == 65) { return(this.FuncResult(new APIReturn(10303, "帐号已存在"))); } else { return(this.FuncResult(new APIReturn(10306, $"注册失败({dcValue.Code})"))); } }
public string getGuid() { return(UrsHelper.MD5(deviceinfo)); }
private string encRegVal(string ip, string code) { string org = string.Format("{0},{1},{2}", ip, code, DateTime.Now.Ticks); return(Convert.ToBase64String(UrsHelper.Encrypt(org, deskey, key_64, iv_64))); }