} else { $username = $mybb->user['username']; $uid = $mybb->user['uid']; } // Set up posthandler. require_once MYBB_ROOT . "inc/datahandlers/post.php"; $posthandler = new PostDataHandler("insert"); $posthandler->action = "post"; // Set the post data that came from the input to the $post array. $post = array("tid" => $mybb->get_input('tid', MyBB::INPUT_INT), "replyto" => $mybb->get_input('replyto', MyBB::INPUT_INT), "fid" => $thread['fid'], "subject" => $mybb->get_input('subject'), "icon" => $mybb->get_input('icon', MyBB::INPUT_INT), "uid" => $uid, "username" => $username, "message" => $mybb->get_input('message'), "ipaddress" => $session->packedip, "posthash" => $mybb->get_input('posthash')); if (isset($mybb->input['pid'])) { $post['pid'] = $mybb->get_input('pid', MyBB::INPUT_INT); } $posthandler->set_data($post); // Now let the post handler do all the hard work. $valid_post = $posthandler->verify_message(); $valid_subject = $posthandler->verify_subject(); // guest post --> verify author if ($post['uid'] == 0) { $valid_username = $posthandler->verify_author(); } else { $valid_username = true; } $post_errors = array(); // Fetch friendly error messages if this is an invalid post if (!$valid_post || !$valid_subject || !$valid_username) { $post_errors = $posthandler->get_friendly_errors(); } // One or more errors returned, fetch error list and throw to newreply page if (count($post_errors) > 0) { $reply_errors = inline_error($post_errors);
} } // If we're preving a post then generate the preview. if ($mybb->input['previewpost']) { // Set up posthandler. require_once MYBB_ROOT . "inc/datahandlers/post.php"; $posthandler = new PostDataHandler("insert"); $posthandler->action = "thread"; // Set the thread data that came from the input to the $thread array. $new_thread = array("fid" => $forum['fid'], "prefix" => $mybb->input['threadprefix'], "subject" => $mybb->input['subject'], "icon" => $mybb->input['icon'], "uid" => $uid, "username" => $username, "message" => $mybb->input['message'], "ipaddress" => get_ip(), "posthash" => $mybb->input['posthash']); if ($pid != '') { $new_thread['pid'] = $pid; } $posthandler->set_data($new_thread); // Now let the post handler do all the hard work. $valid_thread = $posthandler->verify_message(); $valid_subject = $posthandler->verify_subject(); // guest post --> verify author if ($new_thread['uid'] == 0) { $valid_username = $posthandler->verify_author(); } else { $valid_username = true; } $post_errors = array(); // Fetch friendly error messages if this is an invalid post if (!$valid_thread || !$valid_subject || !$valid_username) { $post_errors = $posthandler->get_friendly_errors(); } // One or more errors returned, fetch error list and throw to newreply page if (count($post_errors) > 0) { $thread_errors = inline_error($post_errors);