Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static class Init
- {
- #region Iniciar sesión y verificar los datos del usuario viene desactivado por defecto ponerlo a criterio de cada uno.
- public static string message = null;
- public static int veces = 0; public static int intentos = 3;
- public static bool Login(string Username, string Password)
- {
- try
- {
- MySQL.Conexion = new MySqlConnection("Server=host;Port=3306;Database=database;User=username;Password=password"); MySQL.Conexion.Open();
- MySQL.Query.CommandText = ("SELECT username,motto,rank,mail,account_created,last_online,look FROM users WHERE username = ?Loginname AND password = MD5(?password) LIMIT 1");
- MySQL.Query.Parameters.Add(new MySqlParameter("?Loginname", Username));MySQL.Query.Parameters.Add(new MySqlParameter("?password", Password));
- MySQL.Query.Connection = MySQL.Conexion; MySQL.Consultar = MySQL.Query.ExecuteReader();
- if (MySQL.Consultar.HasRows)
- {
- MySQL.Consultar.Read();
- int rank = Convert.ToInt32(MySQL.Consultar[2].ToString());
- if (rank >= 7)
- {
- //Modificamos la variable a 0 debido a que inicio sesión con éxito.
- veces = 0;
- MessageBox.Show("¡Bienvenido " + Username + " usted se ha logeado correctamente ¡Disfrute!", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
- //Autorizamos al Usuario ya logeado con éxito poder administrar solo es seguridad...
- Kernel.AUTHORIZED(true);
- 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());
- return true;
- }
- else
- {
- message = ("No tienes suficientes poderes para acceder al panel de administración y si vuelves a ejecutarla se auto prohibirá el acceso.");
- Kernel.AUTHORIZED(false);
- return false;
- }
- }
- else
- {
- //Incrementamos el valor de veces que intento logearse sin éxito.
- veces = veces + 1;
- Kernel.AUTHORIZED(false);
- message = ("Tu nombre de usuario o contraseña no coincide con los datos escritos inténtalo de nuevo o espere más tarde.");
- return false;
- }
- }
- catch (Exception ex)
- {
- message = ("Losentimos estamos teniendo problemas con tu acceso contacte con el administrador o espere a más tarde." + ex.Message.ToString());
- return false;
- }
- finally
- {
- MySQL.Query.Parameters.Clear(); MySQL.Conexion.Close(); MySQL.Conexion.Dispose(); Username = null; Password = null;
- }
- }
- #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement