From 6674fca71a32ec661747fd6907329982b25aeee6 Mon Sep 17 00:00:00 2001 From: trinkey Date: Wed, 12 Mar 2025 08:31:53 -0400 Subject: [PATCH] add my changes --- README.md | 8 +- TODO.md | 2 +- admin/all.php | 174 ++++++------------ admin/delete.php | 4 +- admin/fedi.php | 68 +++---- admin/index.php | 33 ++-- admin/mark.php | 28 +-- admin/migrate.php | 20 +- admin/respond.php | 75 ++++---- boilerplate/pageEnd.php | 7 +- boilerplate/pageStart.php | 17 +- boilerplate/question.php | 87 +++++++++ config.example.php | 10 +- css/admin.css | 82 --------- css/base.css | 99 ++++++++++ css/indiv.css | 38 ---- css/main.css | 83 --------- fetch.php | 48 +++-- index.php | 80 ++++---- .../20240218-AddFalsesToPrivRead-67d82b18.php | 4 +- .../20240218-AddMarkReadOption-a7e43358.php | 4 +- .../20240218-AddMigrationsTable-40641e8d.php | 4 +- .../20250310-AddFediIDColumn-64520350.php | 4 +- send.php | 32 +--- setup.php | 28 +-- 25 files changed, 470 insertions(+), 569 deletions(-) create mode 100644 boilerplate/question.php delete mode 100644 css/admin.css create mode 100644 css/base.css delete mode 100644 css/indiv.css delete mode 100644 css/main.css diff --git a/README.md b/README.md index 1cd07e5..26dbbaa 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,10 @@ +trinkey's fork of [notfire's qna](https://git.notfire.cc/notfire/qna) + +has the same functionality but i added custom css support and made the code less messy + +--- + to set up, generally: - make a database in postgres - set up config.php based off of the example -- run `php setup.php` to create the database table \ No newline at end of file +- run `php setup.php` to create the database table diff --git a/TODO.md b/TODO.md index a751cb8..15b5ed3 100644 --- a/TODO.md +++ b/TODO.md @@ -1,3 +1,3 @@ - modifying whether a cw is used or not? - POSSIBLY editing messages / changing their visibility? idk -- some way to automatically get notified \ No newline at end of file +- some way to automatically get notified diff --git a/admin/all.php b/admin/all.php index df9de2f..e0ed36e 100644 --- a/admin/all.php +++ b/admin/all.php @@ -4,131 +4,75 @@ $query = " SELECT * FROM data; "; -$qresp = pg_query($db, $query); +$queryResponse = pg_query($db, $query); +$questions = pg_fetch_all($queryResponse); +asort($questions); -$rows = pg_fetch_all($qresp); +$properTitle = "{$pageTitle} — admin"; +$CSSdownDirectory = 1; +include "../boilerplate/pageStart.php"; +include "../boilerplate/question.php"; + +echo("

{$pageTitle} — admin

"); + +if ($_GET["deleted"] == 1) { + echo("
deleted!
"); +} + +if ($_GET["responded"] == 1) { + echo("
response sent!
"); +} + +if ($_GET["read"] == 1) { + echo("
marked as read!
"); +} + +if ($_GET["unread"] == 1) { + echo("
marked as unread!
"); +} + +if ($_GET["migrated"] == 1) { + echo("
migrations have been run!
"); +} $totalUnresponded = 0; $totalPriv = 0; $totalPrivRead = 0; $totalRespondedPub = 0; -foreach (array_reverse($rows) as $i) { - if ($i["isrespondedto"] === "f" && $i["ispublic"] === "t") { - $totalUnresponded++; - } else if ($i["ispublic"] === "f") { - if ($i["isprivread"] === "t") { - $totalPrivRead++; - } else { - $totalPriv++; - } + +$unresponded = ""; +$private = ""; +$privateRead = ""; +$responded = ""; + +foreach (array_reverse($questions) as $question) { + if ($question["isrespondedto"] === "f" && $question["ispublic"] === "t") { + $totalUnresponded++; + $unresponded .= getQuestion($question, 0, 1, 0, $adminPassword); + } else if ($question["ispublic"] === "f") { + if ($question["isprivread"] === "t") { + $totalPrivRead++; + $privateRead .= getQuestion($question, 0, 1, 0, $adminPassword); } else { - $totalRespondedPub++; + $totalPriv++; + $private .= getQuestion($question, 0, 1, 0, $adminPassword); } + } else { + $totalRespondedPub++; + $responded .= getQuestion($question, 0, 1, 0, $adminPassword); + } } -$properTitle = $pageTitle . " – admin"; - -include '../boilerplate/pageStart.php'; - -echo(""); - -echo("

" . $pageTitle . " – admin

"); - -if ($_GET["deleted"] == 1) { - echo("deleted!"); -} - -if ($_GET["responded"] == 1) { - echo("response sent!"); -} - -if ($_GET["read"] == 1) { - echo("marked as read!"); -} - -if ($_GET["unread"] == 1) { - echo("marked as unread!"); -} - -if ($_GET["migrated"] == 1) { - echo("migrations have been run!"); -} - -asort($rows); - -echo("

not responded to ({$totalUnresponded})

"); -foreach (array_reverse($rows) as $i){ - if ($i["isrespondedto"] === "f" && $i["ispublic"] == "t") { - echo("
"); - if ($i["iscwed"] === "t") { - echo("
cw: " . htmlspecialchars($i["cw"]) . ""); - } - echo(htmlspecialchars($i["text"])); - echo("
" . $i["time"] . "
"); - echo("respond / delete"); - if ($i["iscwed"] === "t") { - echo("
"); - } else { - echo(""); - } - } -} - -echo("

unread private ({$totalPriv})

"); -foreach (array_reverse($rows) as $i){ - if ($i["ispublic"] === "f" && $i["isprivread"] === "f") { - echo("
"); - if ($i["iscwed"] === "t") { - echo("
cw: " . htmlspecialchars($i["cw"]) . ""); - } - echo(htmlspecialchars($i["text"])); - echo("
" . $i["time"] . "
"); - echo("mark read / delete"); - if ($i["iscwed"] === "t") { - echo("
"); - } else { - echo(""); - } - } -} - -echo("

public ({$totalRespondedPub})

"); -foreach (array_reverse($rows) as $i){ - if ($i["ispublic"] === "t" && $i["isrespondedto"] === "t") { - echo("
"); - if ($i["iscwed"] === "t") { - echo("
cw: " . htmlspecialchars($i["cw"]) . ""); - } - echo(htmlspecialchars($i["text"])); - echo("
" . $i["time"] . "
"); - echo("
" . htmlspecialchars($i["responsetext"]) . ""); - echo("
" . $i["responsetime"] . "
"); - echo("edit response / delete"); - if ($i["iscwed"] === "t") { - echo("
"); - } else { - echo(""); - } - } -} - -echo("

read private ({$totalPrivRead})

"); -foreach (array_reverse($rows) as $i){ - if ($i["ispublic"] === "f" && $i["isprivread"] === "t") { - echo("
"); - if ($i["iscwed"] === "t") { - echo("
cw: " . htmlspecialchars($i["cw"]) . ""); - } - echo(htmlspecialchars($i["text"])); - echo("
" . $i["time"] . "
"); - echo("mark unread / delete"); - if ($i["iscwed"] === "t") { - echo("
"); - } else { - echo(""); - } - } -} +echo(" +

not responded to ({$totalUnresponded})

+ {$unresponded} +

unread private ({$totalPriv})

+ {$private} +

public ({$totalRespondedPub})

+ {$responded} +

read private ({$totalPrivRead})

+ {$privateRead} +"); include '../boilerplate/pageEnd.php'; diff --git a/admin/delete.php b/admin/delete.php index db20957..f86f126 100644 --- a/admin/delete.php +++ b/admin/delete.php @@ -3,7 +3,7 @@ $id = (int)$_GET["id"]; if ($id === null) { - exit(); + exit(); } $query = " @@ -15,4 +15,4 @@ pg_query($db, $query); header("Location: index.php?deleted=1&pw={$adminPassword}"); -?> \ No newline at end of file +?> diff --git a/admin/fedi.php b/admin/fedi.php index 58847cd..41e2cfb 100644 --- a/admin/fedi.php +++ b/admin/fedi.php @@ -5,51 +5,41 @@ SELECT * FROM data WHERE id = {$id}; "; -$qresp = pg_query($db, $query); -$arr = pg_fetch_array($qresp); +$queryResponse = pg_query($db, $query); +$question = pg_fetch_array($queryResponse); + +$url = "{$pageProto}://" . $_SERVER["HTTP_HOST"] . $pagePath . "/fetch.php?id={$id}"; + +if (strlen($question["fedipostid"]) == 0) { + $method = "POST"; + $route = $fediAPIRoute; +} else { + $method = "PUT"; + $route = $fediAPIRoute . "/" . $question["fedipostid"]; +} + +$cw = "anonymous question response (automated)"; +if ($question["iscwed"] == "t") { + $cw .= "; cw: {$question['cw']}"; +} $ch = curl_init(); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: {$fediAPIToken}")); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); +curl_setopt($ch, CURLOPT_URL, $route); +curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); +curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array( + "status" => "question: {$question['text']}\n\nresponse: {$question['responsetext']}\n\nlink: {$url}", + "visibility" => $fediVisibility, + "spoiler_text" => $cw +))); -$contentO = $arr["text"]; -$contentR = $arr["responsetext"]; -$url = "{$pageProto}://" . $_SERVER["HTTP_HOST"] . $pagePath . "/fetch.php?id={$id}"; - -if (strlen($arr["fedipostid"]) == 0) { - curl_setopt($ch, CURLOPT_URL, $fediAPIRoute); - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); - - if ($arr["iscwed"] == "t") { - $contentCW = $arr["cw"]; - curl_setopt($ch, CURLOPT_POSTFIELDS, - http_build_query(array('status' => "question: {$contentO}\n\nresponse: {$contentR}\n\nlink: {$url}", 'visibility' => "{$fediVisibility}", 'spoiler_text' => "anonymous question response (automated); cw: {$contentCW}"))); - } else { - curl_setopt($ch, CURLOPT_POSTFIELDS, - http_build_query(array('status' => "question: {$contentO}\n\nresponse: {$contentR}\n\nlink: {$url}", 'visibility' => "{$fediVisibility}", 'spoiler_text' => "anonymous question response (automated)"))); - } - - $resp = curl_exec($ch); - $jsonResp = json_decode($resp, true); - - $fediID = $jsonResp["id"]; - - pg_update($db, "data", array("fedipostid" => $fediID), array("id" => $id)); -} else { - curl_setopt($ch, CURLOPT_URL, ($fediAPIRoute . "/" . $arr["fedipostid"])); - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); - - if ($arr["iscwed"] == "t") { - $contentCW = $arr["cw"]; - curl_setopt($ch, CURLOPT_POSTFIELDS, - http_build_query(array('status' => "question: {$contentO}\n\nresponse: {$contentR}\n\nlink: {$url}", 'visibility' => "{$fediVisibility}", 'spoiler_text' => "anonymous question response (automated); cw: {$contentCW}"))); - } else { - curl_setopt($ch, CURLOPT_POSTFIELDS, - http_build_query(array('status' => "question: {$contentO}\n\nresponse: {$contentR}\n\nlink: {$url}", 'visibility' => "{$fediVisibility}", 'spoiler_text' => "anonymous question response (automated)"))); - } - - curl_exec($ch); +$resp = curl_exec($ch); +if (strlen($question["fedipostid"]) == 0) { + $jsonResp = json_decode($resp, true); + $fediID = $jsonResp["id"]; + pg_update($db, "data", array("fedipostid" => $fediID), array("id" => $id)); } curl_close($ch); diff --git a/admin/index.php b/admin/index.php index 12d9a7e..9b8d82a 100644 --- a/admin/index.php +++ b/admin/index.php @@ -3,23 +3,24 @@ include '../config.php'; if ($_GET["pw"] === $adminPassword) { - if ($_GET["page"] === "delete") { - include 'delete.php'; - } elseif ($_GET["page"] === "respond") { - include 'respond.php'; - } elseif ($_GET["page"] === "mark") { - include 'mark.php'; - } elseif ($_GET["page"] === "migrate") { - include 'migrate.php'; - } else { - include 'all.php'; - } + switch ($_GET["page"]) { + case "delete": include "delete.php"; break; + case "respond": include "respond.php"; break; + case "mark": include "mark.php"; break; + case "migrate": include "migrate.php"; break; + default: include "all.php"; + } } else { - $properTitle = $pageTitle . " – sign in"; - include 'boilerplate/pageStart.php'; + $properTitle = $pageTitle . " — sign in"; + $CSSdownDirectory = 1; + include "../boilerplate/pageStart.php"; - echo("

enter password

"); - echo("

"); + echo(" +

enter password

+

+ "); + + include "../boilerplate/pageEnd.php"; } -?> \ No newline at end of file +?> diff --git a/admin/mark.php b/admin/mark.php index 6e93e73..c5e720c 100644 --- a/admin/mark.php +++ b/admin/mark.php @@ -7,23 +7,23 @@ if ($id === null) { } if ($_GET["action"] === "unread") { - $query = " - UPDATE data - SET isprivread = False - WHERE id = {$id}; - "; - $headerinfo = "Location: index.php?unread=1&pw={$adminPassword}"; -} elseif ($_GET["action"] === "read") { - $query = " - UPDATE data - SET isprivread = True - WHERE id = {$id}; - "; - $headerinfo = "Location: index.php?read=1&pw={$adminPassword}"; + $query = " + UPDATE data + SET isprivread = False + WHERE id = {$id}; + "; + $headerinfo = "Location: index.php?unread=1&pw={$adminPassword}"; +} else if ($_GET["action"] === "read") { + $query = " + UPDATE data + SET isprivread = True + WHERE id = {$id}; + "; + $headerinfo = "Location: index.php?read=1&pw={$adminPassword}"; } pg_query($db, $query); header($headerinfo); -?> \ No newline at end of file +?> diff --git a/admin/migrate.php b/admin/migrate.php index ec16fc8..8904c3d 100644 --- a/admin/migrate.php +++ b/admin/migrate.php @@ -4,23 +4,23 @@ $query = " SELECT * FROM migrations; "; -$qresp = pg_query($db, $query); +$queryResponse = pg_query($db, $query); -$rows = pg_fetch_all($qresp); +$rows = pg_fetch_all($queryResponse); $migrations = array( - "20240218-AddMigrationsTable-40641e8d", - "20240218-AddMarkReadOption-a7e43358", - "20240218-AddFalsesToPrivRead-67d82b18", - "20250310-AddFediIDColumn-64520350" + "20240218-AddMigrationsTable-40641e8d", + "20240218-AddMarkReadOption-a7e43358", + "20240218-AddFalsesToPrivRead-67d82b18", + "20250310-AddFediIDColumn-64520350" ); foreach ($migrations as $mig) { - if (!in_array($mig, array_column($rows, 'id'))) { - include "../migrations/{$mig}.php"; - } + if (!in_array($mig, array_column($rows, 'id'))) { + include "../migrations/{$mig}.php"; + } } header("Location: index.php?migrated=1&pw={$adminPassword}"); -?> \ No newline at end of file +?> diff --git a/admin/respond.php b/admin/respond.php index 7c208ed..d224621 100644 --- a/admin/respond.php +++ b/admin/respond.php @@ -3,27 +3,28 @@ $id = (int)$_GET["id"]; if ($id === null) { - exit(); + exit(); } if ($_GET["text"] !== null) { - $text = $_GET["text"]; - $cdate = date("Y-m-d H:i:sP"); - $query = " - UPDATE data - SET \"responsetime\" = timestamptz'{$cdate}', isrespondedto = True - WHERE id = {$id}; - "; + $text = $_GET["text"]; + $cdate = date("Y-m-d H:i:sP"); - pg_query($db, $query); + $query = " + UPDATE data + SET \"responsetime\" = timestamptz'{$cdate}', isrespondedto = True + WHERE id = {$id}; + "; - pg_update($db, "data", array("responsetext" => $text), array("id" => $id)); + pg_query($db, $query); + pg_update($db, "data", array("responsetext" => $text), array("id" => $id)); - if ($fediEnabled) { - include 'fedi.php'; - } + if ($fediEnabled) { + include "fedi.php"; + } - header("Location: index.php?responded=1&pw={$adminPassword}"); + header("Location: index.php?responded=1&pw={$adminPassword}"); + exit(); } $query = " @@ -31,37 +32,27 @@ SELECT * FROM data WHERE id = {$id}; "; -$qresp = pg_query($db, $query); -$arr = pg_fetch_array($qresp); +$queryResponse = pg_query($db, $query); +$question = pg_fetch_array($queryResponse); -$properTitle = $pageTitle . " – respond to question #" . $id; -include '../boilerplate/pageStart.php'; +$properTitle = $pageTitle . " — respond to question #" . $id; +$CSSdownDirectory = 1; +include "../boilerplate/pageStart.php"; +include "../boilerplate/question.php"; -echo(""); - -if ($arr["ispublic"] === "f") { - echo("

{$pageTitle} – no such question exists

"); - echo("(go back?)"); - http_response_code(404); +if ($question["ispublic"] === "f") { + echo(" +

{$pageTitle} — no such question exists

+ (go back?) + "); + http_response_code(404); } else { - echo("

{$pageTitle} – question number " . $arr["id"] . "

"); - - echo("(go back?)"); - echo("
"); - if ($arr["iscwed"] === "t") { - echo("

cw: " . htmlspecialchars($arr["cw"]) . "

"); - } - echo(htmlspecialchars($arr["text"])); - echo("
" . $arr["time"] . "
"); - if ($_GET["responded"] == 1) { - echo("
" . htmlspecialchars($arr["responsetext"]) . ""); - echo("
" . $arr["responsetime"] . "
"); - echo("

enter your edits

"); - } else { - echo("

enter a response

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

"); + echo(" +

{$pageTitle} — question number {$question['id']}

+ (go back?) + "); + + echo(getQuestion($question, 0, 0, 1, $adminPassword)); } ?> diff --git a/boilerplate/pageEnd.php b/boilerplate/pageEnd.php index 087b532..308b1d0 100644 --- a/boilerplate/pageEnd.php +++ b/boilerplate/pageEnd.php @@ -1,5 +1,2 @@ - -echo("") - -?> \ No newline at end of file + + diff --git a/boilerplate/pageStart.php b/boilerplate/pageStart.php index c08ba77..85445bb 100644 --- a/boilerplate/pageStart.php +++ b/boilerplate/pageStart.php @@ -1,5 +1,14 @@ - -echo("" . $properTitle . "") + + + + <?php echo($properTitle) ?> + + css/base.css"> -?> \ No newline at end of file + "); + } + ?> + + diff --git a/boilerplate/question.php b/boilerplate/question.php new file mode 100644 index 0000000..98aba49 --- /dev/null +++ b/boilerplate/question.php @@ -0,0 +1,87 @@ +{$question['time']}
"; + + if ($question["responsetext"]) { + $q .= "
" . htmlspecialchars($question['responsetext']); + $q .= "
{$question['responsetime']}
"; + } + + if ($isResponding) { + if ($question["responsetext"]) { + $q .= "

enter your edits

"; + } else { + $q .= "

enter a response

"; + } + + $q .= " +
+ + + +
+ +
+ "; + } + + if ($includePermalink === 1) { + $q .= "permalink"; + } + + if ($isAdmin === 1) { + if ($question["ispublic"] === "t") { + $q .= ""; + + if ($question["isrespondedto"] === "t") { + $q .= "edit response"; + } else { + $q .= "respond"; + } + + $q .= ""; + } else { + $q .= "mark "; + + if ($question["isprivread"] === "t") { + $q .= "unread"; + } else { + $q .= "read"; + } + + $q .= ""; + } + + $q .= " / delete"; + } + + if ($question["iscwed"] === "t") { + $open = ""; + + if ($isResponding) { + $open = " open"; + } + + $q = "cw: " . htmlspecialchars($question["cw"]) . "{$q}"; + } + + return "
{$q}
"; +} + +?> diff --git a/config.example.php b/config.example.php index 9f10707..51d251a 100644 --- a/config.example.php +++ b/config.example.php @@ -1,7 +1,7 @@ \ No newline at end of file +?> diff --git a/css/admin.css b/css/admin.css deleted file mode 100644 index 74c0ff3..0000000 --- a/css/admin.css +++ /dev/null @@ -1,82 +0,0 @@ -body { - background-image: url(https://notfire.cc/design/images/groundback.gif); - background-color: black; - color: white; - font-family: Arial, Helvetica, sans-serif; -} - -.permalink { - color: #ff0000; - font-size: .9em; -} - -.goback { - color: #ff0000; -} - -.title { - margin-bottom: .1em; -} - -.question { - margin-top: .7em; - background-color: #2c2c2c; - border-radius: 5px; - max-width: fit-content; - padding: .5em; -} - -.response { - background-color: #505050; - border-radius: 5px; - margin-top: .3em; - padding: .4em; - margin-bottom: .25em; -} - -.time { - font-size: .8em; -} - -.cwfiller { - height: 1.3em; - display: inline-block; -} - -.sect { - margin-top: .2em; - margin-bottom: .2em; -} - -.sentconf { - color: lime; - margin-bottom: .3em; -} - -.sendsum { - font-size: 1.17em; - font-weight: bold; -} - -.sendmsg { - margin-top: 1em; - border-radius: 5px; - background-color: #2c2c2c; - max-width: fit-content; - padding: .7em; -} - -#passinput, .submitbutton { - background-color: black; - color: white; - margin-bottom: .3em; -} - -.submitbutton { - font-size: 1.17em; - margin-top: .3em; -} - -.frm { - margin-bottom: 0px; -} \ No newline at end of file diff --git a/css/base.css b/css/base.css new file mode 100644 index 0000000..f62edb9 --- /dev/null +++ b/css/base.css @@ -0,0 +1,99 @@ +:root { + --background-color: #000000; + --text-color: #ffffff; + --hr-color: #808080; + --link-color: #ff0000; + --confirmation-color: #00ff00; + --question-background: #2c2c2c; + --response-background: #505050; + + /* set to "none" to disable the background image */ + --background-image: url("https://notfire.cc/design/images/groundback.gif"); + --font-family: Arial, Helvetica, sans-serif; +} + +body { + background-image: var(--background-image); + background-color: var(--background-color); + color: var(--text-color); + font-family: var(--font-family); +} + +hr { + border: none; + height: 1.5px; + background-color: var(--hr-color); +} + +.permalink { + color: var(--link-color); + font-size: .9em; +} + +.go-back { + color: var(--link-color); +} + +.title { + margin-bottom: .1em; +} + +.question { + margin-top: .7em; + background-color: var(--question-background); + border-radius: 5px; + max-width: fit-content; + padding: .5em; +} + +.response { + background-color: var(--response-background); + border-radius: 5px; + margin-top: .3em; + padding: .4em; +} + +.time { + font-size: .8em; +} + +.sect { + margin-top: .2em; + margin-bottom: .2em; +} + +.sentconf { + color: var(--confirmation-color); + margin-bottom: .3em; +} + +.sendsum { + font-size: 1.17em; + font-weight: bold; +} + +.sendmsg { + margin-top: 1em; + border-radius: 5px; + background-color: var(--question-background); + max-width: fit-content; + padding: .7em; +} + +#passinput, +#questioninput, +#cwinput, +.submitbutton { + background-color: var(--background-color); + color: var(--text-color); + margin-bottom: .3em; +} + +.submitbutton { + font-size: 1.17em; + margin-top: .3em; +} + +.frm { + margin-bottom: 0px; +} diff --git a/css/indiv.css b/css/indiv.css deleted file mode 100644 index dae1538..0000000 --- a/css/indiv.css +++ /dev/null @@ -1,38 +0,0 @@ -body { - background-image: url(https://notfire.cc/design/images/groundback.gif); - background-color: black; - color: white; - font-family: Arial, Helvetica, sans-serif; -} - -.goback { - color: #ff0000; -} - -.title { - margin-bottom: .1em; -} - -.question { - margin-top: .7em; - background-color: #2c2c2c; - border-radius: 5px; - max-width: fit-content; - padding: .5em; -} - -.response { - background-color: #505050; - border-radius: 5px; - margin-top: .3em; - padding: .4em; -} - -.time { - font-size: .8em; -} - -.cwfiller { - height: 1.3em; - display: inline-block; -} \ No newline at end of file diff --git a/css/main.css b/css/main.css deleted file mode 100644 index 2b692c6..0000000 --- a/css/main.css +++ /dev/null @@ -1,83 +0,0 @@ -body { - background-image: url(https://notfire.cc/design/images/groundback.gif); - background-color: black; - color: white; - font-family: Arial, Helvetica, sans-serif; -} - -.permalink { - color: #ff0000; - font-size: .9em; -} - -.goback { - color: #ff0000; -} - -.title { - margin-bottom: .1em; -} - -.question { - margin-top: .7em; - background-color: #2c2c2c; - border-radius: 5px; - max-width: fit-content; - padding: .5em; -} - -.response { - background-color: #505050; - border-radius: 5px; - margin-top: .3em; - padding: .4em; - margin-bottom: .25em; -} - -.time { - font-size: .8em; -} - -.cwfiller { - height: 1.3em; - display: inline-block; -} - -.sect { - margin-bottom: .2em; - margin-top: .2em; -} - -.sentconf { - color: lime; - margin-top: .3em; - margin-bottom: .3em; -} - -.sendsum { - font-size: 1.17em; - font-weight: bold; -} - -.sendmsg { - margin-top: 1em; - border-radius: 5px; - background-color: #2c2c2c; - max-width: fit-content; - padding: .7em; -} - -#questioninput, #cwinput, .submitbutton { - background-color: black; - color: white; - margin-bottom: .3em; -} - -.submitbutton { - font-size: 1.17em; - margin-top: .3em; -} - -.frm { - margin-bottom: 0px; -} \ No newline at end of file diff --git a/fetch.php b/fetch.php index c7a8d77..dd7a731 100644 --- a/fetch.php +++ b/fetch.php @@ -1,11 +1,12 @@ "); +if (pg_num_rows($queryResponse) === 0 || $question["ispublic"] === "f" || $question["isrespondedto"] === "f") { + echo(" +

{$pageTitle} — no such question exists

+ (go back?) + "); -if (pg_num_rows($qresp) === 0 || $arr["ispublic"] === "f" || $arr["isrespondedto"] === "f") { - echo("

{$pageTitle} – no such question exists

"); - echo("(go back?)"); - http_response_code(404); + http_response_code(404); } else { - echo("

{$pageTitle} – question number " . $arr["id"] . "

"); - - echo("(go back?)"); - echo("
"); - if ($arr["iscwed"] === "t") { - echo("
cw: " . htmlspecialchars($arr["cw"]) . ""); - } - echo(htmlspecialchars($arr["text"])); - echo("
" . $arr["time"] . "
"); - echo("
" . $arr["responsetext"] . ""); - echo("
" . $arr["responsetime"] . "
"); - if ($arr["iscwed"] === "t") { - echo("
"); - } else { - echo(""); - } + echo(" +

{$pageTitle} — question number {$question['id']}

+ (go back?) + "); + + echo(getQuestion($question)); } +include "boilerplate/pageEnd.php"; + ?> diff --git a/index.php b/index.php index 176f837..1c85b34 100644 --- a/index.php +++ b/index.php @@ -1,58 +1,56 @@ "); +$properTitle = "{$pageTitle} — all messages"; +include "boilerplate/pageStart.php"; echo("

" . $pageTitle . "

"); if ($pageDomainEnabled) { - echo("(go back to " . $pageDomain . "?)"); + echo("(go back to " . $pageDomain . "?)"); } if ($_GET["sent"] == 1) { - echo("
message sent!
"); -} - -echo("
send a message!"); - -echo("



"); - -echo("
"); - -echo("

all past messages

"); - -asort($rows); - -foreach (array_reverse($rows) as $i){ - if ($i["ispublic"] === "t" && $i["isrespondedto"] === "t") { - echo("
"); - if ($i["iscwed"] === "t") { - echo("
cw: " . htmlspecialchars($i["cw"]) . ""); - } - echo(htmlspecialchars($i["text"])); - echo("
" . $i["time"] . "
"); - echo("
" . htmlspecialchars($i["responsetext"]) . ""); - echo("
" . $i["responsetime"] . "
"); - echo("permalink"); - if ($i["iscwed"] === "t") { - echo("
"); - } else { - echo(""); - } - } + echo("
message sent!
"); } ?> + +
+
+ send a message! +
+ +
+ +
+ +
+ +
+
+
+
+

all past messages

+ + diff --git a/migrations/20240218-AddFalsesToPrivRead-67d82b18.php b/migrations/20240218-AddFalsesToPrivRead-67d82b18.php index 95c7d17..d734fec 100644 --- a/migrations/20240218-AddFalsesToPrivRead-67d82b18.php +++ b/migrations/20240218-AddFalsesToPrivRead-67d82b18.php @@ -11,9 +11,9 @@ WHERE ispublic IS FALSE; pg_query($db, $query); $dataArray = array( - "id" => "20240218-AddFalsesToPrivRead-67d82b18" + "id" => "20240218-AddFalsesToPrivRead-67d82b18" ); pg_insert($db, "migrations", $dataArray); -?> \ No newline at end of file +?> diff --git a/migrations/20240218-AddMarkReadOption-a7e43358.php b/migrations/20240218-AddMarkReadOption-a7e43358.php index 038b168..2b757cd 100644 --- a/migrations/20240218-AddMarkReadOption-a7e43358.php +++ b/migrations/20240218-AddMarkReadOption-a7e43358.php @@ -10,9 +10,9 @@ ADD COLUMN isprivread BOOLEAN; pg_query($db, $query); $dataArray = array( - "id" => "20240218-AddMarkReadOption-a7e43358" + "id" => "20240218-AddMarkReadOption-a7e43358" ); pg_insert($db, "migrations", $dataArray); -?> \ No newline at end of file +?> diff --git a/migrations/20240218-AddMigrationsTable-40641e8d.php b/migrations/20240218-AddMigrationsTable-40641e8d.php index 62a7a68..da4983c 100644 --- a/migrations/20240218-AddMigrationsTable-40641e8d.php +++ b/migrations/20240218-AddMigrationsTable-40641e8d.php @@ -11,9 +11,9 @@ CREATE TABLE migrations ( pg_query($db, $query); $dataArray = array( - "id" => "20240218-AddMigrationsTable-40641e8d" + "id" => "20240218-AddMigrationsTable-40641e8d" ); pg_insert($db, "migrations", $dataArray); -?> \ No newline at end of file +?> diff --git a/migrations/20250310-AddFediIDColumn-64520350.php b/migrations/20250310-AddFediIDColumn-64520350.php index 042b751..949cd92 100644 --- a/migrations/20250310-AddFediIDColumn-64520350.php +++ b/migrations/20250310-AddFediIDColumn-64520350.php @@ -10,9 +10,9 @@ ADD COLUMN fedipostid TEXT; pg_query($db, $query); $dataArray = array( - "id" => "20250310-AddFediIDColumn-64520350" + "id" => "20250310-AddFediIDColumn-64520350" ); pg_insert($db, "migrations", $dataArray); -?> \ No newline at end of file +?> diff --git a/send.php b/send.php index 136b299..67327ea 100644 --- a/send.php +++ b/send.php @@ -1,36 +1,22 @@ $_GET["text"], - "cw" => $_GET["cw"], - "iscwed" => $iscw, - "time" => $curTime, - "ispublic" => $isPublic, - "isrespondedto" => False + "text" => $_GET["text"], + "cw" => $_GET["cw"], + "iscwed" => !($_GET["cw"] === null || $_GET["cw"] === ""), + "time" => date("Y-m-d H:i:sP"), + "ispublic" => $_GET["public"] == 1, + "isrespondedto" => False ); pg_insert($db, "data", $dataArray); header("Location: index.php?sent=1"); -?> \ No newline at end of file +?> diff --git a/setup.php b/setup.php index 211734e..f8ed149 100644 --- a/setup.php +++ b/setup.php @@ -1,19 +1,19 @@ \ No newline at end of file +?>