Advertisement
Guest User

Untitled

a guest
Mar 18th, 2017
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.96 KB | None | 0 0
  1. string email = bunifuMetroTextbox1.Text;
  2. bool IsRealEmail = Regex.IsMatch(email, @"^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$");
  3.  
  4. if (bunifuMetroTextbox1.Text == "" || bunifuMetroTextbox2.Text == "")
  5. {
  6. label3.Text = "Please type in and username and password.";
  7. return;
  8. }
  9.  
  10.  
  11.  
  12. else if (bunifuMetroTextbox1.Text.Contains("@"))
  13. {
  14. try
  15. {
  16.  
  17. string emails = bunifuMetroTextbox1.Text;
  18. string password = Hash(bunifuMetroTextbox2.Text);
  19. bool r = validate_loginemail(emails, password);
  20. if (r)
  21. {
  22. Assembly assembly = Assembly.GetExecutingAssembly();
  23. FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
  24.  
  25. string v1 = fileVersionInfo.ProductVersion;
  26. string v2 = new WebClient().DownloadString("string");
  27.  
  28. var version1 = new Version(v1);
  29. var version2 = new Version(v2);
  30.  
  31. var vrz = version1.CompareTo(version2);
  32. if (vrz > 0)
  33. {
  34. //just go on with the program; there is nothing to update
  35. }
  36. else if (vrz < 0)
  37. {
  38. DialogResult dialogResult = System.Windows.Forms.MessageBox.Show("There is a new update! Would you like to update?", "Update Program", MessageBoxButtons.YesNo);
  39. if (dialogResult == DialogResult.Yes)
  40. {
  41. System.Diagnostics.Process.Start("http://www.google.com");
  42. }
  43. else if (dialogResult == DialogResult.No)
  44. {
  45.  
  46.  
  47.  
  48. Form1 objFrmMain = new Form1();
  49. this.Hide();
  50. objFrmMain.ShowDialog();
  51. this.Close();
  52. return;
  53. }
  54.  
  55. }
  56.  
  57. else
  58. {
  59. //// Get the object used to communicate with the server.
  60. //FtpWebRequest request = (FtpWebRequest)WebRequest.Create("string");
  61. //request.Method = WebRequestMethods.Ftp.UploadFile;
  62. //// This example assumes the FTP site uses anonymous logon.
  63. //request.Credentials = new NetworkCredential("anonymous", "janeDoe@contoso.com");
  64.  
  65.  
  66. //MemoryStream memStr = new MemoryStream(UTF8Encoding.Default.GetBytes("asdf"));
  67. //System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
  68. //Byte[] bytes = Encoding.GetBytes(memStr);
  69. //Stream requestStream = request.GetRequestStream();
  70. //requestStream.Write(bytes, 0, bytes.Length);
  71. //requestStream.Close();
  72.  
  73.  
  74.  
  75. Form1 objFrmMain = new Form1();
  76. this.Hide();
  77. objFrmMain.ShowDialog();
  78. this.Close();
  79. return;
  80. }
  81. }
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88. else
  89. {
  90. label3.Text = "Incorrect username or password";
  91. }
  92. }
  93.  
  94. catch (Exception ex)
  95. {
  96. MessageBox.Show(ex.Message);
  97. }
  98.  
  99.  
  100.  
  101.  
  102. }
  103. else
  104. {
  105. try
  106. {
  107.  
  108. string username = bunifuMetroTextbox1.Text;
  109. string password = Hash(bunifuMetroTextbox2.Text);
  110. bool r = validate_login(username, password);
  111. if (r)
  112. {
  113. //call Assmebly + identify
  114. Assembly assembly = Assembly.GetExecutingAssembly();
  115. FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
  116.  
  117. //compare Assembly to txt in FTP server
  118. string v1 = fileVersionInfo.ProductVersion;
  119. string v2 = new WebClient().DownloadString("string");
  120.  
  121. var version1 = new Version(v1);
  122. var version2 = new Version(v2);
  123.  
  124. var vrz = version1.CompareTo(version2);
  125. if (vrz > 0)
  126. {
  127. //just go on with the program; there is nothing to update
  128. }
  129. else if (vrz < 0)
  130. {
  131. DialogResult dialogResult = System.Windows.Forms.MessageBox.Show("There is a new update! Would you like to update?", "Update Program", MessageBoxButtons.YesNo);
  132. if (dialogResult == DialogResult.Yes)
  133. {
  134. System.Diagnostics.Process.Start("http://www.google.com");
  135. }
  136. else if (dialogResult == DialogResult.No)
  137. {
  138.  
  139. Form1 objFrmMain = new Form1();
  140. this.Hide();
  141. objFrmMain.ShowDialog();
  142. this.Close();
  143. return;
  144. }
  145.  
  146. }
  147.  
  148. else
  149. {
  150. //string writer = new WebClient().DownloadString("string");
  151. //System.IO.StreamWriter file = new System.IO.StreamWriter(writer);
  152. //file.WriteLine(localIPs);
  153. Form1 objFrmMain = new Form1();
  154. this.Hide();
  155. objFrmMain.ShowDialog();
  156. this.Close();
  157. return;
  158. }
  159. }
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166. else
  167. {
  168. label3.Text = "Incorrect username or password";
  169. }
  170. }
  171.  
  172. catch (Exception ex)
  173. {
  174. MessageBox.Show(ex.Message);
  175. }
  176.  
  177.  
  178.  
  179. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement