} else { if ($_POST["type"] == "open" && date_diff(date_create($_POST["start"]), date_create($_POST["end"]))->format("%r") == "-") { echo "End date must be after start date"; } else { $hash = ""; $account_id = $account !== false ? $account : 0; $public = isset($_POST["public"]); $hidden = isset($_POST["hidden"]); if ($_POST["type"] == "open") { $hash = create_event($_POST["name"], $_POST["start"], $_POST["end"], $_POST["desc"], $_POST["type"], $account_id, $public, $hidden); header('Location: view?event=' . $hash); } else { if ($_POST["type"] == "centered") { $hash = create_event($_POST["name"], date("Y-m-d H:i:s", 0), date("Y-m-d H:i:s", PHP_INT_MAX), $_POST["desc"], $_POST["type"], $account_id, $public, $hidden); $id = get_event($hash)["id"]; $processor = new NaturalLanguageProcessor($_POST["proposal"], date("Y-m-d H:i:s", 0), date("Y-m-d H:i:s", PHP_INT_MAX)); if ($account !== false) { put_schedule("", $processor->Process(), $id, $account, $_POST["proposal"]); } else { put_schedule($_POST["username"], $processor->Process(), $id, $_POST["proposal"]); } header('Location: view?event=' . $hash . "#share"); } } } } } $title = "Create Event"; require_once "header.php"; ?>
} $event = get_event($_GET["event"]); if ($event == null) { header("Location: /" . SITE_ROOT); } if ($event["public"] == 0 && $event["account"] != $account && !(isset($_GET["key"]) && validate_invite($event["id"], $_GET["key"])) && !($account !== false && validate_invite_account($event["id"], $account))) { header("Location: /" . SITE_ROOT); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($account === false && (isset($_POST["name"]) && $_POST["name"] == "")) { echo "Please enter your name"; } else { if ($_POST["text"] == "") { echo "Please enter your availability"; } else { $processor = new NaturalLanguageProcessor($_POST["text"], $event["range_start"], $event["range_end"]); $p = $processor->Process(); if ($p !== false) { $userid = 0; if ($account !== false) { $userid = put_schedule("", $p, $event["id"], $account, $_POST["text"]); } else { if ($event["public"] == 0) { $userid = put_schedule(isset($_POST["name"]) ? $_POST["name"] : "", $p, $event["id"], 0, $_POST["text"], $_GET["key"]); } else { $userid = put_schedule(isset($_POST["name"]) ? $_POST["name"] : "", $p, $event["id"], 0, $_POST["text"]); } } if ($event["public"] == 0) { if ($account !== false) { update_invite_account($event["id"], $account, $userid);