]>
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|NULL Returns an array of objects (notes)
11 public static function find(array $query) : array|NULL
15 if (!isset($config['notes']))
19 foreach ($query as $key => $value)
21 foreach (get_config("notes") as $nkey => $nvalue)
23 if ($value != $nvalue)
30 $note->note
= $nvalue;
34 return !empty($notes) ? $notes : NULL;
38 * Add a note to one or more peices of data
39 * @param array ["ip" => "127.0.0.1"]
40 * @param string $note "This is a note"
43 public static function add(array $params, string $note)
47 foreach ($params as $key => $value)
49 $id = md5(random_bytes(20)); // note ID (for linking)
50 $config['notes'][$key][$value][$id] = $note;
52 write_config(); // write db
55 public static function delete_by_id(string $id)
59 if (!isset($config['notes']))
62 foreach ($config['notes'] as $nkey => $nvalue)
63 foreach ($nvalue as $key => $value)
66 unset($config['notes'][$nkey][$key]);
70 write_config('notes');