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', '
Post edited.
'); Redirect::to('/forum/view_topic/?tid=' . $topic_id . '&pid=' . $post_id); die(); } catch(Exception $e){ die($e->getMessage()); } } else { $error_string = ""; foreach($validation->errors() as $error) { $error_string .= ucfirst($error) . '
'; } Session::flash('failure_post', '
' . $error_string . '
'); } } else { // Bad token - TODO: improve this } } } else { Redirect::to("/forum"); die(); } $token = Token::generate(); ?> <?php echo $sitename; ?> • Forum - Edit Post

Editing post

set('HTML.Doctype', 'XHTML 1.0 Transitional'); $config->set('URI.DisableExternalResources', false); $config->set('URI.DisableResources', false); $config->set('HTML.Allowed', 'u,p,b,i,small,blockquote,span[style],span[class],p,strong,em,li,ul,ol,div[align],br,img'); $config->set('CSS.AllowedProperties', array('text-align', 'float', 'color','background-color', 'background', 'font-size', 'font-family', 'text-decoration', 'font-weight', 'font-style', 'font-size')); $config->set('HTML.AllowedAttributes', 'href, src, height, width, alt, class, *.style'); $config->set('HTML.SafeIframe', true); $config->set('URI.SafeIframeRegexp', '%^(https?:)?//(www\.youtube(?:-nocookie)?\.com/embed/|player\.vimeo\.com/video/)%'); $purifier = new HTMLPurifier($config); ?>

'; ?>