-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.php
More file actions
164 lines (137 loc) · 7.6 KB
/
index.php
File metadata and controls
164 lines (137 loc) · 7.6 KB
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
<!--Written by NineteenEleven for Kablowsion Inc.-->
<?php
define('NineteenEleven', TRUE);
include_once 'includes/config.php';
include_once 'includes/class_lib.php';
$found_user = false;
$timestamp = date('U');
$cacheExpire = cache_time * 86400;
if (PLAYER_TRACKER) {
$mysqliD = new mysqli(DB_HOST,DB_USER,DB_PASS,DONATIONS_DB);
//$SteamQuery = new SteamQuery;
$ConvertID = new SteamIDConvert;
$userip = $_SERVER['REMOTE_ADDR'];
$result = $mysqliD->query("SELECT * FROM `player_analytics` WHERE ip='". $userip . "'ORDER BY id DESC LIMIT 0,1;")or die("Failed to connect to donations database");
function getXML($steam_link_xml, $steamid,$timestamp){
$mysqliC = new mysqli(DB_HOST,DB_USER,DB_PASS,DONATIONS_DB);
global $avatarmedium, $personaname;
$xml = @simplexml_load_file($steam_link_xml);
if(!empty($xml)) {
$avatar = $xml->players->player->avatar;
$avatarmedium = $xml->players->player->avatarmedium;
$avatarfull = $xml->players->player->avatarfull;
$personaname =$xml->players->player->personaname;
$personaname = $mysqliC->escape_string($personaname);
$steamid64 = $xml->players->player->steamid;
$steam_link = $xml->players->player->profileurl;
//update cache database
$mysqliC->query("INSERT INTO `cache` (steamid,
avatar,
avatarmedium,
avatarfull,
personaname,
timestamp,
steamid64,
steam_link)
VALUES ('{$steamid}',
'{$avatar}',
'{$avatarmedium}',
'{$avatarfull}',
'{$personaname}',
'{$timestamp}',
'{$steamid64}',
'{$steam_link}'
);")or die("Failed to update cache");
}
$mysqliC->close();
}
if($result->num_rows > 0){
$row = $result->fetch_array(MYSQLI_ASSOC);
$playername = $row['name'];
$steamid = $row['auth'];
$found_user = true;
$steamid64 = $ConvertID->IDto64($steamid);
$steam_link_xml = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=" . API_KEY . "&format=xml&steamids=" . $steamid64;
$cacheReturn = $mysqliD->query("SELECT * FROM `cache` WHERE steamid ='" . $steamid ."';");
//$cacheReturn = mysql_query($chkCacheSQL);
if($cacheReturn->num_rows > 0) {
$cacheResult = $cacheReturn->fetch_array(MYSQLI_ASSOC);
if($cacheResult['timestamp'] > $cacheExpire){
//cache still valid
$avatarmedium = $cacheResult['avatarmedium'];
}else{
//cache expired, updating
$mysqliD->query("DELETE FROM `cache` WHERE steamid = '".$cacheResult['steamid'] ."';");
getXML($steam_link_xml, $steamid,$timestamp);
}
}else{
//nothing in cache, getting stuff
getXML($steam_link_xml,$steamid,$timestamp);
}
}
$mysqliD->close();
print("<!DOCTYPE html>");
print("<html>");
print('<meta http-equiv="Content-Type"content="text/html;charset=UTF8">');
print("<head>");
//Javascript to allow gifting
print("<script type=\"text/javascript\">");
print("function gift() {document.getElementById('steamid-box').style.display = 'block';
document.getElementById('id-field').value = '';
document.getElementById('id-field').placeholder = 'Enter SteamID here';
document.getElementById('userid').style.display = 'none';
document.getElementById('infobox').style.display = 'block';
}");
print("</script>");
print("</head>");
print("<body id='original'>");
print("<style type=\"text/css\">#infobox{font-size: 12px;}</style>");
print("<center>");
print("<input type=\"image\" src=\"images/btn_donateCC_LG.gif\" form=\"donate_form\" />");
print("<form action=\"donate.php\" target=\"blank\" id=\"donate_form\" method=\"post\">");
print("<p>Amount: $<input type=\"text\" name=\"amount\" size=\"5\" class=\"inputbox\" value=\"5\" required=\"true\"></p>");
if(TIERED_DONOR){
print("<input type=\"radio\" name=\"tier\" value=\"1\" checked =\"1\" id=\"tier1\">".$group1['name']." <input type=\"radio\" name=\"tier\" value=\"2\" id=\"tier2\">".$group2['name']."<br />");
}
if($found_user){
print("<div id='steamid-box' style=\"display:none;\" ><label for='steamid_user'>Steam ID:<br /></label>");
print("<input type=\"text\" name=\"steamid_user\" required=\"true\" id=\"id-field\" value=\"{$steamid}\" ></div>");
print("<div id=\"userid\">Welcome back {$playername} <br />");
print("<img src='{$avatarmedium}' style=\"border:1px solid black;border-radius:5px;\" /><br />");
print("<a href='#' onclick=\"gift();\"> Donate for someone else </a></div>");
print("<div id='infobox' style=\"display:none;\">");
print("<p>Acceptable formats:<br />STEAM_0:0:0000000<br />steamcommunity.com/profiles/1234567891011<br />steamcommunity.com/id/{name} or {name}<br /></p>");
print("</div>");
}else{
print("<label for=\"paypaloption1\">Steam ID:<br /></label><input type=\"text\" id=\"paypaloption1\" name=\"steamid_user\" required=\"true\" id=\"id-box\" placeholder=\"Please enter your SteamID\" required=\"true\" size=\"30\"></p>");
print("<div id='infobox'>");
print("<p>Acceptable formats:<br />STEAM_0:0:0000000<br />steamcommunity.com/profiles/1234567891011<br />steamcommunity.com/id/{name} or {name}<br /></p>");
print("</div>");
}
print("</form>");
print("</center>");
print("</body>");
print("</html>");
}else{
print("<!DOCTYPE html>");
print("<html>");
print("<body>");
print("<style type=\"text/css\">#infobox{font-size: 12px;}</style>");
print("<center>");
print("<input type=\"image\" src=\"images/btn_donateCC_LG.gif\" form=\"donate_form\" />");
print("<form action=\"donate.php\" target=\"blank\" id=\"donate_form\" method=\"post\">");
print("<p>Amount: $<input type=\"text\" id=\"paypalamount\" name=\"amount\" size=\"5\" class=\"inputbox\" value=\"5\" required=\"true\"></p>");
if(TIERED_DONOR){
print("<input type=\"radio\" name=\"tier\" value=\"1\" checked =\"1\" id=\"tier1\">".$group1['name']." <input type=\"radio\" name=\"tier\" value=\"2\" id=\"tier2\">".$group2['name']."<br />");
}
print("<label for=\"paypaloption1\">Steam ID:<br /></label><input type=\"text\" id=\"paypaloption1\" name=\"steamid_user\" required=\"true\" id=\"id-box\" placeholder=\"Please enter your SteamID\" required=\"true\" size=\"30\"></p>");
print("<div id='infobox'>");
print("<p>");
print("Acceptable formats:<br />STEAM_0:0:0000000<br />steamcommunity.com/profiles/1234567891011<br />steamcommunity.com/id/{name} or {name}<br /></p>");
print("</div>");
print("</form>");
print("</center>");
print("</body>");
print("</html>");
}
?>