protected void Page_Load(object sender, EventArgs e) { string platform = Request.Params["platform"]; if (string.IsNullOrEmpty(platform)) { Response.Write("local ret = {code = -1}; return ret;"); return; } string table = ConfigurationManager.AppSettings["acc_" + platform]; if (string.IsNullOrEmpty(table)) { Response.Write("local ret = {code = -15}; return ret;"); return; } string acc = BuildAccount.getAutoAccount(table); if (string.IsNullOrEmpty(acc)) { Response.Write("local ret = {code = -12}; return ret;"); return; } string encrypt = Request.Params["encrypt"]; bool pwd_encrypt = false; if (!string.IsNullOrEmpty(encrypt) && encrypt == "true") { pwd_encrypt = true; } string pwd = null; string out_pwd = null; string save_pwd = null; if (pwd_encrypt) { pwd = BuildAccount.getAutoPassword(6); out_pwd = AESHelper.AESEncrypt(pwd, AES_KEY); save_pwd = AESHelper.MD5Encrypt(pwd); } else { out_pwd = BuildAccount.getAutoPassword(20); pwd = string.Format("{0}{1}{2}{3}{4}{5}", out_pwd[8], out_pwd[16], out_pwd[4], out_pwd[11], out_pwd[2], out_pwd[9]);//password save_pwd = AESHelper.MD5Encrypt(pwd); } string deviceID = Request.Params["deviceID"]; Random rd = new Random(); int randkey = rd.Next(); Dictionary <string, object> updata = new Dictionary <string, object>(); updata["acc"] = acc; updata["pwd"] = save_pwd; DateTime now = DateTime.Now; updata["randkey"] = randkey; updata["lasttime"] = now.Ticks; updata["regedittime"] = now; updata["regeditip"] = Request.ServerVariables.Get("Remote_Addr").ToString(); updata["updatepwd"] = false; //updata["platform"] = Platform; string strerr = MongodbAccount.Instance.ExecuteStoreBykey(table, "acc", acc, updata); if (strerr != "") { Response.Write("local ret = {code = -11}; return ret;"); } else { string channelID = Request.Params["channelID"]; Dictionary <string, object> savelog = new Dictionary <string, object>(); savelog["acc"] = acc; savelog["acc_real"] = acc; if (!string.IsNullOrEmpty(deviceID)) { savelog["acc_dev"] = deviceID; } savelog["ip"] = Request.ServerVariables.Get("Remote_Addr").ToString(); savelog["time"] = now; savelog["channel"] = channelID; MongodbAccount.Instance.ExecuteInsert("RegisterLog", savelog); //渠道每日注册 if (string.IsNullOrEmpty(channelID) == false) { MongodbAccount.Instance.ExecuteIncBykey("day_regedit", "date", DateTime.Now.Date, channelID, 0); } string ret = string.Format("local ret = {{code = 0, acc=\"{0}\", pwd=\"{1}\"}}; return ret;", acc, out_pwd); Response.Write(ret); } //Response.Write("local ret = {code = 0, acc=\"fish000001\", pwd=\"123456\"};"); }
protected void Page_Load(object sender, EventArgs e) { string phoneNum = Request.QueryString["phonenum"]; if (string.IsNullOrEmpty(phoneNum)) { Response.Write(Helper.buildLuaReturn(-2, "err_not_phone"));//号码错误 return; } string phoneCode = Request.QueryString["phonecode"]; if (string.IsNullOrEmpty(phoneCode)) { Response.Write(Helper.buildLuaReturn(-2, "err_not_phone"));//号码错误 return; } phoneNum = Encoding.Default.GetString(Convert.FromBase64String(phoneNum)); phoneNum = AESHelper.AESDecrypt(phoneNum, AES_KEY); //aes解密 phoneCode = Encoding.Default.GetString(Convert.FromBase64String(phoneCode)); phoneCode = AESHelper.AESDecrypt(phoneCode, AES_KEY); //aes解密 List <IMongoQuery> lmq = new List <IMongoQuery>(); lmq.Add(Query.EQ("phoneNum", phoneNum)); lmq.Add(Query.EQ("phoneCode", phoneCode)); Dictionary <string, object> data = MongodbAccount.Instance.ExecuteGetByQuery("BaiduPhoneCode", Query.And(lmq), new string[] { "lastSendTime" }); if (data == null) { Response.Write(Helper.buildLuaReturn(-2, "err_not_phone"));//号码错误 return; } string password = BuildAccount.getAutoPassword(6); string passwordMD5 = AESHelper.MD5Encrypt(password); updateAccountInfos(phoneNum, passwordMD5); //获取帐号信息 List <AccountInfo> accounts = getAccountInfos(phoneNum); //没有帐号 if (accounts.Count == 0) { Response.Write(Helper.buildLuaReturn(-2, "err_not_phone"));//号码错误 return; } else { StringBuilder sb = new StringBuilder(); sb.Append("local ret = {{}};"); sb.Append("ret.code = 0;"); sb.Append("ret.msg = \"\";"); sb.Append("ret.data = {{}};"); for (int i = 0; i < accounts.Count; i++) { string pwd = AESHelper.AESEncrypt(password, AES_KEY); sb.AppendFormat("ret.data[{0}] = {{acc=\"{1}\",pwd=\"{2}\"}};", i + 1, accounts[i].account, pwd); } sb.Append("return ret;"); Response.Write(sb.ToString()); } }