Advertisement
Cherro

dwdwd

May 24th, 2017
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.42 KB | None | 0 0
  1. <?php
  2.  
  3.     require_once( "mta_sdk.php" );
  4.     //$input = mta::getInput();
  5.         //mta::doReturn($input[0] + $input[1]);
  6.    
  7.     $db_host = 'localhost';
  8.     $db_user = 'root';
  9.     $db_pass = 'haslodobazy';
  10.     $db_name = 'lslife';
  11.    
  12.    
  13.    
  14.    
  15. function dbInit()
  16. {
  17.     global $db_host,$db_name,$db_pass,$db_user;
  18.     try
  19.     {
  20.    
  21.         $db = new PDO("mysql:host=".$db_host.";dbname=".$db_name."", $db_user, $db_pass);
  22.         $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  23.         $db->query('SET NAMES utf8');
  24.        
  25.     }
  26.    
  27.     catch(PDOException $e)
  28.     {
  29.         echo $e->getMessage();
  30.     }
  31.    
  32.    $GLOBALS['db']=$db;
  33.     return $db;
  34. }
  35.  
  36.  
  37.  
  38. function authorization($login,$pass)
  39. {
  40.  
  41.    
  42.     dbInit();
  43.     global $db;
  44.     $query = "SELECT members_pass_salt as salt,members_pass_hash as pass FROM fg_core_members WHERE name=:nick";
  45.     $result = $db->prepare($query);
  46.     $result->bindParam(':nick',$login);
  47.     $result->execute();
  48.     $count = $result->rowCount();
  49.     if($count==0)
  50.     {
  51.         echo "false";
  52.     }
  53.     else
  54.     {
  55.             $result = $result->fetchAll(PDO::FETCH_ASSOC);
  56.             $password = crypt( $pass, '$2a$13$' . $result[0]['salt'] );
  57.                 if($password==$result[0]['pass'])
  58.                 {
  59.                         echo "true";
  60.                 }
  61.                 else
  62.                 {
  63.                         echo "false";
  64.                 }
  65.    
  66.     }
  67.  
  68. }
  69.  
  70.  
  71. if(!empty($_POST['usr'])&& !empty($_POST['pass']))
  72. {
  73.     $usr = $_POST['usr'];
  74.     $pass = $_POST['pass'];
  75.     authorization($usr,$pass);
  76. }
  77.  
  78.  
  79. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement