Advertisement
Guest User

Untitled

a guest
Aug 5th, 2015
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.04 KB | None | 0 0
  1. <?php
  2. ob_start();
  3. session_start();
  4. require ('openid.php');
  5.  
  6. function logoutbutton() {
  7.     echo "<form action=\"steamauth/logout.php\" method=\"post\"><input value=\"Logout\" type=\"submit\" /></form>"; //logout button
  8. }
  9.  
  10. function steamlogin()
  11. {
  12. try {
  13.     require("settings.php");
  14.     $openid = new LightOpenID($steamauth['domainname']);
  15.  
  16.     $button['small'] = "small";
  17.     $button['large_no'] = "large_noborder";
  18.     $button['large'] = "large_border";
  19.     $button = $button[$steamauth['buttonstyle']];
  20.    
  21.     if(!$openid->mode) {
  22.         if(isset($_GET['login'])) {
  23.             $openid->identity = 'http://steamcommunity.com/openid';
  24.             header('Location: ' . $openid->authUrl());
  25.         }
  26.  
  27.     return "<form action=\"?login\" method=\"post\"> <input type=\"image\" src=\"http://cdn.steamcommunity.com/public/images/signinthroughsteam/sits_".$button.".png\"></form>";
  28.     }
  29.  
  30.      elseif($openid->mode == 'cancel') {
  31.         echo 'User has canceled authentication!';
  32.     } else {
  33.         if($openid->validate()) {
  34.                 $id = $openid->identity;
  35.                 $ptn = "/^http:\/\/steamcommunity\.com\/openid\/id\/(7[0-9]{15,25}+)$/";
  36.                 preg_match($ptn, $id, $matches);
  37.              
  38.                 $_SESSION['steamid'] = $matches[1];
  39.  
  40.                 //Determine the return to page. We substract "login&"" to remove the login var from the URL.
  41.                 //"file.php?login&foo=bar" would become "file.php?foo=bar"
  42.                 $returnTo = str_replace('login&', '', $_GET['openid_return_to']);
  43.                 //If it didn't change anything, it means that there's no additionals vars, so remove the login var so that we don't get redirected to Steam over and over.
  44.                 if($returnTo === $_GET['openid_return_to']) $returnTo = str_replace('?login', '', $_GET['openid_return_to']);
  45.                 header('Location: '.$returnTo);
  46.         } else {
  47.                 echo "User is not logged in.\n";
  48.         }
  49.  
  50.     }
  51. } catch(ErrorException $e) {
  52.     echo $e->getMessage();
  53. }
  54. }
  55.  
  56. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement