public MnfLogger() { InitializeComponent(); DataContext = this; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; try { if (!File.Exists(NastaveniMnf.UserFile)) { File.Create(NastaveniMnf.UserFile).Close(); } StreamReader sr = new StreamReader(NastaveniMnf.UserFile); var radek = sr.ReadLine(); while (radek != null) { var u = new Uzivatel(); u.JmenoUzivatele = radek; u.HesloUzivatele = sr.ReadLine(); radek = sr.ReadLine(); Uzivatele.Add(u); } sr.Close(); if (LB.Items.Count > 0) { LB.SelectedIndex = 0; } } catch (Exception ex) { Console.WriteLine("Nepodařilo se nahrát uživatele\n" + ex.Message); //MessageBox.Show("Nepodařilo se nahrát uživatele\n" + ex.Message); } }
/// <summary> /// pripoji se a nacte avatary /// </summary> /// <param name="u"></param> public void UserLogIn(Uzivatel u) { try { GetVersion(); Console.WriteLine("Download main.swf"); var responseNON = wc.DownloadString(MnfAddress.SiteSWF("main.swf?version=" + Properties.Settings.Default.Verze)); string[] toDown = new string[] { "highscores", "dialog_manager", "outlined_font", "bubble_manager", "chat_manager", "picture_viewer", "avatar_info", "custom_bg_manager", "friends_list", "mail_manager", "invite_manager", "item_manager", "system_message_manager", "game_settings", "login_screen", "emoticons", "petnis", "avatar" }; foreach (var td in toDown) { Console.WriteLine("Download " + td + ".swf"); responseNON = wc.DownloadString(MnfAddress.SiteSWF(td + ".swf?version=" + Properties.Settings.Default.Verze)); } string s; //Logovani var data = new NameValueCollection(); data["pass"] = u.HesloUzivatele; data["email"] = u.JmenoUzivatele; mnfUzivatel.LoginPaswCrypted = u.HesloUzivatele; Console.WriteLine("Loging to game"); var response = wc.UploadValues(MnfAddress.SiteMain() + MnfAddress.SiteLogin, "POST", data);//&errors=00&user_id=1658254&premium=0&premium_notification=0&overcrowder=0& s = Encoding.UTF8.GetString(response, 0, response.Length); if (UserParse(s)) { MessageBox.Show("Bad login\n" + s); return; } Console.WriteLine("Loging ok"); Console.WriteLine("Download bug_report & avatar_manager_screen"); responseNON = wc.DownloadString(MnfAddress.SiteMain("bug_report.php?email=" + u.JmenoUzivatele + "&avatar=")); responseNON = wc.DownloadString(MnfAddress.SiteSWF("avatar_manager_screen.swf?1." + Properties.Settings.Default.Verze)); ////Zisk Avatara data = new NameValueCollection(); data["pass"] = u.HesloUzivatele; data["user_id"] = mnfUzivatel.UserID.ToString();//nebo user%5Fid Console.WriteLine("read avatars"); response = wc.UploadValues(MnfAddress.SiteMain() + MnfAddress.SiteAvatar, "POST", data); s = Encoding.UTF8.GetString(response, 0, response.Length); string[] ss = s.Split('&')[1].Split(';'); //if (ss.Length < 5) { MessageBox.Show("bad response\n" + s); return true; } Avatars.Clear(); for (int i = 0; i < ss.Length; i++) { var a = new Avatar(); if (a.ParseAvatar(ss[i])) { MessageBox.Show("bad response\n" + ss[i]); } else { Avatars.Add(a); Console.WriteLine("Avatar add " + a.JmenoPostavy); } } } catch (Exception e) { Console.WriteLine("Nepovedlo se pripojit uzivatele " + u.JmenoUzivatele); Console.WriteLine(e); } }
private void AddUser(object sender, RoutedEventArgs e) { MnfLogin ml = new MnfLogin(); if (ml.ShowDialog().Value) { var u = new Uzivatel(); u.JmenoUzivatele = ml.User.JmenoUzivatele; u.HesloUzivatele = CalculateMD5Hash(ml.User.JmenoUzivatele.ToLower() + ml.User.HesloUzivatele).ToLower(); Uzivatele.Add(u); } }
public MnfLogin() { InitializeComponent(); User = new Uzivatel(); DataContext = User; }