qna/admin/respond.php

67 lines
2.1 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 = (int)$_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 \"responsetime\" = timestamptz'{$cdate}', isrespondedto = True
WHERE id = {$id};
";
pg_query($db, $query);
pg_update($db, "data", array("responsetext" => $text), 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);
$properTitle = $pageTitle . " respond to question #" . $id;
include '../boilerplate/pageStart.php';
echo("<link rel=\"stylesheet\" href=\"../css/admin.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: " . htmlspecialchars($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>");
}
$respTxt = htmlspecialchars($arr["responsetext"]);
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\" value=\"{$respTxt}\" autofocus=\"autofocus\" required=\"\"><br><button class=\"submitbutton\" type=\"submit\">send</button></form>");
}
?>