qna/admin/respond.php
2025-03-12 08:31:53 -04:00

58 lines
1.3 KiB
PHP

<?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}");
exit();
}
$query = "
SELECT * FROM data
WHERE id = {$id};
";
$queryResponse = pg_query($db, $query);
$question = pg_fetch_array($queryResponse);
$properTitle = $pageTitle . " &mdash; respond to question #" . $id;
$CSSdownDirectory = 1;
include "../boilerplate/pageStart.php";
include "../boilerplate/question.php";
if ($question["ispublic"] === "f") {
echo("
<h2 class=\"title\">{$pageTitle} &mdash; no such question exists</h2>
<a class=\"go-back\" href=\"index.php\">(go back?)</a>
");
http_response_code(404);
} else {
echo("
<h2 class=\"title\">{$pageTitle} &mdash; question number {$question['id']}</h2>
<a class=\"go-back\" href=\"index.php?pw={$adminPassword}\">(go back?)</a>
");
echo(getQuestion($question, 0, 0, 1, $adminPassword));
}
?>