Advertisement
Guest User

Untitled

a guest
Jul 6th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.15 KB | None | 0 0
  1. <?php
  2.  
  3.     session_start();
  4.    
  5.     require_once ("../../phpBB3/includes/functions.php");
  6.    
  7.     if (!isset($_SESSION['inicjuj']))
  8.     {
  9.         session_regenerate_id();
  10.         $_SESSION['inicjuj'] = true;
  11.         $_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];
  12.     }
  13.    
  14.     if($_SESSION['ip'] != $_SERVER['REMOTE_ADDR'])
  15.     {
  16.         die('Proba przejecia sesji udaremniona!'); 
  17.     }
  18.    
  19.     if(isset($_POST['username'])) {
  20.    
  21.     $username = $_POST['username'];
  22.     $userpassword = $_POST['password'];
  23.    
  24.     $query = "SELECT user_id, username_clean, user_password FROM phpbb_users WHERE group_id='5' && username_clean='" .$username. "'";
  25.    
  26.     if(!$result = $mysqli->query($query)) {
  27.         die ($mysqli->error);
  28.     } else {
  29.         if($row_cnt = $result->num_rows == 0) {
  30.             echo ("Brak uzytkownika!");
  31.         } else {
  32.             $row = $result->fetch_assoc();
  33.            
  34.             if(phpbb_hash($userpassword) == $row['user_password']) {
  35.                 $_SESSION['id'] = $row['user_id'];
  36.             }
  37.         }
  38.     }
  39.     }
  40.    
  41.     if(!isset($_SESSION['id'])) {
  42.    
  43.         echo '<form method="post" action="index.php">
  44.         Zaloguj sie: <input type="text" name="username"/>
  45.        <input type="password" name="password"/>
  46.         <input type="submit" value="OK"/></form>';
  47.         exit;
  48.     }
  49.  
  50. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement