Guest User

Untitled

a guest
Mar 1st, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.14 KB | None | 0 0
  1. <?php
  2. require_once("configs/main.php");
  3. if(!isset($_SESSION['username']))
  4. {
  5.     if(isset($_POST['accountName']))
  6.     {
  7.         $accountName = mysql_real_escape_string(stripslashes($_POST['accountName']));
  8.         $accountPass = mysql_real_escape_string(stripslashes($_POST['password']));
  9.         function sha_password($user, $pass)
  10.         {
  11.             $user = strtoupper($user);
  12.             $pass = strtoupper($pass);
  13.             return SHA1($user.':'.$pass);
  14.         }
  15.         $sha_pass_hash = sha_password($accountName, $accountPass);
  16.         if(!$con)
  17.         {
  18.             echo mysql_error();
  19.         }
  20.         $db_setup = mysql_select_db($db_realm)or die(mysql_error());
  21.         $login_query = mysql_query("SELECT * FROM account WHERE username = '$accountName'");
  22.         $login = mysql_fetch_assoc($login_query);
  23.         if($login)
  24.         {
  25.             if(strtoupper($sha_pass_hash) == $login['sha_pass_hash'])
  26.             {
  27.                 $_SESSION['username'] = $accountName;
  28.                 echo '<br /><br /><meta http-equiv="refresh" content="2"/>';
  29.             }
  30.             else
  31.             {
  32.              echo '<br /><br /><font color="red">Špatné heslo</font><meta http-equiv="refresh" content="2"/>';
  33.              header('Location: index.php');
  34.             }
  35.         }
  36.     }  
  37. }
  38. ?>
Add Comment
Please, Sign In to add comment