Browse Source

Refs #2 show server status

isundil 6 years ago
parent
commit
ec718d2d2e
2 changed files with 12 additions and 2 deletions
  1. 7 2
      index.php
  2. 5 0
      style.css

+ 7 - 2
index.php

@@ -69,9 +69,14 @@ N’hésitez pas a vous renseigner sur toutes les commandes IRC disponibles aux
 </p><p>
 Pour les habitués, vous pouvez vous connecter via votre client habituel en utilisant un des serveur suivant :
 <?php
+$states = getServersState();
 foreach (getServers() as $addr => $config) {
-    echo '<ul class="serverconfig">';
-    echo "<li><span class=\"legend\">Adresse / serveur</span> : <span class=\"value\">${addr}</span></li>";
+    if ($states == null || !isset($states->result) || !isset($states->result->{$addr}))
+        $state = "unknown";
+    else
+        $state = $states->result->{$addr} == 1 ? "online" : "offline";
+    echo "<ul class=\"serverconfig\">";
+    echo "<li><span class=\"legend\">Adresse / serveur</span> : <span class=\"status status-${state}\"></span><span class=\"value\">${addr}</span></li>";
     $portWithSSL = array();
     $portStd = array();
     foreach ($config["ports"] as $port => $useSSL) {

+ 5 - 0
style.css

@@ -25,7 +25,12 @@ a { text-decoration: none; color: rgb(132, 132, 132); }
 ul.chancategory { padding: 0; list-style: none; }
 ul.chancategory > li { text-decoration: underline; }
 ul.chanlist { list-style: none; margin-bottom: 1em; }
+
 ul.serverconfig { list-style: none; }
+.serverconfig .status { display: inline-block; vertical-align: middle; border-radius: .3em; height: .6em; width: .6em; margin: 0 .5em; }
+.serverconfig .status.status-online { background: #42ea42; }
+.serverconfig .status.status-offline { background: red; }
+.serverconfig .status.status-unknown { background: orange; }
 code { margin: 0.75em 0; padding: 0 0.75em; display: block; font-family: "Roboto Mono", monospace; }
 
 .body.body-fixed > .container > div.quizz-header { background: none; text-align: center; }