qna/index.php
2024-12-09 13:33:24 -05:00

47 lines
No EOL
1.8 KiB
PHP

<?php
include 'config.php';
$query = "
SELECT * FROM data;
";
$qresp = pg_query($db, $query);
$rows = pg_fetch_all($qresp);
echo("<link rel=\"stylesheet\" href=\"css/main.css\">");
echo("<h2 class=\"title\">" . $pageTitle . "</h2>");
if ($pageDomainEnabled) {
echo("<a class=\"goback\" href=\"https://{$pageDomainOther}{$pageRoot}\">(go back to " . $pageDomain . "?)</a>");
}
if ($_GET["sent"] == 1) {
echo("<span class=\"sentconf\"><br>message sent!</span>");
}
echo("<div class=\"sendmsg\"><details open=\"\"><summary class=\"sendsum\">send a message!</summary>");
echo("<form class=\"frm\" action=\"send.php\"><label for=\"questioninput\">enter your message: </label><input id=\"questioninput\" name=\"text\" required=\"\"><br><label for=\"cwinput\">cw if applicable: </label><input id=\"cwinput\" name=\"cw\"><br><input type=\"checkbox\" id=\"pubbox\" name=\"public\" value=\"1\" checked> <label for=\"pubbox\">if this is checked, your message will be available publicly</label><br><button class=\"submitbutton\" type=\"submit\">send!</button></form></details></div>");
echo("<hr>");
echo("<h3 class=\"sect\">all past messages</h3>");
for ($i=count($rows); $i>=0; $i--) {
if ($rows[$i]["ispublic"] === "t" && $rows[$i]["isrespondedto"] === "t") {
echo("<div class=\"question\">");
if ($rows[$i]["iscwed"] === "t") {
echo("<details><summary>cw: " . $rows[$i]["cw"] . "</summary><span class=\"cwfiller\"></span>");
}
echo(htmlspecialchars($rows[$i]["text"]));
echo("<div class=\"time\">" . $rows[$i]["time"] . "</div>");
echo("<div class=\"response\">" . htmlspecialchars($rows[$i]["responsetext"]) . "");
echo("<div class=\"time\">" . $rows[$i]["responsetime"] . "</div></div>");
echo("<a class=\"permalink\" href=\"fetch.php?id=" . ($i + 1) . "\">permalink</a></div>");
}
}
?>