qna/index.php
2024-12-09 18:32:49 -05:00

49 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>");
asort($rows);
foreach (array_reverse($rows) as $i){
if ($i["ispublic"] === "t" && $i["isrespondedto"] === "t") {
echo("<div class=\"question\">");
if ($i["iscwed"] === "t") {
echo("<details><summary>cw: " . $i["cw"] . "</summary><span class=\"cwfiller\"></span>");
}
echo(htmlspecialchars($i["text"]));
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>");
}
}
?>