Advertisement
Guest User

Untitled

a guest
Aug 1st, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. <?
  2. $authorization = $_SERVER["HTTP_AUTHORIZATION"];
  3. $success = preg_match("/Basic ([a-zA-Z0-9\+\/=]+)/", $authorization, $matches);
  4.  
  5. $good_user = "Prueba";
  6. $good_password = "123";
  7.  
  8. if($success) {
  9.     $decoded = base64_decode($matches[1], true);
  10.     $parts = explode(':',$decoded);
  11.     $user = $parts[0];
  12.     $password = $parts[1];
  13.     if($user != $good_user || $password != $good_password){
  14.         http_response_code(401);
  15.     } else {
  16.         echo "User: $user \nPassword: $password";
  17.     }
  18.  
  19. } else {
  20.     http_response_code(401);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement