]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blobdiff - misc/user-lookup-misc.php
Include ASN info in user details
[irc/unrealircd/unrealircd-webpanel.git] / misc / user-lookup-misc.php
index fd7cebc87fbf767c9d0d40d95196b0cd0956602f..f367257ebea17a2cba5c9737a1fca642ba5b00a2 100644 (file)
@@ -3,6 +3,19 @@
 function generate_html_whois($user)
 {
        global $rpc;
+       
+       $notes = Notes::find(["nick" => $user->name, "ip" => $user->ip, "account" => $user->account ?? NULL]);
+       $numnotes = [
+               "ip" => isset($notes['ip']['notes']) ? count($notes["ip"]['notes']) : 0,
+               "nick" => isset($notes['ip']['notes']) ? count($notes["nick"]['notes'] ?? []) : 0,
+               "account" => isset($notes['ip']['notes']) ? count($notes['account']['notes'] ?? []) : 0,
+       ];
+       $cc = (isset($user->geoip->country_code)) ? strtolower($user->geoip->country_code) : "";
+       
+       $asn = $user->geoip->asn ?? "none";
+       $asname = $user->geoip->asname ?? "none";
+       Message::Fail(var_export($user->geoip, true));
+       
        ?>
 
        <table class="table-sm table-responsive caption-top table-hover">
@@ -11,14 +24,14 @@ function generate_html_whois($user)
                        top:25px;
                        right: 25px;
                        background-color:lightgrey;
-                       font-size:small;
-                       "
+                       font-size:small;"
                >Reputation <span class="badge badge-danger" style="font-size:small;"><?php echo $user->user->reputation; ?></span>
                </span>
                <tbody>
                        <tr>
                                <th>Nick</th>
                                <td colspan="2"><code><?php echo htmlspecialchars($user->name); ?></code></td>
+                               <td colspan="2"><button id="nicknotes" class="btn btn-sm btn-secondary fa-solid fa-sticky-note text-nowrap"> <?php echo $numnotes['nick']?></div></button></td>
                        </tr><tr>
                                <th>User ID (UID)</th>
                                <td colspan="2"><code><?php echo htmlspecialchars($user->id); ?></code></td>
@@ -27,9 +40,10 @@ function generate_html_whois($user)
                                <td colspan="2"><code><?php echo htmlspecialchars($user->hostname); ?></code></td>
                        </tr><tr>
                                <th>IP</th>
-                               <td colspan="2"><code><?php echo htmlspecialchars($user->ip); ?></code>
+                               <td colspan="2">
+                                       <code><?php echo htmlspecialchars($user->ip); ?></code>
                                <?php
-                               if ($cc = (isset($user->geoip->country_code)) ? strtolower($user->geoip->country_code) : "")
+                               if (strlen($cc))
                                {
                                   ?>  <img src="https://flagcdn.com/48x36/<?php echo htmlspecialchars($cc); ?>.png"
                                                        width="20"
@@ -37,6 +51,10 @@ function generate_html_whois($user)
                                        <?php } ?>
                                        <a href="<?php echo htmlspecialchars(get_config("base_url")."tools/ip-whois.php?ip=$user->ip"); ?>"><button class="btn-sm btn-primary">WHOIS IP</button></a>
                                </td>
+                               <td><button id="ipnotes" class="btn btn-sm btn-secondary fa-solid fa-sticky-note text-nowrap"> <?php echo $numnotes['ip']?></button></td>
+                       </tr><tr>
+                               <th>ASN</th>
+                               <td colspan="2"><code><?php echo "$asname ($asn)"; ?></code></td>
                        </tr><tr>
                                <th>Ident</th>
                                <td colspan="2"><code><?php echo htmlspecialchars($user->user->username); ?></code></td>
@@ -56,6 +74,7 @@ function generate_html_whois($user)
                        <tr>
                                <th>Logged in as</th>
                                <td colspan="2"><code><?php echo (isset($user->user->account)) ? "<a href=\"".get_config("base_url")."users/?account=".htmlspecialchars($user->user->account)."\">".htmlspecialchars($user->user->account)."</a>" : ""; ?></code></td>
+                               <td><button id="account_notes" class="btn btn-sm btn-secondary fa-solid fa-sticky-note text-nowrap"> <?php echo $numnotes['account']?></button></td>
                        </tr>
                        <tr>
                                <th style="background-color: blanchedalmond;border-radius:5px";>Security Groups</th>