]>
jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blob - Classes/class-notes.php
3 /* Make notes against nicks, IPs and account names. */
5 class Notes
{ // OKAY CLASS GET YOUR NOTEPAD OUT
7 * Find function for Notes
8 * @param array $query The query to search for -- ["ip" => "127.0.0.1", "nick" => "bob", "account" => "bob", "id" => "lol]
9 * @return array Returns an array of objects (notes)
11 public static function find(array $query) : array
15 if (!isset($config['notes']))
19 foreach ($query as $key => $value)
21 foreach ($config['notes'] as $nkey => $nvalue) // $nkey = "ip" "nick" "account", $nvalue = array
23 foreach ($nvalue as $k => $n) // $k = "127.0.0.1", "bob", "bobsaccount", $n = array of notes [id => note]
28 $note["type"] = $nkey;
35 return !empty($notes) ? $notes : [];
39 * Add a note to one or more peices of data
40 * @param array ["ip" => "127.0.0.1"]
41 * @param string $note "This is a note"
44 public static function add(array $params, string $note)
48 foreach ($params as $key => $value)
50 $id = md5(random_bytes(20)); // note ID (for linking)
51 $config['notes'][$key][$value][$id] = $note;
53 write_config(); // write db
56 public static function delete_by_id(string $id)
60 if (!isset($config['notes']))
63 foreach ($config['notes'] as $nkey => $nvalue)
64 foreach ($nvalue as $key => $value)
67 unset($config['notes'][$nkey][$key]);
71 write_config('notes');