Skip to content

Commit

Permalink
Merge pull request #196 from Deadlineem/master
Browse files Browse the repository at this point in the history
Additions
  • Loading branch information
ldilley authored Oct 5, 2023
2 parents ed3c54a + ede4ab2 commit d9e204a
Show file tree
Hide file tree
Showing 3 changed files with 157 additions and 0 deletions.
47 changes: 47 additions & 0 deletions contrib/Multi-Stat/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
*,
*::before,
*::after {
padding: 0;
margin: 0;
box-sizing: border-box;
}
body {
background-color: #000;
color: #fff;
font-size: 16px;
}
.container {
width: 100%;
}
.header {
font-size: 22px;
font-weight: bold;
}
.logo {
width: 5%;
margin: 25px;

}
.text-left {
text-align: left;
text-wrap: wrap;
}
.item {
width: 90%;
background-color: #333;
padding: 25px 25px 15px 15px;
margin: 25px 10px 0px;

border-radius: 15px;
color: #FFF;
}
.pull-left {
float: left;
}
.pull-right {
float: right;
}
.list {
margin-top: 25px;
width: 50%;
}
94 changes: 94 additions & 0 deletions contrib/Multi-Stat/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php
require_once("settings.php");

function generate_box($ip, $port, $protocol)
{
$urlParts = explode('.', $ip);
end($urlParts);
$urlParts = prev($urlParts);

$runCMD = 'PowerShell.exe "(MineStat -Address ' . $ip . ' -Port ' . $port . ' -Protocol ' . $protocol . ' -Timeout 1 | ConvertTo-Json)"';
$output = json_decode(mb_convert_encoding(shell_exec($runCMD), 'UTF-8', 'UTF-8'), true);

// Check for JSON decoding errors
if (json_last_error() !== JSON_ERROR_NONE || !isset($output["connection_status"])) {
exit("Error occured");
// Handle the error here, you can log it or return a custom error message
}

$status = false;
$statusType = "Offline";
switch ($output["connection_status"]) {
case 'Success':
$statusType = "Online";
$status = true;
break;
case 'Connfail':
$statusType = "Connection Failure";
break;
case 'Timeout':
$statusType = "Timed Out";
break;
}

$ip = $output["address"];
$port = $output["port"];
$version = $output["version"];
$motd = $output["stripped_motd"];
$current_players = $output["current_players"];
$max_players = $output["max_players"];
$latency = $output["latency"];
//more available: https://github.com/FragLand/minestat/tree/master/PowerShell
$output = "\n\naddress : $ip\n"
. "port : $port\n"
. "version : $version\n"
. "motd : $motd\n"
. "current_players : $current_players\n"
. "max_players : $max_players\n"
. "latency : $latency\n\n\n";

if ($status != true)
return '<div class="alert alert-danger">Server: ' . $ip . ':' . $port . ' is currently Offline!<br />Status Type: ' . $statusType . '</div>';
else
return "<pre class='item text-left'><center>$urlParts - $protocol</center>" . $output . "</pre><br />";
}
?>
<html>

<head>
<title><?php echo $siteTitle; ?></title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<link rel="stylesheet" href="css/style.css" /> <!-- Extra Styling -->
<link rel="icon" type="image/png" href="">
</head>

<body>
<center>
<div class="container">
<img src="" class="logo" />
<div class="header"><?php echo $siteName; ?></div>
<div class="list pull-left">
<?php
foreach ($javaIP as $ip) {
echo generate_box($ip, 25565, 'Json');
}
?>
</div>
<div class="list pull-right">
<?php
foreach ($bedrockIP as $ip) {
echo generate_box($ip, 19132, 'BedrockRaknet');
}
?>
</div>
</div>
</center>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script> <!-- Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script> <!-- Popper -->
<script src="https://code.jquery.com/jquery-3.7.1.min.js" integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script> <!-- JQuery -->
</body>

</html>

16 changes: 16 additions & 0 deletions contrib/Multi-Stat/settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
$siteTitle = "Multi-Stat Server Status"; // Changes the Page Title
$siteName = "Multi-Stat by DeadlineEm"; // Changes the Header name

// Change or Add to these arrays to retrieve the server IP/URL

// Bedrock Servers
$bedrockIP = array("localhost"); // The IP/Hostname of the BEDROCK server(s) separate with , (Example: "1.1.1.1", "2.2.2.2")

// Java Servers
$javaIP = array("localhost"); // The IP/Hostname of the JAVA server(s) separate with , (Example: "1.1.1.1", "2.2.2.2")

// NOTE: As long as the server address is a valid server and the powershell module is installed, you can put the address here, it does not have to be a locally hosted server you just need
// to have the powershell module installed and some sort of webserver for a status page. This can all be done on a windows server and is recommended for use on that as its faster, safer
// and more reliable than a home webserver.
?>

0 comments on commit d9e204a

Please sign in to comment.