]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/commitdiff
properly fix broken js, move after doctype
authorValerie Pond <redacted>
Wed, 12 Apr 2023 10:42:05 +0000 (11:42 +0100)
committerValerie Pond <redacted>
Wed, 12 Apr 2023 10:42:05 +0000 (11:42 +0100)
header.php
vendor/unrealircd/unrealircd-rpc/lib/Stats.php [new file with mode: 0644]

index df46ea86f975c7e44a6d4b078276f1a3442931d6..0d483bfd3ff8ffaad28d25c29fd88f44ecea6c7f 100644 (file)
@@ -1,7 +1,11 @@
 <?php
 if (is_auth_provided() && !str_ends_with($_SERVER['SCRIPT_FILENAME'], "setup.php"))
 {?>
-       <script>
+       
+<?php }
+$arr = []; Hook::run(HOOKTYPE_PRE_HEADER, $arr); ?>
+<!DOCTYPE html>
+<head><script>
                var BASE_URL = "<?php echo get_config("base_url"); ?>";
                function timeoutCheck() {
                        var xhttp = new XMLHttpRequest();
@@ -9,7 +13,7 @@ if (is_auth_provided() && !str_ends_with($_SERVER['SCRIPT_FILENAME'], "setup.php
                                if (this.readyState == 4 && this.status == 200) {
                                        var data = JSON.parse(this.responseText);
                                        if (data.session == 'none')
-                                               window.location = get_config("base_url") + 'login/?timeout=1&redirect=' + encodeURIComponent(window.location.pathname);
+                                               window.location = BASE_URL + 'login/?timeout=1&redirect=' + encodeURIComponent(window.location.pathname);
                                }
                        };
                        xhttp.open("GET", BASE_URL + "api/timeout.php", true);
@@ -18,10 +22,6 @@ if (is_auth_provided() && !str_ends_with($_SERVER['SCRIPT_FILENAME'], "setup.php
                timeoutCheck();
                setInterval(timeoutCheck, 15000);
        </script>
-<?php }
-$arr = []; Hook::run(HOOKTYPE_PRE_HEADER, $arr); ?>
-<!DOCTYPE html>
-<head>
 <div class="media">
 <div class="media-body">
 
diff --git a/vendor/unrealircd/unrealircd-rpc/lib/Stats.php b/vendor/unrealircd/unrealircd-rpc/lib/Stats.php
new file mode 100644 (file)
index 0000000..9f306f0
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+
+namespace UnrealIRCd;
+
+use Exception;
+use stdClass;
+
+class Stats
+{
+
+    public Connection $connection;
+
+    public function __construct(Connection $conn)
+    {
+        $this->connection = $conn;
+    }
+
+    /**
+     * Get basic statistical information: user counts, channel counts, etc.
+     *
+     * @return stdClass|array|bool
+     */
+    public function get(int $object_detail_level=1): stdClass|array|bool
+    {
+        return $this->connection->query('stats.get', [
+            'object_detail_level' => $object_detail_level,
+        ]);
+    }
+}