Guest User

check.php

a guest
May 3rd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.79 KB | None | 0 0
  1. <?php
  2. $link = mysqli_connect("localhost", "mysql_username","mysql_password");
  3. $database = mysqli_select_db($link, "mysql_database");
  4.  
  5. $user = $_GET['username'];
  6. $password = $_GET['password'];
  7. $hwid = $_GET['hwid'];
  8. $tables = "mybb_users";
  9.  
  10. $sql = "SELECT * FROM ". $tables ." WHERE username = '". mysqli_real_escape_string($link,$user) ."'" ;
  11. $result = $link->query($sql);
  12. if ($result->num_rows > 0) {
  13.     // Outputting the rows
  14.     while($row = $result->fetch_assoc())
  15.     {
  16.        
  17.         $password = $row['password'];
  18.         $salt = $row['salt'];
  19.         $plain_pass = $_GET['password'];
  20.         $stored_pass = md5(md5($salt).md5($plain_pass));
  21.        
  22.         function Redirect($url, $permanent = false)
  23.         {
  24.             if (headers_sent() === false)
  25.             {
  26.                 header('Location: ' . $url, true, ($permanent === true) ? 301 : 302);
  27.             }
  28.         exit();
  29.         }
  30.        
  31.         if($stored_pass != $row['password'])
  32.         {
  33.             echo "p0<br>"; // Wrong pass, user exists
  34.         }
  35.         else
  36.         {
  37.             echo "p1<br>"; // Correct pass
  38.         }
  39.        
  40.         echo "g" . $row['usergroup'] . "<br>";
  41.  
  42.         if (strlen($row['hwid']) > 1)
  43.         {
  44.             if ($hwid != $row['hwid'])
  45.             {
  46.                 echo "h2"; // Wrong
  47.             }
  48.             else
  49.             {
  50.                 echo "h1"; // Correct
  51.             }
  52.         }
  53.         else
  54.         {
  55.             $sql = "UPDATE ". $tables ." SET hwid='$hwid' WHERE username='$user'";
  56.             if(mysqli_query($link, $sql))
  57.             {
  58.                 echo $row['hwid'];
  59.                 echo "h3"; // HWID Set
  60.             }
  61.             else
  62.             {
  63.                 echo "h4"; // Else errors
  64.             }
  65.         }
  66.     }
  67. }  
  68. ?>
Add Comment
Please, Sign In to add comment