isLoggedIn()){ Redirect::to('/forum'); die(); } // Initialise $forum = new Forum(); require('inc/includes/html/library/HTMLPurifier.auto.php'); // HTML Purifier if(isset($_GET["pid"]) && isset($_GET["tid"])){ if(is_numeric($_GET["pid"]) && is_numeric($_GET["tid"])){ $post_id = $_GET["pid"]; $topic_id = $_GET["tid"]; } else { Redirect::to('/forum/error/?error=not_exist'); die(); } } else { Redirect::to('/forum/error/?error=not_exist'); die(); } /* * Is the post the first in the topic? If so, allow the title to be edited. */ $post_editing = $queries->orderWhere("posts", "topic_id = " . $topic_id, "id", "ASC LIMIT 1"); if($post_editing[0]->id == $post_id){ $edit_title = true; /* * Get the title of the topic */ $post_title = $queries->getWhere("topics", array("id", "=", $topic_id)); $post_title = htmlspecialchars($post_title[0]->topic_title); } /* * Get the post we're editing */ $post_editing = $queries->getWhere("posts", array("id", "=", $post_id)); if($user->data()->id === $post_editing[0]->post_creator || $user->data()->group_id == 2 || $user->data()->group_id == 3){ if(Input::exists()) { if(Token::check(Input::get('token'))) { $validate = new Validate(); $validation = array( 'content' => array( 'required' => true, 'min' => 2, 'max' => 20480 ) ); // add title to validation if we need to if(isset($edit_title)){ $validation['title'] = array( 'required' => true, 'min' => 2, 'max' => 64 ); } $validation = $validate->check($_POST, $validation); if($validation->passed()){ try { // update post content $queries->update("posts", $post_id, array( 'post_content' => htmlspecialchars(Input::get('content')) )); if(isset($edit_title)){ // update title $queries->update("topics", $topic_id, array( 'topic_title' => htmlspecialchars_decode(Input::get('title')) )); } Session::flash('success_post', '