Advertisement
Guest User

sys_valida_usuario

a guest
Sep 25th, 2014
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.28 KB | None | 0 0
  1. <?php
  2. require("config_claro.php");
  3. require("sys_funciones.php");
  4. $ip = $_SERVER["REMOTE_ADDR"];
  5.      $zone = 3600*-5; //USA
  6.    $hoy  = gmdate("Y-m-d h:i:s", time() + $zone);
  7. $int=0;
  8.  
  9. $consul="select * from empleado where (codigo = '$codigo') and (clave = '$clave') and (existe='1')";
  10. $resul=mysql_query($consul, $con);
  11. $uid=0;
  12. $sid=0;
  13. $activo=0;
  14. $err=0;
  15. $tot=0;
  16.  
  17. //------------------------------------------------------------------------------
  18. while($f=mysql_fetch_array($resul))
  19.  {
  20.    $uid    = $f["Id"];
  21.      $activo = $f["activo"];
  22.  }
  23. //------------------------------------------------------------------------------
  24. if($activo>0)
  25.  {
  26.     if($uid>0)
  27.      {
  28.         $consul="select count(Id) as tot from empleado_tienda where idempleado = '$uid'";
  29.         $resul=mysql_query($consul, $con);
  30.         $f=mysql_fetch_array($resul);
  31.         $tot=$f[0];
  32.             if($tot>0)
  33.              {
  34.                   $consul="delete from ip where ipnro = '$ip'";
  35.                   $resul=mysql_query($consul, $con);           
  36.                   $sid = IniciarSesion($uid, $con);          
  37.              }
  38.             else
  39.              {
  40.               $err=2; // datos correctos pero no tiene tienda!
  41.              }
  42.      }    
  43.     else
  44.      {    
  45.       $err=1; // nombre de usuario o contrase�a incorrecta!
  46.       $consul="insert into ip(ipnro,fecha_hora,user,pass) values ('$ip','$hoy','$codigo','$clave')";
  47.       $resul=mysql_query($consul, $con);             
  48.      }
  49.  }
  50. else //del if $activo>0
  51.  {
  52.    if($uid>0)
  53.       {
  54.          $err=3; // existe pero no esta activo!
  55.         }
  56.     else
  57.      {    
  58.       $err=1; // nombre de usuario o contrase�a incorrecta!
  59.       $consul="insert into ip(ipnro,fecha_hora,user,pass) values ('$ip','$hoy','$codigo','$clave')";
  60.       $resul=mysql_query($consul, $con);             
  61.      }
  62.  }
  63.       $consul="select ipnro,count(*) from ip group by ipnro having ipnro = '$ip'";
  64.       $resul=mysql_query($consul, $con);
  65.       $f=mysql_fetch_array($resul);
  66.       $int=$f[1];
  67.       if($int>2)
  68.       {            
  69.     mail('info@sistemaclaro.com', 'Bloqueo IP', $ip);
  70.     mail('alonso1978@gmail.com', 'Bloqueo IP', $ip);
  71.       }
  72. //------------------------------------------------------------------------------
  73. if($sid>0)
  74.  {$destino="sys_login2.php?sid=$sid&uid=$uid";}
  75. else
  76.  {$destino="sys_login.php?err=$err";}
  77. header("location: $destino");
  78. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement