public function update() { static::$auth->mustBeAdmin(); $thread = new Thread($_POST['id']); $thread->processArray($_POST); if (!$thread->isValid()) { $_SESSION['thread.form'] = $thread; header("Location: ./?page=thread.edit&id=" . $_POST['id']); exit; } if ($_FILES['poster']['error'] === UPLOAD_ERR_OK) { $thread->savePoster($_FILES['poster']['tmp_name']); } else { if (isset($_POST['remove-image']) && $_POST['remove-image'] === "TRUE") { $thread->poster = null; } } $thread->save(); header("Location: ./?page=thread&id=" . $thread->id); }