-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.old
170 lines (122 loc) · 5.99 KB
/
index.old
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<html>
<body>
<form method="post" action="">
<table border="0">
<tr><td> Steam Community Path:</td><td> <input type="text" name="path" /></td></tr>
<tr><td> <input type="submit" name="submit" value="Submit" /></td><td><input type="reset" value="Clear" /></td></tr>
</table>
</form>
</body>
</html>
<?php
function strip_cdata($string)
{
preg_match_all('/<!\[cdata\[(.*?)\]\]>/is', $string, $matches);
return str_replace($matches[0], $matches[1], $string);
}
if(isset($_POST['submit'])) {
include_once('config.php');
$dbhost = $config['dbhost'];
$dbuser = $config['dbuser'];
$dbpw = $config['dbpw'];
$apiKey = "4025BCF7889FDAE9DC651ECE0EC4022E";
$path = $_REQUEST['path'];
$xml = simplexml_load_file("http://steamcommunity.com/id/".$path."/?xml=1");
$steamID = $xml->steamID64;
if($steamID != ""){
$xmldeep = simplexml_load_file("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=".$apiKey."&steamids=".$steamID."&format=xml");
$dbh = new PDO("mysql:host=".$dbhost.";dbname=progressbar", $dbuser, $dbpw);
echo "Connected to database.<br>";
$stmt = $dbh->prepare("SELECT `steam_id` FROM `users` WHERE `steam_id` = :steamID");
$stmt->bindValue(":steamID", $steamID);
$stmt->execute();
print_r($stmt->rowCount());
if($stmt->rowCount() == 0) {
echo "<br><br>This is a new user! <br><br>";
$steam_name = strip_cdata($xml->steamID);
$steam_realname = $xmldeep->players->player->realname;
$steam_avatar = strip_cdata($xml->avatarIcon);
$steam_avatar_med = strip_cdata($xml->avatarMedium);
$steam_avatar_full = strip_cdata($xml->avatarFull);
$steam_customURL = strip_cdata($xml->customURL);
$steam_membersince = $xmldeep->players->player->timecreated;
$steam_lastlogoff = $xmldeep->players->player->lastlogoff;
$steam_loc_country = $xmldeep->players->player->loccountrycode;
$steam_loc_state = $xmldeep->players->player->locstatecode;
$steam_loc_cityid = $xmldeep->players->player->loccityid;
echo "Name: ".$steam_name." <br>";
echo "Steam ID: ".$steamID." <br>";
echo "Real Name: ".$steam_realname." <br>";
echo "Last Log Off: ".$steam_lastlogoff." <br><br>";
try {
$qry = "INSERT INTO `users` (`name`,`steam_id`,`steam_name`,`steam_realname`,`steam_customurl`,`steam_avatar`,`steam_avatar_med`,`steam_avatar_full`,`steam_loc_country`, `steam_loc_state`,`steam_loc_cityid`,`steam_lastlogoff`,`steam_membersince`) VALUES (:name,:steam_id,:steam_name,:steam_realname,:steam_customurl,:steam_avatar,:steam_avatar_med,:steam_avatar_full,:steam_loc_country, :steam_loc_state,:steam_loc_cityid,FROM_UNIXTIME(:steam_lastlogoff),FROM_UNIXTIME(:steam_membersince))";
$sql = $dbh->prepare($qry);
$sql->bindValue(':name', $steam_name);
$sql->bindValue(':steam_id', $steamID);
$sql->bindValue(':steam_name', $steam_name);
$sql->bindValue(':steam_realname', $steam_realname);
$sql->bindValue(':steam_customurl', $steam_customURL);
$sql->bindValue(':steam_avatar', $steam_avatar);
$sql->bindValue(':steam_avatar_med', $steam_avatar_med);
$sql->bindValue(':steam_avatar_full', $steam_avatar_full);
$sql->bindValue(':steam_loc_country', $steam_loc_country);
$sql->bindValue(':steam_loc_state', $steam_loc_state);
$sql->bindValue(':steam_loc_cityid', $steam_loc_cityid);
$sql->bindValue(':steam_lastlogoff', $steam_lastlogoff);
$sql->bindValue(':steam_membersince', $steam_membersince);
$sql->execute();
echo "Inserted into DB!<br>";
print_r($sql);
$dhb = null;
}
catch(PDOException $e) {
echo $e->getMessage();
}
} else {
echo "<br><br>Existing user!<br>";
echo "Attempting to update information";
$steam_name = strip_cdata($xml->steamID);
$steam_realname = $xmldeep->players->player->realname;
$steam_avatar = strip_cdata($xml->avatarIcon);
$steam_avatar_med = strip_cdata($xml->avatarMedium);
$steam_avatar_full = strip_cdata($xml->avatarFull);
$steam_customURL = strip_cdata($xml->customURL);
$steam_membersince = $xmldeep->players->player->timecreated;
$steam_lastlogoff = $xmldeep->players->player->lastlogoff;
$steam_loc_country = $xmldeep->players->player->loccountrycode;
$steam_loc_state = $xmldeep->players->player->locstatecode;
$steam_loc_cityid = $xmldeep->players->player->loccityid;
echo "Name: ".$steam_name." <br>";
echo "Steam ID: ".$steamID." <br>";
echo "Real Name: ".$steam_realname." <br>";
echo "Last Log Off: ".$steam_lastlogoff." <br><br>";
try {
$qry = "UPDATE `users` SET `name`=':name',`steam_name`=':steam_name',`steam_realname`=':steam_realname',`steam_customurl`=':steam_customurl',`steam_avatar`=':steam_avatar',`steam_avatar_med`=':steam_avatar_med',`steam_avatar_full`=':steam_avatar_full',`steam_loc_country`=':steam_loc_country', `steam_loc_state`=':steam_loc_state',`steam_loc_cityid`=':steam_loc_cityid',`steam_lastlogoff`=FROM_UNIXTIME(':steam_lastlogoff'),`steam_membersince`=FROM_UNIXTIME(':steam_membersince') WHERE `steam_id`=':steam_id'";
$sql = $dbh->prepare($qry);
$sql->bindValue(':name', $steam_name);
$sql->bindValue(':steam_id', $steamID);
$sql->bindValue(':steam_name', $steam_name);
$sql->bindValue(':steam_realname', $steam_realname);
$sql->bindValue(':steam_customurl', $steam_customURL);
$sql->bindValue(':steam_avatar', $steam_avatar);
$sql->bindValue(':steam_avatar_med', $steam_avatar_med);
$sql->bindValue(':steam_avatar_full', $steam_avatar_full);
$sql->bindValue(':steam_loc_country', $steam_loc_country);
$sql->bindValue(':steam_loc_state', $steam_loc_state);
$sql->bindValue(':steam_loc_cityid', $steam_loc_cityid);
$sql->bindValue(':steam_lastlogoff', $steam_lastlogoff);
$sql->bindValue(':steam_membersince', $steam_membersince);
$sql->execute();
echo "Inserted into DB!<br>";
print_r($sql);
$dhb = null;
}
catch(PDOException $e) {
echo $e->getMessage();
}
}
} else {
echo "That's not your Community URL, friend";
}
}
?>