-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
executable file
·105 lines (97 loc) · 2.82 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
<?php
$ip = "docker.vignat"; //IP or domain name
$port = "25566" // Query port
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php echo $ip; ?> - Minecraft Server</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="jumbotron-narrow.css" rel="stylesheet">
</head>
<?php
require __DIR__ . '/vendor/autoload.php';
use xPaw\MinecraftQuery;
use xPaw\MinecraftQueryException;
$q = new MinecraftQuery();
$e = array();
try
{
$q->Connect($ip, $port);
$info = $q->GetInfo();
$players = $q->GetPlayers();
}
catch(MinecraftQueryException $exception)
{
$e[] = $exception->getMessage();
}
?>
<body>
<br>
<div class="container">
<div class="header clearfix">
<h3 class="text-muted"><?php echo $ip; ?> - Minecraft Server</h3>
</div>
<div class="jumbotron">
<?php
if(empty($e))
{
?>
<p><strong>Motd : </strong><?php echo $info['HostName'] ?></p>
<p><strong>Game : </strong><?php echo $info['GameName'].' / '.$info['Software'].' ('.$info['Version'].')' ?></p>
<p><strong>Players : </strong><?php echo $info['Players'].' / '.$info['MaxPlayers'] ?></p>
<p><strong>IP:Port : </strong><?php echo $info['HostIp'].':'.$info['HostPort'] ?></p>
<?php
}
else
{
echo "<p class=\"lead\">Erreur : ".$e[0]."</p>";
}
?>
</div>
<?php
if(empty($e))
{
?>
<hr>
<div class="jumbotron">
<p class="lead">
<strong>Players online :</strong>
</p>
<?php
if($info['Players'] == 0)
{ ?>
<p>No players connected.</p>
<?php
}
else
{
?>
<div class="row">
<?php
$size = 250;
echo "<ul>";
foreach ($players as $player)
{
echo "<div class=\"col-sm-6 col-md-4\"><div class=\"thumbnail\">";
echo "<img src='scripts/skin.php?u=".$player."&s=".$size."' />";
echo "<div class=\"caption\"><h3 class=\"text-center\">".$player."</h3></div>";
echo "</div></div>";
}
echo "</ul></div>";
}
echo "</div>";
}
?>
</div>
<footer class="footer">
<div class="container text-center">
<p>Made with <span class="glyphicon glyphicon-heart" aria-hidden="true"></span> by <a href="https://github.com/p1rox">@p1rox</a></p>
</div>
</footer>
</body>
</html>