SHARE
TWEET

Untitled

a guest Jun 15th, 2017 122 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     public function log_me_in($username, $password) {
  2.         global $ibd;
  3.        
  4.         // CONVERT TO ALL LOWERCASE
  5.         $username = strtolower($username);
  6.        
  7.         // MAKE USERNAME SAFE FOR DB CHECK
  8.         $username = $this->cleanString($username);
  9.        
  10.         // CONVERT TO ALL LOWERCASE
  11.         $password = strtolower($password);
  12.        
  13.         // MAKE PASSWORD SAFE FOR DB CHECK
  14.         $password = $this->cleanString($password);
  15.        
  16.         // ENCRYPT THE PASSWORD
  17.         $password = $this->salt($password);
  18.        
  19.         $query = $ibd -> ibd_select("*", TBL_LOGIN, "user='$username' AND pass='$password'", null, null);
  20.         $row = mysql_fetch_array($query);
  21.        
  22.         $details = mysql_fetch_array($this->get_user_details($row['id']));
  23.        
  24.         if (mysql_num_rows($query) == 0) {
  25.             $match = false;
  26.         } else {
  27.             $match = true;
  28.         }
  29.        
  30.         $agent = md5($_SERVER['HTTP_USER_AGENT']);
  31.        
  32.         $sess_array = array('id'=>$row['id'], 'name'=>$details['fname'] . ' ' . $details['lname'], 'user'=>$row['user'], 'pass'=>$row['pass'], 'level'=>$row['type'], 'agent'=>$agent, 'match'=>$match);
  33.        
  34.         return $sess_array;
  35.        
  36.     }
  37.    
  38.    
  39.     public function get_user_details($id) {
  40.         global $ibd;
  41.         if ($id == null) {
  42.             if ($_SESSION['id'] != null)
  43.                 $id = $_SESSION['id'];
  44.             //else
  45.                 //echo 'There was an error getting the user details.';
  46.                 //break;
  47.         }
  48.         $query = $ibd -> ibd_select("*", TBL_USERDETAILS, "uID='$id'", null, "1");
  49.         return $query;
  50.     }
  51.  
  52.  
  53.     public function is_user_logged_in() {
  54.         if (isset($_SESSION['user']) && ($_SESSION['agent'] == md5($_SERVER['HTTP_USER_AGENT']))) {
  55.             return true;
  56.         } else {
  57.             return false;
  58.         }
  59.     }
  60.  
  61.  
  62. session_name ('ibd_uID');
  63. session_start();
  64.  
  65. include ('global.php');
  66.  
  67. if (isset($_POST['admin_login'])) {
  68.    
  69.     $ref = $_POST['refURL'];
  70.  
  71.     $sess_array = $glbl->log_me_in($_POST['username'], $_POST['password']);
  72.    
  73.     foreach ($sess_array as $sess_name => $sess_key) {
  74.         $_SESSION[$sess_name] = $sess_key;
  75.     }
  76.    
  77.     if ($_SESSION['match'] != true) {
  78.         //$ref .= 'no_match/';
  79.         echo '<script type="text/javascript">alert(\'The username / password you entered were not found.  Please try again.\');</script>';
  80.         $glbl -> logHistory('User Login - FAILED - Incorrect username / password. (user entered: '.$_POST['username'].' / password entered: '.$_POST['password'].')');
  81.     } else {
  82.         $glbl -> logHistory('User Login - SUCCESSFULL');
  83.     }
  84.    
  85.     echo $glbl->redirectMe($ref);
  86.    
  87. }
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