Advertisement
Guest User

Untitled

a guest
May 19th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. <?php
  2. require_once("./includes/Header.php");
  3. $pagina = 'Autentificare';
  4. if(isset($_SESSION['username']))
  5. {
  6. Header("Location: /panel");
  7. return 1;
  8. }
  9. if(isset($_POST['login']))
  10. {
  11. if($Informatii['Criptare'] == 1)
  12. {
  13. $salt = '78sdjs86d2h';
  14. $username = mysqli_real_escape_string($DB_H, addslashes($_POST['username']));
  15. $password = mysqli_real_escape_string($DB_H, addslashes($_POST['password']));
  16. $hash1 = hash('sha256', $password . $salt);
  17. $hash = strtoupper($hash1);
  18. $password = $hash;
  19. }
  20. if($Informatii['Criptare'] == 0)
  21. {
  22. $username = mysqli_real_escape_string($DB_H, addslashes($_POST['username']));
  23. $password = mysqli_real_escape_string($DB_H, addslashes($_POST['password']));
  24. }
  25.  
  26. $dbh = new PDO("mysql:host=".$mysqli['SQL_HOST'].";dbname=".$mysqli['SQL_DB']."", "".$mysqli['SQL_USER']."", "".$mysqli['SQL_PASS']."");
  27.  
  28. $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  29.  
  30. $stmt = $dbh->prepare("SELECT id, Name, password FROM ".$mysqli['SQL_ACCOUNTS']."
  31. WHERE Name = :numele AND password = :parola");
  32.  
  33. /*** bind the parameters ***/
  34. $stmt->bindParam(':numele', $username, PDO::PARAM_STR);
  35. $stmt->bindParam(':parola', $password, PDO::PARAM_STR, 40);
  36.  
  37. /*** execute the prepared statement ***/
  38. $stmt->execute();
  39.  
  40. /*** check for a result ***/
  41. $user_id = $stmt->fetchColumn();
  42.  
  43. /*** if we have no result then fail boat ***/
  44. if($user_id == false)
  45. {
  46. $msg = "Parola introdusă de tine este greșită!";
  47.  
  48. }
  49. /*** if we do have a result, all is well ***/
  50. else
  51. {
  52. /*** set the session user_id variable ***/
  53. $_SESSION['username'] = $username;
  54. $_SESSION['password'] = $password;
  55. echo "
  56. <script type='text/javascript'>
  57. <!--
  58. function Redirect()
  59. {
  60. window.location='/panel/';
  61. }
  62. setTimeout('Redirect()', 50);
  63. //-->
  64. </script>";
  65.  
  66. }
  67. }
  68.  
  69. ?>
  70.  
  71.  
  72. <div class="breadcrumbs" id="breadcrumbs">
  73. <script type="text/javascript">
  74. try{
  75. ace.settings.check('breadcrumbs' , 'fixed')}
  76. catch(e){
  77. }
  78. </script>
  79. <ul class="breadcrumb">
  80. <li>
  81. <i class="icon-home home-icon">
  82. </i>
  83. <a href="index"><?= $Informatii['NumeleComunitatii'] ?>
  84. </a>
  85. </li>
  86. <li class="active">
  87. <i class="icon-angle-right">
  88. </i>
  89. <?php echo htmlspecialchars($pagina);?>
  90. </li>
  91. </ul>
  92. <div class="nav-search" id="nav-search">
  93. <form class="form-search" action="search.php">
  94. <span class="input-icon">
  95. <input type="text" placeholder="Caută un jucător.." name="name" class="nav-search-input" autocomplete="off">
  96. <i class="icon-search nav-search-icon">
  97. </i>
  98. </span>
  99. </form>
  100. </div>
  101. </div>
  102.  
  103.  
  104. <div class="page-content">
  105. <div class="row-fluid">
  106.  
  107.  
  108. <center>
  109. <h3>Autentificare</h3>
  110.  
  111. <?php if(isset($msg)): ?>
  112. <h5><font color="red"><?= $msg ?></font></h5>
  113. <?php endif; ?>
  114. <hr>
  115.  
  116.  
  117. <form method="post" action="">
  118.  
  119. <p>Numele tău din joc:</p>
  120.  
  121. <input type="text" name="username">
  122.  
  123. <p>Parola folosită la inregistrare:</p>
  124.  
  125. <input type="password" name="password" value ="">
  126. <br>
  127. <button type="submit" name="login" class="btn btn-primary">Autentificare</button>
  128. <!-- <a type="submit" href ="recover.php" value="Recuperare" class="btn btn-primary">Recuperare</a> -->
  129.  
  130. </form>
  131.  
  132. <br><br>
  133.  
  134. </center>
  135.  
  136.  
  137. </div>
  138. </div>
  139. <?php require_once("./includes/Footer.php"); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement