Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
63 lines (62 sloc) 2.26 KB
<?php
$config = array(
'server' => '1b8e5fa30cb2681b', //Your server UID (You can find it in CraftList server edit page)
'limit' => 50, //Limit of players (0 for unlimited)
'rank' => true, //Show player rank?
'avatar' => true, //Show player avatar?
'timeout' => 3 //Timeout for craftlist.eu
);
?>
<!--
# Name: CraftList.eu PlayerVotes
# Author: haelexuis [h4elexu1s(#)gmail.com]
# Version: 0.9
# Newest version on: https://github.com/haelexuis/ServerVotes/blob/master/CraftList.php
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<meta name="author" content="haelexuis"/>
<link rel="stylesheet" type="text/css" href="https://craftlist.eu/css/api/votes.css"/>
</head>
<body>
<table>
<thead>
<?php echo $config['rank'] ? '<th>Rank</th>' : '' ?>
<?php echo $config['avatar'] ? '<th>Avatar</th>' : '' ?>
<th>Nickname</th>
<th>Votes</th>
<th>Latest vote</th>
</thead>
<tbody>
<?php
$timeout = stream_context_create(array('http' => array('timeout' => $config['timeout'])));
if($data = @file_get_contents('https://craftlist.eu/public/api/'.$config['server'].'/votes.json', 0, $timeout)) {
if($data != '[]') {
$lines = 0;
$json = json_decode($data);
foreach($json as $key => $value) {
if($lines <= $config['limit'] || $config['limit'] == 0) {
?>
<tr>
<?php echo $config['rank'] ? '<td>' . $value->rank . '</td>' : '' ?>
<?php echo $config['avatar'] ? '<td><img alt="' . $key . '" src="https://minotar.net/helm/' . $key . '/15.png"/></td>' : '' ?>
<td><?php echo $key ?></td>
<td><?php echo $value->votes ?></td>
<td><?php echo date('d. m. Y H:i', $value->latest) ?></td>
</tr>
<?php
$lines++;
}
else
break;
}
}
}
else
echo 'CraftList.eu is currently down';
?>
</tbody>
</table>
</body>