'Missing required Space ID.']); return; } $stmt = 'DELETE FROM spaceMembers where space = ?'; exec_stmt($stmt, 'i', $_POST['id']); $stmt = 'DELETE FROM space WHERE id = ?'; exec_stmt($stmt, 'i', $_POST['id']); } function handleNewSpace() { if (!isset($_POST['name']) || !isset($_POST['description']) || !isset($_POST['visibility'])) { error_log('ruh roh'); return; } $id = randomId(2) * -1; /* $name = htmlspecialchars($_POST['name'], ENT_QUOTES, 'UTF-8'); */ /* $description = htmlspecialchars($_POST['description'], ENT_QUOTES, 'UTF-8'); */ $space = new Space($id, $_POST['name'], $_POST['description'], $_POST['visibility'], null, null, isset($_POST['space']) ? Space::retrieveFromDB($_POST['space']) : null, true); error_log(pretty_dump($space)); Space::addUserToSpace(unserialize($_SESSION['user'])->getId(), $id * -1, 1, true); } function handleNewPost() { if (!isset($_POST['postType']) || !isset($_POST['space'])) return; switch ($_POST['postType']) { case 'Thought': if (!isset($_POST['thought'])) return; $id = randomId(1) * -1; new Thought(Space::retrieveFromDB($_POST['space']), $id, unserialize($_SESSION['user']), 3, 2, urldecode($_POST['thought'])); break; case 'Moment': break; case 'Essay': new Essay(Space::retrieveFromDB($_POST['space']), null, unserialize($_SESSION['user']), 3, 2, $_POST['title'], $_POST['markdown'], $_POST['excerpt']); break; } } function handleSignup() { if (!isset($_POST['username']) || !isset($_POST['password']) || !isset($_POST['vPassword'])) return; if ($_POST['password'] != $_POST['vPassword']) return; $_SESSION['user'] = serialize(new User(randomId(0) * -1, null, $_POST['username'], null, null, null, 3, password_hash($_POST['password'], PASSWORD_DEFAULT))); header('Location: .'); } function handleUsernameCheck() { if (!isset($_POST['username'])) return; echo json_encode(['exists' => User::exists($_POST['username'])]); } function handleSignupHTML() { if (isset($_SESSION['user'])) header('Location: .'); echo json_encode(['html' => User::getSignupHTML()]); } function handleLoginHTML() { if (isset($_SESSION['user'])) header('Location: .'); echo json_encode(['html' => User::getLoginHTML()]); } function handleDeletePost() { if (!isset($_POST['id'])) { echo json_encode(['error' => 'Missing required Post ID.']); return; } $stmt = 'DELETE FROM post WHERE id = ?'; exec_stmt($stmt, 'i', $_POST['id']); } function handleNewSpaceHTML() { $user = unserialize($_SESSION['user']); $html = '