Guest User

Untitled

a guest
Apr 2nd, 2013
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.65 KB | None | 0 0
  1. //Change the DO_LOGIN Module in your modules.php to:
  2.  
  3. <!-- DO_LOGIN-->
  4. <div id="do_login">
  5. <?php
  6.  
  7. if(isset($_POST['login_submit'])) {
  8.     if(isset($_POST["user"]) && isset($_POST["pw"])) {
  9.  
  10.         $user = $_POST["user"];
  11.         $pw = $_POST["pw"];
  12.  
  13.         $connection = mysql_connect($mysqlhost, $mysqluser, $mysqlpw) or die ($db_error);
  14.         mysql_select_db($mysqldb, $connection) or die($db_error);
  15.        
  16.         $a=mysql_query("SELECT password FROM authme where username = '$user'");
  17.         if(mysql_num_rows($a) == 1 ) {
  18.             $password_info=mysql_fetch_array($a);
  19.             $sha_info = explode("$",$password_info[0]);
  20.         } else {
  21.             echo '<div class="alert alert-error"><center>Du bist nicht registriert<meta http-equiv="refresh" content="2; URL=index.php"></center></div>';
  22.         }
  23.        
  24.         if( $sha_info[1] === "SHA" ) {
  25.             $salt = $sha_info[2];
  26.             $sha256_password = hash('sha256', $pw);
  27.             $sha256_password .= $sha_info[2];;
  28.             if(strcasecmp(trim($sha_info[3]),hash('sha256', $sha256_password) ) == 0 ) {
  29.                 $_SESSION['User'] = $user;
  30.                 ini_set("session.cookie_lifetime","7200"); //set session timeout to 2h
  31.    
  32.                 if($_SESSION['User']) {
  33.                     echo '<div class="alert alert-success"><center>'.$login_success.'<meta http-equiv="refresh" content="2; URL=index.php"></center></div>';
  34.                 }else{
  35.                     echo '<div class="alert alert-error"><center>'.$unknown_error.'<meta http-equiv="refresh" content="2; URL=index.php"> ';
  36.                 }
  37.             } else {
  38.             echo '<div class="alert alert-error"><center>'.$login_wrong.'<meta http-equiv="refresh" content="2; URL=index.php"></center></div>';
  39.             }
  40.         }
  41.     }
  42.    
  43.     mysql_close($connection);
  44. }
  45. ?>
  46. </div>
  47. <!-- DO_LOGIN -->
Advertisement
Add Comment
Please, Sign In to add comment