daily pastebin goal
75%
SHARE
TWEET

Untitled

a guest Jun 8th, 2017 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. include('config.php');
  3. if(isset($_POST['Submit']))
  4. {
  5.         $username = mysql_real_escape_string($_POST['username']);
  6.         $pass = mysql_real_escape_string($_POST['password']);
  7.         $hash = md5(rand(10000, 99999));
  8.         $password = sha1(strtoupper($username).":".strtoupper($pass));
  9.        
  10.         $account_id = mysql_fetch_array(mysql_query("SELECT `id` FROM `".$database."`.`users` WHERE `username` = '".$username."'"));
  11.         $row = mysql_fetch_assoc(mysql_query("SELECT `password` FROM `".$database."`.`users` WHERE `username` = '".$username."'"));
  12.  
  13. if($row['password'] == $password)
  14.     {
  15.         if(mysql_num_rows(mysql_query("SELECT NULL FROM `".$database."`.`users` WHERE `username` = '".$account_id['id']."'")) > 0)
  16.         {
  17.             mysql_query("UPDATE `".$database."`.`users` SET `sessionkey` = '".$hash."' `time` = '".(time()+60*60)."' `ip` = '".md5($_SERVER['REMOTE_ADDR'])."' WHERE `account` = '".$account_id['id']."'");
  18.         }
  19.         else
  20.         {
  21.             setcookie('logged_in',$hash,time()+60*60, "/");
  22.             mysql_query("INSERT INTO `".$database."`.`sessionkeys` (`account`,`sessionkey`,`time`,`ip`) VALUES ('".$account_id['id']."','".$hash."','".(time()+60*60)."','".md5($_SERVER['REMOTE_ADDR'])."')");
  23.             header('Location:/');
  24.         }
  25.     }
  26. else
  27.     {
  28.         $fp = fopen("log.txt", "w");
  29.         fwrite($fp, "[".date("Y.m.d H:i:s", time())."] Felhasználónév: ".$username." IP: ".base64_encode($_SERVER['REMOTE_ADDR'])."\n");
  30.         fclose($fp);
  31.     }
  32. }
  33. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top