<commit_before><?php

/**
 * @name      ElkArte Forum
 * @copyright ElkArte Forum contributors
 * @license   BSD http://opensource.org/licenses/BSD-3-Clause
 *
 * This software is a derived product, based on:
 *
 * Simple Machines Forum (SMF)
 * copyright:	2011 Simple Machines (http://www.simplemachines.org)
 * license:  	BSD, See included LICENSE.TXT for terms and conditions.
 *
 * @version 1.0 Alpha
 *
 * The job of this file is to handle everything related to posting replies,
 * new topics, quotes, and modifications to existing posts.  It also handles
 * quoting posts by way of javascript.
 *
 */

if (!defined('ELKARTE'))
	die('No access...');

class Post_Controller
{
	/**
	 * Handles showing the post screen, loading the post to be modified, and loading any post quoted.
	 *
	 * - additionally handles previews of posts.
	 * - @uses the Post template and language file, main sub template.
	 * - allows wireless access using the protocol_post sub template.
	 * - requires different permissions depending on the actions, but most notably post_new, post_reply_own, and post_reply_any.
	 * - shows options for the editing and posting of calendar events and attachments, as well as the posting of polls.
	 * - accessed from ?action=post.
	 *
	 *  @param array $post_errors holds any errors found tyring to post
	 */
	function action_post()
	{
		global $txt, $scripturl, $topic, $modSettings, $board;
		global $user_info, $context, $settings;
		global $options, $language;

		$db = database();

		loadLanguage('Post');

		// You can't reply with a poll... hacker.
		if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg']))
			unset($_REQUEST['poll']);

		$post_errors = error_context::context('post', 1);
		$attach_errors = error_context::context('attachment', 1);

		// Posting an event?
		$context['make_event'] = isset($_REQUEST['calendar']);
		$context['robot_no_index'] = true;
		$template_layers = Template_Layers::getInstance();
		$template_layers->add('postarea');

		// You must be posting to *some* board.
		if (empty($board) && !$context['make_event'])
			fatal_lang_error('no_board', false);

		if ($context['make_event'])
			$template_layers->add('make_event');

		require_once(SUBSDIR . '/Post.subs.php');
		require_once(SUBSDIR . '/Messages.subs.php');

		if (isset($_REQUEST['xml']))
		{
			$context['sub_template'] = 'post';

			// Just in case of an earlier error...
			$context['preview_message'] = '';
			$context['preview_subject'] = '';
		}

		// No message is complete without a topic.<commit_msg>Undefined variable $first_subject<commit_after><?php

/**
 * @name      ElkArte Forum
 * @copyright ElkArte Forum contributors
 * @license   BSD http://opensource.org/licenses/BSD-3-Clause
 *
 * This software is a derived product, based on:
 *
 * Simple Machines Forum (SMF)
 * copyright:	2011 Simple Machines (http://www.simplemachines.org)
 * license:  	BSD, See included LICENSE.TXT for terms and conditions.
 *
 * @version 1.0 Alpha
 *
 * The job of this file is to handle everything related to posting replies,
 * new topics, quotes, and modifications to existing posts.  It also handles
 * quoting posts by way of javascript.
 *
 */

if (!defined('ELKARTE'))
	die('No access...');

class Post_Controller
{
	/**
	 * Handles showing the post screen, loading the post to be modified, and loading any post quoted.
	 *
	 * - additionally handles previews of posts.
	 * - @uses the Post template and language file, main sub template.
	 * - allows wireless access using the protocol_post sub template.
	 * - requires different permissions depending on the actions, but most notably post_new, post_reply_own, and post_reply_any.
	 * - shows options for the editing and posting of calendar events and attachments, as well as the posting of polls.
	 * - accessed from ?action=post.
	 *
	 *  @param array $post_errors holds any errors found tyring to post
	 */
	function action_post()
	{
		global $txt, $scripturl, $topic, $modSettings, $board;
		global $user_info, $context, $settings;
		global $options, $language;

		$db = database();

		loadLanguage('Post');

		// You can't reply with a poll... hacker.
		if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg']))
			unset($_REQUEST['poll']);

		$post_errors = error_context::context('post', 1);
		$attach_errors = error_context::context('attachment', 1);
		$first_subject = '';

		// Posting an event?
		$context['make_event'] = isset($_REQUEST['calendar']);
		$context['robot_no_index'] = true;
		$template_layers = Template_Layers::getInstance();
		$template_layers->add('postarea');

		// You must be posting to *some* board.
		if (empty($board) && !$context['make_event'])
			fatal_lang_error('no_board', false);

		if ($context['make_event'])
			$template_layers->add('make_event');

		require_once(SUBSDIR . '/Post.subs.php');
		require_once(SUBSDIR . '/Messages.subs.php');

		if (isset($_REQUEST['xml']))
		{
			$context['sub_template'] = 'post';

			// Just in case of an earlier error...
			$context['preview_message'] = '';
			$context['preview_subject'] = '';
		}

		// No message is complete without a topic.
{'fraction_non_alphanumeric': 0.13787731256085686, 'fraction_numerical': 0.003505355404089581, 'mean_word_length': 4.035294117647059, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4028015', 'n_tokens_mistral': 1659, 'n_tokens_neox': 1507, 'n_words': 494}