add boilerplate to pages to make them a bit more valid, also preload values for response edits

This commit is contained in:
notfire 2025-02-27 09:02:58 -05:00
parent a65df574ca
commit 28d453b614
No known key found for this signature in database
GPG key ID: 3AFDACAAB4E56B16
7 changed files with 40 additions and 10 deletions

View file

@ -26,6 +26,12 @@ foreach (array_reverse($rows) as $i) {
}
}
$properTitle = $pageTitle . " admin";
include '../boilerplate/pageStart.php';
echo("<link rel=\"stylesheet\" href=\"../css/admin.css\">");
echo("<h2 class=\"title\">" . $pageTitle . " admin</h2>");
if ($_GET["deleted"] == 1) {
@ -59,7 +65,7 @@ foreach (array_reverse($rows) as $i){
}
echo(htmlspecialchars($i["text"]));
echo("<div class=\"time\">" . $i["time"] . "</div>");
echo("<a class=\"permalink\" href=\"index.php?page=respond&id=" . $i["id"] . "&pw={$adminPassword}\">respond</a> / <a class=\"permalink\" href=\"index.php?page=delete&id=" . $i["id"] . "&pw={$adminPassword}\">delete</a></div>");
echo("<a class=\"permalink\" href=\"index.php?page=respond&id=" . $i["id"] . "&pw={$adminPassword}\">respond</a> / <a class=\"permalink\" href=\"index.php?page=delete&id=" . $i["id"] . "&pw={$adminPassword}\">delete</a></details></div>");
}
}
@ -72,7 +78,7 @@ foreach (array_reverse($rows) as $i){
}
echo(htmlspecialchars($i["text"]));
echo("<div class=\"time\">" . $i["time"] . "</div>");
echo("<a class=\"permalink\" href=\"index.php?page=mark&action=read&id=" . $i["id"] . "&pw={$adminPassword}\">mark read</a> / <a class=\"permalink\" href=\"index.php?page=delete&id=" . $i["id"] . "&pw={$adminPassword}\">delete</a></div>");
echo("<a class=\"permalink\" href=\"index.php?page=mark&action=read&id=" . $i["id"] . "&pw={$adminPassword}\">mark read</a> / <a class=\"permalink\" href=\"index.php?page=delete&id=" . $i["id"] . "&pw={$adminPassword}\">delete</a></details></div>");
}
}
@ -87,7 +93,7 @@ foreach (array_reverse($rows) as $i){
echo("<div class=\"time\">" . $i["time"] . "</div>");
echo("<div class=\"response\">" . htmlspecialchars($i["responsetext"]) . "");
echo("<div class=\"time\">" . $i["responsetime"] . "</div></div>");
echo("<a class=\"permalink\" href=\"index.php?page=respond&responded=1&id=" . $i["id"] . "&pw={$adminPassword}\">edit response</a> / <a class=\"permalink\" href=\"index.php?page=delete&id=" . $i["id"] . "&pw={$adminPassword}\">delete</a></div>");
echo("<a class=\"permalink\" href=\"index.php?page=respond&responded=1&id=" . $i["id"] . "&pw={$adminPassword}\">edit response</a> / <a class=\"permalink\" href=\"index.php?page=delete&id=" . $i["id"] . "&pw={$adminPassword}\">delete</a></details></div>");
}
}
@ -100,8 +106,10 @@ foreach (array_reverse($rows) as $i){
}
echo(htmlspecialchars($i["text"]));
echo("<div class=\"time\">" . $i["time"] . "</div>");
echo("<a class=\"permalink\" href=\"index.php?page=mark&action=unread&id=" . $i["id"] . "&pw={$adminPassword}\">mark unread</a> / <a class=\"permalink\" href=\"index.php?page=delete&id=" . $i["id"] . "&pw={$adminPassword}\">delete</a></div>");
echo("<a class=\"permalink\" href=\"index.php?page=mark&action=unread&id=" . $i["id"] . "&pw={$adminPassword}\">mark unread</a> / <a class=\"permalink\" href=\"index.php?page=delete&id=" . $i["id"] . "&pw={$adminPassword}\">delete</a></details></div>");
}
}
include '../boilerplate/pageEnd.php';
?>

