-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
148 lines (131 loc) · 6.25 KB
/
index.php
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
<?php
define('NineteenEleven', TRUE);
require_once 'includes/config.php';
require_once ABSDIR . 'includes/SourceBansClass.php';
echo "<!--Donations Control v" . VERSION_NEW . " written by NineteenEleven @ 1911.expert-->";
try {
$sb = new sb;
$gotDb = true;
} catch (Exception $ex) {
$gotDb = false;
}
$found_user = false;
$timestamp = date('U');
if (PLAYER_TRACKER && $gotDb) {
$userip = $_SERVER['REMOTE_ADDR'];
try {
$stmt = $sb->ddb->prepare("SELECT * FROM `player_analytics` WHERE ip=? ORDER BY id DESC LIMIT 0,1;");
$stmt->bindParam(1, $userip, PDO::PARAM_STR);
$stmt->execute();
} catch (Exception $ex) {
}
if ($stmt->rowCount() == 1) {
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$playername = $row['name'];
$steam_id = $row['auth'];
$found_user = true;
//$cacheReturn = $mysqliD->query("SELECT * FROM `cache` WHERE steamid ='" . $steamid . "';");
$stmt = $sb->ddb->query("SELECT * FROM `cache` WHERE steamid ='$steam_id';");
$cache = $stmt->fetch(PDO::FETCH_ASSOC);
if (!empty($cache)) {
$cacheExpire = (cache_time * 86400) + $cache['timestamp'];
if ($timestamp < $cacheExpire) {
//cache still valid
$avatarmedium = $cache['avatarmedium'];
} else {
//cache expired, updating
try {
$sb->ddb->exec("DELETE FROM `cache` WHERE steamid = '" . $cache['steamid'] . "';");
require_once ABSDIR . 'includes/SteamClass.php';
$steam = new SteamIDConvert($steam_id);
$steam->SteamIDCheck()->fillCache();
$playername = $steam->playerSummaries->response->players[0]->personaname;
$avatarmedium = $steam->playerSummaries->response->players[0]->avatarmedium;
$steam_id = $steam->steam_id;
} catch (Exception $ex) {
$found_user = false;
}
}
} else {
//nothing in cache, getting stuff
try {
$sb->ddb->exec("DELETE FROM `cache` WHERE steamid = '" . $cache['steamid'] . "';");
require_once ABSDIR . 'includes/SteamClass.php';
$steam = new SteamIDConvert($steam_id);
$steam->SteamIDCheck()->fillCache();
$playername = $steam->playerSummaries->response->players[0]->personaname;
$avatarmedium = $steam->playerSummaries->response->players[0]->avatarmedium;
$steam_id = $steam->steam_id;
} catch (Exception $ex) {
$found_user = false;
}
}
} else {
$found_user = false;
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<!-- Javascript to allow gifting -->
<script type="text/javascript">
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';
}
;
function submitDC() {
document.getElementById('donateForm').submit();
};
function changeAmount(dcAmt){
document.getElementById('donateAmt').value = dcAmt;
};
</script>
</head>
<body id='original'>
<style type="text/css">#infobox{font-size: 12px;}</style>
<center>
<form action="donate.php" target="blank" id="donateForm" method="post">
<input type="image" src="images/btn_donateCC_LG.gif" form="donateForm" onclick='submitDC();' />
<input type="hidden" name="donateForm" value="submit" id='submitBtn' />
<p>Amount: $<input type="text" name="amount" size="5" class="inputbox" value="5" required id='donateAmt'></p>
<?php
$groups = $sb->listGroups();
if ($groups !== false) {
$i = 0;
foreach ($groups as $group) {
echo "<div class='group' style='display:inline-block;'><input type='radio' name='tier' ";
if ($i == 0) {
echo "checked";
}
echo " required value='" . $group['id'] . "' onclick='changeAmount(\"".$group['minimum']."\");' />" . $group['name'] . " </div>";
$i++;
}
} else {
echo "No Groups are set up yet!";
}
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='$steam_id' ></div>");
print("<div id='userid'>Welcome back $playername <br />");
print("<img src='$avatarmedium' style='border:1px solid black;border-radius:5px;' /><br />");
print("<span style='cursor:pointer;' onclick='gift();'> Donate for someone else</span></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("<br /><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>");
}
?>
</form>
</center>
</body>
</html>