add boilerplate to pages to make them a bit more valid

This commit is contained in:
notfire 2025-02-27 08:46:39 -05:00
parent a65df574ca
commit 91f55f0350
Signed by: notfire
GPG key ID: 3AFDACAAB4E56B16
7 changed files with 37 additions and 7 deletions

View file

@ -28,6 +28,10 @@ foreach (array_reverse($rows) as $i) {
echo("<h2 class=\"title\">" . $pageTitle . " admin</h2>"); echo("<h2 class=\"title\">" . $pageTitle . " admin</h2>");
$properTitle = $pageTitle . " admin";
include '../boilerplate/pageStart.php';
if ($_GET["deleted"] == 1) { if ($_GET["deleted"] == 1) {
echo("<span class=\"sentconf\">deleted!</span>"); echo("<span class=\"sentconf\">deleted!</span>");
} }
@ -55,7 +59,7 @@ foreach (array_reverse($rows) as $i){
if ($i["isrespondedto"] === "f" && $i["ispublic"] == "t") { if ($i["isrespondedto"] === "f" && $i["ispublic"] == "t") {
echo("<div class=\"question\">"); echo("<div class=\"question\">");
if ($i["iscwed"] === "t") { if ($i["iscwed"] === "t") {
echo("<details><summary>cw: " . htmlspecialchars($i["cw"]) . "</summary><span class=\"cwfiller\"></span>"); echo("<details><summary>cw: " . htmlspecialchars($i["cw"]) . "</summary><span class=\"cwfiller\"></span></details>");
} }
echo(htmlspecialchars($i["text"])); echo(htmlspecialchars($i["text"]));
echo("<div class=\"time\">" . $i["time"] . "</div>"); echo("<div class=\"time\">" . $i["time"] . "</div>");
@ -68,7 +72,7 @@ foreach (array_reverse($rows) as $i){
if ($i["ispublic"] === "f" && $i["isprivread"] === "f") { if ($i["ispublic"] === "f" && $i["isprivread"] === "f") {
echo("<div class=\"question\">"); echo("<div class=\"question\">");
if ($i["iscwed"] === "t") { if ($i["iscwed"] === "t") {
echo("<details><summary>cw: " . htmlspecialchars($i["cw"]) . "</summary><span class=\"cwfiller\"></span>"); echo("<details><summary>cw: " . htmlspecialchars($i["cw"]) . "</summary><span class=\"cwfiller\"></span></details>");
} }
echo(htmlspecialchars($i["text"])); echo(htmlspecialchars($i["text"]));
echo("<div class=\"time\">" . $i["time"] . "</div>"); echo("<div class=\"time\">" . $i["time"] . "</div>");
@ -81,7 +85,7 @@ foreach (array_reverse($rows) as $i){
if ($i["ispublic"] === "t" && $i["isrespondedto"] === "t") { if ($i["ispublic"] === "t" && $i["isrespondedto"] === "t") {
echo("<div class=\"question\">"); echo("<div class=\"question\">");
if ($i["iscwed"] === "t") { if ($i["iscwed"] === "t") {
echo("<details><summary>cw: " . htmlspecialchars($i["cw"]) . "</summary><span class=\"cwfiller\"></span>"); echo("<details><summary>cw: " . htmlspecialchars($i["cw"]) . "</summary><span class=\"cwfiller\"></span></details>");
} }
echo(htmlspecialchars($i["text"])); echo(htmlspecialchars($i["text"]));
echo("<div class=\"time\">" . $i["time"] . "</div>"); echo("<div class=\"time\">" . $i["time"] . "</div>");
@ -96,7 +100,7 @@ foreach (array_reverse($rows) as $i){
if ($i["ispublic"] === "f" && $i["isprivread"] === "t") { if ($i["ispublic"] === "f" && $i["isprivread"] === "t") {
echo("<div class=\"question\">"); echo("<div class=\"question\">");
if ($i["iscwed"] === "t") { if ($i["iscwed"] === "t") {
echo("<details><summary>cw: " . htmlspecialchars($i["cw"]) . "</summary><span class=\"cwfiller\"></span>"); echo("<details><summary>cw: " . htmlspecialchars($i["cw"]) . "</summary><span class=\"cwfiller\"></span></details>");
} }
echo(htmlspecialchars($i["text"])); echo(htmlspecialchars($i["text"]));
echo("<div class=\"time\">" . $i["time"] . "</div>"); echo("<div class=\"time\">" . $i["time"] . "</div>");
@ -104,4 +108,6 @@ foreach (array_reverse($rows) as $i){
} }
} }
include '../boilerplate/pageEnd.php';
?> ?>

View file

@ -17,6 +17,9 @@ if ($_GET["pw"] === $adminPassword) {
include 'all.php'; include 'all.php';
} }
} else { } else {
$properTitle = $pageTitle . " sign in";
include 'boilerplate/pageStart.php';
echo("<h2 class=\"sect\">enter password</h2>"); 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>"); 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,6 +34,10 @@ WHERE id = {$id};
$qresp = pg_query($db, $query); $qresp = pg_query($db, $query);
$arr = pg_fetch_array($qresp); $arr = pg_fetch_array($qresp);
$runOnLoad = "document.getElementById(\"passinput\").value = " . htmlspecialchars($arr["responsetext"]);
$properTitle = $pageTitle . " respond to question #" . $id;
include 'boilerplate/pageStart.php';
echo("<link rel=\"stylesheet\" href=\"css/indiv.css\">"); echo("<link rel=\"stylesheet\" href=\"css/indiv.css\">");
if ($arr["ispublic"] === "f") { if ($arr["ispublic"] === "f") {
@ -57,7 +61,7 @@ if ($arr["ispublic"] === "f") {
} else { } else {
echo("<h3>enter a response</h3>"); 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>"); 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\" 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 onload=\"" . $runOnLoad . "\">")
?>

View file

@ -16,6 +16,9 @@ WHERE id = {$id};
$qresp = pg_query($db, $query); $qresp = pg_query($db, $query);
$arr = pg_fetch_array($qresp); $arr = pg_fetch_array($qresp);
$properTitle = $pageTitle . " question #" . $id;
include 'boilerplate/pageStart.php';
echo("<link rel=\"stylesheet\" href=\"css/indiv.css\">"); echo("<link rel=\"stylesheet\" href=\"css/indiv.css\">");
if (pg_num_rows($qresp) === 0 || $arr["ispublic"] === "f" || $arr["isrespondedto"] === "f") { if (pg_num_rows($qresp) === 0 || $arr["ispublic"] === "f" || $arr["isrespondedto"] === "f") {
@ -28,7 +31,7 @@ if (pg_num_rows($qresp) === 0 || $arr["ispublic"] === "f" || $arr["isrespondedto
echo("<a class=\"goback\" href=\"index.php\">(go back?)</a>"); echo("<a class=\"goback\" href=\"index.php\">(go back?)</a>");
echo("<div class=\"question\">"); echo("<div class=\"question\">");
if ($arr["iscwed"] === "t") { if ($arr["iscwed"] === "t") {
echo("<details><summary>cw: " . htmlspecialchars($arr["cw"]) . "</summary><span class=\"cwfiller\"></span>"); echo("<details><summary>cw: " . htmlspecialchars($arr["cw"]) . "</summary><span class=\"cwfiller\"></span></details>");
} }
echo(htmlspecialchars($arr["text"])); echo(htmlspecialchars($arr["text"]));
echo("<div class=\"time\">" . $arr["time"] . "</div>"); echo("<div class=\"time\">" . $arr["time"] . "</div>");

View file

@ -10,6 +10,10 @@ $qresp = pg_query($db, $query);
$rows = pg_fetch_all($qresp); $rows = pg_fetch_all($qresp);
$properTitle = $pageTitle . " all questions";
include 'boilerplate/pageStart.php';
echo("<link rel=\"stylesheet\" href=\"css/main.css\">"); echo("<link rel=\"stylesheet\" href=\"css/main.css\">");
echo("<h2 class=\"title\">" . $pageTitle . "</h2>"); echo("<h2 class=\"title\">" . $pageTitle . "</h2>");
@ -36,7 +40,7 @@ foreach (array_reverse($rows) as $i){
if ($i["ispublic"] === "t" && $i["isrespondedto"] === "t") { if ($i["ispublic"] === "t" && $i["isrespondedto"] === "t") {
echo("<div class=\"question\">"); echo("<div class=\"question\">");
if ($i["iscwed"] === "t") { if ($i["iscwed"] === "t") {
echo("<details><summary>cw: " . htmlspecialchars($i["cw"]) . "</summary><span class=\"cwfiller\"></span>"); echo("<details><summary>cw: " . htmlspecialchars($i["cw"]) . "</summary><span class=\"cwfiller\"></span></details>");
} }
echo(htmlspecialchars($i["text"])); echo(htmlspecialchars($i["text"]));
echo("<div class=\"time\">" . $i["time"] . "</div>"); echo("<div class=\"time\">" . $i["time"] . "</div>");