hlsdk

steamid

Jul 24th, 2010
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.56 KB | None | 0 0
  1. <html><body>
  2. <?php
  3.  
  4. //http://steamcommunity.com/profiles/123
  5. //http://us3.php.net/bc
  6.  
  7. //http://www.joe.to/moo/sid_convert.php
  8.  
  9. //ini_set('error_reporting', E_ALL);
  10. //ini_set('display_errors', 1);
  11.  
  12. set_time_limit(3);
  13.  
  14. //http://forums.alliedmods.net/showthread.php?t=60899
  15. function GetFriendID($pszAuthID)
  16. {
  17.  
  18.     $iServer = "0";
  19.     $iAuthID = "0";
  20.    
  21.     $szAuthID = $pszAuthID;
  22.    
  23.     $szTmp = strtok($szAuthID, ":");
  24.    
  25.     while(($szTmp = strtok(":")) !== false)
  26.     {
  27.         $szTmp2 = strtok(":");
  28.         if($szTmp2 !== false)
  29.         {
  30.             $iServer = $szTmp;
  31.             $iAuthID = $szTmp2;
  32.         }
  33.     }
  34.     if($iAuthID == "0")
  35.         return "0";
  36.  
  37.     $i64friendID = bcmul($iAuthID, "2");
  38.  
  39.     //Friend ID's with even numbers are the 0 auth server.
  40.     //Friend ID's with odd numbers are the 1 auth server.
  41.     $i64friendID = bcadd($i64friendID, bcadd("76561197960265728", $iServer));
  42.    
  43.     return $i64friendID;
  44. }
  45. function GetAuthID($i64friendID)
  46. {
  47.     $tmpfriendID = $i64friendID;
  48.     $iServer = "1";
  49.     if(bcmod($i64friendID, "2") == "0")
  50.     {
  51.         $iServer = "0";
  52.     }
  53.     $tmpfriendID = bcsub($tmpfriendID,$iServer);
  54.     if(bccomp("76561197960265728",$tmpfriendID) == -1)
  55.         $tmpfriendID = bcsub($tmpfriendID,"76561197960265728");
  56.     $tmpfriendID = bcdiv($tmpfriendID, "2");
  57.     return ("STEAM_0:" . $iServer . ":" . $tmpfriendID);
  58. }
  59.  
  60. function AtoF_callback($matches)
  61. {
  62.     return '<a href="http://steamcommunity.com/profiles/'.GetFriendID($matches[0]).'">'.$matches[0].'</a>';
  63. }
  64.  
  65. function FtoA_callback($matches)
  66. {
  67.     $trimmed = trim($matches[0], ":]'\"");
  68.     return GetAuthID($trimmed);
  69. }
  70.  
  71. if(isset($_POST['message']) && strlen($_POST['message']) > 0)
  72. {
  73.     $message = $_POST['message'];
  74.  
  75.     $message = htmlentities($message);
  76.    
  77.     $message = preg_replace_callback("/STEAM_\d*:\d*:\d*/i",
  78.                 "AtoF_callback", $message);
  79.  
  80.     $message = preg_replace("/\n/","<br>",$message);
  81.     echo $message;
  82.    
  83. }
  84.  
  85. if(isset($_POST['message2']) && strlen($_POST['message2']) > 0)
  86. {
  87.     $message = $_POST['message2'];
  88.    
  89.     $message = htmlentities($message);
  90.  
  91.     $message = preg_replace_callback("/:\d*\]/",
  92.                 "FtoA_callback", $message);
  93.  
  94.     $message = preg_replace("/\n/","<br>",$message);
  95.     echo $message;
  96.    
  97. }
  98.  
  99. ?>
  100.  
  101. <form style="display: inline;" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" target="_self">
  102. <p>
  103. SteamID to link<br><textarea name="message" wrap=""></textarea><br>
  104. FriendID(format :N] ) to SteamID, use src of group front page<br><textarea name="message2" wrap=""></textarea><br>
  105. </p>
  106. <input type="submit">
  107. </form>
  108.  
  109. </body></html>
Add Comment
Please, Sign In to add comment