Advertisement
Guest User

Untitled

a guest
Jan 19th, 2014
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.00 KB | None | 0 0
  1. <?php
  2. ob_start();
  3. session_start();
  4. /////////////////////////////////////////
  5. ////////PUDS Config Installer////////////
  6. //////Configuration//////////////////////
  7. //Steam API Key//////////////////////////
  8. $_STEAMAPI = "6ADF5081CA454CF75F8F3848F80FB91F";
  9. /////////////////////////////////////////
  10. require("openid.php");
  11. require("admin.php");
  12. ?>
  13. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  14. <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
  15. <head>
  16. <link rel="stylesheet" type="text/css" href="style.css">
  17. <title>PUDS Donation System</title>
  18. </head>
  19. <body>
  20. <div id="header">
  21. <h1>PayPay-ULX Donation System Config Installer</h1>
  22. </div>
  23. <?php
  24. function curDomain() {
  25. $pageURL = 'http';
  26. if ($_SERVER["HTTPS"] == "on") {
  27. $pageURL .= "s";
  28. }
  29. $pageURL .= "://";
  30. if ($_SERVER["SERVER_PORT"] != "80") {
  31. $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"];
  32. } else {
  33. $pageURL .= $_SERVER["SERVER_NAME"];
  34. }
  35. return $pageURL;
  36. }
  37. //Gets the current Directory
  38. function curDirectory() {
  39. $current_dir_url = 'http';
  40. if ($_SERVER["HTTPS"] == "on") {
  41. $pageURL .= "s";
  42. }
  43. $current_dir_url .= "://";
  44. if ($_SERVER["SERVER_PORT"] != "80") {
  45. $current_dir_url .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"];
  46. } else {
  47. $current_dir_url .= $_SERVER["SERVER_NAME"];
  48. }
  49. $current_dir_url .= dirname($_SERVER['PHP_SELF']);
  50. return $current_dir_url;
  51. }
  52. function GetSteamNorm($Steam64){
  53.  
  54. $authserver = bcsub( $Steam64, '76561197960265728' ) & 1;
  55. //Get the third number of the steamid $authid = ( bcsub( $Steam64, '76561197960265728' ) - $authserver ) / 2;
  56. //Concatenate the STEAM_ prefix and the first number, which is always 0, as well as colons with the other two numbers $steamid = "STEAM_0:$authserver:$authid";
  57. return $steamid;
  58. }
  59. $curdirectory = curDirectory();
  60. $curdomain = curDomain();
  61.  
  62. if(empty($_STEAMAPI)) {
  63. echo "<h1>You have not configured PUDS installer correctly! Please edit login.php and put your Steam API Key in the top of the file and try again!</h1>";
  64. } else {
  65. if (!isset($_SESSION['id'])){
  66. echo "
  67. <p>Please login to configure Wullys PayPal-ULX Donation System</p>
  68. <form action='?login' method='post'>
  69. <input type='image' src='http://cdn.steamcommunity.com/public/images/signinthroughsteam/sits_small.png'>
  70. </form>
  71. <h2>Instructions for use:</h2>
  72. <p>Sign in through steam. If you are the first user it will make you admin.</p>
  73. <p>You will be told your not admin, Log out then Log in again to be authenticated as admin.</p>";
  74.  
  75. try {
  76. $openid = new LightOpenID($curdomain);
  77. if(!$openid->mode){
  78. if(isset($_GET['login'])) {
  79. $openid->identity = 'http://steamcommunity.com/openid/?l=english';
  80. // This is forcing english because it has a weird habit of selecting a random language otherwise
  81. header('Location: ' . $openid->authUrl());
  82. }
  83. } elseif($openid->mode == 'cancel') {
  84. echo 'User has canceled authentication!';
  85. } else {
  86. if($openid->validate()) {
  87. $id = $openid->identity;
  88. // identity is something like: http://steamcommunity.com/openid/id/76561197960435530
  89. // we only care about the unique account ID at the end of the URL.
  90. $ptn = "/^http:\/\/steamcommunity\.com\/openid\/id\/(7[0-9]{15,25}+)$/";
  91. preg_match($ptn, $id, $matches);
  92. echo "User is logged in (steamID: $matches[1])\n";
  93. $url = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=$_STEAMAPI&steamids=$matches[1]";
  94. $json_object= file_get_contents($url);
  95. $json_decoded = json_decode($json_object);
  96. foreach ($json_decoded->response->players as $player){
  97. /*echo "
  98. <br/>Player ID: $player->steamid
  99. <br/>Player Name: $player->personaname
  100. <br/>Profile URL: $player->profileurl
  101. <br/>SmallAvatar: <img src='$player->avatar'/>
  102. <br/>MediumAvatar: <img src='$player->avatarmedium'/>
  103. <br/>LargeAvatar: <img src='$player->avatarfull'/>";
  104. echo "<br/>SmallAvatar: <img src='$player->avatar'/>";
  105. */
  106. $steam64 = $player->steamid;
  107. $steamID = GetSteamNorm($steam64);
  108.  
  109. //Get players ingame name
  110. $_SESSION['id'] = $steam64;
  111. $_SESSION['sid'] = $steamID;
  112. $_SESSION['name'] = $player->personaname;
  113. $_SESSION['mAvatar'] = $player->avatarmedium;
  114. $_SESSION['steamAPI'] = $_STEAMAPI;
  115. if(empty($admin)){
  116. $str = "<?php \$admin = '$steam64';?>";
  117. $fp = FOPEN("admin.php", "w");
  118. FWRITE($fp, $str);
  119. FCLOSE($fp);
  120. echo "<p> Successfully made $friendlyName an admin!</p>";
  121. header("Location: $curdirectory/logout.php");
  122. }
  123. if($steam64 == $admin){
  124. $_SESSION['admin'] = True;
  125. } else {
  126. $_SESSION['admin'] = False;
  127. }
  128. }
  129. header("Location: $curdirectory/install.php");
  130. }
  131. }
  132. } catch(ErrorException $e) {
  133. echo $e->getMessage();
  134. }
  135. } else {
  136.  
  137. }
  138. }
  139. ?>
  140. </body>
  141. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement