115 lines
4.3 KiB
PHP
115 lines
4.3 KiB
PHP
<?php
|
||
|
||
$query = "
|
||
SELECT * FROM data;
|
||
";
|
||
|
||
$qresp = pg_query($db, $query);
|
||
|
||
$rows = pg_fetch_all($qresp);
|
||
|
||
$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++;
|
||
}
|
||
} else {
|
||
$totalRespondedPub++;
|
||
}
|
||
}
|
||
|
||
$properTitle = $pageTitle . " – admin";
|
||
|
||
include '../boilerplate/pageStart.php';
|
||
|
||
echo("<link rel=\"stylesheet\" href=\"../css/admin.css\">");
|
||
|
||
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>");
|
||
}
|
||
|
||
if ($_GET["read"] == 1) {
|
||
echo("<span class=\"sentconf\">marked as read!</span>");
|
||
}
|
||
|
||
if ($_GET["unread"] == 1) {
|
||
echo("<span class=\"sentconf\">marked as unread!</span>");
|
||
}
|
||
|
||
if ($_GET["migrated"] == 1) {
|
||
echo("<span class=\"sentconf\">migrations have been run!</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: " . htmlspecialchars($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></details></div>");
|
||
}
|
||
}
|
||
|
||
echo("<h3 class=\"sect\">unread private ({$totalPriv})</h3>");
|
||
foreach (array_reverse($rows) as $i){
|
||
if ($i["ispublic"] === "f" && $i["isprivread"] === "f") {
|
||
echo("<div class=\"question\">");
|
||
if ($i["iscwed"] === "t") {
|
||
echo("<details><summary>cw: " . htmlspecialchars($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=mark&action=read&id=" . $i["id"] . "&pw={$adminPassword}\">mark read</a> / <a class=\"permalink\" href=\"index.php?page=delete&id=" . $i["id"] . "&pw={$adminPassword}\">delete</a></details></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: " . htmlspecialchars($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></details></div>");
|
||
}
|
||
}
|
||
|
||
echo("<h3 class=\"sect\">read private ({$totalPrivRead})</h3>");
|
||
foreach (array_reverse($rows) as $i){
|
||
if ($i["ispublic"] === "f" && $i["isprivread"] === "t") {
|
||
echo("<div class=\"question\">");
|
||
if ($i["iscwed"] === "t") {
|
||
echo("<details><summary>cw: " . htmlspecialchars($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=mark&action=unread&id=" . $i["id"] . "&pw={$adminPassword}\">mark unread</a> / <a class=\"permalink\" href=\"index.php?page=delete&id=" . $i["id"] . "&pw={$adminPassword}\">delete</a></details></div>");
|
||
}
|
||
}
|
||
|
||
include '../boilerplate/pageEnd.php';
|
||
|
||
?>
|