Advertisement
Guest User

Untitled

a guest
May 2nd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.70 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4. $rootpath = '../';
  5.  
  6. include $rootpath."_includes/config.php";
  7. include CLASSES."dbUtil/dbUtil.php";
  8. include CLASSES."dbUtil/varie.dbUtil.php";
  9.  
  10.  
  11. $dbUtil = new dbUtil();
  12. $varie = new varie();
  13.  
  14.  
  15. $template = "template.php";
  16. $body = "index.inc.php";
  17.  
  18. $maxData = 10;
  19.  
  20. try {
  21.  
  22.  
  23. if(isset($_GET["logout"])){
  24.  
  25. $_SESSION = array();
  26. session_destroy();
  27.  
  28. //header('Location:'.$rootpath.'');
  29. }
  30.  
  31.  
  32. //sponsor
  33. $sponsor = $varie->sponsor(SPONSOR_QUADRATO);
  34. $eventi = $varie->eventi();
  35.  
  36.  
  37.  
  38.  
  39. $checkSystemLogin = 0; // 0 Login da effettuare - 1 Login Effettuato Correttamente - 2 Login errato
  40.  
  41.  
  42. $userId=0;
  43. $userTypeId=0;
  44. $userSpazioClubId=0;
  45.  
  46.  
  47. function check($user,$password){
  48.  
  49. global $dbUtil;
  50.  
  51. $_SESSION = array();
  52.  
  53.  
  54. // visione della tabella
  55.  
  56. //$dati=mysql_query("SELECT * FROM User2 WHERE Username='".$user."' AND Password='".$password."'");
  57. $sql = "SELECT * FROM ".TABLE_USER2." WHERE Username='".$user."' AND Password='".$password."'";
  58. $dbUtil->query($sql);
  59. //echo $sql;
  60.  
  61.  
  62. while($array=$dbUtil->fetchAssoc()){
  63.  
  64. $usernme=$array["Username"];
  65.  
  66. $passwrd=$array["Password"];
  67.  
  68. if (($user==$usernme) AND ($password==$passwrd)) {
  69.  
  70.  
  71. $_SESSION["session_username"] = $usernme;
  72. // $_SESSION["session_password"] = $passwrd;
  73. $_SESSION["session_userID"] = $array["UserId"];
  74. $_SESSION["session_userTypeID"]= $array["TypeUser"];
  75. $_SESSION["session_mail"] = $array["Email"];
  76. $_SESSION["session_loginok"] = '1';
  77.  
  78. return true;
  79.  
  80. }
  81.  
  82. }
  83.  
  84. //$dbUtil->pre($array);
  85.  
  86. return false;
  87.  
  88. }
  89.  
  90.  
  91.  
  92.  
  93.  
  94. if ($_GET['login']=='1') {
  95.  
  96.  
  97.  
  98. // check Username e Password
  99.  
  100. if(isset($_POST["username"])){
  101.  
  102.  
  103.  
  104. if ($md5Mode==1)
  105.  
  106. {
  107. $pwd = md5($_POST["password"]);
  108. } else
  109.  
  110. {
  111. $pwd = $_POST["password"];
  112. }
  113.  
  114.  
  115.  
  116. if (check($_POST["username"],$pwd)){
  117.  
  118.  
  119. $checkSystemLogin = '1';
  120.  
  121. //header('Location:'.$_SERVER["HTTP_REFERER"].'');
  122. $mess = "Login effettuato correttamente";
  123.  
  124.  
  125.  
  126.  
  127.  
  128. }else{
  129.  
  130.  
  131.  
  132. $mess="Errore di connessione - NOME UTENTE o PASSWORD ERRATA";
  133.  
  134. // echo "<META http-equiv=\"Refresh\" Content=\"0;url=index.php?error=$mess\">";
  135.  
  136. $checkSystemLogin = 2;
  137.  
  138. }
  139.  
  140. }else{
  141.  
  142.  
  143.  
  144. $mess="Errore di connessione - NOME UTENTE o PASSWORD ERRATA";
  145.  
  146. // echo "<META http-equiv=\"Refresh\" Content=\"0;url=index.php?error=$mess\">";
  147.  
  148. $checkSystemLogin = 2;
  149.  
  150. }
  151.  
  152.  
  153.  
  154. }
  155.  
  156.  
  157. } catch (Exception $exc) {
  158. $mess = $exc->getMessage();
  159. }
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169. $dbUtil->closeDb();
  170.  
  171. require FLD_TEMPLATES.$template;
  172. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement