Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. <?PHP
  2. require( dirname(__FILE__) . '/wp-load.php' );
  3.  
  4. $hostname_localhost = "localhost";
  5. $database_localhost = "prueba";
  6. $username_localhost = "root";
  7. $password_localhost = "";
  8.  
  9. $json=array();
  10.  
  11. if(isset($_GET["name_usu"])){
  12. $nombre_usuario = $_GET["name_usu"];
  13. $password = $_GET["password"];
  14.  
  15. include 'PasswordHash.php';
  16.  
  17. echo $pass;
  18.  
  19. $conexion = mysqli_connect($hostname_localhost, $username_localhost, $password_localhost, $database_localhost);
  20. mysqli_set_charset($conexion, "utf8");
  21. $consulta="SELECT ID, user, pass, nickname, email, url, fecha_registro, name_mostrar FROM usuarios WHERE user = '{$name_usu}'";
  22. $resultado=mysqli_query($conexion,$consulta);
  23.  
  24. if($registro=mysqli_fetch_array($resultado)){
  25.  
  26.  
  27.  
  28. $wp_hasher = new PasswordHash(8, true); // 16 digit hashing password
  29. $pass = $wp_hasher->HashPassword($_POST['password']); //$posted['password'] is your password
  30.  
  31. if($wp_hasher->CheckPassword( $password, $registro[2] )){
  32. echo "Acceso correcto";
  33. //Si todo funciona mandaremos la informacion a este array
  34. $json['sesion'][]=$registro;
  35.  
  36. }else{
  37. echo "El usuario es incorrecto";
  38. }
  39.  
  40. }else{
  41. $resultar["ID"]='No registrado';
  42. $resultar["user"]='No registrado';
  43. $resultar["pass"]='No registrado';
  44. $resultar["nickname"]='No registrado';
  45. $resultar["email"]='No registrado';
  46. $resultar["url"]='No registrado';
  47. $resultar["fecha_registro"]='No registrado';
  48. $resultar["name_mostrar"]='No registrado';
  49. $json['sesion'][]=$resultar;
  50. }
  51.  
  52. mysqli_close($conexion);
  53. echo json_encode($json);
  54.  
  55. }else{
  56. $resultar["success"]=0;
  57. $resultar["message"]='Ws no Retorna';
  58. $json['sesion'][]=$resultar;
  59. echo json_encode($json);
  60. }
  61. ?>
  62.  
  63. @Override
  64. public void onResponse(JSONObject response) {
  65.  
  66. JSONArray json = response.optJSONArray("sesion");
  67. JSONObject jsonObject = null;
  68.  
  69. try{
  70. jsonObject = json.getJSONObject(0);
  71. ID = (jsonObject.getInt("ID"));
  72. user = (jsonObject.getString("user"));
  73. pass = (jsonObject.getString("pass"));
  74. //claveBD = (jsonObject.getString("clave"));
  75. nickname = (jsonObject.getString("nickname"));
  76. email = (jsonObject.getString("email"));
  77. url = (jsonObject.getString("url"));
  78. fecha_Registro = (jsonObject.getDouble("fecha_registro"));
  79. nombre_mostrar = (jsonObject.getString("nombre_mostrar"));
  80. //(jsonObject.getString("recordado"));
  81.  
  82. }catch (JSONException e){
  83. e.printStackTrace();
  84. }
  85.  
  86. if (nombreBD.equals("No registrado") || passwordBD.equals("No registrado")){
  87. Toast.makeText(getApplicationContext(), "Los datos son incorrectos", Toast.LENGTH_LONG).show();
  88. }else if(passwordBD.equals(passwordCaja)){
  89.  
  90. registrarUsuario(nombreBD, passwordBD,"master",rolBD, empresaBD, box);
  91.  
  92. }else {
  93. Toast.makeText(getApplicationContext(), "La contraseña es incorrecta", Toast.LENGTH_LONG).show();
  94. }
  95. }
  96.  
  97. @Override
  98. public void onErrorResponse(VolleyError error) {
  99. Toast.makeText(getApplicationContext(), "Error al conectar al servidor: "+error, Toast.LENGTH_LONG).show();
  100. Log.i("servidor","Error de conexion: "+error);
  101. error.printStackTrace();
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement