It's old and it belongs to the mod on my server.
Unfortunately, it does not work and I'm not very experienced in PHP and HTML just a little.
This is how it looks at the moment: http://hlsw.rocks-clan.de/~akooh/fastDL ... _stats.php
Syntax: Select all
<html>
<head>
<script src="">
</script>
<style>
body {
background-color: black;
color: white;
font-family: "Trebuchet MS", sans-serif;
font_size: 16px;
background-repeat: no-repeat;
background-image: url(http://hlsw.rocks-clan.de/~akooh/fastDL/config/background01.png);
background-attachment:fixed;
text-shadow: 0px 1px 2px black;
}
h1 {
padding: none;
margin: none;
font-size: 24px;
}
h1 em {
font-size: 16px;
font-weight: bold;
display: inline-block;
}
table.sortable tr td:first-child {
text-align: center;
}
table.sortable th:not(.sorttable_sorted):not(.sorttable_sorted_reverse):not(.sorttable_nosort):after {
content: " \25B4\25BE"
}
#details {
float: right;
padding: 0;
margin: 0;
}
#details table {
border-spacing: 0;
border-collapse: collapse;
}
.grid {
display: flex;
flex-direction: row;
}
.grid * {
flex-grow: 1;
width: 50%;
}
.legend {
display: block;
float: left;
width: 10em;
font-weight: bold;
}
#details {
width: 25%;
visibility: hidden;
position: fixed;
right: 1em;
}
#details table th {
text-align: left;
}
#details table h2 {
padding: none;
margin: none;
padding-top: 1.5em;
}
#lang {
display: block;
top: 0;
right: 0;
position: absolute;
width: 24px;
height: 24px;
}
.clickable {
cursor: pointer;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div id="details">
<table>
<tr><td colspan="2"><h1 id="name">Fuckin Fucks</h1><i id="lang"><i>
</td></tr>
<tr><th class="legend">last connected on:</th> <td id="last_connection">13. Juni 2016 11h23</td></tr>
<tr><th class="legend">Total Points:</th><td id="points">12312312</td></tr>
<tr><th class="legend">Maps played:</th> <td id="maps">71</td></tr>
<tr><th class="legend">Jetpacks left:</th> <td id="jet">2</td></tr>
<tr><td colspan="2"><h2>Kills</h2></td></tr>
<tr><th class="legend">Kills:</th> <td id="kills">2130</td></tr>
<tr><th class="legend">Deaths:</th> <td id="deaths">860</td></tr>
<tr><th class="legend">Suicides:</th> <td id="suicides">29</td></tr>
<tr><td colspan="2"><h2>Records</h2></td></tr>
<tr><th class="legend">Consecutive Kills:</th> <td id="consecutive_kills">45</td></tr>
<tr><th class="legend">Max pts for 1 kill:</th> <td id="max_point">1234</td> </tr>
<tr><th class="legend">Distance:</th> <td id="distance">109</td></tr>
<tr><th class="legend">Postal:</th> <td id="postal">6</td></tr>
<tr><td colspan="2"><h2>Naughty</h2></td></tr>
<tr><th class="legend">Punished:</th> <td id="punished">45</td></tr>
<tr><th class="legend">Kicked:</th> <td id="kicks">1234</td></tr>
<tr><th class="legend">Ban:</th> <td id="reason_for_ban"></td></tr>
</table>
</div>
</div>
</table>
</div>
<h1>Ranking
<?php
function joinPaths() {
$args = func_get_args();
$paths = array();
foreach ($args as $arg) {
$paths = array_merge($paths, (array)$arg);
}
$paths = array_map(create_function('$p', 'return trim($p, "/");'), $paths);
$paths = array_filter($paths);
return join('/', $paths);
}
$ftp_connection = array(
"username" => "",
"password" => "",
"server" => "gs.rocks-clan.de",
"port" => "",
# this is probably the same
"directory" => "home/akooh/gameserver/postalalt/hl2mp",
);
$local_directory = "stats/";
$max_age = 5;
$file_names = array(
"rank.txt",
);
$info_file = "stats/index.json";
function updateLastDownload($info_file){
$json_data = array(
"last_download" => time(),
);
//echo $json_data;
$json_string = json_encode($json_data);
//echo $json_string;
file_put_contents($info_file, $json_string);
}
if (!file_exists($info_file)) {
//echo "File was not existing";
updateLastDownload($info_file);
}
$json_string = file_get_contents($info_file);
$json_data = json_decode($json_string, true);
$age_difference = (time() - $json_data["last_download"]);
$file_too_old = $age_difference > (60 * $max_age);
if($file_too_old) {
//echo "Downloading";
$connection = ftp_connect($ftp_connection["server"]);
$login_successful = ftp_login($connection,
$ftp_connection["username"],
$ftp_connection["password"]);
if((!$connection) || (!$login_successful)) {
echo "[[Error Connecting.]]";
exit;
}
foreach ($file_names as $file_name) {
$server_file = joinPaths($ftp_connection["directory"], $file_name);
$local_file = joinPaths($local_directory, $file_name);
$last_load = ftp_get($connection, $local_file, $server_file, FTP_BINARY);
//echo "Dowload of file ". $file_name . " was successful:" . $last_load;
}
ftp_close($connection);
updateLastDownload($info_file);
}
else {
//echo "file is current";
}
$age_difference_minutes = round($age_difference / 60.0, 0);
if ($age_difference_minutes == 0) {
echo "<em>Last Update: Right now !</em>";
} elseif ($age_difference_minutes == 1) {
echo "<em>Last Update: 1 minute ago.</em>";
} else {
echo "<em>Last Update: " . $age_difference_minutes . " minutes ago.</em>";
}
?>
</h1>
<?php
$columns = array(
"steamid" => 0,
"name" => 1,
"kills" => 2,
"deaths" => 3,
"teamkill" => 4,
"kicks" => 5,
"suicides" => 6,
"points" => 7,
"maps" => 8,
"burn" => 9,
"max_point" => 13,
"punished" => 15,
"reason_for_ban" => 21,
"ban" => 22,
"distance" => 16,
"postal" => 29,
"sensei" => 32,
"headshots" => 25,
"lang" => 18,
"consecutive_kills" => 12,
"last_connection" => 26,
"jet" => 17,
);
foreach($file_names as $file_name) {
$local_file = joinPaths($local_directory, $file_name);
$contents = file_get_contents($local_file);
$file = file($local_file);
function breakit($csv_string) {
return str_getcsv($csv_string, ";");
}
$data = array_map("breakit", $file, array(";"));
function compare($a, $b) {
global $columns;
$lhs = $a[$columns["points"]];
$rhs = $b[$columns["points"]];
if ($lhs == $rhs) return 0;
return $lhs > $rhs ? -1 : 1;
}
uasort($data, compare);
$rank = 1;
$header_columns = array(
"name", "points", "kills",
"deaths", "postal", "sensei", "consecutive_kills",
"suicides", "kicks",
);
$detail_columns = array(
"name",
"last_connection",
"points",
"maps",
"jet",
"kills",
"kicks",
"lang",
"deaths",
"suicides",
"consecutive_kills",
"max_point",
"distance",
"postal",
"punished",
"max_point",
"reason_for_ban"
);
echo "<table class='sortable'>";
echo "<tr>";
echo "<th>Rank</th>";
foreach($header_columns as $header) {
echo "<th>" . ucfirst($header) . "</th>";
}
echo "</tr>";
foreach ($data as $userinfo) {
$javascript_thingi = "updateDetails({";
foreach($detail_columns as $detail ) {
$javascript_thingi .= "'$detail': '";
$javascript_thingi .= $userinfo[$columns[$detail]];
$javascript_thingi .= "',";
}
$javascript_thingi .= "});";
echo "<tr class=\"clickable\" onclick=\"$javascript_thingi\">";
echo "<td>$rank</td>";
$rank++;
foreach ($header_columns as $header_column) {
echo "<td>" . $userinfo[$columns[$header_column]] . "</td>";
}
echo "</tr>";
}
}
echo "</table>";?>
<script language="JavaScript">
function updateDetails(data){
document.getElementById("details").style.visibility = "visible";
for(key in data) {
if(data.hasOwnProperty(key)) {
let value = data[key];
try {
if (key == "last_connection") {
value = new Date(value * 1000.0);
}
if (key == "lang") {
document.getElementById(key).style.background = "url('stats/24/" + value + ".png')";
continue;
}
document.getElementById(key).innerHTML = value;
} catch(e) {
console.log(key)
}
}
}
}
</script>
</body>
</html>