View file

@ -2,8 +2,6 @@
include '../config.php';
echo("<link rel=\"stylesheet\" href=\"../css/admin.css\">");
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("<h2 class=\"sect\">enter password</h2>");
echo("<form class=\"frm\" action=\"index.php\"><input id=\"passinput\" name=\"pw\" required=\"\"><br><button class=\"submitbutton\" type=\"submit\">login</button></form>");
}

View file

@ -34,7 +34,10 @@ WHERE id = {$id};
$qresp = pg_query($db, $query);
$arr = pg_fetch_array($qresp);
echo("<link rel=\"stylesheet\" href=\"css/indiv.css\">");
$properTitle = $pageTitle . " respond to question #" . $id;
include '../boilerplate/pageStart.php';
echo("<link rel=\"stylesheet\" href=\"../css/admin.css\">");
if ($arr["ispublic"] === "f") {
echo("<h2 class=\"title\">{$pageTitle} no such question exists</h2>");
@ -57,7 +60,8 @@ if ($arr["ispublic"] === "f") {
} else {
echo("<h3>enter a response</h3>");
}
echo("<form class=\"frm\" action=\"index.php\"><input hidden name=\"id\" value=\"{$id}\"><input hidden name=\"page\" value=\"respond\"><input hidden name=\"pw\" value=\"{$adminPassword}\"><input id=\"passinput\" name=\"text\" required=\"\"><br><button class=\"submitbutton\" type=\"submit\">send</button></form>");
$respTxt = htmlspecialchars($arr["responsetext"]);
echo("<form class=\"frm\" action=\"index.php\"><input hidden name=\"id\" value=\"{$id}\"><input hidden name=\"page\" value=\"respond\"><input hidden name=\"pw\" value=\"{$adminPassword}\"><input id=\"passinput\" name=\"text\" value=\"{$respTxt}\" autofocus=\"autofocus\" required=\"\"><br><button class=\"submitbutton\" type=\"submit\">send</button></form>");
}
?>

5
boilerplate/pageEnd.php Normal file
View file

@ -0,0 +1,5 @@
<?php
// set up the page to have proper tags like <title>
echo("</body></html>")
?>

View file

@ -0,0 +1,5 @@
<?php
// set up the page to have proper tags like <title>
echo("<!DOCTYPE html><html><head><title>" . $properTitle . "</title><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"/></head><body>")
?>

View file

@ -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("<link rel=\"stylesheet\" href=\"css/indiv.css\">");
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("<div class=\"time\">" . $arr["time"] . "</div>");
echo("<div class=\"response\">" . $arr["responsetext"] . "");
echo("<div class=\"time\">" . $arr["responsetime"] . "</div></div></div>");
echo("<div class=\"time\">" . $arr["responsetime"] . "</div></div></details></div>");
}
?>

View file

@ -10,6 +10,10 @@ $qresp = pg_query($db, $query);
$rows = pg_fetch_all($qresp);
$properTitle = $pageTitle . " all questions";
include 'boilerplate/pageStart.php';
echo("<link rel=\"stylesheet\" href=\"css/main.css\">");
echo("<h2 class=\"title\">" . $pageTitle . "</h2>");
@ -42,7 +46,7 @@ foreach (array_reverse($rows) as $i){
echo("<div class=\"time\">" . $i["time"] . "</div>");
echo("<div class=\"response\">" . htmlspecialchars($i["responsetext"]) . "");
echo("<div class=\"time\">" . $i["responsetime"] . "</div></div>");
echo("<a class=\"permalink\" href=\"fetch.php?id=" . $i["id"] . "\">permalink</a></div>");
echo("<a class=\"permalink\" href=\"fetch.php?id=" . $i["id"] . "\">permalink</a></details></div>");
}
}