private void ProcessRegister(ref HttpResponse response, ref HttpRequest request) { string username = request.Form["user"]; string password = request.Form["password1"]; Login.log.Debug(username); Login.log.Debug(password); int inviteid = request.Cookies["inviteid"].content.ConvertToInt(0); using (MemberShipbussiness a = new MemberShipbussiness()) { if (a.ExistsUsername(username)) { response.ReturnAndRedict("该用户名已被注册", "login.do"); } else { if (a.CreateUsername(username, password, inviteid)) { response.cookies.Add(new HttpCookie { name = "username", content = username.ToSafeString(), Expires = DateTime.Now.AddYears(1) }); response.cookies.Add(new HttpCookie { name = "password", content = password.ToSafeString(), Expires = DateTime.Now.AddYears(1) }); response.ReturnAndRedict("注册成功", "game.htm"); } } } }
public HttpResponse Process(HttpRequest request) { var response = new HttpResponse(); response.ContentType = "text/html; charset=utf-8"; if (!WebServer.Instance.IsOpen) { response.ReturnAndRedict("服务器尚未开放!", "login.htm"); } else { string name = request.Cookies["username"].content; string pass = request.Cookies["password"].content; using (MemberShipbussiness a = new MemberShipbussiness()) { int b = 0; if (a.CheckUser(name, pass)) { b = a.GetUserType(name); if (b >= 2) { var x = request.QueryString["ForceLoginUsername"]; if (x != "" && a.ExistsUsername(x)) { name = x; } } pass = Guid.NewGuid().ToString(); PlayerManager.Add(name, pass); string content = $"user={name}&key={pass}"; INVelocityEngine FileEngine = NVelocityEngineFactory.CreateNVelocityFileEngine(Server.ModulePath + @"vm", false); IDictionary context = new Hashtable(); context.Add("Username", name); context.Add("Content", content); context.Add("Edition", "0"); context.Add("Rand", DateTime.Now.Ticks.ToString()); context.Add("UserType", b.ToString()); response.Write(FileEngine.Process(context, "Game.vm")); } else { response.cookies.Add(new HttpCookie { name = "username", Expires = DateTime.Now.AddYears(-1) }); response.cookies.Add(new HttpCookie { name = "password", Expires = DateTime.Now.AddYears(-1) }); response.ReturnAndRedict("用户名或密码错误!", "login.htm"); } } } return(response); }