readonly()) { header("Location: index.html"); exit; } $title = ""; $error = ""; $post = null; $thread = null; try { if (isset($_POST["submit"])) { if (isset($_POST["p"])) { $pid = (int)safe_post("p"); $post = get_single_post($pid); erase_post($post); // the whole thread may have been deleted if this was the // only post in it $url = ""; if (thread_exists($post->thread_id())) $url = make_thread_link_impl($post->thread_id()); else $url = make_forum_link_impl($post->forum_id()); header("Location: $url"); exit; } else if (isset($_POST["t"])) { $tid = (int)safe_post("t"); $thread = get_thread($tid); erase_thread($thread); $url = make_forum_link_impl($thread->forum_id()); header("Location: $url"); exit; } } else if (isset($_GET["p"])) { $pid = (int)safe_get("p"); $post = get_single_post($pid); $title = loc("erase_post_title"); set_this_link("erase", array("p" => $pid)); } else if (isset($_GET["t"])) { $tid = (int)safe_get("t"); $thread = get_thread($tid); $title = loc("erase_thread_title"); set_this_link("erase", array("t" => $tid)); } else { throw new bad_parameters(); } } catch(bad_parameters $e) { $error = "bad parameters"; } catch(forum_not_found $e) { $error = "forum not found"; } catch(thread_not_found $e) { $error = "thread not found"; } catch(post_not_found $e) { $error = "post not found"; } catch(db_exception $e) { $error = $e->html(); } output_head("forum", $title); ?>