Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.66 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using MySql.Data.MySqlClient;
  11.  
  12. namespace GetNek_ReemB_Launcher_Login
  13. {
  14. public partial class Form1 : Form
  15.  
  16. {
  17. private bool Drag;
  18. private int MouseX;
  19. private int MouseY;
  20.  
  21. private const int WM_NCHITTEST = 0x84;
  22. private const int HTCLIENT = 0x1;
  23. private const int HTCAPTION = 0x2;
  24.  
  25. private bool m_aeroEnabled;
  26.  
  27. private const int CS_DROPSHADOW = 0x00020000;
  28. private const int WM_NCPAINT = 0x0085;
  29. private const int WM_ACTIVATEAPP = 0x001C;
  30.  
  31. [System.Runtime.InteropServices.DllImport("dwmapi.dll")]
  32. public static extern int DwmExtendFrameIntoClientArea(IntPtr hWnd, ref MARGINS pMarInset);
  33. [System.Runtime.InteropServices.DllImport("dwmapi.dll")]
  34. public static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize);
  35. [System.Runtime.InteropServices.DllImport("dwmapi.dll")]
  36.  
  37. public static extern int DwmIsCompositionEnabled(ref int pfEnabled);
  38. [System.Runtime.InteropServices.DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")]
  39. private static extern IntPtr CreateRoundRectRgn(
  40. int nLeftRect,
  41. int nTopRect,
  42. int nRightRect,
  43. int nBottomRect,
  44. int nWidthEllipse,
  45. int nHeightEllipse
  46. );
  47.  
  48. string externalip = new System.Net.WebClient().DownloadString("http://icanhazip.com");
  49.  
  50. public struct MARGINS
  51. {
  52. public int leftWidth;
  53. public int rightWidth;
  54. public int topHeight;
  55. public int bottomHeight;
  56. }
  57. protected override CreateParams CreateParams
  58. {
  59. get
  60. {
  61. m_aeroEnabled = CheckAeroEnabled();
  62. CreateParams cp = base.CreateParams;
  63. if (!m_aeroEnabled)
  64. cp.ClassStyle |= CS_DROPSHADOW; return cp;
  65. }
  66. }
  67. private bool CheckAeroEnabled()
  68. {
  69. if (Environment.OSVersion.Version.Major >= 6)
  70. {
  71. int enabled = 0; DwmIsCompositionEnabled(ref enabled);
  72. return (enabled == 1) ? true : false;
  73. }
  74. return false;
  75. }
  76. protected override void WndProc(ref Message m)
  77. {
  78. switch (m.Msg)
  79. {
  80. case WM_NCPAINT:
  81. if (m_aeroEnabled)
  82. {
  83. var v = 2;
  84. DwmSetWindowAttribute(this.Handle, 2, ref v, 4);
  85. MARGINS margins = new MARGINS()
  86. {
  87. bottomHeight = 1,
  88. leftWidth = 0,
  89. rightWidth = 0,
  90. topHeight = 0
  91. }; DwmExtendFrameIntoClientArea(this.Handle, ref margins);
  92. }
  93. break;
  94. default: break;
  95. }
  96. base.WndProc(ref m);
  97. if (m.Msg == WM_NCHITTEST && (int)m.Result == HTCLIENT) m.Result = (IntPtr)HTCAPTION;
  98. }
  99. private void PanelMove_MouseDown(object sender, MouseEventArgs e)
  100. {
  101. Drag = true;
  102. MouseX = Cursor.Position.X - this.Left;
  103. MouseY = Cursor.Position.Y - this.Top;
  104. }
  105. private void PanelMove_MouseMove(object sender, MouseEventArgs e)
  106. {
  107. if (Drag)
  108. {
  109. this.Top = Cursor.Position.Y - MouseY;
  110. this.Left = Cursor.Position.X - MouseX;
  111. }
  112. }
  113. private void PanelMove_MouseUp(object sender, MouseEventArgs e) { Drag = false; }
  114. public Form1()
  115. {
  116. InitializeComponent();
  117.  
  118. }
  119.  
  120. private void Form1_Load(object sender, EventArgs e)
  121. {
  122. textBox4.Text = externalip;
  123.  
  124. }
  125.  
  126. private void Form1_Shown(object sender, EventArgs e)
  127. {
  128.  
  129.  
  130. }
  131.  
  132. private void pictureBox1_Click(object sender, EventArgs e)
  133. {
  134.  
  135. }
  136.  
  137. private void textBox1_TextChanged(object sender, EventArgs e)
  138. {
  139.  
  140. }
  141.  
  142. private void button5_Click(object sender, EventArgs e)
  143. {
  144. System.Diagnostics.Process.Start("http://discord.gg");
  145. }
  146.  
  147. private void button3_Click(object sender, EventArgs e)
  148. {
  149. Application.Exit();
  150. }
  151.  
  152. private void button4_Click(object sender, EventArgs e)
  153. {
  154. this.WindowState = FormWindowState.Minimized;
  155. }
  156.  
  157. private void button1_Click(object sender, EventArgs e)
  158. {
  159. string connstring = @"server=den1.mysql6.gear.host;userid=loginlauncher;password=Rk9461Q_EqT-;database=loginlauncher";
  160. MySqlConnection conn = null;
  161.  
  162. try
  163. {
  164. conn = new MySqlConnection(connstring);
  165. conn.Open();
  166.  
  167. string query = "SELECT * FROM loginlauncher_users WHERE username ='" + textBox1.Text + "'AND password ='" + textBox3.Text + "'";
  168. MySqlDataAdapter da = new MySqlDataAdapter(query, conn);
  169. DataSet ds = new DataSet();
  170. da.Fill(ds, "table_name");
  171. DataTable dt = ds.Tables["table_name"];
  172.  
  173.  
  174.  
  175. if (dt.Rows.Count >= 1)
  176. {
  177.  
  178.  
  179.  
  180. Console.WriteLine(dt.Rows[0][2].ToString());
  181. if (dt.Rows[0][2].ToString() == ""){
  182. MySqlCommand comm = conn.CreateCommand();
  183. comm.CommandText = "UPDATE loginlauncher_users SET externalip = @ip WHERE username = @username;";
  184. comm.Parameters.Add("ip", MySqlDbType.VarChar).Value = externalip;
  185. comm.Parameters.Add("username", MySqlDbType.VarChar).Value = textBox1.Text;
  186.  
  187. comm.ExecuteNonQuery();
  188.  
  189. }
  190. else
  191. {
  192.  
  193.  
  194. }
  195.  
  196. bool IsAllowed = false;
  197.  
  198. if (dt.Rows[0][2].ToString() == externalip.ToString())
  199. {
  200. IsAllowed = true;
  201. MessageBox.Show("התחברת בהצלחה, ברשותך זמן מוגבל להתחבר לשרת הפייבאם טרם תצטרך להקליד את שם המשתמש והסיסמה מחדש", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
  202.  
  203. }
  204. else
  205. {
  206.  
  207. MessageBox.Show(".שם המשתמש והסיסמה שלך נכונים, אבל האייפי שלך שונה", "הכניסה נדחתה", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  208. }
  209.  
  210. MySqlCommand comm2 = conn.CreateCommand();
  211. comm2.CommandText = "UPDATE loginlauncher_users SET IsAllowed = @IsAllowed WHERE username = @username;";
  212. comm2.Parameters.Add("IsAllowed", MySqlDbType.Bit).Value = IsAllowed;
  213. comm2.Parameters.Add("username", MySqlDbType.VarChar).Value = textBox1.Text;
  214.  
  215. comm2.ExecuteNonQuery();
  216.  
  217.  
  218. foreach (DataRow row in dt.Rows) // כושון
  219. {
  220. if (IsAllowed ) {
  221. Properties.Settings.Default.name = row[0].ToString();
  222. this.Opacity = 0;
  223. this.Visible = false;
  224. this.ShowInTaskbar = false;
  225. this.ShowIcon = false;
  226.  
  227. Form2 f2 = new Form2();
  228. f2.Show();
  229. }
  230. }
  231. }
  232. else { MessageBox.Show("!הפרטים שהוזנו לא תקינים", "שגיאה", MessageBoxButtons.OK, MessageBoxIcon.Error); }
  233.  
  234. }
  235. catch (Exception)
  236. {
  237. MessageBox.Show("!אירעה שגיאה במסד הנתונים", "שגיאה", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  238. }
  239. finally
  240. {
  241. if (conn != null)
  242. {
  243. conn.Close();
  244. }
  245. }
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252. }
  253.  
  254. private void textBox4_TextChanged(object sender, EventArgs e)
  255. {
  256.  
  257. }
  258.  
  259. private void textBox4_TextChanged_1(object sender, EventArgs e)
  260. {
  261.  
  262. }
  263.  
  264. private void textBox5_TextChanged(object sender, EventArgs e)
  265. {
  266.  
  267. }
  268.  
  269. private void button6_Click(object sender, EventArgs e)
  270. {
  271.  
  272. }
  273.  
  274. private void button2_Click(object sender, EventArgs e)
  275. {
  276. string connstring = @"server=den1.mysql6.gear.host;userid=loginlauncher;password=Rk9461Q_EqT-;database=loginlauncher";
  277. MySqlConnection conn = null;
  278.  
  279. try
  280. {
  281. conn = new MySqlConnection(connstring);
  282. conn.Open();
  283.  
  284. string query = "SELECT * FROM loginlauncher_users WHERE username ='" + textBox1.Text + "'AND password ='" + textBox3.Text + "' AND IsAdmin =1";
  285. MySqlDataAdapter da = new MySqlDataAdapter(query, conn); // בולבול
  286. DataSet ds = new DataSet();
  287. da.Fill(ds, "table_name");
  288. DataTable dt = ds.Tables["table_name"];
  289.  
  290. if (dt.Rows.Count >= 1)
  291. {
  292. MessageBox.Show("התחברת כמנהל בהצלחה", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
  293. this.Opacity = 0;
  294. this.Visible = false;
  295. this.ShowInTaskbar = false;
  296. this.ShowIcon = false;
  297.  
  298. Form3 f3 = new Form3();
  299. f3.Show();
  300. }
  301. else { MessageBox.Show("!הפרטים שהוזנו לא תקינים", "שגיאה", MessageBoxButtons.OK, MessageBoxIcon.Error); }
  302.  
  303. }
  304. catch (Exception)
  305. {
  306. MessageBox.Show("!אירעה שגיאה במסד הנתונים", "שגיאה", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  307. }
  308. finally
  309. {
  310. if (conn != null)
  311. {
  312. conn.Close();
  313. }
  314. }
  315. }
  316. }
  317. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement