From: Valerie Pond Date: Mon, 8 Jul 2024 02:33:18 +0000 (+0800) Subject: Add start of Notes functionality X-Git-Url: https://jfr.im/git/irc/unrealircd/unrealircd-webpanel.git/commitdiff_plain/7bcd30edb23fcc1872f0a6772ab91b3c9d8b4779 Add start of Notes functionality --- diff --git a/Classes/class-notes.php b/Classes/class-notes.php new file mode 100644 index 0000000..ca9f604 --- /dev/null +++ b/Classes/class-notes.php @@ -0,0 +1,72 @@ + "127.0.0.1", "nick" => "bob", "account" => "bob", "id" => "lol] + * @return array|NULL Returns an array of objects (notes) + */ + public static function find(array $query) : array|NULL + { + global $config; + read_config_db(); + if (!isset($config['notes'])) + return NULL; + + $notes = []; + foreach ($query as $key => $value) + { + foreach (get_config("notes") as $nkey => $nvalue) + { + if ($value != $nvalue) + continue; + + $note = (object)[]; + $note->id = $nkey; + $note->type = $key; + $note->data - $value; + $note->note = $nvalue; + $notes[] = $note; + } + } + return !empty($notes) ? $notes : NULL; + } + + /** + * Add a note to one or more peices of data + * @param array ["ip" => "127.0.0.1"] + * @param string $note "This is a note" + * @return void + */ + public static function add(array $params, string $note) + { + global $config; + read_config_db(); + foreach ($params as $key => $value) + { + $id = md5(random_bytes(20)); // note ID (for linking) + $config['notes'][$key][$value][$id] = $note; + } + write_config(); // write db + } + + public static function delete_by_id(string $id) + { + global $config; + read_config_db(); + if (!isset($config['notes'])) + return NULL; + + foreach ($config['notes'] as $nkey => $nvalue) + foreach ($nvalue as $key => $value) + if ($value == $id) + { + unset($config['notes'][$nkey][$key]); + break; + } + + write_config('notes'); + } +} diff --git a/inc/common.php b/inc/common.php index 96721e6..3bd7823 100644 --- a/inc/common.php +++ b/inc/common.php @@ -466,6 +466,7 @@ require_once UPATH . "/Classes/class-log.php"; require_once UPATH . "/Classes/class-message.php"; require_once UPATH . "/Classes/class-rpc.php"; require_once UPATH . "/Classes/class-paneluser.php"; +require_once UPATH . "/Classes/class-notes.php"; require_once UPATH . "/Classes/class-plugins.php"; /* Do various checks and reading, except during setup step 1. */ diff --git a/settings/general.php b/settings/general.php index 0cee9c8..8a0c3ae 100644 --- a/settings/general.php +++ b/settings/general.php @@ -64,6 +64,34 @@ if (isset($_POST['submit']) && $canEdit) do_log("\$_POST", $_POST); do_log("\$_FILES", $_FILES); ?> + +

General Settings


@@ -83,6 +111,133 @@ do_log("\$_FILES", $_FILES); Enabling this will likely make your webpanel more difficult to use +
+
Themes
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+