diff --git a/css/base.css b/css/base.css index 35da159..b89c5b8 100644 --- a/css/base.css +++ b/css/base.css @@ -38,7 +38,8 @@ h3 { } input, -select { +select, +button { background-color: var(--input-background); color: var(--color); border: 1px solid var(--border); @@ -48,11 +49,14 @@ select { } input:focus, -select:focus { +select:focus, +button:focus { outline: 2px solid var(--subtext); } -input::placeholder { +input::placeholder, +i, +.gray { color: var(--subtext); } @@ -65,8 +69,8 @@ a:hover { text-decoration: underline; } -i { - color: var(--subtext); +a.plain { + color: var(--color); } ul { @@ -88,6 +92,14 @@ ul { margin-bottom: 20px; } +.red { + color: var(--red); +} + +.yellow { + color: var(--yellow); +} + #container { text-align: left; margin: 0 10vw; diff --git a/index.php b/index.php index 618eb29..1ca4598 100644 --- a/index.php +++ b/index.php @@ -2,11 +2,11 @@ include "config.php"; include "helper.php"; -include "boilerplate/head.php"; $user = is_logged_in(); if ($user === false) { + include "boilerplate/head.php"; echo "{$lang['account']['log_in']}"; $q = "SELECT count(*) FROM users LIMIT 1;"; @@ -17,8 +17,36 @@ if ($user === false) { include "boilerplate/foot.php"; exit(); +} else if ($_SERVER["REQUEST_METHOD"] === "POST") { + $intent = $_POST["intent"]; + + if ($intent === "create-item") { + $row_id = $_POST["row"]; + $date = strtotime($_POST["date"]); + $description = $_POST["description"]; + + if (strlen($row_id) !== 64 || !preg_match("/[a-f0-9]{64}/", $row_id)) { + $err = lang["add"]["errors"]["invalid_id"]; + } else if ($date === false) { + $err = lang["add"]["errors"]["date"]; + } else if (strlen($description) === 0 || strlen($description) > 256) { + $err = lang["add"]["errors"]["description_length"]; + } else { + pg_insert( + $db, "item", array( + "id" => generate_id(), + "row" => $row_id, + "description" => $description, + "date" => date("Y-m-d", $date) + ) + ); + } + } +} else if ($_GET["del"] && strlen($_GET["del"]) === 64 && preg_match("/[a-f0-9]{64}/", $_GET["del"])) { + pg_query($db, "DELETE FROM item WHERE id='{$_GET['del']}';"); } +include "boilerplate/head.php"; $select_options = ""; $todo_list = ""; @@ -40,7 +68,7 @@ foreach ($sections as $section) { $first = true; foreach ($rows as $row) { - $select_options .= "