mrooeww
This commit is contained in:
commit
e2d7ebf6ae
9 changed files with 181 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
config.php
|
0
admin.php
Normal file
0
admin.php
Normal file
15
config.example.php
Normal file
15
config.example.php
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// timezone (valid ones: https://www.php.net/manual/en/timezones.php)
|
||||||
|
date_default_timezone_set('America/New_York');
|
||||||
|
|
||||||
|
// database setup
|
||||||
|
$dbHost = "localhost";
|
||||||
|
$dbName = "postgres";
|
||||||
|
$dbUsername = "postgres";
|
||||||
|
$dbPassword = "postgres";
|
||||||
|
|
||||||
|
$dbInfo = "host={$dbHost} dbname={$dbName} user={$dbUsername} password={$dbPassword}";
|
||||||
|
$db = pg_connect($dbInfo);
|
||||||
|
|
||||||
|
?>
|
37
fetch.php
Normal file
37
fetch.php
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
include 'config.php';
|
||||||
|
|
||||||
|
$id = $_GET["id"];
|
||||||
|
|
||||||
|
if ($id === null) {
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = "
|
||||||
|
SELECT * FROM data
|
||||||
|
WHERE id = {$id};
|
||||||
|
";
|
||||||
|
|
||||||
|
$qresp = pg_query($db, $query);
|
||||||
|
$arr = pg_fetch_array($qresp);
|
||||||
|
|
||||||
|
echo("<link rel=\"stylesheet\" href=\"indiv.css\">");
|
||||||
|
|
||||||
|
if (pg_num_rows($qresp) === 0 || $arr["ispublic"] === "f" || $arr["isrespondedto"] === "f") {
|
||||||
|
echo("<h1 class=\"title\">no such question exists<h1>");
|
||||||
|
} else {
|
||||||
|
echo("<h1 class=\"title\">individual question</h1>");
|
||||||
|
|
||||||
|
echo("<a class=\"goback\" href=\"index.php\">(go back?)</a>");
|
||||||
|
echo("<div class=\"question\">");
|
||||||
|
if ($arr["iscwed"] === "t") {
|
||||||
|
echo("<details><summary>cw: " . $arr["cw"] . "</summary><span class=\"cwfiller\"></span>");
|
||||||
|
}
|
||||||
|
echo($arr["text"]);
|
||||||
|
echo("<div class=\"time\">" . $arr["time"] . "</div>");
|
||||||
|
echo("<div class=\"response\">" . $arr["responsetext"] . "");
|
||||||
|
echo("<div class=\"time\">" . $arr["responsetime"] . "</div></div></div>");
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
22
index.php
Normal file
22
index.php
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
include 'config.php';
|
||||||
|
|
||||||
|
$_SERVER["id"] = 1;
|
||||||
|
|
||||||
|
$id = $_SERVER["id"];
|
||||||
|
|
||||||
|
if ($id === null) {
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = "
|
||||||
|
SELECT * FROM data
|
||||||
|
WHERE id = {$id};
|
||||||
|
";
|
||||||
|
|
||||||
|
$qresp = pg_query($db, $query);
|
||||||
|
|
||||||
|
echo (pg_fetch_array($qresp)[1]);
|
||||||
|
|
||||||
|
?>
|
37
indiv.css
Normal file
37
indiv.css
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
body {
|
||||||
|
background-color: black;
|
||||||
|
color: white;
|
||||||
|
font-family: Arial, Helvetica, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
.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;
|
||||||
|
}
|
||||||
|
|
||||||
|
.time {
|
||||||
|
font-size: .8em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cwfiller {
|
||||||
|
height: 1.3em;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
16
respond.php
Normal file
16
respond.php
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
include 'config.php';
|
||||||
|
|
||||||
|
$timed = date("Y-m-d h:i:sP");
|
||||||
|
|
||||||
|
$query = "
|
||||||
|
UPDATE data
|
||||||
|
SET isrespondedto = true,
|
||||||
|
responsetext = 'teeheee HHIIIIII!!!!!',
|
||||||
|
responsetime = timestamptz'{$timed}'
|
||||||
|
WHERE id = 1";
|
||||||
|
|
||||||
|
pg_query($db, $query);
|
||||||
|
|
||||||
|
?>
|
30
send.php
Normal file
30
send.php
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
include 'config.php';
|
||||||
|
|
||||||
|
if ($_GET["text"] === null || $_GET["public"] === null) {
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_GET["cw"] === null) {
|
||||||
|
$iscw = False;
|
||||||
|
} else {
|
||||||
|
$iscw = True;
|
||||||
|
}
|
||||||
|
|
||||||
|
$curTime = date("Y-m-d h:i:sP");
|
||||||
|
|
||||||
|
$dataArray = array(
|
||||||
|
"text" => $_GET["text"],
|
||||||
|
"cw" => $_GET["cw"],
|
||||||
|
"iscwed" => $iscw,
|
||||||
|
"time" => $curTime,
|
||||||
|
"ispublic" => $_GET["public"],
|
||||||
|
"isrespondedto" => False
|
||||||
|
);
|
||||||
|
|
||||||
|
pg_insert($db, "data", $dataArray);
|
||||||
|
|
||||||
|
header("Location: index.php?sent=1");
|
||||||
|
|
||||||
|
?>
|
23
setup.php
Normal file
23
setup.php
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
include 'config.php';
|
||||||
|
|
||||||
|
$query = "
|
||||||
|
CREATE TABLE data (
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
text TEXT NOT NULL,
|
||||||
|
cw TEXT,
|
||||||
|
iscwed BOOLEAN NOT NULL,
|
||||||
|
time TIMESTAMPTZ NOT NULL,
|
||||||
|
ispublic BOOLEAN NOT NULL,
|
||||||
|
isrespondedto BOOLEAN NOT NULL,
|
||||||
|
responsetext TEXT,
|
||||||
|
responsetime TIMESTAMPTZ
|
||||||
|
);
|
||||||
|
";
|
||||||
|
|
||||||
|
pg_query($db, $query);
|
||||||
|
|
||||||
|
echo "database set up";
|
||||||
|
|
||||||
|
?>
|
Loading…
Reference in a new issue