diff --git a/app/pswd.php b/app/pswd.php
index 59e7571..1f65476 100644
--- a/app/pswd.php
+++ b/app/pswd.php
@@ -1,13 +1,11 @@
{ result.innerHTML = \"Copied\"; } );'>Copy
\n";
echo "\n";
-
-require "$root/templates/footer.php";
+require "$_shared/footer.php";
?>
diff --git a/index.php b/index.php
index 495a4df..a23a58e 100644
--- a/index.php
+++ b/index.php
@@ -1,7 +1,7 @@
Apps
Public
@@ -14,5 +14,5 @@ require "$root/templates/header.php";
Media viewer
Media downloader
diff --git a/local/media/get.php b/local/media/get.php
index 74b725f..96f9b14 100644
--- a/local/media/get.php
+++ b/local/media/get.php
@@ -1,8 +1,7 @@
Try $list
";
}
}
-
-require "$root/templates/footer.php";
+require "$_shared/footer.php";
?>
diff --git a/local/notes/db.php b/local/notes/db.php
deleted file mode 100644
index 58bdacc..0000000
--- a/local/notes/db.php
+++ /dev/null
@@ -1,8 +0,0 @@
- PDO::ERRMODE_EXCEPTION,
- PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
-]);
-$pdo->query("create table mail(id int)");
-?>
diff --git a/local/notes/db.sql b/local/notes/db.sql
new file mode 100644
index 0000000..daffd5f
--- /dev/null
+++ b/local/notes/db.sql
@@ -0,0 +1,8 @@
+drop schema if exists notes cascade;
+create schema notes;
+create table notes.entries(
+ id int generated always as identity primary key,
+ title text not null,
+ note text not null,
+ date date default current_date not null
+);
diff --git a/local/notes/index.php b/local/notes/index.php
index 963b81b..71e61aa 100644
--- a/local/notes/index.php
+++ b/local/notes/index.php
@@ -1,15 +1,18 @@
Write a note
Notes
$note
\n";
+require_once "$_shared/lib.php";
+$pdo = pdo_init();
+$entries = $pdo->query("select * from notes.entries order by date desc");
+foreach ($entries as $entry) {
+ $id = $entry["id"];
+ $text = $entry["title"];
+ echo "$text
\n";
}
-require "$root/templates/footer.php";
+require "$_shared/footer.php";
?>
diff --git a/local/notes/write.php b/local/notes/write.php
index 3f0e120..6245fee 100644
--- a/local/notes/write.php
+++ b/local/notes/write.php
@@ -1,41 +1,51 @@
prepare("delete from notes.entries where id = ?");
+ $stmt->execute([$note_id]);
+ header("Location: .");
+ exit;
+ }
+ $stmt = $pdo->prepare("select * from notes.entries where id = ?");
+ $stmt->execute([$note_id]);
+ $entry = $stmt->fetch();
+ $title = $entry["title"];
+ $note = $entry["note"];
+ $date = $entry["date"];
+ $del_href = "Delele";
};
break;
case "POST":
- file_put_contents("notesDir/" . base64_encode($_POST["title"]), $_POST["note"]);
+ $pdo = pdo_init();
+ if ($_POST["id"] == "") {
+ $stmt = $pdo->prepare("insert into notes.entries
+ (title, note, date) values (?, ?, ?)");
+ $stmt->execute([$_POST["title"], $_POST["note"], $_POST["date"]]);
+ } else {
+ $stmt = $pdo->prepare("update notes.entries
+ set title = ?, note = ?, date = ? where id = ?");
+ $stmt->execute([$_POST["title"], $_POST["note"], $_POST["date"], $_POST["id"]]);
+ }
header("Location: .");
exit;
}
$_title = "Notes";
-$root = $_SERVER["DOCUMENT_ROOT"];
-require "$root/templates/header.php";
+require "$_shared/header.php";
?>
-
diff --git a/style.css b/style.css
index f96eba6..49d3884 100644
--- a/style.css
+++ b/style.css
@@ -1,7 +1,18 @@
+a {
+ color: #00ffff;
+}
+button {
+ padding: 5px 10px;
+}
+.note {
+ width: 98%;
+ height: 280px;
+}
body {
color: #ffffff;
background: #000000;
}
-a {
- color: #00ffff;
+.content {
+ color: #ffffff;
+ background-color: #303030;
}
diff --git a/templates/lib.php b/templates/lib.php
new file mode 100644
index 0000000..8a62d40
--- /dev/null
+++ b/templates/lib.php
@@ -0,0 +1,7 @@
+ PDO::FETCH_ASSOC,
+ ]);
+}
+?>