public void ProcessRequest(HttpContext context) { string callback = ""; try { string cacheKey = WebBase.GetQueryStringString("cacheKey", ""); string passKey = WebBase.GetQueryStringString("passKey", ""); //键值是否有效 if (string.IsNullOrEmpty(cacheKey)) { callback = ("CacheKey is not null!"); } //对传递的参数进行有效性检查 if (passKey != viviLib.Security.Cryptography.MD5(cacheKey + viviapi.SysConfig.MemCachedConfig.AuthCode)) { callback = ("AuthCode is not valid!"); } if (string.IsNullOrEmpty(callback)) { WebCache.LoadCacheStrategy(new DefaultCacheStrategy()); WebCache.GetCacheService().RemoveObject(cacheKey); WebCache.LoadDefaultCacheStrategy(); } callback = "OK"; } catch (Exception) { callback = "Error"; } context.Response.ContentType = "text/plain"; context.Response.Write(callback); }
public override void OnLoad(HttpContext context) { string msg = ""; try { #region string phone = GetValue("phone"); if (!string.IsNullOrEmpty(phone)) { if (phone == CurrentUser.Tel) { msg = "不能为原手机号码一样"; } else if (Validate.IsMobileNum(phone)) { #region 设置短信发送信息 CCPRestSDK.CCPRestSDK api = new CCPRestSDK.CCPRestSDK(); //ip格式如下,不带https:// //app.cloopen.com:8883 bool isInit = api.init("app.cloopen.com", "8883"); api.setAccount("8a48b5515018a0f4015045e342b14990", "07c2d4f927a1443fb4ffffe158ee39b8"); // api.setAppId("aaf98f8954939ed50154bdd0afb22d09"); #endregion bool isupdate = (CurrentUser.IsPhonePass == 1); string cacheKey = string.Format(Constant.PhoneVerificationCacheKey, phone); string validcode = (string)WebCache.GetCacheService().RetrieveObject(cacheKey); if (validcode == null) { validcode = new Random().Next(10000, 99999).ToString(CultureInfo.InvariantCulture); WebCache.GetCacheService().AddObject(cacheKey, validcode); } string smscontext = ""; //string.Format("您的验证码是:{0}[{1}]", validcode, viviapi.BLL.WebInfoFactory.CurrentWebInfo.Name); if (isupdate) { api.setAppId("aaf98f8954939ed50154bdd0afb22d09"); } // smscontext = SMSTempSettings.SMS_Temp_Modify; else { api.setAppId("aaf98f8954939ed50154bdd0afb22d09"); //smscontext = SMSTempSettings.SMS_Temp_Authenticate; } //if (!string.IsNullOrEmpty(smscontext)) //{ // smscontext = smscontext.Replace("{@username}", CurrentUser.full_name); // smscontext = smscontext.Replace("{@sitename}", // viviapi.BLL.WebInfoFactory.CurrentWebInfo.Name); // smscontext = smscontext.Replace("{@authcode}", validcode); //} if (isInit) { // Dictionary<string, object> retData = api.SendTemplateSMS(短信接收号码, 短信模板id, 内容数据); string[] data = { "铭云支付商户-大宝", "100" }; // string[] data = { CurrentUser.full_name, validcode }; Dictionary <string, object> retData = api.SendTemplateSMS(phone, "87105", data); msg = classHelp.getDictionaryData(retData); } else { msg = "初始化失败"; } //string result = SMS.SendSmsWithCheck(phone, smscontext, ""); //if (string.IsNullOrEmpty(result)) //{ // msg = "true"; //} //else //{ // msg = result; //} } else { msg = "请输入正确的手机号码123"; } } else { msg = "请输入手机号码"; } #endregion } catch (Exception ex) { ExceptionHandler.HandleException(ex); msg = "error"; } context.Response.ContentType = "text/plain"; context.Response.Write(msg); }
public void OnLoad(HttpContext context) { string msg = ""; try { #region string phone = GetValue("phone"); if (!string.IsNullOrEmpty(phone)) { //if (phone == CurrentUser.Tel) //{ // msg = "不能为原手机号码一样"; //} if (Validate.IsMobileNum(phone)) { //bool isupdate = (CurrentUser.IsPhonePass == 1); string cacheKey = string.Format(Constant.PhoneVerificationCacheKey, phone); string validcode = (string)WebCache.GetCacheService().RetrieveObject(cacheKey); if (validcode == null) { validcode = new Random().Next(10000, 99999).ToString(CultureInfo.InvariantCulture); WebCache.GetCacheService().AddObject(cacheKey, validcode); } string smscontext = ""; //string.Format("您的验证码是:{0}[{1}]", validcode, viviapi.BLL.WebInfoFactory.CurrentWebInfo.Name); //if (isupdate) // smscontext = SMSTempSettings.SMS_Temp_Modify; //else //{ smscontext = SMSTempSettings.SMS_Temp_Authenticate; //} if (!string.IsNullOrEmpty(smscontext)) { //smscontext = smscontext.Replace("{@username}", CurrentUser.full_name); smscontext = smscontext.Replace("{@sitename}", viviapi.BLL.WebInfoFactory.CurrentWebInfo.Name); smscontext = smscontext.Replace("{@authcode}", validcode); } string result = SMS.SendSmsWithCheck(phone, smscontext, ""); if (string.IsNullOrEmpty(result)) { msg = "true"; } else { msg = result; } } else { msg = "请输入正确的手机号码"; } } else { msg = "请输入手机号码"; } #endregion } catch (Exception ex) { ExceptionHandler.HandleException(ex); msg = "error"; } context.Response.ContentType = "text/plain"; context.Response.Write(msg); }
public override void OnLoad(HttpContext context) { string msg = ""; try { #region string phone = GetValue("phone"); string ValidateCode = GetValue("ValidateCode"); if (!string.IsNullOrEmpty(phone)) { if (string.IsNullOrEmpty(ValidateCode)) { msg = "验证码为空,请输入验证码"; } else { //验证验证码 if (context.Session["_ValidateCode"] == null) { msg = "验证码过期"; } else { string sessionCode = context.Session["_ValidateCode"].ToString(); if (sessionCode.ToLower() != ValidateCode.ToLower()) { msg = "验证码错误, 请重新输入!"; } else { if (phone == CurrentUser.Tel) { msg = "不能为原手机号码一样"; } else if (Validate.IsMobileNum(phone)) { #region 设置短信发送信息 CCPRestSDK.CCPRestSDK api = new CCPRestSDK.CCPRestSDK(); //ip格式如下,不带https:// //app.cloopen.com:8883 bool isInit = api.init("app.cloopen.com", "8883"); api.setAccount("8aaf07085adadc12015adb64bea70074", "547a3c1801b04b6ab2ebedc5d7ed1694"); api.setAppId("8aaf07085adadc12015adb64c05a007b"); // api.setAppId("aaf98f8954939ed50154bdd0afb22d09"); #endregion bool isupdate = (CurrentUser.IsPhonePass == 1); string cacheKey = string.Format(Constant.PhoneVerificationCacheKey, phone); string validcode = (string)WebCache.GetCacheService().RetrieveObject(cacheKey); if (validcode == null) { validcode = new Random().Next(10000, 99999).ToString(CultureInfo.InvariantCulture); WebCache.GetCacheService().AddObject(cacheKey, validcode); } if (isInit) { // Dictionary<string, object> retData = api.SendTemplateSMS(短信接收号码, 短信模板id, 内容数据); string[] data = { CurrentUser.full_name, validcode }; // string[] data = { CurrentUser.full_name, validcode }; Dictionary <string, object> retData = api.SendTemplateSMS(phone, "162881", data); if (retData["statusCode"].ToString() == "000000") { msg = "true"; } else { msg = classHelp.getDictionaryData(retData); } context.Session["_ValidateCode"] = null; } else { msg = "初始化失败"; } #region 原有的发送短信 //string result = SMS.SendSmsWithCheck(phone, smscontext, ""); //if (string.IsNullOrEmpty(result)) //{ // msg = "true"; //} //else //{ // msg = result; //} } //else if (Validate.IsMobileNum(phone)) //{ // bool isupdate = (CurrentUser.IsPhonePass == 1); // string cacheKey = string.Format(Constant.PhoneVerificationCacheKey, phone); // string validcode = (string)WebCache.GetCacheService().RetrieveObject(cacheKey); // if (validcode == null) // { // validcode = new Random().Next(10000, 99999).ToString(CultureInfo.InvariantCulture); // WebCache.GetCacheService().AddObject(cacheKey, validcode); // } // string smscontext = ""; //string.Format("您的验证码是:{0}[{1}]", validcode, viviapi.BLL.WebInfoFactory.CurrentWebInfo.Name); // if (isupdate) // smscontext = SMSTempSettings.SMS_Temp_Modify; // else // { // smscontext = SMSTempSettings.SMS_Temp_Authenticate; // } // if (!string.IsNullOrEmpty(smscontext)) // { // smscontext = smscontext.Replace("{@username}", CurrentUser.full_name); // smscontext = smscontext.Replace("{@sitename}", // viviapi.BLL.WebInfoFactory.CurrentWebInfo.Name); // smscontext = smscontext.Replace("{@authcode}", validcode); // } // string result = SMS.SendSmsWithCheck(phone, smscontext, ""); // if (string.IsNullOrEmpty(result)) // { // msg = "true"; // } // else // { // msg = result; // } //} #endregion else { msg = "请输入正确的手机号码"; } } } } } else { msg = "请输入手机号码"; } #endregion } catch (Exception ex) { ExceptionHandler.HandleException(ex); msg = "error"; } context.Response.ContentType = "text/plain"; context.Response.Write(msg); }
public void OnLoad(HttpContext context) { string msg = ""; try { #region string email = GetValue("phone"); int emailExists = viviapi.BLL.User.Factory.EmailExists(email); if (!string.IsNullOrEmpty(email)) { if (Validate.IsEmail(email)) { if (emailExists == 999) { string cacheKey = string.Format(Constant.EmailRegCodeCacheKey, email); string validcode = (string)WebCache.GetCacheService().RetrieveObject(cacheKey); if (validcode == null) { //validcode = "1000".ToString(CultureInfo.InvariantCulture); //WebCache.GetCacheService().AddObject(cacheKey, validcode); //context.Response.ContentType = "text/plain"; //context.Response.Write("true"); validcode = new Random().Next(10000, 99999).ToString(CultureInfo.InvariantCulture); WebCache.GetCacheService().AddObject(cacheKey, validcode); } string smscontext = Helper.GetRegCodeTemp(); if (!string.IsNullOrEmpty(smscontext)) { smscontext = smscontext.Replace("{#regcode#}", validcode); smscontext = smscontext.Replace("{#sitename#}", viviapi.BLL.WebInfoFactory.CurrentWebInfo.Name); smscontext = smscontext.Replace("{#sitename#}", viviapi.BLL.WebInfoFactory.CurrentWebInfo.Domain); } var emailcom = new EmailHelper(email , email + "邮箱验证" , smscontext , true , System.Text.Encoding.Default); bool result = emailcom.Send(); if (result) { msg = "true"; } else { msg = "邮件发送失败"; } } else if (emailExists == 1) { msg = "该邮箱正在审核"; } else if (emailExists == 2) { msg = "该邮箱已注册"; } else if (emailExists == 3) { msg = "该邮箱已被锁定"; } else if (emailExists == 4) { msg = "您的邮箱审核失败"; } } else { msg = "请输入正确的手机号码"; } } else { msg = "请输入手机号码"; } #endregion } catch (Exception ex) { ExceptionHandler.HandleException(ex); msg = "error"; } context.Response.ContentType = "text/plain"; context.Response.Write(msg); }