more stuff!
This commit is contained in:
parent
e2d7ebf6ae
commit
b8e4117c1c
11 changed files with 318 additions and 19 deletions
65
admin/all.php
Normal file
65
admin/all.php
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$query = "
|
||||||
|
SELECT * FROM data;
|
||||||
|
";
|
||||||
|
|
||||||
|
$qresp = pg_query($db, $query);
|
||||||
|
|
||||||
|
$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") {
|
||||||
|
$totalUnresponded++;
|
||||||
|
} else if ($rows[$i]["ispublic"] === "f") {
|
||||||
|
$totalPriv++;
|
||||||
|
} else {
|
||||||
|
$totalRespondedPub++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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") {
|
||||||
|
echo("<div class=\"question\">");
|
||||||
|
if ($rows[$i]["iscwed"] === "t") {
|
||||||
|
echo("<details><summary>cw: " . $rows[$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("<h3 class=\"sect\">private ({$totalPriv})</h3>");
|
||||||
|
for ($i=count($rows); $i>=0; $i--) {
|
||||||
|
if ($rows[$i]["ispublic"] === "f") {
|
||||||
|
echo("<div class=\"question\">");
|
||||||
|
if ($rows[$i]["iscwed"] === "t") {
|
||||||
|
echo("<details><summary>cw: " . $rows[$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("<h3 class=\"sect\">public ({$totalRespondedPub})</h3>");
|
||||||
|
for ($i=count($rows); $i>=0; $i--) {
|
||||||
|
if ($rows[$i]["ispublic"] === "t" && $rows[$i]["isrespondedto"] === "t") {
|
||||||
|
echo("<div class=\"question\">");
|
||||||
|
if ($rows[$i]["iscwed"] === "t") {
|
||||||
|
echo("<details><summary>cw: " . $rows[$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>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
20
admin/index.php
Normal file
20
admin/index.php
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
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';
|
||||||
|
} else {
|
||||||
|
include 'all.php';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo("<h2 class=\"sect\">enter password</h2>");
|
||||||
|
echo("<form class=\"frm\" action=\"index.php\"><input id=\"passinput\" name=\"pw\" required=\"\"><br><button class=\"submitbutton\" type=\"submit\">login</button></form>");
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -3,12 +3,26 @@
|
||||||
// timezone (valid ones: https://www.php.net/manual/en/timezones.php)
|
// timezone (valid ones: https://www.php.net/manual/en/timezones.php)
|
||||||
date_default_timezone_set('America/New_York');
|
date_default_timezone_set('America/New_York');
|
||||||
|
|
||||||
|
// admin
|
||||||
|
$adminPassword = "setAPasswordHere!123";
|
||||||
|
|
||||||
|
// page title
|
||||||
|
$pageTitle = "the cool qna";
|
||||||
|
|
||||||
|
$pageDomainEnabled = True;
|
||||||
|
$pageDomain = "example.com";
|
||||||
|
$pageDomainOther = $pageDomain; // you can comment out and change this to a subdomain you want to "go back to". eg your site is me.example.org but you want it to say example.org
|
||||||
|
//$pageDomainOther = "me.example.com";
|
||||||
|
$pageRoot = "/"; // path to go to
|
||||||
|
|
||||||
// database setup
|
// database setup
|
||||||
$dbHost = "localhost";
|
$dbHost = "localhost";
|
||||||
$dbName = "postgres";
|
$dbName = "postgres";
|
||||||
$dbUsername = "postgres";
|
$dbUsername = "postgres";
|
||||||
$dbPassword = "postgres";
|
$dbPassword = "postgres";
|
||||||
|
|
||||||
|
|
||||||
|
// !!! DON'T CHANGE ANYTHING AFTER THIS UNLESS YOU KNOW WHAT YOU'RE DOING !!!
|
||||||
$dbInfo = "host={$dbHost} dbname={$dbName} user={$dbUsername} password={$dbPassword}";
|
$dbInfo = "host={$dbHost} dbname={$dbName} user={$dbUsername} password={$dbPassword}";
|
||||||
$db = pg_connect($dbInfo);
|
$db = pg_connect($dbInfo);
|
||||||
|
|
||||||
|
|
83
css/admin.css
Normal file
83
css/admin.css
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
body {
|
||||||
|
background-image: url(https://notfire.cc/design/images/groundback.gif);
|
||||||
|
background-color: black;
|
||||||
|
color: white;
|
||||||
|
font-family: Arial, Helvetica, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
.permalink {
|
||||||
|
color: #ff0000;
|
||||||
|
font-size: .9em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.goback {
|
||||||
|
color: #ff0000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
margin-bottom: .1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.question {
|
||||||
|
margin-top: .7em;
|
||||||
|
background-color: #2c2c2c;
|
||||||
|
border-radius: 5px;
|
||||||
|
max-width: fit-content;
|
||||||
|
padding: .5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.response {
|
||||||
|
background-color: #505050;
|
||||||
|
border-radius: 5px;
|
||||||
|
margin-top: .3em;
|
||||||
|
padding: .4em;
|
||||||
|
margin-bottom: .25em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.time {
|
||||||
|
font-size: .8em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cwfiller {
|
||||||
|
height: 1.3em;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sect {
|
||||||
|
margin-top: .2em;
|
||||||
|
margin-bottom: .2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sentconf {
|
||||||
|
color: lime;
|
||||||
|
margin-top: .3em;
|
||||||
|
margin-bottom: .3em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sendsum {
|
||||||
|
font-size: 1.17em;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sendmsg {
|
||||||
|
margin-top: 1em;
|
||||||
|
border-radius: 5px;
|
||||||
|
background-color: #2c2c2c;
|
||||||
|
max-width: fit-content;
|
||||||
|
padding: .7em;
|
||||||
|
}
|
||||||
|
|
||||||
|
#passinput, .submitbutton {
|
||||||
|
background-color: black;
|
||||||
|
color: white;
|
||||||
|
margin-bottom: .3em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.submitbutton {
|
||||||
|
font-size: 1.17em;
|
||||||
|
margin-top: .3em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.frm {
|
||||||
|
margin-bottom: 0px;
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
body {
|
body {
|
||||||
|
background-image: url(https://notfire.cc/design/images/groundback.gif);
|
||||||
background-color: black;
|
background-color: black;
|
||||||
color: white;
|
color: white;
|
||||||
font-family: Arial, Helvetica, sans-serif;
|
font-family: Arial, Helvetica, sans-serif;
|
83
css/main.css
Normal file
83
css/main.css
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
body {
|
||||||
|
background-image: url(https://notfire.cc/design/images/groundback.gif);
|
||||||
|
background-color: black;
|
||||||
|
color: white;
|
||||||
|
font-family: Arial, Helvetica, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
.permalink {
|
||||||
|
color: #ff0000;
|
||||||
|
font-size: .9em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.goback {
|
||||||
|
color: #ff0000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
margin-bottom: .1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.question {
|
||||||
|
margin-top: .7em;
|
||||||
|
background-color: #2c2c2c;
|
||||||
|
border-radius: 5px;
|
||||||
|
max-width: fit-content;
|
||||||
|
padding: .5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.response {
|
||||||
|
background-color: #505050;
|
||||||
|
border-radius: 5px;
|
||||||
|
margin-top: .3em;
|
||||||
|
padding: .4em;
|
||||||
|
margin-bottom: .25em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.time {
|
||||||
|
font-size: .8em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cwfiller {
|
||||||
|
height: 1.3em;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sect {
|
||||||
|
margin-bottom: .2em;
|
||||||
|
margin-top: .2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sentconf {
|
||||||
|
color: lime;
|
||||||
|
margin-top: .3em;
|
||||||
|
margin-bottom: .3em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sendsum {
|
||||||
|
font-size: 1.17em;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sendmsg {
|
||||||
|
margin-top: 1em;
|
||||||
|
border-radius: 5px;
|
||||||
|
background-color: #2c2c2c;
|
||||||
|
max-width: fit-content;
|
||||||
|
padding: .7em;
|
||||||
|
}
|
||||||
|
|
||||||
|
#questioninput, #cwinput, .submitbutton {
|
||||||
|
background-color: black;
|
||||||
|
color: white;
|
||||||
|
margin-bottom: .3em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.submitbutton {
|
||||||
|
font-size: 1.17em;
|
||||||
|
margin-top: .3em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.frm {
|
||||||
|
margin-bottom: 0px;
|
||||||
|
}
|
10
fetch.php
10
fetch.php
|
@ -16,19 +16,21 @@ WHERE id = {$id};
|
||||||
$qresp = pg_query($db, $query);
|
$qresp = pg_query($db, $query);
|
||||||
$arr = pg_fetch_array($qresp);
|
$arr = pg_fetch_array($qresp);
|
||||||
|
|
||||||
echo("<link rel=\"stylesheet\" href=\"indiv.css\">");
|
echo("<link rel=\"stylesheet\" href=\"css/indiv.css\">");
|
||||||
|
|
||||||
if (pg_num_rows($qresp) === 0 || $arr["ispublic"] === "f" || $arr["isrespondedto"] === "f") {
|
if (pg_num_rows($qresp) === 0 || $arr["ispublic"] === "f" || $arr["isrespondedto"] === "f") {
|
||||||
echo("<h1 class=\"title\">no such question exists<h1>");
|
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 {
|
} else {
|
||||||
echo("<h1 class=\"title\">individual question</h1>");
|
echo("<h2 class=\"title\">{$pageTitle} – question number " . $arr["id"] . "</h2>");
|
||||||
|
|
||||||
echo("<a class=\"goback\" href=\"index.php\">(go back?)</a>");
|
echo("<a class=\"goback\" href=\"index.php\">(go back?)</a>");
|
||||||
echo("<div class=\"question\">");
|
echo("<div class=\"question\">");
|
||||||
if ($arr["iscwed"] === "t") {
|
if ($arr["iscwed"] === "t") {
|
||||||
echo("<details><summary>cw: " . $arr["cw"] . "</summary><span class=\"cwfiller\"></span>");
|
echo("<details><summary>cw: " . $arr["cw"] . "</summary><span class=\"cwfiller\"></span>");
|
||||||
}
|
}
|
||||||
echo($arr["text"]);
|
echo(htmlspecialchars($arr["text"]));
|
||||||
echo("<div class=\"time\">" . $arr["time"] . "</div>");
|
echo("<div class=\"time\">" . $arr["time"] . "</div>");
|
||||||
echo("<div class=\"response\">" . $arr["responsetext"] . "");
|
echo("<div class=\"response\">" . $arr["responsetext"] . "");
|
||||||
echo("<div class=\"time\">" . $arr["responsetime"] . "</div></div></div>");
|
echo("<div class=\"time\">" . $arr["responsetime"] . "</div></div></div>");
|
||||||
|
|
47
index.php
47
index.php
|
@ -2,21 +2,46 @@
|
||||||
|
|
||||||
include 'config.php';
|
include 'config.php';
|
||||||
|
|
||||||
$_SERVER["id"] = 1;
|
|
||||||
|
|
||||||
$id = $_SERVER["id"];
|
|
||||||
|
|
||||||
if ($id === null) {
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
$query = "
|
$query = "
|
||||||
SELECT * FROM data
|
SELECT * FROM data;
|
||||||
WHERE id = {$id};
|
|
||||||
";
|
";
|
||||||
|
|
||||||
$qresp = pg_query($db, $query);
|
$qresp = pg_query($db, $query);
|
||||||
|
|
||||||
echo (pg_fetch_array($qresp)[1]);
|
$rows = pg_fetch_all($qresp);
|
||||||
|
|
||||||
|
echo("<link rel=\"stylesheet\" href=\"css/main.css\">");
|
||||||
|
|
||||||
|
echo("<h2 class=\"title\">" . $pageTitle . "</h2>");
|
||||||
|
|
||||||
|
if ($pageDomainEnabled) {
|
||||||
|
echo("<a class=\"goback\" href=\"https://{$pageDomainOther}{$pageRoot}\">(go back to " . $pageDomain . "?)</a>");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_GET["sent"] == 1) {
|
||||||
|
echo("<span class=\"sentconf\"><br>message sent!</span>");
|
||||||
|
}
|
||||||
|
|
||||||
|
echo("<div class=\"sendmsg\"><details open=\"\"><summary class=\"sendsum\">send a message!</summary>");
|
||||||
|
|
||||||
|
echo("<form class=\"frm\" action=\"send.php\"><label for=\"questioninput\">enter your message: </label><input id=\"questioninput\" name=\"text\" required=\"\"><br><label for=\"cwinput\">cw if applicable: </label><input id=\"cwinput\" name=\"cw\"><br><input type=\"checkbox\" id=\"pubbox\" name=\"public\" value=\"1\" checked> <label for=\"pubbox\">if this is checked, your message will be available publicly</label><br><button class=\"submitbutton\" type=\"submit\">send!</button></form></details></div>");
|
||||||
|
|
||||||
|
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") {
|
||||||
|
echo("<div class=\"question\">");
|
||||||
|
if ($rows[$i]["iscwed"] === "t") {
|
||||||
|
echo("<details><summary>cw: " . $rows[$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>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -9,7 +9,7 @@ UPDATE data
|
||||||
SET isrespondedto = true,
|
SET isrespondedto = true,
|
||||||
responsetext = 'teeheee HHIIIIII!!!!!',
|
responsetext = 'teeheee HHIIIIII!!!!!',
|
||||||
responsetime = timestamptz'{$timed}'
|
responsetime = timestamptz'{$timed}'
|
||||||
WHERE id = 1";
|
";
|
||||||
|
|
||||||
pg_query($db, $query);
|
pg_query($db, $query);
|
||||||
|
|
||||||
|
|
12
send.php
12
send.php
|
@ -2,16 +2,22 @@
|
||||||
|
|
||||||
include 'config.php';
|
include 'config.php';
|
||||||
|
|
||||||
if ($_GET["text"] === null || $_GET["public"] === null) {
|
if ($_GET["text"] === null) {
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_GET["cw"] === null) {
|
if ($_GET["cw"] === null || $_GET["cw"] === "") {
|
||||||
$iscw = False;
|
$iscw = False;
|
||||||
} else {
|
} else {
|
||||||
$iscw = True;
|
$iscw = True;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($_GET["public"] == 1) {
|
||||||
|
$isPublic = True;
|
||||||
|
} else {
|
||||||
|
$isPublic = False;
|
||||||
|
}
|
||||||
|
|
||||||
$curTime = date("Y-m-d h:i:sP");
|
$curTime = date("Y-m-d h:i:sP");
|
||||||
|
|
||||||
$dataArray = array(
|
$dataArray = array(
|
||||||
|
@ -19,7 +25,7 @@ $dataArray = array(
|
||||||
"cw" => $_GET["cw"],
|
"cw" => $_GET["cw"],
|
||||||
"iscwed" => $iscw,
|
"iscwed" => $iscw,
|
||||||
"time" => $curTime,
|
"time" => $curTime,
|
||||||
"ispublic" => $_GET["public"],
|
"ispublic" => $isPublic,
|
||||||
"isrespondedto" => False
|
"isrespondedto" => False
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue