Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ($openid->validate()) {
- $id = $openid->identity;
- $ptn = "/^http:\/\/steamcommunity\.com\/openid\/id\/(7[0-9]{15,25}+)$/";
- preg_match($ptn, $id, $matches);
- $url = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=3221FA24CE20748290BD9DA9FA5FD385&steamids=$matches[1]";
- $json_object = file_get_contents($url);
- $json_decoded = json_decode($json_object);
- foreach ($json_decoded->response->players as $player) {
- $steamid = $player->steamid;
- $name = $player->personaname;
- $avatar = $player->avatar;
- }
- $hash = md5($steamid . time() . rand(1, 50));
- $sql = $db->query("SELECT * FROM `users` WHERE `steamid` = '" . $steamid . "'");
- $row = $sql->fetchAll(PDO::FETCH_ASSOC);
- if (count($row) == 0) {
- $db->exec("INSERT INTO `users` (`hash`, `steamid`, `name`, `avatar`) VALUES ('" . $hash . "', '" . $steamid . "', " . $db->quote($name) . ", '" . $avatar . "')");
- } else {
- $db->exec("UPDATE `users` SET `hash` = '" . $hash . "', `name` = " . $db->quote($name) . ", `avatar` = '" . $avatar . "' WHERE `steamid` = '" . $steamid . "'");
- }
- setcookie('hash', $hash, time() + 3600 * 24 * 7, '/');
- header('Location: http://www.erzis.ct8.pl/sets.php?id=' . $hash);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement