sure it absolutely works but not that well
This commit is contained in:
parent
b8e4117c1c
commit
e7b55beded
9 changed files with 131 additions and 57 deletions
4
TODO.md
Normal file
4
TODO.md
Normal file
|
@ -0,0 +1,4 @@
|
|||
- modifying whether a cw is used or not?
|
||||
- POSSIBLY editing messages / changing their visibility? idk
|
||||
- some way to automatically get notified
|
||||
- some way to automatically post to fedi on response
|
|
@ -11,54 +11,64 @@ $rows = pg_fetch_all($qresp);
|
|||
$totalUnresponded = 0;
|
||||
$totalPriv = 0;
|
||||
$totalRespondedPub = 0;
|
||||
for ($i=count($rows); $i>=0; $i--) {
|
||||
if ($rows[$i]["isrespondedto"] === "f" && $rows[$i]["ispublic"] === "t") {
|
||||
foreach (array_reverse($rows) as $i) {
|
||||
if ($i["isrespondedto"] === "f" && $i["ispublic"] === "t") {
|
||||
$totalUnresponded++;
|
||||
} else if ($rows[$i]["ispublic"] === "f") {
|
||||
} 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>");
|
||||
}
|
||||
|
||||
echo("<h3 class=\"sect\">not responded to ({$totalUnresponded})</h3>");
|
||||
for ($i=count($rows); $i>=0; $i--) {
|
||||
if ($rows[$i]["isrespondedto"] === "f" && $rows[$i]["ispublic"] == "t") {
|
||||
foreach (array_reverse($rows) as $i){
|
||||
if ($i["isrespondedto"] === "f" && $i["ispublic"] == "t") {
|
||||
echo("<div class=\"question\">");
|
||||
if ($rows[$i]["iscwed"] === "t") {
|
||||
echo("<details><summary>cw: " . $rows[$i]["cw"] . "</summary><span class=\"cwfiller\"></span>");
|
||||
if ($i["iscwed"] === "t") {
|
||||
echo("<details><summary>cw: " . $i["cw"] . "</summary><span class=\"cwfiller\"></span>");
|
||||
}
|
||||
echo(htmlspecialchars($rows[$i]["text"]));
|
||||
echo("<div class=\"time\">" . $rows[$i]["time"] . "</div>");
|
||||
echo("<a class=\"permalink\" href=\"index.php?page=edit&id=" . ($i + 1) . "\">edit</a> / <a class=\"permalink\" href=\"index.php?page=respond&id=" . ($i + 1) . "\">respond</a> / <a class=\"permalink\" href=\"index.php?page=delete&id=" . ($i + 1) . "\">delete</a></div>");
|
||||
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>");
|
||||
for ($i=count($rows); $i>=0; $i--) {
|
||||
if ($rows[$i]["ispublic"] === "f") {
|
||||
foreach (array_reverse($rows) as $i){
|
||||
if ($i["ispublic"] === "f") {
|
||||
echo("<div class=\"question\">");
|
||||
if ($rows[$i]["iscwed"] === "t") {
|
||||
echo("<details><summary>cw: " . $rows[$i]["cw"] . "</summary><span class=\"cwfiller\"></span>");
|
||||
if ($i["iscwed"] === "t") {
|
||||
echo("<details><summary>cw: " . $i["cw"] . "</summary><span class=\"cwfiller\"></span>");
|
||||
}
|
||||
echo(htmlspecialchars($rows[$i]["text"]));
|
||||
echo("<div class=\"time\">" . $rows[$i]["time"] . "</div>");
|
||||
echo("<a class=\"permalink\" href=\"index.php?page=edit&id=" . ($i + 1) . "\">edit</a></div>");
|
||||
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>");
|
||||
for ($i=count($rows); $i>=0; $i--) {
|
||||
if ($rows[$i]["ispublic"] === "t" && $rows[$i]["isrespondedto"] === "t") {
|
||||
foreach (array_reverse($rows) as $i){
|
||||
if ($i["ispublic"] === "t" && $i["isrespondedto"] === "t") {
|
||||
echo("<div class=\"question\">");
|
||||
if ($rows[$i]["iscwed"] === "t") {
|
||||
echo("<details><summary>cw: " . $rows[$i]["cw"] . "</summary><span class=\"cwfiller\"></span>");
|
||||
if ($i["iscwed"] === "t") {
|
||||
echo("<details><summary>cw: " . $i["cw"] . "</summary><span class=\"cwfiller\"></span>");
|
||||
}
|
||||
echo(htmlspecialchars($rows[$i]["text"]));
|
||||
echo("<div class=\"time\">" . $rows[$i]["time"] . "</div>");
|
||||
echo("<div class=\"response\">" . htmlspecialchars($rows[$i]["responsetext"]) . "");
|
||||
echo("<div class=\"time\">" . $rows[$i]["responsetime"] . "</div></div>");
|
||||
echo("<a class=\"permalink\" href=\"index.php?page=edit&id=" . ($i + 1) . "\">edit</a></div>");
|
||||
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>");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
20
admin/delete.php
Normal file
20
admin/delete.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
$id = $_GET["id"];
|
||||
|
||||
if ($id === null) {
|
||||
exit();
|
||||
}
|
||||
|
||||
$query = "
|
||||
DELETE FROM data
|
||||
WHERE id = {$id};
|
||||
";
|
||||
|
||||
pg_query($db, $query);
|
||||
|
||||
echo("done");
|
||||
|
||||
header("Location: index.php?deleted=1&pw={$adminPassword}");
|
||||
|
||||
?>
|
|
@ -5,10 +5,10 @@ include '../config.php';
|
|||
echo("<link rel=\"stylesheet\" href=\"../css/admin.css\">");
|
||||
|
||||
if ($_GET["pw"] === $adminPassword) {
|
||||
if ($_GET["page"] === "all") {
|
||||
include 'all.php';
|
||||
} elseif ($_GET["page" === "edit"]) {
|
||||
include 'edit.php';
|
||||
if ($_GET["page"] === "delete") {
|
||||
include 'delete.php';
|
||||
} elseif ($_GET["page"] === "respond") {
|
||||
include 'respond.php';
|
||||
} else {
|
||||
include 'all.php';
|
||||
}
|
||||
|
|
57
admin/respond.php
Normal file
57
admin/respond.php
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?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_query($db, $query);
|
||||
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("<details><summary>cw: " . $arr["cw"] . "</summary><span class=\"cwfiller\"></span>");
|
||||
}
|
||||
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>");
|
||||
}
|
||||
|
||||
?>
|
|
@ -50,7 +50,6 @@ body {
|
|||
|
||||
.sentconf {
|
||||
color: lime;
|
||||
margin-top: .3em;
|
||||
margin-bottom: .3em;
|
||||
}
|
||||
|
||||
|
|
18
index.php
18
index.php
|
@ -30,17 +30,17 @@ echo("<hr>");
|
|||
|
||||
echo("<h3 class=\"sect\">all past messages</h3>");
|
||||
|
||||
for ($i=count($rows); $i>=0; $i--) {
|
||||
if ($rows[$i]["ispublic"] === "t" && $rows[$i]["isrespondedto"] === "t") {
|
||||
foreach (array_reverse($rows) as $i){
|
||||
if ($i["ispublic"] === "t" && $i["isrespondedto"] === "t") {
|
||||
echo("<div class=\"question\">");
|
||||
if ($rows[$i]["iscwed"] === "t") {
|
||||
echo("<details><summary>cw: " . $rows[$i]["cw"] . "</summary><span class=\"cwfiller\"></span>");
|
||||
if ($i["iscwed"] === "t") {
|
||||
echo("<details><summary>cw: " . $i["cw"] . "</summary><span class=\"cwfiller\"></span>");
|
||||
}
|
||||
echo(htmlspecialchars($rows[$i]["text"]));
|
||||
echo("<div class=\"time\">" . $rows[$i]["time"] . "</div>");
|
||||
echo("<div class=\"response\">" . htmlspecialchars($rows[$i]["responsetext"]) . "");
|
||||
echo("<div class=\"time\">" . $rows[$i]["responsetime"] . "</div></div>");
|
||||
echo("<a class=\"permalink\" href=\"fetch.php?id=" . ($i + 1) . "\">permalink</a></div>");
|
||||
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=\"fetch.php?id=" . $i["id"] . "\">permalink</a></div>");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
16
respond.php
16
respond.php
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
|
||||
include 'config.php';
|
||||
|
||||
$timed = date("Y-m-d h:i:sP");
|
||||
|
||||
$query = "
|
||||
UPDATE data
|
||||
SET isrespondedto = true,
|
||||
responsetext = 'teeheee HHIIIIII!!!!!',
|
||||
responsetime = timestamptz'{$timed}'
|
||||
";
|
||||
|
||||
pg_query($db, $query);
|
||||
|
||||
?>
|
2
send.php
2
send.php
|
@ -18,7 +18,7 @@ if ($_GET["public"] == 1) {
|
|||
$isPublic = False;
|
||||
}
|
||||
|
||||
$curTime = date("Y-m-d h:i:sP");
|
||||
$curTime = date("Y-m-d H:i:sP");
|
||||
|
||||
$dataArray = array(
|
||||
"text" => $_GET["text"],
|
||||
|
|
Loading…
Add table
Reference in a new issue