From 28d453b6141defc2a97c9a7845c7232065184bef Mon Sep 17 00:00:00 2001 From: notfire Date: Thu, 27 Feb 2025 09:02:58 -0500 Subject: [PATCH] add boilerplate to pages to make them a bit more valid, also preload values for response edits --- admin/all.php | 16 ++++++++++++---- admin/index.php | 5 +++-- admin/respond.php | 8 ++++++-- boilerplate/pageEnd.php | 5 +++++ boilerplate/pageStart.php | 5 +++++ fetch.php | 5 ++++- index.php | 6 +++++- 7 files changed, 40 insertions(+), 10 deletions(-) create mode 100644 boilerplate/pageEnd.php create mode 100644 boilerplate/pageStart.php diff --git a/admin/all.php b/admin/all.php index d002a9e..8ad8d2f 100644 --- a/admin/all.php +++ b/admin/all.php @@ -26,6 +26,12 @@ foreach (array_reverse($rows) as $i) { } } +$properTitle = $pageTitle . " – admin"; + +include '../boilerplate/pageStart.php'; + +echo(""); + echo("

" . $pageTitle . " – admin

"); if ($_GET["deleted"] == 1) { @@ -59,7 +65,7 @@ foreach (array_reverse($rows) as $i){ } echo(htmlspecialchars($i["text"])); echo("
" . $i["time"] . "
"); - echo("respond / delete"); + echo("respond / delete"); } } @@ -72,7 +78,7 @@ foreach (array_reverse($rows) as $i){ } echo(htmlspecialchars($i["text"])); echo("
" . $i["time"] . "
"); - echo("mark read / delete"); + echo("mark read / delete"); } } @@ -87,7 +93,7 @@ foreach (array_reverse($rows) as $i){ echo("
" . $i["time"] . "
"); echo("
" . htmlspecialchars($i["responsetext"]) . ""); echo("
" . $i["responsetime"] . "
"); - echo("edit response / delete"); + echo("edit response / delete"); } } @@ -100,8 +106,10 @@ foreach (array_reverse($rows) as $i){ } echo(htmlspecialchars($i["text"])); echo("
" . $i["time"] . "
"); - echo("mark unread / delete"); + echo("mark unread / delete"); } } +include '../boilerplate/pageEnd.php'; + ?> diff --git a/admin/index.php b/admin/index.php index 2dfb424..12d9a7e 100644 --- a/admin/index.php +++ b/admin/index.php @@ -2,8 +2,6 @@ include '../config.php'; -echo(""); - if ($_GET["pw"] === $adminPassword) { if ($_GET["page"] === "delete") { include 'delete.php'; @@ -17,6 +15,9 @@ if ($_GET["pw"] === $adminPassword) { include 'all.php'; } } else { + $properTitle = $pageTitle . " – sign in"; + include 'boilerplate/pageStart.php'; + echo("

enter password

"); echo("

"); } diff --git a/admin/respond.php b/admin/respond.php index 1c2a7e0..7c208ed 100644 --- a/admin/respond.php +++ b/admin/respond.php @@ -34,7 +34,10 @@ WHERE id = {$id}; $qresp = pg_query($db, $query); $arr = pg_fetch_array($qresp); -echo(""); +$properTitle = $pageTitle . " – respond to question #" . $id; +include '../boilerplate/pageStart.php'; + +echo(""); if ($arr["ispublic"] === "f") { echo("

{$pageTitle} – no such question exists

"); @@ -57,7 +60,8 @@ if ($arr["ispublic"] === "f") { } else { echo("

enter a response

"); } - echo("

"); + $respTxt = htmlspecialchars($arr["responsetext"]); + echo("

"); } ?> diff --git a/boilerplate/pageEnd.php b/boilerplate/pageEnd.php new file mode 100644 index 0000000..087b532 --- /dev/null +++ b/boilerplate/pageEnd.php @@ -0,0 +1,5 @@ + +echo("") + +?> \ No newline at end of file diff --git a/boilerplate/pageStart.php b/boilerplate/pageStart.php new file mode 100644 index 0000000..b8139e2 --- /dev/null +++ b/boilerplate/pageStart.php @@ -0,0 +1,5 @@ + +echo("" . $properTitle . "") + +?> \ No newline at end of file diff --git a/fetch.php b/fetch.php index 505d24e..e6a9532 100644 --- a/fetch.php +++ b/fetch.php @@ -16,6 +16,9 @@ WHERE id = {$id}; $qresp = pg_query($db, $query); $arr = pg_fetch_array($qresp); +$properTitle = $pageTitle . " – question #" . $id; +include 'boilerplate/pageStart.php'; + echo(""); if (pg_num_rows($qresp) === 0 || $arr["ispublic"] === "f" || $arr["isrespondedto"] === "f") { @@ -33,7 +36,7 @@ if (pg_num_rows($qresp) === 0 || $arr["ispublic"] === "f" || $arr["isrespondedto echo(htmlspecialchars($arr["text"])); echo("
" . $arr["time"] . "
"); echo("
" . $arr["responsetext"] . ""); - echo("
" . $arr["responsetime"] . "
"); + echo("
" . $arr["responsetime"] . "
"); } ?> diff --git a/index.php b/index.php index 999474d..4045891 100644 --- a/index.php +++ b/index.php @@ -10,6 +10,10 @@ $qresp = pg_query($db, $query); $rows = pg_fetch_all($qresp); +$properTitle = $pageTitle . " – all questions"; + +include 'boilerplate/pageStart.php'; + echo(""); echo("

" . $pageTitle . "

"); @@ -42,7 +46,7 @@ foreach (array_reverse($rows) as $i){ echo("
" . $i["time"] . "
"); echo("
" . htmlspecialchars($i["responsetext"]) . ""); echo("
" . $i["responsetime"] . "
"); - echo("permalink"); + echo("permalink"); } }