{$lang['account']['log_in']}"; $q = "SELECT count(*) FROM users LIMIT 1;"; if ($signups !== false || ($signups === false && pg_fetch_array(pg_query($db, $q))["count"] !== 0)) { echo " - {$lang['account']['sign_up']}"; } 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 = ""; $q = "SELECT * FROM section WHERE users='{$user['id']}' ORDER BY LOWER(name) ASC;"; $sections = pg_fetch_all(pg_query($db, $q)); foreach ($sections as $section) { $q = "SELECT * FROM row WHERE section='{$section['id']}' ORDER BY LOWER(name) ASC;"; $rows = pg_fetch_all(pg_query($db, $q)); $show_subtitle = $section["show_subtitle"] === "t"; $enable_optgroup = $show_subtitle || count($rows) !== 1; $todo_list .= "