protected override void HandleRequest() { string status = "<Error>Internal server error</Error>"; using (Database db = new Database()) { Account acc; if (CheckAccount(acc = db.Verify(Query["guid"], Query["password"], Program.GameData), db)) { if (acc.Rank < 1) { status = "<Error>Only donators can port prod accounts to the private server.</Error>"; } else if (acc.IsProdAccount && acc.Rank < 2) { status = "<Error>You account is already transfered.</Error>"; } else if (!acc.Banned) { HttpWebRequest req = (HttpWebRequest)WebRequest.Create(String.Format("http://www.realmofthemadgodhrd.appspot.com/char/list?guid={0}&{1}={2}", Query["prodGuid"], Query["prodGuid"].StartsWith("kongregate:") || Query["prodGuid"].StartsWith("steamworks:") ? "secret" : "password", Query["prodPassword"])); var resp = req.GetResponse(); Chars chrs = new Chars(); chrs.Characters = new List<Char>(); string s; using (StreamReader rdr = new StreamReader(resp.GetResponseStream())) s = rdr.ReadToEnd(); s = s.Replace("False", "false").Replace("True", "true"); try { XmlSerializer serializer = new XmlSerializer(chrs.GetType(), new XmlRootAttribute("Chars") { Namespace = "" }); chrs = (Chars)serializer.Deserialize(new StringReader(s)); if (db.SaveChars(acc.AccountId, new [email protected]().GetChars(Query["guid"], Query["password"], Program.GameData), chrs, Program.GameData)) status = "<Success />"; } catch (Exception e) { Program.logger.Error(e); } } else status = "<Error>Account under Maintenance</Error>"; } else status = "<Error>Account credentials not valid</Error>"; } using (StreamWriter wtr = new StreamWriter(Context.Response.OutputStream)) wtr.Write(status); }