Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $apiKey = "41A4485DDA5F97E5E31B8BC05EC091E4";
- $steam=$_GET['stid'];
- $info = "";
- if (empty($steam)) {
- $info="ERR_EMPTY";
- } else if (preg_match('/^STEAM_0:[01]:[0-9]{2,12}$/', $steam)) {
- $steam64 = st32to64($steam);
- $jsonURL = $steam64;
- $steam32 = $steam;
- } else if (preg_match('/^http:\/\/steamcommunity.com\/profiles\/\d{17}$/', $steam)) {
- preg_match('/^http:\/\/steamcommunity.com\/profiles\/(\d{17})$/', $steam,$steam);
- $steam32 = st64to32($steam[1]);
- $jsonURL = $steam[1];
- }
- else if (preg_match('/^\d{17}$/', $steam)) {
- $steam32 = st64to32($steam);
- $jsonURL = $steam;
- } else {
- if(empty($info)){
- $info='ERR_NOT_VALID';
- }
- }
- function st32to64($steam_id)
- {
- list( , $m1, $m2) = explode(':', $steam_id, 3);
- list($steam_cid, ) = explode('.', bcadd((((int) $m2 * 2) + $m1), '76561197960265728'), 2);
- return $steam_cid;
- }
- function st64to32($steam_cid)
- {
- $id = array('STEAM_0');
- $id[1] = substr($steam_cid, -1, 1) % 2 == 0 ? 0 : 1;
- $id[2] = bcsub($steam_cid, '76561197960265728');
- if(bccomp($id[2], '0') != 1)
- {
- return false;
- }
- $id[2] = bcsub($id[2], $id[1]);
- list($id[2], ) = explode('.', bcdiv($id[2], 2), 2);
- return implode(':', $id);
- }
- if($jsonURL){
- $json = file_get_contents("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=$apiKey&steamids=$jsonURL&format=json");
- $json = json_decode($json,true);
- $userdata = $json['response']['players'][0];
- if(empty($userdata)){
- if(empty($info)){
- $info='ERR_PROFILE_NOT_FOUND';
- }
- }
- }
- if(empty($info)){
- $info='VALID';
- }
- echo $info;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement