public ActionResult LogIn() { if (Session.CurrentUser() != null) { return(RedirectToAction("Index", "Home")); } else { var model = new LoginModel(); HttpCookie cookie = HttpContext.Request.Cookies[Constant.BCS_LOGIN_INFO]; if (cookie != null && cookie.Expires >= DateTime.Now) { model.UserName = string.IsNullOrEmpty(cookie.Values[Constant.BCS_LOGIN_USERNAME]) ? string.Empty : SecurityMethod.Base64Decode(cookie.Values[Constant.BCS_LOGIN_USERNAME]); model.Password = string.IsNullOrEmpty(cookie.Values[Constant.BCS_LOGIN_PASSWORD]) ? string.Empty : SecurityMethod.Base64Decode(cookie.Values[Constant.BCS_LOGIN_PASSWORD]); // LogIn SecurityService.Login(model.UserName.Trim(), model.Password.Trim(), model.RememberMe); } return(View(model)); } }
/// <summary> /// 手机码验证错误次数加1 /// </summary> /// <param name="business"></param> /// <param name="uniqueKey"></param> public void IncreaseErrorCount(SMSBusiness business, string uniqueKey) { SecurityMethod securityMethod = SecurityMethod.CellphoneCode; var errorKey = $"{Platform}:{securityMethod.ToString()}:{business.ToString()}:ErrorCounts:{uniqueKey}"; var errorCountsStr = RedisHelper.StringGet(Constant.REDIS_SMS_DBINDEX, errorKey); int.TryParse(errorCountsStr, out int errorCount); ++errorCount; int spInt = Constant.VIRIFY_FAILD_LOCK_TIME; if (business == SMSBusiness.Register || business == SMSBusiness.UpdateCellphoneNew) { spInt = Constant.REGISTER_FAILD_LOCK_TIME; } RedisHelper.StringSet(Constant.REDIS_SMS_DBINDEX, errorKey, errorCount.ToString(), TimeSpan.FromMinutes(spInt)); if (errorCount >= Constant.VIRIFY_FAILD_TIMES_LIMIT) { var minCount = GetErrorLockTime(Constant.REDIS_SMS_DBINDEX, errorKey); ThrowMoreTimesException(business, minCount); } else { ThrowVerifyFaildException(securityMethod, Constant.VIRIFY_FAILD_TIMES_LIMIT - errorCount); } }
/// <summary> /// 错误次数加1(除手机码验证) /// </summary> /// <param name="securityMethod"></param> /// <param name="accountId"></param> /// <param name="childrMethod">子操作类型,如安全验证包含多个方式的验证,此参数用于返回相应的错误代码</param> public void IncreaseErrorCount(SecurityMethod securityMethod, string accountId, SecurityMethod?childrMethod = null) { var errorKey = $"{Platform}:{securityMethod.ToString()}:ErrorCounts:{accountId}"; if (securityMethod == SecurityMethod.TempToken) { errorKey = $"{Platform}:{childrMethod}:{securityMethod.ToString()}:ErrorCounts:{accountId}"; } var errorCountsStr = RedisHelper.StringGet(errorKey); int.TryParse(errorCountsStr, out int errorCount); ++errorCount; int spInt = Constant.VIRIFY_FAILD_LOCK_TIME; RedisHelper.StringSet(errorKey, errorCount.ToString(), TimeSpan.FromMinutes(spInt)); if (errorCount >= Constant.VIRIFY_FAILD_TIMES_LIMIT) { var minCount = GetErrorLockTime(errorKey); ThrowMoreTimesException(securityMethod, minCount); } else { ThrowVerifyFaildException(securityMethod, Constant.VIRIFY_FAILD_TIMES_LIMIT - errorCount, childrMethod); } }
/// <summary> /// Writes security header /// </summary> /// <param name="stream">Ouput stream</param> /// <param name="method">Security method</param> /// <param name="macKey">Key</param> public static void WriteHeaderSecurity(MemoryStream stream, SecurityMethod method, byte[] macKey) { WriteShortInteger(stream, HEADER_SEC); switch (method) { case SecurityMethod.NETWPIN: WriteShortInteger(stream, SEC_NETWPIN); break; case SecurityMethod.USERPIN: WriteShortInteger(stream, SEC_USERPIN); break; case SecurityMethod.USERNETWPIN: WriteShortInteger(stream, SEC_USERNETWPIN); break; case SecurityMethod.USERPINMAC: WriteShortInteger(stream, SEC_USERPINMAC); break; } WriteShortInteger(stream, HEADER_MAC); string macKeyString = string.Empty; foreach (byte b in macKey) { macKeyString += b.ToString("X2"); } WriteTextString(stream, macKeyString); }
public static bool CheckAccount(string _email, string _password) { int userID = 0; SqlConnection dbConn = new SqlConnection(AppEnv.ConnectionString); SqlCommand dbCmd = new SqlCommand("Main_Members_CheckAccount", dbConn); dbCmd.CommandType = CommandType.StoredProcedure; dbCmd.Parameters.AddWithValue("@Email", _email); dbCmd.Parameters.AddWithValue("@Password", SecurityMethod.MD5Encrypt(_password)); try { dbConn.Open(); SqlDataReader dr = dbCmd.ExecuteReader(); if (dr.Read()) { userID = dr.GetInt32(0); } else { userID = 0; } } finally { dbConn.Close(); } return(userID > 0); }
/// <summary> /// 安全验证多次错误异常(除手机码验证) /// </summary> /// <param name="securityMethod"></param> /// <param name="minCount"></param> private void ThrowMoreTimesException(SecurityMethod securityMethod, int minCount) { switch (securityMethod) { case SecurityMethod.LoginGoogleAuthencator: case SecurityMethod.LoginBySMSGoogleAuthencator: case SecurityMethod.GoogleAuthencator: throw new CommonException(ReasonCode.GOOGLEAUTH_ERROR_TOO_MANY_TIMES, string.Format(GeneralResources.EMVerifyLimit5Times, minCount)); case SecurityMethod.Password: throw new CommonException(ReasonCode.LOGIN_ERROR_TOO_MANY_TIMES, string.Format(GeneralResources.EMPasswordTry5Times, minCount)); case SecurityMethod.OldPassword: throw new CommonException(ReasonCode.OLD_PASSWORD_TOO_MANY_TIMES, string.Format(GeneralResources.EMPasswordError5Times, minCount)); case SecurityMethod.Pin: throw new CommonException(ReasonCode.PIN_ERROR_5_TIMES, string.Format(GeneralResources.EMPINInputLimit, minCount)); case SecurityMethod.RegisterPhoneCode: throw new CommonException(ReasonCode.PHONECODE_VERIFYFAILED_TOOMANY_TEIMS, string.Format(GeneralResources.EMRegisterVerifyLimit5Times, minCount)); case SecurityMethod.SecurityValidate: throw new CommonException(ReasonCode.SECURITY_ERROR_TOO_MANY_TIMES, string.Format(GeneralResources.EMVerifyLimit5Times, minCount)); case SecurityMethod.TempToken: throw new CommonException(ReasonCode.SECURITY_ERROR_TOO_MANY_TIMES, string.Format(GeneralResources.EMVerifyLimit5Times, minCount)); } throw new CommonException(ReasonCode.SECURITY_ERROR_TOO_MANY_TIMES, string.Format(GeneralResources.EMVerifyLimit5Times, minCount)); }
protected void Page_Load(object sender, EventArgs e) { ILog logger = LogManager.GetLogger("DoGetDownloadURL"); try { string msisdn = Request.QueryString["Msisdn"]; string reqTime = Request.QueryString["reqTime"]; string shortCode = Request.QueryString["shortcode"]; string reqId = Request.QueryString["reqId"]; string username = Request.QueryString["username"]; string password = Request.QueryString["password"]; string gameId = Request.QueryString["GameID"]; logger.Debug(" "); logger.Debug(" "); logger.Debug("----- VMS API CALL DoGetDownloadURL ----- :" + "msisdn : " + msisdn + " |reqTime : " + reqTime + " |shortCode : " + shortCode + " |reqId : " + reqId + " |userName : "******" |password : "******" |GameId : " + gameId); logger.Debug(" "); logger.Debug(" "); if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password)) { var item = new VmsAppboxGamelinkLog(); item.GameId = ConvertUtility.ToInt32(gameId); item.Msisdn = msisdn; item.ReqTime = reqTime; item.ShortCode = shortCode; item.ReqId = reqId; item.UserName = username; item.Password = password; ApiController.ApiVmsAppboxGamelinkLog(item); string key = DateTime.Now.ToString("ddMMyyyy") + gameId; key = SecurityMethod.MD5Encrypt(key); string strValue = string.Format("gameid={0}|reqid={1}|msisdn={2}|key={3}|source={4}|type={5}", gameId, reqId, msisdn, key, "WAP", "2"); byte[] dataEncode = Encoding.UTF8.GetBytes(strValue); Base64Encoder myEncoder = new Base64Encoder(dataEncode); StringBuilder encodevaulue = new StringBuilder(); encodevaulue.Append(myEncoder.GetEncoded()); string url = "http://vmgame.vn/wap/dlgame.ashx?value=" + encodevaulue; logger.Debug("----- VMS API CALL DoGetDownloadURL URL RESPONSE ----- :" + url); Response.Write(url); } } catch (Exception ex) { logger.Debug(" "); logger.Debug(" "); logger.Debug("----- VMS API CALL DoGetDownloadURL ----- :" + ex); logger.Debug(" "); logger.Debug(" "); } }
public string GenegeToken(SecurityMethod securityMethod) { var token = RandomAlphaNumericGenerator.Generate(16); string tokenKey = $"{Platform}:{securityMethod.ToString()}:{SecurityMethod.TempToken.ToString()}:{token}"; RedisHelper.StringSet(tokenKey, token, TimeSpan.FromMinutes(Constant.TEMPTOKEN_EXPIRED_TIME)); return(token); }
/// <summary> /// 清除安全验证错误次数(除手机码验证) /// </summary> /// <param name="securityMethod"></param> /// <param name="accountId"></param> /// <param name="childrMethod"></param> public void DeleteErrorCount(SecurityMethod securityMethod, string accountId, SecurityMethod?childrMethod = null) { var errorKey = $"{Platform}:{securityMethod.ToString()}:ErrorCounts:{accountId}"; if (securityMethod == SecurityMethod.TempToken) { errorKey = $"{Platform}:{childrMethod}:{securityMethod.ToString()}:ErrorCounts:{accountId}"; } RedisHelper.KeyDelete(errorKey); }
/// <summary> /// Get user by userName /// </summary> /// <param name="userName"></param> /// <param name="password"></param> /// <returns></returns> public UserInfo GetUser(string userName, string password) { try { var ctx = SingletonIpl.GetInstance <SqlDataProvider>(); var user = ctx.GetUser(userName, SecurityMethod.MD5Encrypt(password)); return(user); } catch (Exception) { return(null); } }
/// <summary> /// Validation UserName & Password /// </summary> /// <param name="userName"></param> /// <param name="password"></param> /// <returns></returns> public bool IsAuthenticated(string userName, string password) { try { var ctx = SingletonIpl.GetInstance <SqlDataProvider>(); return(ctx.IsAuthenticated(userName, SecurityMethod.MD5Encrypt(password))); } catch (Exception) { return(false); } }
/// <summary> /// 手机码验证错误次数检查 /// </summary> /// <param name="business"></param> /// <param name="uniqueKey"></param> /// <returns></returns> public int CheckErrorCount(SMSBusiness business, string uniqueKey) { SecurityMethod securityMethod = SecurityMethod.CellphoneCode; var errorKey = $"{Platform}:{securityMethod.ToString()}:{business.ToString()}:ErrorCounts:{uniqueKey}"; var errorCountsStr = RedisHelper.StringGet(Constant.REDIS_SMS_DBINDEX, errorKey); int.TryParse(errorCountsStr, out int errorCount); if (errorCount >= Constant.VIRIFY_FAILD_TIMES_LIMIT) { var minCount = GetErrorLockTime(Constant.REDIS_SMS_DBINDEX, errorKey); ThrowMoreTimesException(business, minCount); } return(errorCount); }
protected void btLogin_Click(object sender, EventArgs e) { string returnUrl = Request.QueryString["returnUrl"]; if ((UserController.ValidateUser(txtUsername.Text.Trim(), SecurityMethod.MD5Encrypt(txtPassword.Text.Trim())) != null)) { AuthenticateUtility.LoginUser(txtUsername.Text.Trim(), true); AppEnv.SetLanguage("vi-VN"); Response.Redirect("/Authenticate.aspx"); } else { //Response.Write("NULL"); } }
public void VerifyToken(string key, string token, SecurityMethod securityMethod) { string tokenKey = $"{Platform}:{securityMethod.ToString()}:{SecurityMethod.TempToken.ToString()}:{key}"; var cacheToken = RedisHelper.StringGet(tokenKey); var errorCount = CheckErrorCount(SecurityMethod.TempToken, key, securityMethod); if (string.IsNullOrEmpty(cacheToken)) { IncreaseErrorCount(SecurityMethod.TempToken, key, securityMethod); } if (token != cacheToken) { IncreaseErrorCount(SecurityMethod.TempToken, key, securityMethod); } RedisHelper.KeyDelete(tokenKey); DeleteErrorCount(SecurityMethod.TempToken, key, securityMethod); }
protected void cmdUpdate_Click(object sender, EventArgs e) { if (SecurityMethod.MD5Encrypt(txtCurPwd.Text) != CurrentAdminInfo.User_Password) { lblUpdateStatus.Text = "<font color='red'>Mật khẩu cũ không đúng !</font>"; return; } CurrentAdminInfo.User_Password = SecurityMethod.MD5Encrypt(txtNewPwd.Text); try { UserDB.Update(CurrentAdminInfo); lblUpdateStatus.Text = MiscUtility.UPDATE_SUCCESS; } catch { lblUpdateStatus.Text = MiscUtility.UPDATE_ERROR; } }
/// <summary> /// 安全验证错误次数检查(除手机码验证) /// </summary> /// <param name="securityMethod"></param> /// <param name="accountId"></param> /// <param name="childrMethod"></param> /// <returns></returns> public int CheckErrorCount(SecurityMethod securityMethod, string accountId, SecurityMethod?childrMethod = null) { var errorKey = $"{Platform}:{securityMethod.ToString()}:ErrorCounts:{accountId}"; if (securityMethod == SecurityMethod.TempToken) { errorKey = $"{Platform}:{childrMethod}:{securityMethod.ToString()}:ErrorCounts:{accountId}"; } var errorCountsStr = RedisHelper.StringGet(errorKey); int.TryParse(errorCountsStr, out int errorCount); if (errorCount >= Constant.VIRIFY_FAILD_TIMES_LIMIT) { var minCount = GetErrorLockTime(errorKey); ThrowMoreTimesException(securityMethod, minCount); } return(errorCount); }
protected void cmdUpdate_Click(object sender, EventArgs e) { int userID = ConvertUtility.ToInt32(txtID.Text); UserInfo info = UserDB.GetInfo(userID); if (info == null) { return; } info.User_Email = txtEmail.Text.Trim(); info.User_FullName = txtFullName.Text; if (txtPassword.Text.Trim() != string.Empty) { info.User_Password = SecurityMethod.MD5Encrypt(txtPassword.Text.Trim()); } info.User_Gender = (dropGender.SelectedValue == "1") ? true : false; info.User_Address = txtAddress.Text; info.User_Birthday = txtBirthDay.Text; info.User_Phone = txtPhone.Text; info.User_SuperAdmin = chkIsSuperAdmin.Checked; try { UserDB.Update(info); foreach (ListItem item in lstGroups.Items) { if (item.Selected) { GroupMemberDB.AddUser(info.User_ID, Convert.ToInt32(item.Value)); } else { GroupMemberDB.RemoverUser(info.User_ID, Convert.ToInt32(item.Value)); } } lblUpdateStatus.Text = MiscUtility.UPDATE_SUCCESS; } catch { lblUpdateStatus.Text = MiscUtility.UPDATE_ERROR; } }
/// <summary> /// 验证失败异常 /// </summary> /// <param name="securityMethod"></param> /// <param name="timesLeft"></param> /// <param name="childrMethod"></param> private void ThrowVerifyFaildException(SecurityMethod securityMethod, int timesLeft, SecurityMethod?childrMethod = null) { switch (securityMethod) { case SecurityMethod.CellphoneCode: throw new CommonException(ReasonCode.WRONG_CODE_ENTERRED, string.Format(GeneralResources.EMSMSCodeError, timesLeft)); case SecurityMethod.LoginGoogleAuthencator: case SecurityMethod.LoginBySMSGoogleAuthencator: case SecurityMethod.GoogleAuthencator: throw new CommonException(ReasonCode.GOOGLEAUTH_VERIFY_FAIL, string.Format(GeneralResources.EMGoogleCodeError, timesLeft)); case SecurityMethod.Password: throw new CommonException(ReasonCode.WRONG_PASSWORD_ENTERRED, string.Format(GeneralResources.EMAccountPasswordError, timesLeft)); case SecurityMethod.OldPassword: throw new CommonException(ReasonCode.WRONG_OLD_PASSWORD_ENTERRED, string.Format(GeneralResources.EMPasswordError, timesLeft)); case SecurityMethod.Pin: throw new CommonException(ReasonCode.PIN_ERROR, string.Format(GeneralResources.EMPINInputError, timesLeft)); case SecurityMethod.RegisterPhoneCode: throw new CommonException(ReasonCode.WRONG_CODE_ENTERRED, string.Format(GeneralResources.EMSMSCodeError, timesLeft)); case SecurityMethod.SecurityValidate: if (childrMethod.HasValue) { if (childrMethod.Value == SecurityMethod.GoogleAuthencator) { throw new CommonException(ReasonCode.WRONG_SECURITYGOOGLECODE_ENTERRED, string.Format(GeneralResources.EMGoogleCodeError, timesLeft)); } else if (childrMethod.Value == SecurityMethod.CellphoneCode) { throw new CommonException(ReasonCode.WRONG_SECURITYPHONECODE_ENTERRED, string.Format(GeneralResources.EMSMSCodeError, timesLeft)); } } throw new CommonException(ReasonCode.FAIL_AUTHENTICATOR, string.Format(GeneralResources.SecurityValidateError, timesLeft)); case SecurityMethod.TempToken: throw new CommonException(ReasonCode.FAIL_AUTHENTICATOR, string.Format(GeneralResources.SecurityValidateError, timesLeft)); } throw new CommonException(ReasonCode.FAIL_AUTHENTICATOR, string.Format(GeneralResources.SecurityValidateError, timesLeft)); }
protected void btnUpdate_Click(object sender, EventArgs e) { if (txtPassword.Text.Trim() != string.Empty && txtPassword.Text.Trim() == txtPasswordConfirm.Text.Trim()) { try { UserController.ResetPassword(userId, SecurityMethod.MD5Encrypt(txtPassword.Text.Trim())); lblUpdateStatus.Text = MiscUtility.MSG_UPDATE_SUCCESS; } catch (Exception ex) { lblUpdateStatus.Text = ex.Message; } } else { lblUpdateStatus.Text = "Mật khẩu không đúng"; } }
public static bool Login(string username, string password, bool rememberAccount) { Logout(); if (Authenticate.IsAuthenticated(username, password)) { FormsAuthentication.Initialize(); var ticket = new FormsAuthenticationTicket(1, Constant.BCS_CURRENT_USER + username + Constant.BCS_MEMBER_SEPARATOR + password, DateTime.Now, DateTime.Now.AddMinutes(HttpContext.Current.Session.Timeout), rememberAccount, "", FormsAuthentication.FormsCookiePath); string encrypetedTicket = FormsAuthentication.Encrypt(ticket); if (!FormsAuthentication.CookiesSupported) { //If the authentication ticket is specified not to use cookie, set it in the URL FormsAuthentication.SetAuthCookie(encrypetedTicket, false); } else { var authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encrypetedTicket) { HttpOnly = true, Path = "/", Expires = ticket.Expiration, Shareable = true }; HttpContext.Current.Response.Cookies.Add(authCookie); } // Write cookie Login Infomation if (rememberAccount) { var cookie = new HttpCookie(Constant.BCS_LOGIN_INFO); cookie.Values.Add(Constant.BCS_LOGIN_USERNAME, SecurityMethod.Base64Encode(username)); cookie.Values.Add(Constant.BCS_LOGIN_PASSWORD, SecurityMethod.Base64Encode(password)); cookie.Expires = DateTime.Now.AddDays(30); HttpContext.Current.Response.Cookies.Add(cookie); } return(true); } return(false); }
protected void cmdAddNew_Click(object sender, EventArgs e) { UserInfo info = new UserInfo(); info.User_Email = txtEmail.Text.Trim(); info.User_FullName = txtFullName.Text; info.User_Password = SecurityMethod.MD5Encrypt(txtPassword.Text.Trim()); info.User_Gender = (dropGender.SelectedValue == "1") ? true : false; info.User_Address = txtAddress.Text; info.User_Birthday = txtBirthDay.Text; info.User_Phone = txtPhone.Text; info.User_SuperAdmin = chkIsSuperAdmin.Checked; try { txtID.Text = UserDB.Insert(info).ToString(); foreach (ListItem item in lstGroups.Items) { if (item.Selected) { GroupMemberDB.AddUser(Convert.ToInt32(txtID.Text), Convert.ToInt32(item.Value)); } else { GroupMemberDB.RemoverUser(Convert.ToInt32(txtID.Text), Convert.ToInt32(item.Value)); } } //Response.Write(FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text.Trim(), "md5")); //Response.Write("<br />"); //Response.Write(SecurityMethod.MD5Encrypt(txtPassword.Text.Trim())); lblUpdateStatus.Text = MiscUtility.UPDATE_SUCCESS; } catch { lblUpdateStatus.Text = MiscUtility.UPDATE_ERROR; } }
public void VerifyToken(string token, SecurityMethod securityMethod, bool needDeleteToken = true) { string tokenKey = $"{Platform}:{securityMethod.ToString()}:{SecurityMethod.TempToken.ToString()}:{token}"; var cacheToken = RedisHelper.StringGet(tokenKey); var errorCount = CheckErrorCount(SecurityMethod.TempToken, token); if (string.IsNullOrEmpty(cacheToken)) { IncreaseErrorCount(SecurityMethod.TempToken, token); ++errorCount; throw new CommonException(ReasonCode.FAIL_AUTHENTICATOR, string.Format(GeneralResources.SecurityValidateError, errorCount)); } if (token != cacheToken) { IncreaseErrorCount(SecurityMethod.TempToken, token); ++errorCount; throw new CommonException(ReasonCode.FAIL_AUTHENTICATOR, string.Format(GeneralResources.SecurityValidateError, errorCount)); } RedisHelper.KeyDelete(tokenKey); DeleteErrorCount(SecurityMethod.TempToken, token); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Session["msisdn"] == null) { int is3g = 0; string msisdn = MobileUtils.GetMSISDN(out is3g); if (!string.IsNullOrEmpty(msisdn) && MobileUtils.CheckOperator(msisdn, "vietnammobile")) { Session["telco"] = Constant.T_Vietnamobile; Session["msisdn"] = msisdn; } else { Session["msisdn"] = null; Session["telco"] = Constant.T_Undefined; } } string k = Request.QueryString["k"]; string key = DateTime.Now.ToString("yyyyMMdd"); string en = SecurityMethod.MD5Encrypt(key); if (en == k) { Session["ChargedOk"] = "OK"; DataTable dt = TintucController.GetRandomForSmile(); string link = "/Thugian/Download.aspx?id=" + dt.Rows[0]["Distribution_ID"] + "&lang=1&w=320"; Response.Redirect(link); } else { Response.Redirect(AppEnv.GetSetting("WapDefault")); } } }
public ActionResult Index() { if (Session.CurrentUser() != null) { return(RedirectToAction("Index", "Home")); } else { var model = new LoginModel(); HttpCookie cookie = Request.Cookies[Constant.BCS_LOGIN_INFO]; if (cookie != null) { model.UserName = string.IsNullOrEmpty(cookie.Values[Constant.BCS_LOGIN_USERNAME]) ? string.Empty : SecurityMethod.Base64Decode(cookie.Values[Constant.BCS_LOGIN_USERNAME]); model.Password = string.IsNullOrEmpty(cookie.Values[Constant.BCS_LOGIN_PASSWORD]) ? string.Empty : SecurityMethod.Base64Decode(cookie.Values[Constant.BCS_LOGIN_PASSWORD]); } return(View("Login", model)); } }
protected void Page_Load(object sender, EventArgs e) { lang = Request.QueryString["lang"]; if (string.IsNullOrEmpty(lang)) { Response.Redirect("/Game/GameHot.aspx?w=320&lang=1"); } Session["LastPage"] = Request.RawUrl; if (!IsPostBack) { width = ConvertUtility.ToInt32(Request.QueryString["w"]); if (width == 0) { width = (int)Constant.DefaultScreen.Standard; } ltrWidth.Text = "<meta content=\"width=" + width + "; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;\" name=\"viewport\" />"; // var advertisement = new Advertisement { Channel = "Home", Position = "HomeCenter", Param = 0, Lang = lang, Width = width.ToString() }; litAds.Text = advertisement.GetAds(); var advertisement1 = new Advertisement { Channel = "Home", Position = "UnderLinks", Param = 0, Lang = lang, Width = width.ToString() }; litAds1.Text = advertisement1.GetAds(); #region TU DONG DK SUB GAME if (Session["msisdn"] == null) { int is3g; string msisdn = MobileUtils.GetMSISDN(out is3g); if (!string.IsNullOrEmpty(msisdn) && MobileUtils.CheckOperator(msisdn, "vietnammobile")) { Session["telco"] = Constant.T_Vietnamobile; Session["msisdn"] = msisdn; } else { Session["msisdn"] = null; Session["telco"] = Constant.T_Undefined; } } //string url = UrlProcess.GetGameHomeUrl("1", "320", "0"); if (Session["msisdn"] != null) { string value = AppEnv.RegisterService(AppEnv.GetSetting("S2ShortCode"), "0", Session["msisdn"].ToString(), "DK", "DK GAME"); //ANDY Service S2_94x string[] res = value.Split('|'); if (res.Length > 0) { if (res[0] == "1") //DK THANH CONG { pnlThongBao.Visible = true; } } } #endregion } if (string.IsNullOrEmpty(Request.QueryString["display"])) { display = "home"; } else { display = Request.QueryString["display"]; } Literal title = new Literal(); Literal ltrEnd = new Literal(); Literal ltrEnd1 = new Literal(); try { string wapHomeURL = "http://wap.vietnamobile.com.vn"; DataTable dtMusic = GameController.GetAllGame_ByPackageID(ConvertUtility.ToInt32(AppEnv.GetSetting("packageIdGame"))); title.Text = "<style type=\"text/css\">body {font-family:Verdana, Arial, Helvetica; font-size:12px;} .mainmenu {display:block;width: 100%;background-color: #de60cb;color:#fff;text-align:center;line-height:25px;} .mainmenu a{color:#fff;} a:link, a:visited {text-decoration:none;}</style>"; if (lang == "1") { title.Text += "<div style=\"background-color:#EA6A00;color:#FFFFFF;display:block;line-height:25px;width:100%;margin-top:5px;padding-left:5px;font-weight:bold;\">" + "Chào mừng bạn đến với dịch vụ game <b style=\"color:blue\">(Miễn Phí)</b> của Vietnamobile" + "</div>"; } else { title.Text += "<div style=\"background-color:#EA6A00;color:#FFFFFF;display:block;line-height:25px;width:100%;margin-top:5px;padding-left:5px;font-weight:bold;\">" + "Chao mung ban den voi dich vu game <b style=\"color:blue\">(Miễn Phí)</b> cua Vietnamobile" + "</div>"; } plList.Controls.Add(title); foreach (DataRow row in dtMusic.Rows) { HyperLink lnkfile = new HyperLink(); if (lang == "1") { lnkfile.Text = row["Name"].ToString(); } else { lnkfile.Text = UnicodeUtility.UnicodeToKoDau(row["Name"].ToString()); } lnkfile.NavigateUrl = AppEnv.GetSetting("JavaGameDownload") + "?id=" + row["GameID"] + "&type=3" + "&code=" + SecurityMethod.MD5Encrypt(row["GameID"].ToString()); lnkfile.Attributes.Add("style", "color:#006CBF;padding-left:15px;padding-top:5px;padding-bottom:5px;display:block"); lnkfile.Attributes.Add("class", "bold"); plList.Controls.Add(lnkfile); } //Khuyen mai ltrEnd1.Text = "</div><div style=\"border-bottom: 1px solid #790083;height: 7px; margin: 5px 0 10px 0; width: 100%;\"></div>"; ltrEnd.Text = "</div><div style=\"height: 7px; margin: 5px 0 0px 0; width: 100%;\"></div>"; ltrEnd.Text += "<div style=\"background-color: #EA6A00; color: #FFFFFF; display: block; line-height: 25px; text-align: center; width: 100%;\">"; ltrEnd.Text += "<a style=\"color:#fff\" href=\"" + wapHomeURL + "\">Trang chủ</a> | <a style=\"color:#fff\" href=\"" + wapHomeURL + "/Game/Default.aspx?lang=1&display=home&hotro=0\">Game</a> | <a style=\"color:#fff\" href=\"" + wapHomeURL + "/Music/Default.aspx?lang=1&display=home\">Nhạc</a> | <a style=\"color:#fff\" href=\"" + wapHomeURL + "/Thethao/Default.aspx?lang=1&display=home\">Bóng đá</a></div>"; plList.Controls.Add(ltrEnd); } catch (Exception ex) { Response.Write(ex.ToString()); } }
protected void HienThiNoiDung(Boolean thuchien) { pnlNoiDung.Visible = true; id = ConvertUtility.ToInt32(Request.QueryString["id"]); DataTable dtDetail = RTController.GetRingToneDetailByIDHasCache(Session["telco"].ToString(), id); chitietGiaodich = "Nhạc: " + dtDetail.Rows[0]["SongNameUnicode"].ToString() + " -- id:" + id.ToString() + " -- newtransactionid: " + ConvertUtility.ToString(Session["transactionid"]) + " -- old tranid: " + ConvertUtility.ToString(Session["transactionid_old"]); if (thuchien) { DataTable dtKhuyenMai = RTController.GetRingToneDetailRandom(Session["telco"].ToString(), id); string khuyenmaiID = ConvertUtility.ToString(dtKhuyenMai.Rows[0]["W_RTItemID"]); lnkKhuyenMai.NavigateUrl = UrlProcess.GetGameDownloadItem(Session["telco"].ToString(), "2", khuyenmaiID, SecurityMethod.MD5Encrypt(khuyenmaiID)); if (lang == "1") { ltrTieuDe.Text = linkStr; lblTen.Text = dtDetail.Rows[0]["SongNameUnicode"].ToString(); lnkDownload.Text = Resources.Resource.wBamDeTai; ltrNoiDung.Text = Resources.Resource.wMuaThanhCong + " bản nhạc " + dtDetail.Rows[0]["SongNameUnicode"].ToString(); lnkKhuyenMai.Text = "Nhạc tặng: " + dtKhuyenMai.Rows[0]["SongNameUnicode"].ToString(); } else { ltrTieuDe.Text = linkStr_KD; lblTen.Text = dtDetail.Rows[0]["SongName"].ToString(); lnkDownload.Text = Resources.Resource.wBamDeTai_KD; ltrNoiDung.Text = Resources.Resource.wMuaThanhCong_KD + " ban nhac " + dtDetail.Rows[0]["SongName"].ToString(); lnkKhuyenMai.Text = "Nhac tang: " + dtKhuyenMai.Rows[0]["SongName"].ToString(); }; lnkDownload.NavigateUrl = UrlProcess.GetGameDownloadItem(Session["telco"].ToString(), "2", id.ToString(), SecurityMethod.MD5Encrypt(id.ToString())); Transaction.Success(Session["telco"].ToString(), Session["msisdn"].ToString(), price, lnkDownload.NavigateUrl, id.ToString(), chitietGiaodich, 2); RTController.SetDownloadCounter(Session["telco"].ToString(), id); } else { //Thông báo lỗi thanh toán if (lang == "1") { ltrTieuDe.Text = linkStr + " » " + Resources.Resource.wThongBao; ltrNoiDung.Text = Resources.Resource.wThongBaoLoiThanhToan; } else { ltrTieuDe.Text = linkStr_KD + " » " + Resources.Resource.wThongBao_KD; ltrNoiDung.Text = Resources.Resource.wThongBaoLoiThanhToan_KD; } Transaction.Failure(Session["telco"].ToString(), Session["msisdn"].ToString(), price, Request.Url.ToString(), id.ToString(), chitietGiaodich, 2, messageReturn); //--Thông báo lỗi thanh toán } //log charging ILog logger = log4net.LogManager.GetLogger(Session["telco"].ToString()); logger.Debug("--------------------------------------------------"); logger.Debug("MSISDN:" + Session["msisdn"].ToString()); logger.Debug("Dich vu: Nhac chuong - parameter: " + price + " - Ten: " + dtDetail.Rows[0]["SongName"].ToString() + " - id: " + id); logger.Debug("Nhac chuong Url:" + lnkDownload.NavigateUrl); logger.Debug("IP:" + HttpContext.Current.Request.UserHostAddress); logger.Debug("Error:" + messageReturn); logger.Debug("Current Url:" + Request.RawUrl); //end log }
/// <summary> /// PIX configuration section /// </summary> public HL7ConfigurationSection(SecurityMethod securityMethod) { this.Services = new List <ServiceDefinition>(); this.Security = securityMethod; }
protected void btnUpdate_Click(object sender, EventArgs e) { if (Page.IsValid) { try { int userId = ConvertUtility.ToInt32(Request.QueryString["uid"]); UserInfo user = new UserInfo(); user.Username = txtUsername.Text.Trim(); user.DisplayName = txtDisplayName.Text.Trim(); user.IsAdmin = chkIsAdmin.Checked; user.IsSuperAdmin = chkIsSuperAdmin.Checked; user.MaSo = txtMaSo.Text.Trim(); user.HoTen = txtFullName.Text.Trim(); user.NgaySinh = ConvertUtility.ToDateTime(txtNgaySinh.Text.Trim()); user.GioiTinh = ConvertUtility.ToInt32(dropGioiTinh.SelectedValue); user.IDChucVu = ConvertUtility.ToInt32(dropChucVu.SelectedValue); user.IDTrungTam = ConvertUtility.ToInt32(dropTrungTam.SelectedValue); user.IDPhong = ConvertUtility.ToInt32(dropPhong.SelectedValue); user.NoiSinh = txtNoiSinh.Text.Trim(); user.NguyenQuan = txtNguyenQuan.Text.Trim(); user.QuocTich = txtQuocTich.Text.Trim(); user.DanToc = txtDanToc.Text.Trim(); user.TonGiao = txtTonGiao.Text.Trim(); user.DiaChiThuongChu = txtDiaChiThuongChu.Text.Trim(); user.DiaChiTamChu = txtDiaChiTamChu.Text.Trim(); user.TrangThai = ConvertUtility.ToInt32(dropTrangThai.SelectedValue); if (userId > 0) { user.UserID = userId; UserController.UpdateUser(user); lblUpdateStatus.Text = MiscUtility.MSG_UPDATE_SUCCESS; } else { if (txtPassword.Text.Trim() != txtPasswordConfirm.Text.Trim()) { return; } user.Password = SecurityMethod.MD5Encrypt(txtPassword.Text.Trim()); userId = UserController.AddUser(user); if (userId > 0) { RoleController.AddUserToRole(userId, AppEnv.DEFAULT_ROLE, AppEnv.PortalId()); Response.Redirect(AppEnv.AdminUrlParams("createuser") + "&uid=" + userId); } else { lblUpdateStatus.Text = "Tên đăng nhập lại đã tồn tại."; } } } catch (Exception ex) { lblUpdateStatus.Text = ex.Message; } } }
protected void HienThiNoiDung(Boolean thuchien, Boolean isLog) { pnlNoiDung.Visible = true; id = ConvertUtility.ToInt32(Request.QueryString["id"]); DataTable dtDetail = MusicController.GetItemDetailHasCache(AppEnv.CheckFreeContentTelco(), id); //chitietGiaodich = "Nhạc: " + dtDetail.Rows[0]["SongNameUnicode"].ToString() + " -- id:" + id.ToString() + " -- newtransactionid: " + ConvertUtility.ToString(Session["transactionid"]) + " -- old tranid: " + ConvertUtility.ToString(Session["transactionid_old"]); chitietGiaodich = "Nhạc: " + dtDetail.Rows[0]["SongNameUnicode"].ToString() + " -- id:" + id.ToString(); if (thuchien) { DataTable dtKhuyenMai = MusicController.GetItemDetailRandom(AppEnv.CheckFreeContentTelco(), id); string khuyenmaiID = ConvertUtility.ToString(dtKhuyenMai.Rows[0]["W_MItemID"]); lnkKhuyenMai.NavigateUrl = UrlProcess.GetGameDownloadItem(AppEnv.CheckFreeContentTelco(), "22", khuyenmaiID, SecurityMethod.MD5Encrypt(khuyenmaiID)); //if (lang == "1") //{ ltrTieuDe.Text = "ÂM NHẠC"; lblTen.Text = dtDetail.Rows[0]["SongNameUnicode"].ToString(); lnkDownload.Text = Resources.Resource.wBamDeTai; ltrNoiDung.Text = Resources.Resource.wMuaThanhCong + " bản nhạc " + dtDetail.Rows[0]["SongNameUnicode"].ToString(); lnkKhuyenMai.Text = "Nhạc tặng: " + dtKhuyenMai.Rows[0]["SongNameUnicode"].ToString(); //} //else //{ // ltrTieuDe.Text = "AM NHAC"; // lblTen.Text = dtDetail.Rows[0]["SongName"].ToString(); // lnkDownload.Text = Resources.Resource.wBamDeTai_KD; // ltrNoiDung.Text = Resources.Resource.wMuaThanhCong_KD + " ban nhac " + dtDetail.Rows[0]["SongName"].ToString(); // lnkKhuyenMai.Text = "Nhac tang: " + dtKhuyenMai.Rows[0]["SongName"].ToString(); //} lnkDownload.NavigateUrl = UrlProcess.GetGameDownloadItem(AppEnv.CheckFreeContentTelco(), "22", id.ToString(), SecurityMethod.MD5Encrypt(id.ToString())); if (free != true) { if (isLog) { Transaction.Success(Session["telco"].ToString(), Session["msisdn"].ToString(), price, lnkDownload.NavigateUrl, id.ToString(), chitietGiaodich, 2); } } MusicController.SetDownloadCounter(AppEnv.CheckFreeContentTelco(), id); } else { //Thông báo lỗi thanh toán //if (lang == "1") //{ ltrTieuDe.Text = Resources.Resource.wThongBao; ltrNoiDung.Text = Resources.Resource.wThongBaoLoiThanhToan; //} //else //{ // ltrTieuDe.Text = Resources.Resource.wThongBao_KD; // ltrNoiDung.Text = Resources.Resource.wThongBaoLoiThanhToan_KD; //} if (isLog) { Transaction.Failure(Session["telco"].ToString(), Session["msisdn"].ToString(), price, Request.Url.ToString(), id.ToString(), chitietGiaodich, 2, messageReturn); } //--Thông báo lỗi thanh toán } //log charging if (free != true) { if (isLog) { ILog logger = LogManager.GetLogger(Session["telco"].ToString()); logger.Debug("--------------------------------------------------"); logger.Debug("MSISDN:" + Session["msisdn"]); logger.Debug("Dich vu: Am nhac - parameter: " + price + " - Ten: " + dtDetail.Rows[0]["SongName"] + " - id: " + id); logger.Debug("Am nhac Url:" + lnkDownload.NavigateUrl); logger.Debug("IP:" + HttpContext.Current.Request.UserHostAddress); logger.Debug("Error:" + messageReturn); logger.Debug("Current Url:" + Request.RawUrl); } } //end log }
void rptItem_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemIndex < 0) { return; } HyperLink lnkAvatar = (HyperLink)e.Item.FindControl("lnkAvatar"); Image imgAvatar = (Image)e.Item.FindControl("imgAvatar"); HyperLink lnkTen = (HyperLink)e.Item.FindControl("lnkTen"); DataRowView row = (DataRowView)e.Item.DataItem; string download = AppEnv.GetSetting("VNMdownload"); imgAvatar.ImageUrl = "http://media.xzone.vn/" + row["Path"].ToString().Replace("~/", ""); lnkTen.NavigateUrl = lnkAvatar.NavigateUrl = download + "?type=1&id=" + row["ID"].ToString() + "&code=" + SecurityMethod.MD5Encrypt(row["ID"].ToString()); if (lang == "1") { lnkTen.Text = row["Wallpaper_Name"].ToString(); } else { lnkTen.Text = UnicodeUtility.UnicodeToKoDau(row["Wallpaper_Name"].ToString()); } }
/// <summary> /// Writes security header /// </summary> /// <param name="stream">Ouput stream</param> /// <param name="method">Security method</param> /// <param name="macKey">Key</param> public static void WriteHeaderSecurity(MemoryStream stream, SecurityMethod method, byte[] macKey) { WriteShortInteger(stream, HEADER_SEC); switch (method) { case SecurityMethod.NETWPIN: WriteShortInteger(stream, SEC_NETWPIN); break; case SecurityMethod.USERPIN: WriteShortInteger(stream, SEC_USERPIN); break; case SecurityMethod.USERNETWPIN: WriteShortInteger(stream, SEC_USERNETWPIN); break; case SecurityMethod.USERPINMAC: WriteShortInteger(stream, SEC_USERPINMAC); break; } WriteShortInteger(stream, HEADER_MAC); string macKeyString = string.Empty; foreach (byte b in macKey) macKeyString += b.ToString("X2"); WriteTextString(stream, macKeyString); }