This repository was archived by the owner on Jul 22, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotes.php
More file actions
executable file
·158 lines (141 loc) · 4.56 KB
/
notes.php
File metadata and controls
executable file
·158 lines (141 loc) · 4.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php
# Setup.
session_start();
if (isset($_POST['logout'])) {
session_destroy();
header("Location: index.php");
}
if (!isset($_SESSION["hash"]))
header("Location: index.php");
include("interface/interface.php");
db_connect();
# Variables.
$hash = $_SESSION["hash"];
define("PAGE_TITLE", "Notes");
define("PAGE_PATH", "notes.php");
$note_ids = db_notes_get_id_range();
$card_display_style = "collect";
# Handle operations performed on notes.
for ($id=$note_ids['begin']; $id<=$note_ids['end']; $id++) {
# Handle: Delete note.
if (isset($_POST['note_delete_'.strval($id)])) {
db_note_delete($id);
header('Location: '.$_SERVER['REQUEST_URI']);
stop();
}
# Handle: Share note.
if (isset($_POST['note_share_'.strval($id)])) {
if (!isset($_POST['note_share_username_'.strval($id)])) {
echo '<script>alert("Share note: Missing username.");</script>';
} else {
$username = $_POST['note_share_username_'.strval($id)];
$success = db_note_share($hash, $id, $username);
if (!$success) {
echo '<script>alert("Could not share note. Check the username.");</script>';
} else {
header('Location: '.$_SERVER['REQUEST_URI']);
stop();
}
}
}
}
# Handle: Add note.
if (isset($_POST['note_add'])) {
# Stop if missing information.
if (!isset($_POST['note_name']) || strlen($_POST['note_name']) == 0) {
echo '<script>alert("Note needs a description.");</script>';
} else {
# Retrieve information.
$name = $_POST['note_name'];
$img_addr = null;
if (isset($_POST['note_img']))
$img_addr = $_POST['note_img'];
# Add note.
db_note_add($hash, $name, $img_addr);
header('Location: '.$_SERVER['REQUEST_URI']);
stop();
}
}
?>
<!DOCTYPE html>
<html>
<!-- Head -->
<head>
<?php include("snippets/head.php"); ?>
</head>
<!-- Body -->
<body>
<main>
<!-- Header -->
<?php include("snippets/header.php"); ?>
<!-- Big Title: Notes -->
<?php
$TITLE_BIG_1 = "Notes";
$TITLE_BIG_2 = "Take note of potentially interesting artists, events, or anything else.";
include("snippets/title_big.php");
?>
<!-- Add Note -->
<div class="container">
<div class="row align-items-center g-lg-5 py-5">
<div class="col-md-10 mx-auto col-lg-5">
<form method="post" class="p-2 p-md-4 border rounded-3 bg-light">
<p class="card-text"><h1 class="h4">Take note</h1></p>
<div class="mb-3">
<label for="note_name" class="form-label">Content</label>
<input type="text" class="form-control" name="note_name" required="required">
</div>
<div class="mb-3">
<label for="note_img" class="form-label text-muted">Image Address (optional)</label>
<input type="text" class="form-control" name="note_img">
</div>
<div class="d-flex justify-content-between align-items-center">
<div class="btn-group">
<button type="submit" class="px-4 btn btn-primary" name="note_add">Add</button>
</div>
</div>
</form>
</div>
</div>
</div>
<!-- Album: Notes -->
<div class="album py-5 bg-light">
<div class="container">
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-3 g-3">
<!-- Notes -->
<?php
$notes = db_notes_get($hash);
if (!is_null($notes)) {
while (true) {
$note = $notes->fetch_assoc();
if (!$note)
break;
include("snippets/card_note.php");
}
} else {
include("snippets/hint_nothing.php");
}
?>
</div>
</div>
</div>
<!-- Footer -->
<?php include("snippets/footer.php") ?>
</main>
</body>
<script>
function note_share_show(i)
{
var el_share_enable = document.getElementById("note_share_enable_"+i.toString());
el_share_enable.style.display = "none";
var el_share_form = document.getElementById("note_share_form_"+i.toString());
el_share_form.style.display = "block";
}
function note_share_hide(i)
{
var el_share_enable = document.getElementById("note_share_enable_"+i.toString());
el_share_enable.style.display = "block";
var el_share_form = document.getElementById("note_share_form_"+i.toString());
el_share_form.style.display = "none";
}
</script>
</html>