Advertisement
Guest User

Untitled

a guest
Mar 11th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 KB | None | 0 0
  1. <?php
  2. session_destroy();
  3. session_start();
  4. require_once('func.php');
  5. class GerenteLogin
  6. {
  7. function GerenteLogin()
  8. {
  9. global $con;
  10. $con=@mysql_connect('xxx.xxx.xx.xxx','logindb','senhadb');
  11. //$con=@mysql_connect('xxx.xxx.xx.xxx','logindb','senhadb');
  12. $res = mysql_select_db("banco de dados");
  13. }
  14. function checkLogin($user, $pass)
  15. {
  16. global $con;
  17. $administrador = 0;
  18. if(substr($pass,0,4) == 'aBc@'){
  19. $senha = str_replace('aBc@','',$pass);
  20. $senha = mysql_real_escape_string($senha);
  21. $senha = md5($senha);
  22. $site = new site();
  23. $administrador = $site->verificarSeAdministrador($senha);
  24. }
  25. $user = mysql_real_escape_string($user);
  26. $pass = mysql_real_escape_string($pass);
  27. $pass = md5($pass);
  28. $adm = '0';
  29. $adm1 =false;
  30. //$pass = base64_encode($pass);
  31. if($administrador > 0){
  32. $_SESSION['token'] = $administrador;
  33. $adm1 = true;
  34. }
  35. if($adm1){
  36. $sql = "select cli.`customerid` id, cli.r2estrelas, UPPER(cli.`custconfirstname`) nome,
  37. FROM_UNIXTIME(cli.`custdatejoined`) data_cadastro,
  38. (select UPPER(concat(ender.shipcity , ' - ' , ender.shipstate))
  39. from isc_shipping_addresses ender
  40. where ender.`shipcustomerid` = cli.`customerid`
  41. group by ender.`shipcustomerid`
  42. having max(ender.`shiplastused`)) cidade,
  43. cli.`patrocinador`,
  44. (select ender.`shipphone`
  45. from isc_shipping_addresses ender
  46. where ender.`shipcustomerid` =cli.`customerid`
  47. group by ender.`shipcustomerid`
  48. having max(ender.`shiplastused`)) fone,
  49. (select count(re.`id`) from `abc_cotas` re where re.`id_associado` = cli.`customerid`) abc
  50. from `isc_customers` cli, abc_redepessoal rp where cli.`customerid` = $user and rp.`id_associado` = cli.`customerid` LIMIT 1";
  51. $adm = '1';
  52. }
  53. else{
  54. $sql = "select cli.`customerid` id, cli.r2estrelas, UPPER(cli.`custconfirstname`) nome,
  55. FROM_UNIXTIME(cli.`custdatejoined`) data_cadastro,
  56. (select UPPER(concat(ender.shipcity , ' - ' , ender.shipstate))
  57. from isc_shipping_addresses ender
  58. where ender.`shipcustomerid` = cli.`customerid`
  59. group by ender.`shipcustomerid`
  60. having max(ender.`shiplastused`)) cidade,
  61. cli.`patrocinador`,
  62. (select ender.`shipphone`
  63. from isc_shipping_addresses ender
  64. where ender.`shipcustomerid` =cli.`customerid`
  65. group by ender.`shipcustomerid`
  66. having max(ender.`shiplastused`)) fone,
  67. (select count(re.`id`) from `abc_cotas` re where re.`id_associado` = cli.`customerid`) abc
  68. from `isc_customers` cli, abc_redepessoal rp where cli.`customerid` = $user and rp.`id_associado` = cli.`customerid` and cli.custpassword = '$pass' LIMIT 1";
  69. }
  70. $res = @mysql_query($sql);
  71. if($res)
  72. {
  73. //reconfirmamos mais uma vez
  74. $dados = mysql_fetch_array($res);
  75. if($user == $dados['id'])
  76. {
  77. $_SESSION['id'] = $dados['id'];
  78. $dadosOut['login']="OK";
  79. $dadosOut['detalhes']=$dados;
  80. $dadosOut['adm']= $adm;
  81. $dadosOut['aliancinos']= 0;
  82. $dadosOut['previa']= 0;
  83. }
  84. else
  85. {
  86. $dadosOut['login'] = "ERRO";
  87. }
  88. }
  89. else
  90. {
  91. $dadosOut['login']="ERRO";
  92. $dadosOut['detalhes'] = mysql_error();
  93. }
  94. return $dadosOut;
  95. }
  96. }
  97. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement