load->view('header', ['active' => 'csgo', 'title' => 'CS:GO Tools', 'additionalStyles' => ['csgo.css']]); $this->load->view('tools/csgo', ['user' => $user]); $this->load->view('footer', ['additionalScripts' => ['lib/nanobar.min.js', 'csgo.js']]); } public function data($user) { $data = simplexml_load_string(file_get_contents('http://steamcommunity.com/id/' . $user . '/?xml=1')); $a['player_exists'] = true; $a['player_owns_game'] = true; $a['id64'] = (string)$data->steamID64; $a['id'] = (string)$data->steamID; $a['name'] = (string)$data->realname; $a['location'] = (string)$data->location; $a['onStat'] = (string)$data->onlineState; $a['statusMes'] = (string)$data->stateMessage; $a['avatar'] = (string)$data->avatarFull; $a['vacban'] = (string)$data->vacBanned; $a['tradeban'] = (string)$data->tradeBanState; if($a['id'] == "") { $a['player_exists'] = false; $a['player_owns_game'] = false; echo json_encode($a); exit; } $status = ['in-game' => 'In Game', 'online' => 'Online', 'offline' => 'Offline', 'busy' => 'Busy', 'away' => 'Away']; $a['status'] = $status[$a['onStat']]; $successful = file_get_contents('http://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v0002/?appid=730&key=79E0709F4D4157636A833312C91639FC&steamid=' . $a['id64'], true); if($successful == false) { goto go_on; } $data = json_decode($successful, true)['playerstats']; $stats = $data['stats']; $kills = []; foreach ($stats as $stat) { $a[$stat['name']] = $stat['value']; if (strpos($stat['name'], 'total_kills_') !== false && !in_array($stat['name'], ['total_kills_headshot', 'total_kills_enemy_weapon', 'total_kills_enemy_blinded', 'total_kills_knife_fight', 'total_kills_against_zoomed_sniper'])) { $kills[] = $stat['value'] . '_' . explode('_', $stat['name'])[2]; } } natsort($kills); $a['kills'] = array_reverse($kills); if ($a['last_match_wins'] > $a['last_match_rounds'] / 2) { $a['last_match_end_status'] = 2; } elseif ($a['last_match_wins'] < $a['last_match_rounds'] / 2) { $a['last_match_end_status'] = 0; } else { $a['last_match_end_status'] = 1; } if(isset($data['achievements'])) { $ach = $data['achievements']; foreach ($ach as $entry) { $a[$entry['name']] = $entry['achieved']; } $a['total_time_played'] = round($a['total_time_played'] / 60 / 60); } else { $a['player_owns_game'] = false; } go_on: $data = json_decode(file_get_contents('http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=79E0709F4D4157636A833312C91639FC&steamids=' . $a['id64']), true)['response']; $data = $data['players']; $data = $data[0]; $a['lastseen'] = $data['lastlogoff']; $a['url'] = $data['profileurl']; $a['created'] = $data['timecreated']; $a['country'] = $data['loccountrycode']; $a['weapon_list'] = [ 1 => ["Desert Eagle", "deagle"], 2 => ["Dual Berettas", "elite"], 3 => ["Five-SeveN", "fiveseven"], 4 => ["Glock-18", "glock"], 7 => ["AK-47", "ak47"], 8 => ["AUG", "aug"], 9 => ["AWP", "awp"], 10 => ["FAMAS", "famas"], 11 => ["G3SG1", "g3sg1"], 13 => ["Galil AR", "galilar"], 14 => ["M249", "m249"], 16 => ["M4A4", "m4a4"], 17 => ["MAC-10", "mac10"], 19 => ["P90", "p90"], 24 => ["UMP-45", "ump45"], 25 => ["XM1014", "xm1014"], 26 => ["PP-Bizon", "bizon"], 27 => ["MAG-7", "mag7"], 28 => ["Negev", "negev"], 29 => ["Sawed-Off", "sawedoff"], 30 => ["Tec-9", "tec9"], 31 => ["Zeus x27", "taser"], 32 => ["P2000", "hkp2000"], 33 => ["MP7", "m79"], 34 => ["MP9", "mp9"], 35 => ["Nova", "nova"], 36 => ["P250", "p250"], 38 => ["SCAR-20", "scar20"], 39 => ["SG 553", "sg556"], 40 => ["SSG 08", "ssg08"], 42 => ["Knife", "knife_ct"], 43 => ["Flashbang", "flashbang"], 44 => ["High Explosive Grenade", "hegrenade"], 45 => ["Smoke Grenade", "smokegrenade"], 46 => ["Molotov", "molotov"], 47 => ["Decoy Grenade", "decoy"], 48 => ["Incendiary Grenade", "incgrenade"], 59 => ["Knife", "knife"], 60 => ["M4A1-S", "m4a1"], 61 => ["USP-S", "usp"], 63 => ["CZ75-Auto", "cz75"], 64 => ["R8 Revolver", "deagle"], ]; if(isset($a['total_kills_headshot'])) { $a['total_headshot_rate'] = number_format( $a['total_kills_headshot'] / $a['total_kills'] * 100, 1, lang('csgo_comma'), lang('csgo_point')) . " %"; $a['total_kills'] = number_format($a['total_kills'], 0, lang('csgo_comma'), lang('csgo_point')); $a['total_time_played'] = number_format($a['total_time_played'], 0, lang('csgo_comma'), lang('csgo_point')) . " h"; $a['total_accuracy'] = number_format($a['total_shots_hit'] / $a['total_shots_fired'] * 100, 1, lang('csgo_comma'), lang('csgo_point')) . " %"; $a['total_mvps'] = number_format($a['total_mvps'], 0, lang('csgo_comma'), lang('csgo_point')); $a['total_win_rate'] = number_format($a['total_wins'] / $a['total_rounds_played'] * 100, 1, lang('csgo_comma'), lang('csgo_point')) . " %"; $a['total_planted_bombs'] = number_format($a['total_planted_bombs'], 0, lang('csgo_comma'), lang('csgo_point')); $a['total_rescued_hostages'] = number_format($a['total_rescued_hostages'], 0, lang('csgo_comma'), lang('csgo_point')); $a['last_match_result'] = $a['last_match_end_status'] == 2 ? 'win' : ''; $a['last_match_outcome'] = lang('csgo_' . $a['last_match_end_status']); $a['last_match_favweapon_accuracy'] = number_format($a['last_match_favweapon_hits'] / $a['last_match_favweapon_shots'] * 100, 1, lang('csgo_comma'), lang('csgo_point')); $a['last_match_kd'] = number_format($a['last_match_kills'] / $a['last_match_deaths'], 2, lang('csgo_comma'), lang('csgo_point')); $a['last_match_kills'] = number_format($a['last_match_kills'], 0, lang('csgo_comma'), lang('csgo_point')); $a['last_match_deaths'] = number_format($a['last_match_deaths'], 0, lang('csgo_comma'), lang('csgo_point')); $a['last_match_mvps'] = number_format($a['last_match_mvps'], 0, lang('csgo_comma'), lang('csgo_point')); $a['last_match_damage'] = number_format($a['last_match_damage'], 0, lang('csgo_comma'), lang('csgo_point')); $a['last_match_money_spent'] = number_format($a['last_match_money_spent'], 0, lang('csgo_comma'), lang('csgo_point')); $a['last_match_dominations'] = number_format($a['last_match_dominations'], 0, lang('csgo_comma'), lang('csgo_point')); $a['last_match_revenges'] = number_format($a['last_match_revenges'], 0, lang('csgo_comma'), lang('csgo_point')); $a['last_match_contribution_score'] = number_format($a['last_match_contribution_score'], 0, lang('csgo_comma'), lang('csgo_point')); $a['favweapons'] = ''; for ($i = 0; $i < 5; $i++) { $weapon = $a['kills'][$i]; $killCount = explode('_', $weapon)[0]; $weaponName = explode('_', $weapon)[1]; $a['favweapons'] .= '
  • ' : 'line">'; $a['favweapons'] .= '

    ' . ($i + 1); if ($i > 0) { $a['favweapons'] .= '. '; } $a['favweapons'] .= ' ' . $weaponName . '

    '; if ($i == 0) { $a['favweapons'] .= ''; } else { $a['favweapons'] .= ' '; } $a['favweapons'] .= '

    ' . $killCount . '

  • '; } $a['total_deaths'] = number_format($a['total_deaths'], 0, lang('csgo_comma'), lang('csgo_point')); $a['total_kd'] = number_format($a['total_kills'] / $a['total_deaths'], 2, lang('csgo_comma'), lang('csgo_point')); $a['total_contribution_score'] = number_format($a['total_contribution_score'], 0, lang('csgo_comma'), lang('csgo_point')); $a['total_damage_done'] = number_format($a['total_damage_done'], 0, lang('csgo_comma'), lang('csgo_point')) . ' HP'; $a['total_shots_fired'] = number_format($a['total_shots_fired'], 0, lang('csgo_comma'), lang('csgo_point')); $a['total_shots_hit'] = number_format($a['total_shots_hit'], 0, lang('csgo_comma'), lang('csgo_point')); $a['total_kills_headshot'] = number_format($a['total_kills_headshot'], 0, lang('csgo_comma'), lang('csgo_point')); $a['total_dominations'] = number_format($a['total_dominations'], 0, lang('csgo_comma'), lang('csgo_point')); $a['total_revenges'] = number_format($a['total_revenges'], 0, lang('csgo_comma'), lang('csgo_point')); $a['total_matches_played'] = number_format($a['total_matches_played'], 0, lang('csgo_comma'), lang('csgo_point')); $a['total_matches_won'] = number_format($a['total_matches_won'], 0, lang('csgo_comma'), lang('csgo_point')); $a['total_matches_won_percent'] = number_format($a['total_matches_won'] / $a['total_matches_played'] * 100, 2, lang('csgo_comma'), lang('csgo_point')) . ' %'; $a['total_rounds_played'] = number_format($a['total_rounds_played'], 0, lang('csgo_comma'), lang('csgo_point')); $a['total_wins'] = number_format($a['total_wins'], 0, lang('csgo_comma'), lang('csgo_point')); $a['total_wins_pistolround'] = number_format($a['total_wins_pistolround'], 0, lang('csgo_comma'), lang('csgo_point')); $a['total_defused_bombs'] = number_format($a['total_defused_bombs'], 0, lang('csgo_comma'), lang('csgo_point')); $a['total_rescued_hostages'] = number_format($a['total_rescued_hostages'], 0, lang('csgo_comma'), lang('csgo_point')); $a['total_kills_enemy_blinded'] = number_format($a['total_kills_enemy_blinded'], 0, lang('csgo_comma'), lang('csgo_point')); $a['total_kills_knife_fight'] = number_format($a['total_kills_knife_fight'], 0, lang('csgo_comma'), lang('csgo_point')); $a['total_kills_against_zoomed_sniper'] = number_format($a['total_kills_against_zoomed_sniper'], 0, lang('csgo_comma'), lang('csgo_point')); $a['total_kills_taser'] = number_format($a['total_kills_taser'], 0, lang('csgo_comma'), lang('csgo_point')); $a['total_kills_enemy_weapon'] = number_format($a['total_kills_enemy_weapon'], 0, lang('csgo_comma'), lang('csgo_point')); $a['total_money_earned'] = number_format($a['total_money_earned'], 0, lang('csgo_comma'), lang('csgo_point')) . ' $'; $a['total_weapons_donated'] = number_format($a['total_weapons_donated'], 0, lang('csgo_comma'), lang('csgo_point')); $a['total_broken_windows'] = number_format($a['total_broken_windows'], 0, lang('csgo_comma'), lang('csgo_point')); } else { $a['player_owns_game'] = false; } header('Content-Type: application/json'); echo json_encode($a); } public function getDefaultPage($user) { $this->load->view('csgo-tools', ['user' => $user]); } }