diff --git a/README.md b/README.md
index 2e2d947..eb9e7e0 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,8 @@
# auth-site
This repository contains scripts needed to enable authentication on your SWG Source VM.
+
+add the entry below to your localoptions.cfg file to enable this function.
+
+[CentralServer]
+ metricsDataURL=http://127.0.0.1/serverstatus.php
+ webUpdateIntervalSeconds=60
diff --git a/html/index.php b/html/index.php
index 047a64d..d37f1b5 100644
--- a/html/index.php
+++ b/html/index.php
@@ -2,7 +2,7 @@
-SWG Source Server Main Page
+SWG Server Main Page
@@ -134,8 +134,7 @@ function BothFieldsIdenticalCaseSensitive() {
WELCOME
to
- SWG Source Server v2.2
- This is the Login frontend for your NGE server
+ SWG Source Server v3.0.2
Click below to Create a New Account
Register an Account
@@ -147,25 +146,50 @@ function BothFieldsIdenticalCaseSensitive() {
-Server Status
+Server Status
| Login Server: ";
- echo $login ? "Online" : "Offline | ";
- echo "| Game Server: ";
- echo $game ? "Online" : "Offline |
";
+
+ $data = json_decode( file_get_contents( 'status.txt' ), true );
+ $lastUpdated = $data['lastUpdated'];
+
+ if (time() > $lastUpdated + 70) {
+ $scar = "0";
+ $status = "Offline";
+ } else {
+ $scar = "1";
+ $status = "Online";
+ }
+
+ $newTime = time() - $lastUpdated;
+ $requestLastUpdated = idate('s', $newTime);
+
+ if ($scar === "1") {
+ $loadingState = $data['lastLoadingStateTime'];
+ $timediff = time() - $loadingState;
+ } elseif ($scar === "0") {
+ $timediff = time() - $lastUpdated;
+ }
+
+ function secondsToTime($seconds) {
+ $dtF = new \DateTime('@0');
+ $dtT = new \DateTime("@$seconds");
+ return $dtF->diff($dtT)->format('%a day(s), %h hour(s), %i minute(s)');
+ }
+
+ echo "" . $data['clusterName'] . " " . $status . " ";
+ echo "Current Population: " . $data['totalPlayerCount'] . ", ";
+ echo "Highest Population: " . $data['highestPlayerCount'] . " ";
+ echo "Last Updated: " . $requestLastUpdated . " seconds ago. ";
+ if ($scar === "1") {
+ echo "Uptime: " . secondsToTime($timediff);
+ } elseif ($scar === "0") {
+ echo "Downtime: " . secondsToTime($timediff);
+ }
+
?>
| | | | | |
diff --git a/html/serverstatus.php b/html/serverstatus.php
new file mode 100644
index 0000000..88e561b
--- /dev/null
+++ b/html/serverstatus.php
@@ -0,0 +1,32 @@
+ $clusterName,
+ 'lastUpdated' => $lastUpdated,
+ 'totalPlayerCount' => $totalPlayerCount,
+ 'highestPlayerCount' => $highestPlayerCount,
+ 'lastLoadingStateTime' => $lastLoadingStateTime,
+ 'timeClusterWentIntoLoadingState' => $timeClusterWentIntoLoadingState);
+
+//Write this data to the Metrics File
+file_put_contents('status.txt', json_encode($return), LOCK_EX);
+
+if($totalPlayerCount > $highestPlayerCount) {
+ file_put_contents('players.txt', $totalPlayerCount, LOCK_EX);
+}
+
+