]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/commitdiff
More towards notes (still not finished)
authorValerie Pond <redacted>
Mon, 8 Jul 2024 04:10:15 +0000 (12:10 +0800)
committerValerie Pond <redacted>
Mon, 8 Jul 2024 04:10:15 +0000 (12:10 +0800)
Classes/class-notes.php
misc/user-lookup-misc.php
users/details.php

index ca9f604213f691558d25807ca3406257d08261d7..d6686e9fc6f3f176da634f24c0f1c3f9d4d781b6 100644 (file)
@@ -6,32 +6,33 @@ class Notes { // OKAY CLASS GET YOUR NOTEPAD OUT
        /**
         * Find function for Notes
         * @param array $query The query to search for -- ["ip" => "127.0.0.1", "nick" => "bob", "account" => "bob", "id" => "lol] 
-        * @return array|NULL Returns an array of objects (notes)
+        * @return array Returns an array of objects (notes)
         */
-       public static function find(array $query) : array|NULL
+       public static function find(array $query) : array
        {
                global $config;
                read_config_db();
                if (!isset($config['notes']))
-                       return NULL;
+                       return [];
 
                $notes = [];
                foreach ($query as $key => $value)
-               {       
-                       foreach (get_config("notes") as $nkey => $nvalue)
+               {
+                       foreach ($config['notes'] as $nkey => $nvalue) // $nkey = "ip" "nick" "account", $nvalue = array
                        {
-                               if ($value != $nvalue)
-                                       continue;
-                                       
-                               $note = (object)[];
-                               $note->id = $nkey;
-                               $note->type = $key;
-                               $note->data - $value;
-                               $note->note = $nvalue;
-                               $notes[] = $note;
+                               foreach ($nvalue as $k => $n) // $k = "127.0.0.1", "bob", "bobsaccount", $n = array of notes [id => note]
+                               {
+                                       if ($value != $k)
+                                               continue;
+                                       $note = [];
+                                       $note["type"] = $nkey;
+                                       $note["data"] = $k;
+                                       $note["notes"] = $n;
+                                       $notes[$key] = $note;
+                               }
                        }
                }
-               return !empty($notes) ? $notes : NULL;
+               return !empty($notes) ? $notes : [];
        }
        
        /**
index fd7cebc87fbf767c9d0d40d95196b0cd0956602f..fe8d9c675d92ed9e4487516295593e229df3739b 100644 (file)
@@ -3,6 +3,14 @@
 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']) : [],
+               "nick" => isset($notes['ip']['notes']) ? count($notes["nick"]['notes'] ?? []) : [],
+               "account" => isset($notes['ip']['notes']) ? count($notes['account']['notes'] ?? []) : [],
+       ];
+       
        ?>
 
        <table class="table-sm table-responsive caption-top table-hover">
@@ -11,14 +19,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>
@@ -37,6 +45,7 @@ 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>Ident</th>
                                <td colspan="2"><code><?php echo htmlspecialchars($user->user->username); ?></code></td>
@@ -56,6 +65,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>
index 1a4fa6d2d87a88b2758d336c630e5131184968d3..13d8872766c6c7ea4af7f95292d0df712d03d7d1 100644 (file)
@@ -31,10 +31,13 @@ if (isset($_GET['nick']))
   </div>
 </form>
 
-<?php if (!$nick){
-       require_once("../inc/footer.php");
+<?php if (!$nick)
+{
+       require_once "../inc/footer.php";
        return;
-} ?>
+}
+
+?>
 <br>
 <div class="container-xxl">
   <div class="row">