-<!DOCTYPE html>
-<link href="/css/unrealircd-admin.css" rel="stylesheet">
-<body>
-<div id="headerContainer">
-<h2>UnrealIRCd <small>Administration Panel</small></h2><br>
+<?php
+require_once "common.php";
+require_once "connection.php";
+require_once "header.php";
+
+$stats = $rpc->stats()->get();
+?>
+<div class="row ml-0">
+<h2>Network Overview</h2><div data-toggle="tooltip" data-placement="top" title="The stats on this page are updated in real-time"
+ class="card text-center row font-weight-bold"
+ style="margin-left:5%;height:26px;width:60px;background-color:red;color:white">
+<small style="margin-left:-40px;padding-top:3px;margin-right:-50px">⚪</small>LIVE</div>
</div>
-<script src="js/unrealircd-admin.js" defer></script>
-<div class="topnav">
- <a data-tab-target="#overview" class="active" href="#overview">Overview</a>
- <a data-tab-target="#Users" href="#Users">Users</a>
- <a data-tab-target="#Channels" href="#Channels">Channels</a>
- <a data-tab-target="#TKL" href="#TKL">Server Bans</a>
- <a data-tab-target="#Spamfilter" href="#Spamfilter">Spamfilter</a>
-</div>
<?php
-/**
- * Provide a admin area view for the plugin
- *
- * This file is used to markup the admin-facing aspects of the plugin.
- *
- * @link https://https://github.com/ValwareIRC
- * @since 1.0.0
- *
- * @package Unrealircd
- * @subpackage Unrealircd/admin/partials
- */
-
-define('UPATH', true);
-include "Classes/class-rpc.php";
-
-rpc_pop_lists(); // populate our static lists (users, channels, tkl, spamfilter)
+$array_of_stats = (array)$stats;
+
+/* What if someone wants to add their own stats... */
+Hook::run(HOOKTYPE_PRE_OVERVIEW_CARD, $array_of_stats);
+
+/* This makes sure that a plugin which called the parameter
+ * by reference can add/update the stats for display here.
+*/
+$stats = (object) $array_of_stats;
+
+$userlist = [];
+Hook::run(HOOKTYPE_GET_USER_LIST, $userlist);
+$num_of_panel_admins = count($userlist);
+
?>
+<style>
+ .card {
+ min-height: 100%;
+ }
+ </style>
+<div class="container card-container" style="margin-left:40px;margin-top:30px">
-<div class="tab-content\">
-<div id="overview" data-tab-content class="active">
- <table class='unrealircd_overview'>
- <th>Chat Overview</th><th></th>
- <tr><td><b>Users</b></td><td><?php echo count(RPC_List::$user); ?></td></tr>
- <tr><td><b>Opers</b></td><td><?php echo RPC_List::$opercount; ?></td></tr>
- <tr><td><b>Services</b></td><td><?php echo RPC_List::$services_count; ?></td></tr>
- <tr><td><b>Most popular channel</b></td><td><?php echo RPC_List::$most_populated_channel; ?> (<?php echo RPC_List::$channel_pop_count; ?> users)</td></tr>
- <tr><td><b>Channels</b></td><td><?php echo count(RPC_List::$channel); ?></td></tr>
- <tr><td><b>Server bans</b></td><td><?php echo count(RPC_List::$tkl); ?></td></tr>
- <tr><td><b>Spamfilter entries</b></td><td><?php echo count(RPC_List::$spamfilter); ?></td></tr></th>
- </table></div></div>
-
- <div class="tab-content\">
- <div id="Users" data-tab-content>
- <p></p>
- <table class='users_overview'>
- <th>Nick</th>
- <th>UID</th>
- <th>Host / IP</th>
- <th>Account</th>
- <th>Usermodes</th>
- <th>Oper</th>
- <th>Secure</th>
- <th>Connected to</th>
- <th>Reputation <a href="https://www.unrealircd.org/docs/Reputation_score"></a>ℹ️</th>
-
- <?php
- foreach(RPC_List::$user as $user)
- {
- echo "<tr>";
- echo "<td>".$user['name']."</td>";
- echo "<td>".$user['id']."</td>";
- echo "<td>".$user['hostname']." (".$user['ip'].")</td>";
- $account = (isset($user['account'])) ? $user['account'] : "";
- echo "<td>".$account."</td>";
- $modes = (isset($user['user']['modes'])) ? "+" . $user['user']['modes'] : "<none>";
- echo "<td>".$modes."</td>";
- $oper = (isset($user['user']['operlogin'])) ? $user['user']['operlogin']." (".$user['user']['operclass'].")" : "";
- echo "<td>".$oper."</td>";
- $secure = (isset($user['tls'])) ? "✅" : "❌";
- echo "<td>".$secure."</td>";
- echo "<td>".$user['user']['servername']."</td>";
- echo "<td>".$user['user']['reputation']."</td>";
+ <div class="row mt-3">
+ <div class="col-sm mb-3">
+ <div class="card text-center">
+ <div class="card-header bg-success text-white">
+ <div class="row">
+ <div class="col">
+ <i class="fa fa-users fa-3x"></i><span class="position-absolute badge rounded-pill badge-warning">
+ <?php echo "Record: ".$stats->user->record; ?>
+ </span>
+ </div>
+ <div class="col">
+ <h3 id="stats_user_total" class="display-4"><?php echo $stats->user->total; ?></h3>
+ </div>
+ </div>
+ </div>
+ <div class="card-body">
+ <div class="row">
+ <div class="col">
+ <h6>Users Online</h6>
+ </div>
+ <div class="col"> <a class="btn btn-primary" href="<?php echo get_config("base_url"); ?>users">View</a></div>
+ </div>
+ </div>
+ </div>
+
+
+ </div>
+ <div class="col-sm mb-3">
+ <div class="card text-center">
+ <div class="card-header bg-primary text-white">
+ <div class="row">
+ <div class="col">
+ <i class="fa fa-hashtag fa-3x"></i>
+ </div>
+ <div class="col">
+ <h3 id="stats_channel_total" class="display-4"><?php echo $stats->channel->total; ?></h3>
+ </div>
+ </div>
+ </div>
+ <div class="card-body">
+ <div class="row">
+ <div class="col">
+ <h6>Channels</h6>
+ </div>
+ <div class="col"><a class="btn btn-primary" href="<?php echo get_config("base_url"); ?>channels">View</a></div>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="col-sm mb-3">
+ <div class="card text-center">
+ <div class="card-header bg-warning">
+ <div class="row">
+ <div class="col">
+ <i class="fa fa-shield-halved fa-3x"></i>
+ </div>
+ <div class="col">
+ <h3 id="stats_oper_total" class="display-4"><?php echo $stats->user->oper; ?></h3>
+ </div>
+ </div>
+ </div>
+ <div class="card-body">
+ <div class="row">
+ <div class="col">
+ <h6>Opers</h6>
+ </div>
+ <div class="col"><a class="btn btn-primary" href="<?php echo get_config("base_url")."users/?operonly"; ?>">View</a></div>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <div class="col-sm mb-3">
+ <div class="card text-center">
+ <div class="card-header bg-secondary text-white">
+ <div class="row">
+ <div class="col">
+ <i class="fa fa-network-wired fa-3x"></i>
+ </div>
+ <div class="col">
+ <h3 id="stats_server_total" class="display-4"><?php echo $stats->server->total; ?></h3>
+ </div>
+ </div>
+ </div>
+ <div class="card-body">
+ <div class="row">
+ <div class="col">
+ <h6>Servers</h6>
+ </div>
+ <div class="col"> <a class="btn btn-primary" href="<?php echo get_config("base_url"); ?>servers">View</a></div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+</div>
+<div class="container card-container" style="margin-left:40px;margin-top:30px">
+
+ <div class="row">
+ <div class="col-sm mb-3">
+ <div class="card text-center">
+ <div class="card-header bg-danger text-white">
+ <div class="row">
+ <div class="col">
+ <i class="fa fa-ban fa-3x"></i>
+ </div>
+ <div class="col">
+ <h3 id="num_server_bans" class="display-4"><?php echo $stats->server_ban->server_ban; ?></h3>
+ </div>
+ </div>
+ </div>
+ <div class="card-body">
+ <div class="row">
+ <div class="col">
+ <h6>Server Bans</h6>
+ </div>
+ <div class="col"> <a class="btn btn-primary" href="<?php echo get_config("base_url"); ?>server-bans">View</a></div>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="col-sm mb-3">
+ <div class="card text-center">
+ <div class="card-header bg-secondary text-white">
+ <div class="row">
+ <div class="col">
+ <i class="fa fa-filter fa-3x"></i>
+ </div>
+ <div class="col">
+ <h3 id="num_spamfilter_entries" class="display-4"><?php echo $stats->server_ban->spamfilter; ?></h3>
+ </div>
+ </div>
+ </div>
+ <div class="card-body">
+ <div class="row">
+ <div class="col">
+ <h6>Spamfilter</h6>
+ </div>
+ <div class="col"> <a class="btn btn-primary" href="<?php echo get_config("base_url"); ?>spamfilter.php">View</a></div>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="col-sm mb-3">
+ <div class="card text-center">
+ <div class="card-header bg-primary text-white">
+ <div class="row">
+ <div class="col">
+ <i class="fa fa-door-open fa-3x"></i>
+ </div>
+ <div class="col">
+ <h3 id="num_ban_exceptions" class="display-4"><?php echo $stats->server_ban->server_ban_exception; ?></h3>
+ </div>
+ </div>
+ </div>
+
+ <div class="card-body">
+ <div class="row">
+ <div class="col">
+ <h6>Server Ban Exceptions</h6>
+ </div>
+ <div class="col"> <a class="btn btn-primary" href="<?php echo get_config("base_url"); ?>server-bans/ban-exceptions.php">View</a></div>
+ </div>
+ </div>
+ </div>
+ </div>
+ <?php
+ if ($stats->server->ulined) {
+ $bg = "bg-success";
+ $tooltip = "Users / Servers";
}
- ?></table></div></div>
-
- <div class="tab-content\">
- <div id="Channels" data-tab-content>
- <p></p>
- <table class='users_overview'>
- <th>Name</th>
- <th>Created</th>
- <th>User count</th>
- <th>Topic</th>
- <th>Topic Set</th>
- <th>Modes</th>
-
- <?php
- foreach(RPC_List::$channel as $channel)
- {
- echo "<tr>";
- echo "<td>".$channel['name']."</td>";
- echo "<td>".$channel['creation_time']."</td>";
- echo "<td>".$channel['num_users']."</td>";
- $topic = (isset($channel['topic'])) ? $channel['topic'] : "";
- echo "<td>".$topic."</td>";
- $setby = (isset($channel['topic'])) ? "By ".$channel['topic_set_by'] .", at ".$channel['topic_set_at'] : "";
- echo "<td>".$setby."</td>";
- $modes = (isset($channel['modes'])) ? "+" . $channel['modes'] : "<none>";
- echo "<td>".$modes."</td>";
+ else
+ $bg = "bg-warning";
+ ?>
+ <div class="col-sm mb-3">
+ <div class="card text-center">
+ <div class="card-header <?php echo $bg; ?> text-white">
+ <div class="row">
+ <div class="col">
+ <i class="fa fa-database fa-3x"> </i>
+ </div>
+ <div class="col">
+ <span data-toggle="tooltip" title="<?php echo $tooltip; ?>" style="border-bottom: 1px dotted #000000">
+ <h3 id="stats_uline_total" class="display-4"><?php echo $stats->user->ulined; ?>/<?php echo $stats->server->ulined; ?></h3>
+ </div>
+ </div>
+ </div>
+ <div class="card-body">
+ <div class="row">
+ <div class="col">
+ <h6>Services Online</h6>
+ </div>
+ <div class="col"> <a class="btn btn-primary" href="<?php echo get_config("base_url")."users/?servicesonly"; ?>">View</a></div>
+ </div>
+ </div>
+
+ </div>
+ </div>
+ </div>
+</div>
+
+
+<script>
+ function updateStats(e)
+ {
+ var data;
+ try {
+ data = JSON.parse(e.data);
+ } catch(e) {
+ return;
}
- ?></table></div></div>
-
-
- <div class="tab-content\">
- <div id="TKL" data-tab-content>
- <p></p>
- <table class='users_overview'>
- <th>Mask</th>
- <th>Type</th>
- <th>Set By</th>
- <th>Set On</th>
- <th>Expires</th>
- <th>Duration</th>
- <th>Reason</th>
-
- <?php
- foreach(RPC_List::$tkl as $tkl)
- {
- echo "<tr>";
- echo "<td>".$tkl['name']."</td>";
- echo "<td>".$tkl['type_string']."</td>";
- echo "<td>".$tkl['set_by']."</td>";
- echo "<td>".$tkl['set_at_string']."</td>";
- echo "<td>".$tkl['expire_at_string']."</td>";
- echo "<td>".$tkl['duration_string']."</td>";
- echo "<td>".$tkl['reason']."</td>";
+ document.getElementById("stats_user_total").innerHTML = data.user.total;
+ document.getElementById("stats_channel_total").innerHTML = data.channel.total;
+ document.getElementById("stats_oper_total").innerHTML = data.user.oper;
+ document.getElementById("stats_server_total").innerHTML = data.server.total;
+ document.getElementById("num_server_bans").innerHTML = data.server_ban.server_ban;
+ document.getElementById("num_spamfilter_entries").innerHTML = data.server_ban.spamfilter;
+ document.getElementById("num_ban_exceptions").innerHTML = data.server_ban.server_ban_exception;
+ document.getElementById("stats_uline_total").innerHTML = data.user.ulined + "/" + data.server.ulined;
+ }
+ function initStats()
+ {
+ if (!!window.EventSource) {
+ var source = new EventSource('api/overview.php');
+ source.addEventListener('message', updateStats, false);
}
- ?></table></div></div>
-
+ }
+ initStats();
+ //setInterval(updateStats, 1000); // Update stats every second
+ // ^ commented out but may want to restart initStats() when connection is lost.
- <div class="tab-content\">
- <div id="Spamfilter" data-tab-content>
- <p></p>
- <table class='users_overview'>
- <th>Mask</th>
- <th>Type</th>
- <th>Set By</th>
- <th>Set On</th>
- <th>Expires</th>
- <th>Duration</th>
- <th>Match Type</th>
- <th>Action</th>
- <th>Action Duration</th>
- <th>Target</th>
- <th>Reason</th>
- <?php
- foreach(RPC_List::$spamfilter as $sf)
+ window.addEventListener('resize', function() {
+ var containers = document.querySelectorAll('.card-container');
+ var width = window.innerWidth;
+ if (width < 768)
{
- echo "<tr>";
- echo "<td>".$sf['name']."</td>";
- echo "<td>".$sf['type_string']."</td>";
- echo "<td>".$sf['set_by']."</td>";
- echo "<td>".$sf['set_at_string']."</td>";
- echo "<td>".$sf['expire_at_string']."</td>";
- echo "<td>".$sf['duration_string']."</td>";
- echo "<td>".$sf['match_type']."</td>";
- echo "<td>".$sf['ban_action']."</td>";
- echo "<td>".$sf['ban_duration_string']."</td>";
- for ($i = 0, $targs = ""; ($c = $sf['spamfilter_targets'][$i]); $i++)
- {
- if ($c == "c")
- $targs .= "Channel, ";
- else if ($c == "p")
- $targs .= "Private,";
- else if ($c == "n")
- $targs .= "Notice, ";
- else if ($c == "N")
- $targs .= "Channel notice, ";
- else if ($c == "P")
- $targs .= "Part message, ";
- else if ($c == "q")
- $targs .= "Quit message, ";
- else if ($c == "d")
- $targs .= "DCC filename, ";
- else if ($c == "a")
- $targs .= "Away message, ";
- else if ($c == "t")
- $targs .= "Channel topic, ";
- else if ($c == "T")
- $targs .= "MessageTag, ";
- else if ($c == "u")
- $targs .= "Usermask, ";
-
- $targs = rtrim($targs,", ");
- }
- echo "<td>".$targs."</td>";
- echo "<td>".$sf['reason']."</td>";
-
+ containers.forEach((container) => {
+ container.removeAttribute('style');
+
+ });
+ } else
+ {
+ containers.forEach((container) => {
+ container.style.marginLeft = "40px";
+ container.style.marginTop = "30px";
+
+ });
}
- ?></table></div></div>
-
-</body>
+ });
+</script>
+
+<div class="container card-container card-container" style="margin-left:40px;margin-top:10px">
+
+ <div class="row">
+ <div class="col-sm-3">
+ <div class="card text-center">
+ <div class="card-header bg-success text-white">
+ <div class="row">
+ <div class="col">
+ <i class="fa fa-lock-open fa-3x"></i>
+ </div>
+ <div class="col">
+ <h3 class="display-4"><?php echo $num_of_panel_admins; ?></h3>
+ </div>
+ </div>
+ </div>
+ <div class="card-body">
+ <div class="row">
+ <div class="col">
+ <h6>Panel Accounts</h6>
+ </div>
+ <div class="col"> <a class="btn btn-primary" href="<?php echo get_config("base_url"); ?>settings">View</a></div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+<?php
+
+Hook::run(HOOKTYPE_OVERVIEW_CARD, $stats);
-<div class="footer"><p>Copyright 2022 © <a href="https://unrealircd.org/">UnrealIRCd</a></p></div>
\ No newline at end of file
+require_once "footer.php";