commit 7ee55fcd427fc3bc848ca18a6be9607066ca6de9
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date: Thu, 24 Oct 2024 16:30:44 +0200
feat: add function to read notes
Diffstat:
2 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/data/.empty b/data/.empty
diff --git a/lib/read.php b/lib/read.php
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: AGPL-3.0-or-later
+ * SPDX-FileCopyrightText: 2021-2024 JayVii <jayvii[AT]posteo[DOT]de>
+ */
+
+<?php
+
+function read_note(
+ string $user,
+ string $category,
+ string $filename,
+) {
+
+ /* Create full file path name */
+ $dirpath = "./data/" . $user . "/" . $category;
+ $filepath = $dirpath . "/" . $filename;
+
+ /* create file-handle */
+ $file = fopen(
+ $filepath,
+ "r"
+ );
+
+ /* Read from file */
+ $content = fread($file);
+
+ /* return content.If reading fails, returns "false" */
+ return $content;
+
+}
+
+?>