public string DoLogin() { string UserName = Request["UserName"].Trim(); string PWD = Request["PWD"].Trim(); string Code = Request["Code"].Trim(); if (string.IsNullOrEmpty(UserName)) { return("请输入用户名!"); } if (string.IsNullOrEmpty(PWD)) { return("请输入密码!"); } if (string.IsNullOrEmpty(Code)) { return("请输入验证码!"); } if (Session[Keys.SESSION_CODE] == null) { return("验证码已过期,请刷新验证码!"); } if (Code.ToLower() != Session[Keys.SESSION_CODE].ToString().ToLower()) { return("您输入的验证码不正确!"); } if (!gum.IsGameUser(UserName)) { return("您输入的用户不存在!"); } GameUser gu = new GameUser(); gu = gum.GetGameUser(UserName, DESEncrypt.Md5(PWD, 32)); if (gu == null) { return("您输入的用户或密码有误!"); } if (gu.IsLock == 1) { return("您输入的用户或密码有误!"); } if (alm.IsLock(BBRequest.GetIP())) { return("您输入的用户或密码有误!"); } Session[Keys.SESSION_USER] = gu.Id; Session.Timeout = 120; gum.UpdateLastLogin(gu.Id); if (Request["ck1"] == "on") { Utils.WriteCookie("6qmgamesame", DESEncrypt.DesEncrypt(UserName) + "|" + DESEncrypt.DesEncrypt(PWD), 10080); } else { Utils.WriteCookie("6qmgamesame", "", -10); } return("True"); }
public ActionResult LoginGame(string GameNo, int Qf) { g = gm.GetGame(GameNo); GameServer gs = new GameServer(); gs = sm.GetGameServer(g.Id, Qf); ViewData["Title"] = "5577yx-" + g.Name; ViewData["ServerName"] = g.Name + "-" + gs.Name; ViewData["GameNo"] = g.GameNo; ViewData["Qf"] = Qf; if (gs.State == 1 && gs.StartTime < DateTime.Now) { gs.State = 4; sm.UpdateServer(gs); } if (gs.State != 1 && gs.StartTime > DateTime.Now) { gs.State = 1; sm.UpdateServer(gs); } if (gs.State == 1 && gs.StartTime > DateTime.Now) { TimeSpan ts = gs.StartTime - DateTime.Now; ViewData["TimeSpan"] = ts.TotalMilliseconds; } if (gs.State == 1 || gs.State == 2) { ViewData["State"] = gs.State; return(View("~/Views/GameCenter/LoginGame.cshtml")); } int UserId = BBRequest.GetUserId(); if (UserId > 0) { ViewData["LoginUrl"] = gm.LoginUrl(g.Id, UserId, gs.Id, 0); gum.UpdateLastLogin(UserId); OnlineLog ol = new OnlineLog(0, UserId, g.Id, gs.Id, DateTime.Now, 0, 0); new OnlineLogManager().AddOnlineLog(ol); } else { if (Utils.GetCookie("6qmgamesame") != "") { string value = Utils.GetCookie("6qmgamesame"); string UserName = DESEncrypt.DesDecrypt(value.Split('|')[0]); string PWD = DESEncrypt.DesDecrypt(value.Split('|')[1]); GameUser gu = gum.GetGameUser(UserName, DESEncrypt.Md5(PWD, 32)); if (gu != null) { BBRequest.WriteUserId(gu.Id); gum.UpdateLastLogin(gu.Id); ViewData["LoginUrl"] = gm.LoginUrl(g.Id, gu.Id, gs.Id, 0); OnlineLog ol = new OnlineLog(0, gu.Id, g.Id, gs.Id, DateTime.Now, 0, 0); new OnlineLogManager().AddOnlineLog(ol); } else { return(RedirectToAction("Login", "Home")); } } else { return(RedirectToAction("Login", "Home")); } } return(View("~/Views/GameCenter/LoginGame.cshtml")); }