Created
March 24, 2018 21:30
-
-
Save BaileyJM02/5769700cf0a9ba1e5c5e27c82649957a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(E_ALL); | |
ini_set('display_errors', false); | |
ini_set('html_errors', false); | |
$json = file_get_contents("https://si3.raxsoft.com/api/removed"); | |
$data = json_decode($json, true); | |
$unique_users = array(); | |
$users = array(); | |
//Get every session | |
foreach (array_keys($data) as &$value) { | |
$x = $value; | |
//Every unique id | |
foreach (array_keys($data[$value]) as &$value2) { | |
//User values | |
foreach (array_keys($data[$value][$value2]) as &$sub_value) { | |
$username = $data[$value][$value2]["Username"]; | |
//get ["Username"] value | |
if ($sub_value == "Username") { | |
//Convert username to var | |
$actual_name = $data[$value][$value2]["Username"]; | |
//Check if in arra already - we only want one | |
if (!in_array($actual_name, $unique_users)) { | |
//if unique add to array | |
array_push($unique_users, $data[$value][$value2]["Username"]); | |
} | |
$users[$username]["Name"] = $actual_name; | |
} | |
if ($sub_value == "CreditsEarned") { | |
//Convert CreditsEarned to var | |
$actual_name = $data[$value][$value2]["CreditsEarned"]; | |
$array = $users[$username]; | |
$users[$username]["Credits Earned"] += round(intval($actual_name), 3); | |
} | |
if ($sub_value == "TotalMinutesMined") { | |
//Convert TotalMinutesMined to var | |
$actual_name = $data[$value][$value2]["TotalMinutesMined"]; | |
$array = $users[$username]; | |
$users[$username]["Minutes Mined"] += intval($actual_name); | |
} | |
if ($sub_value == "LastSeen") { | |
//Convert LastSeen to time | |
$actual_date = $data[$value][$value2]["LastSeen"]; | |
$users[$username]["Last Seen Unix"] = $actual_date - 1; | |
$users[$username]["Last Seen"] = 0; | |
$datetime = new DateTime("@$actual_date"); | |
$actual_name = $datetime->format('d-m-Y'); | |
$array = $users[$username]; | |
//get the latest date | |
if ($users[$username]["Last Seen Unix"] < $actual_date) { | |
$users[$username]["Last Seen"] = $actual_name; | |
} | |
} | |
if ($sub_value == "Speed") { | |
//Convert LastSeen to var | |
$actual_name = $data[$value][$value2]["Speed"]; | |
$array = $users[$username]; | |
//get the fastest speed | |
if ($users[$username]["Speed"] <= intval($actual_name)) { | |
$users[$username]["Speed"] = intval($actual_name); | |
} | |
} | |
if ($sub_value == "MTDCoins") { | |
//Convert MTDCoins to var | |
$actual_name = $data[$value][$value2]["MTDCoins"]; | |
$array = $users[$username]; | |
$users[$username]["MTD Coins"] += round(floatval($actual_name), 3); | |
} | |
if ($sub_value == "LTDCoins") { | |
//Convert LTDCoins to var | |
$actual_name = $data[$value][$value2]["LTDCoins"]; | |
$array = $users[$username]; | |
$users[$username]["LTD Coins"] += round(floatval($actual_name), 3); | |
} | |
if ($sub_value == "UnpaidCoins") { | |
//Convert UnpaidCoins to var | |
$actual_name = $data[$value][$value2]["UnpaidCoins"]; | |
$array = $users[$username]; | |
$users[$username]["Unpaid Coins"] += round(floatval($actual_name), 3); | |
} | |
if ($sub_value == "FriendlyCoinName") { | |
//Convert FriendlyCoinName to var | |
$actual_name = $data[$value][$value2]["FriendlyCoinName"]; | |
$array = $users[$username]; | |
$users[$username]["Coin Name"] = $actual_name; | |
} | |
if ($sub_value == "TotalHash") { | |
//Convert TotalHash to var | |
$actual_name = $data[$value][$value2]["TotalHash"]; | |
$array = $users[$username]; | |
$users[$username]["Total Hash"] += floatval($actual_name); | |
} | |
} | |
} | |
} | |
//Admin section | |
if (isset($users[null])) { | |
//give all of the annonymous users a friendly name | |
$users[null]["Name"] = "<i>Annonymous</i>"; | |
} | |
if (isset($users["removed@gmail.com"])) { | |
//change from email to protect identity | |
$users["removed@gmail.com"]["Name"] = "skhrk"; | |
} | |
if (isset($users["hh295832"])) { | |
//remove test account from list | |
unset($users["hh295832"]); | |
} | |
//remove unwanted collums | |
foreach (array_keys($users) as &$user) { | |
//unset($users[$user]["Total Hash"]); | |
unset($users[$user]["Last Seen Unix"]); | |
} | |
//order | |
foreach($users as $key => $value) { | |
//sort by MTD Coins | |
$emp[$key] = $value['MTD Coins']; | |
} | |
array_multisort($emp, SORT_DESC, $users); | |
//[END] Admim section | |
include('assets/include/header.php'); | |
include('assets/include/navbar.php'); | |
?> | |
<h1>Welcome</h1> | |
<p>Please view the scoreboard below. <i>This website is still in <b>beta</b>.</i></p> | |
<?php if (count($users) > 0) : ?> | |
<!-- end container --> | |
<div class="scroll table-responsive"> | |
<table class="table table-striped table-bordered"> | |
<thead class="thead-dark"> | |
<tr> | |
<th>Pos</th> | |
<th><?php echo implode('</th><th>', array_keys(current($users))); ?></th> | |
</tr> | |
</thead> | |
<tbody> | |
<?php $r = 1; foreach ($users as $row): array_map('htmlentities', $row); ?> | |
<tr><td><?php echo $r++; ?></td> | |
<td><?php echo implode('</td><td>', $row); ?></td> | |
</tr> | |
<?php endforeach; ?> | |
</tbody> | |
</table> | |
</div> | |
<?php endif; | |
include('assets/include/footer.php'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment