qna/admin/respond.php
2024-12-09 18:06:25 -05:00

62 lines
No EOL
2 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
$id = $_GET["id"];
if ($id === null) {
exit();
}
if ($_GET["text"] !== null) {
$text = $_GET["text"];
$cdate = date("Y-m-d H:i:sP");
$query = "
UPDATE data
SET \"responsetext\" = '{$text}', \"responsetime\" = timestamptz'{$cdate}', isrespondedto = True
WHERE id = {$id};
";
pg_update($db, "data", array("responsetext" => $text, "responsetime" => "timestamptz'{$cdate}", "isrespondedto" => "True"), array("id" => $id));
if ($fediEnabled) {
include 'fedi.php';
}
header("Location: index.php?responded=1&pw={$adminPassword}");
}
$query = "
SELECT * FROM data
WHERE id = {$id};
";
$qresp = pg_query($db, $query);
$arr = pg_fetch_array($qresp);
echo("<link rel=\"stylesheet\" href=\"css/indiv.css\">");
if ($arr["ispublic"] === "f") {
echo("<h2 class=\"title\">{$pageTitle} no such question exists</h2>");
echo("<a class=\"goback\" href=\"index.php\">(go back?)</a>");
http_response_code(404);
} else {
echo("<h2 class=\"title\">{$pageTitle} question number " . $arr["id"] . "</h2>");
echo("<a class=\"goback\" href=\"index.php?pw={$adminPassword}\">(go back?)</a>");
echo("<div class=\"question\">");
if ($arr["iscwed"] === "t") {
echo("<h3>cw: " . $arr["cw"] . "</h3>");
}
echo(htmlspecialchars($arr["text"]));
echo("<div class=\"time\">" . $arr["time"] . "</div>");
if ($_GET["responded"] == 1) {
echo("<div class=\"response\">" . htmlspecialchars($arr["responsetext"]) . "");
echo("<div class=\"time\">" . $arr["responsetime"] . "</div></div>");
echo("<h3>enter your edits</h3>");
} else {
echo("<h3>enter a response</h3>");
}
echo("<form class=\"frm\" action=\"index.php\"><input hidden name=\"id\" value=\"{$id}\"><input hidden name=\"page\" value=\"respond\"><input hidden name=\"pw\" value=\"{$adminPassword}\"><input id=\"passinput\" name=\"text\" required=\"\"><br><button class=\"submitbutton\" type=\"submit\">send</button></form>");
}
?>