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

77 lines
No EOL
2.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
$query = "
SELECT * FROM data;
";
$qresp = pg_query($db, $query);
$rows = pg_fetch_all($qresp);
$totalUnresponded = 0;
$totalPriv = 0;
$totalRespondedPub = 0;
foreach (array_reverse($rows) as $i) {
if ($i["isrespondedto"] === "f" && $i["ispublic"] === "t") {
$totalUnresponded++;
} else if ($i["ispublic"] === "f") {
$totalPriv++;
} else {
$totalRespondedPub++;
}
}
echo("<h2 class=\"title\">" . $pageTitle . " admin</h2>");
if ($_GET["deleted"] == 1) {
echo("<span class=\"sentconf\">deleted!</span>");
}
if ($_GET["responded"] == 1) {
echo("<span class=\"sentconf\">response sent!</span>");
}
asort($rows);
echo("<h3 class=\"sect\">not responded to ({$totalUnresponded})</h3>");
foreach (array_reverse($rows) as $i){
if ($i["isrespondedto"] === "f" && $i["ispublic"] == "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("<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("<h3 class=\"sect\">private ({$totalPriv})</h3>");
foreach (array_reverse($rows) as $i){
if ($i["ispublic"] === "f") {
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("<a class=\"permalink\" href=\"index.php?page=delete&id=" . $i["id"] . "&pw={$adminPassword}\">delete</a></div>");
}
}
echo("<h3 class=\"sect\">public ({$totalRespondedPub})</h3>");
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=\"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>");
}
}
?>