Advertisement
Guest User

Untitled

a guest
Sep 15th, 2017
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.30 KB | None | 0 0
  1. public static class Init
  2. {
  3.  
  4. #region Iniciar sesión y verificar los datos del usuario viene desactivado por defecto ponerlo a criterio de cada uno.
  5. public static string message = null;
  6. public static int veces = 0; public static int intentos = 3;
  7. public static bool Login(string Username, string Password)
  8. {
  9. try
  10. {
  11. MySQL.Conexion = new MySqlConnection("Server=host;Port=3306;Database=database;User=username;Password=password"); MySQL.Conexion.Open();
  12. MySQL.Query.CommandText = ("SELECT username,motto,rank,mail,account_created,last_online,look FROM users WHERE username = ?Loginname AND password = MD5(?password) LIMIT 1");
  13. MySQL.Query.Parameters.Add(new MySqlParameter("?Loginname", Username));MySQL.Query.Parameters.Add(new MySqlParameter("?password", Password));
  14. MySQL.Query.Connection = MySQL.Conexion; MySQL.Consultar = MySQL.Query.ExecuteReader();
  15. if (MySQL.Consultar.HasRows)
  16. {
  17. MySQL.Consultar.Read();
  18. int rank = Convert.ToInt32(MySQL.Consultar[2].ToString());
  19. if (rank >= 7)
  20. {
  21. //Modificamos la variable a 0 debido a que inicio sesión con éxito.
  22. veces = 0;
  23. MessageBox.Show("¡Bienvenido " + Username + " usted se ha logeado correctamente ¡Disfrute!", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
  24. //Autorizamos al Usuario ya logeado con éxito poder administrar solo es seguridad...
  25. Kernel.AUTHORIZED(true);
  26. FuseInfo.ManagerUser(MySQL.Consultar[0].ToString(), MySQL.Consultar[1].ToString(), Convert.ToInt32(MySQL.Consultar[2].ToString()), MySQL.Consultar[3].ToString(), Convert.ToInt32(MySQL.Consultar[4].ToString()), Convert.ToInt32(MySQL.Consultar[5].ToString()), MySQL.Consultar[6].ToString());
  27. return true;
  28. }
  29. else
  30. {
  31. message = ("No tienes suficientes poderes para acceder al panel de administración y si vuelves a ejecutarla se auto prohibirá el acceso.");
  32. Kernel.AUTHORIZED(false);
  33. return false;
  34. }
  35. }
  36. else
  37. {
  38. //Incrementamos el valor de veces que intento logearse sin éxito.
  39. veces = veces + 1;
  40. Kernel.AUTHORIZED(false);
  41. message = ("Tu nombre de usuario o contraseña no coincide con los datos escritos inténtalo de nuevo o espere más tarde.");
  42. return false;
  43. }
  44. }
  45. catch (Exception ex)
  46. {
  47.  
  48. message = ("Losentimos estamos teniendo problemas con tu acceso contacte con el administrador o espere a más tarde." + ex.Message.ToString());
  49. return false;
  50. }
  51. finally
  52. {
  53. MySQL.Query.Parameters.Clear(); MySQL.Conexion.Close(); MySQL.Conexion.Dispose(); Username = null; Password = null;
  54. }
  55. }
  56. #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement