• SteamID to Community ID.
    8 replies, posted
I was working on a web page for my admin mod in garry's mod. I looked around trying to find a reliable formula to convert steam id to community id but was unable to find one that worked when I adapted it. I searched and found one on facepunch but didn't work for me. If anyone has a link or the code I would deeply be thankful.
[url]http://www.phpfreaks.com/forums/php-coding-help/steamid-gt-steam-community-id/[/url]
I use something like the following. Extract what you need. [php] <form method="get" action=""> <div> <fieldset> <legend>Input</legend> <table> <tbody> <tr> <td>SteamID (eg: STEAM_0:1:21603250)<br>Community URL (eg: http://steamcommunity.com/id/cherry_jimbo/ <b>or</b> http://steamcommunity.com/profiles/76561198003472229)<br> <input type="text" size="70" name="s" value="<?php echo htmlentities(stripslashes($_GET['s']),ENT_QUOTES); ?>"> </td> </tr> <tr> <td align="right"> <input class="button" type="submit" accesskey="s" value="Submit"> </td> </tr> </tbody> </table> </fieldset> </div> </form> <?php $ret=get_input_type($_GET['s']); if ($ret==''){ }else if (is_string($ret)){ echo '<div><fieldset><legend>Output</legend><table><tbody><tr><td>'; echo $ret; echo '</td></tr></tbody></table></fieldset>'; if ($_GET['s']!=='') { echo $notice; } echo '</div>'; }else if (is_array($ret)){ echo '<div><fieldset><legend>Output</legend><table><tbody><tr><td>'; convert($ret['type'],$ret['data']); echo '</td></tr></tbody></table></fieldset>'; if ($_GET['s']!=='') { echo $notice; } echo '</div>'; } function convert($type,$data){ switch($type){ case 'steamid': $main='http://steamcommunity.com/profiles/'.bcadd((($data['auth']*2)+$data['server']),'76561197960265728'); echo 'FriendID: <a href="'.$main.'" target="blank">'.bcadd((($data['auth']*2)+$data['server']),'76561197960265728').'</a>'; break; case 'friendid': if (substr($data,-1)%2==0) $server=0; else $server=1; $auth=bcsub($data,'76561197960265728'); if (bccomp($auth,'0')!=1) {echo "Error: invalid CommunityURL or SteamID";return;} $auth=bcsub($auth,$server); $auth=bcdiv($auth,2); echo 'SteamID: STEAM_0:'.$server.':'.$auth; break; } } function get_input_type($data){ $data=strtolower(trim($data)); if ($data!='') { if (strlen($data)>80) return "too long"; if (substr($data,0,7)=='steam_0') { $tmp=explode(':',$data); if ((count($tmp)==3) && is_numeric($tmp[1]) && is_numeric($tmp[2])){ return array('type'=>'steamid','data'=>array('auth'=>$tmp[2],'server'=>$tmp[1])); }else{ return "Error: invalid SteamID"; } }else if ($p=strrpos($data,'/')){ $tmp=explode('/',$data); foreach ($tmp as $item){ if (is_numeric($item)){ $a=$item; break; } } if ((is_numeric($a)) && (ereg('7656119', $a))) return array('type'=>'friendid','data'=>$a); else { $xml = @simplexml_load_file($data."?xml=1"); $steamid64=$xml->steamID64; if (!ereg('7656119', $steamid64)) return "Error: invalid link"; else return array('type'=>'friendid','data'=>$steamid64); } }else if ((is_numeric($data)) && (ereg('7656119', $a))){ return array('type'=>'friendid','data'=>$data); }else{ $xml = @simplexml_load_file("http://steamcommunity.com/id/".$data."?xml=1"); $steamid64=$xml->steamID64; if (!ereg('7656119', $steamid64)) return "Error: invalid input"; else return array('type'=>'friendid','data'=>$steamid64); } }else{ return ""; } } ?> [/php]
[code] $steamId = $row['steamid']; $gameType = 0; $authServer = 0; $steamId = str_replace('STEAM_', '' ,$steamId); $parts = explode(':', $steamId); $gameType = $parts[0]; $authServer = $parts[1]; $clientId = $parts[2]; $res = bcadd((bcadd('76561197960265728', $authServer)), (bcmul($clientId, '2'))); $cid = str_replace('.0000000000', '', $res); $url = 'http://www.steamcommunity.com/profiles/'; //<a href={$url}{$cid}>{$row['steamid']}</a> // Heres what you need after you've query'd and converted there steam id. [/code] Thanks for the help here's code I used/modified. Also ban page coming along nicely. Just need to style it. [media]http://i53.tinypic.com/103wy6t.png[/media]
Nah man they both tried to leak my gamemode by black mailing me with a rar file containing my gamemode with a exe which was a worm. Flapjack(Flapdar) and Chief tiger saw the shit go down. There's a couple posts of me and him going at it yesterday. He also sent me a PM on FP. [QUOTE=Kopimi]Hey Mate, I know you're probably a little bit butthurt about the fact that my Jailbreak server is more popular than yours, but DDoSing it is for babies. So I've decided if you guys at Original Babies DDoS again, I'll go ahead and release your gamemode. [url]http://filesmelt.com/dl/OG_Jail.zip[/url] Sandbox derived, really? Your Friend, Kopimi[/QUOTE] That is my game mode missing bunch of files. Caution it contains a worm.
Probably should snip the link just to be safe. Mods ban for malicious links, even if you have a warning.
[url]http://forums.alliedmods.net/showthread.php?t=60899[/url] Edit: Oh I'm late.
Sorry, you need to Log In to post a reply to this thread.