<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="./contrib/xsl/modx.prosilver.en.xsl"?>
<!--
	NOTICE: Please open this file in your web browser. If presented with a security warning, you may safely tell it to allow the blocked content.
-->
<!--For security purposes, please check: http://www.phpbb.com/mods/ for the latest version of this MOD. Although MODs are checked before being allowed in the MODs Database there is no guarantee that there are no security problems within the MOD. No support will be given for MODs not found within the MODs Database which can be found at http://www.phpbb.com/mods/-->
<mod xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.phpbb.com/mods/xml/modx-1.2.5.xsd">
	<header>
		<license>http://opensource.org/licenses/gpl-license.php GNU General Public License v2</license>
		<title lang="en">Prime Censor Block</title>
	<description lang="en">Prevents the submission of a form when a post, private message, username, e-mail address, signature, or custom profile field contains text that would ordinarily be censored.</description>
	    <author-notes lang="en">Creating, maintaining, and updating MODs requires a lot of time and effort, so if you like this MOD and have the desire to express your thanks through donations, that would be greatly appreciated. My Paypal ID is primehalo@gmail.com, or contact me for my mailing address. The suggested donation amount for this MOD is $5.00 (but any amount will help).</author-notes>
		<author-group>
			<author>
				<realname>Ken F. Innes IV</realname>
				<email>primehalo@gmail.com</email>
				<username>primehalo</username>
				<homepage><![CDATA[http://www.absoluteanime.com/admin/mods.htm#censor_block]]></homepage>
			</author>
		</author-group>
		<mod-version>1.0.3a</mod-version>
		<installation>
			<level>easy</level>
			<time>300</time>
			<target-version>3.0.8</target-version>
		</installation>
		<history>
			<entry>
				<date>2009-03-01</date>
				<rev-version>1.0.0</rev-version>
				<changelog lang="en">
					<change>Initial release.</change>
				</changelog>
			</entry>
			<entry>
				<date>2009-05-18</date>
				<rev-version>1.0.1</rev-version>
				<changelog lang="en">
					<change>Fixed a bug that would flag non-strings as being forbidden text.</change>
					<change>Add a flag that can disable the mod for admins.</change>
				</changelog>
			</entry>
			<entry>
				<date>2009-09-03</date>
				<rev-version>1.0.2</rev-version>
				<changelog lang="en">
					<change>Display the BBCodes in the preview when a forbidden word is found so the highlighted words don't end up inside an HTML tag.</change>
				</changelog>
			</entry>
			<entry>
				<date>2009-12-24</date>
				<rev-version>1.0.3</rev-version>
				<changelog lang="en">
					<change>Provide an option to do case insensitive comparisons.</change>
				</changelog>
			</entry>
			<entry>
				<date>2011-06-20</date>
				<rev-version>1.0.3a</rev-version>
				<changelog lang="en">
					<change>Added a Russian translation.</change>
				</changelog>
			</entry>
		</history>
		<link-group>
			<link type="language" href="contrib/language - ru.xml" realname="ru" lang="en">Russian</link>

			<link type="contrib" href="contrib/update 1.0.0 to 1.0.1.xml" lang="en">Update 1.0.0 to 1.0.1</link>
			<link type="contrib" href="contrib/update 1.0.1 to 1.0.2.xml" lang="en">Update 1.0.1 to 1.0.2</link>
			<link type="contrib" href="contrib/update 1.0.2 to 1.0.3.xml" lang="en">Update 1.0.2 to 1.0.3</link>
		</link-group>
	</header>
	<action-group>
		<copy>
 			<file from="root/includes/prime_censor_block.php" to="includes/prime_censor_block.php" />
 			<file from="root/language/en/mods/prime_censor_block.php" to="language/en/mods/prime_censor_block.php" />
		</copy>
		<open src="posting.php">
			<edit>
				<find><![CDATA[		$message_parser->parse($post_data['enable_bbcode'], ($config['allow_post_links']) ? $post_data['enable_urls'] : false, $post_data['enable_smilies'], $img_status, $flash_status, $quote_status, $config['allow_post_links']);]]></find>
				<action type="before-add"><![CDATA[//-- mod: Prime Censor Block ------------------------------------------------//
// If forbidden words exist, stop any posting and do a preview so we can highlight the offending words.
		include($phpbb_root_path . 'includes/prime_censor_block.' . $phpEx);
		$prime_censor_block->check_post($post_data['post_subject'], $message_parser->message, $post_data['poll_title'], $post_data['poll_options']);
		$prime_censor_block->set_preview($preview, $submit);
		$prime_censor_block->update_bbcode_state($post_data['enable_bbcode']);
//-- end: Prime Censor Block ------------------------------------------------//]]></action>
				<action type="after-add"><![CDATA[//-- mod: Prime Censor Block ------------------------------------------------//
		$prime_censor_block->restore_bbcode_state($post_data['enable_bbcode']);
//-- end: Prime Censor Block ------------------------------------------------//]]></action>
			</edit>
			<edit>
				<find><![CDATA[	$preview_subject = censor_text($post_data['post_subject']);]]></find>
				<action type="after-add"><![CDATA[//-- mod: Prime Censor Block ------------------------------------------------//
	$preview_subject = $prime_censor_block->highlight($post_data['post_subject'], $preview_subject);
	$poll_delete = isset($poll_delete) ? $poll_delete : false;
//-- end: Prime Censor Block ------------------------------------------------//
]]></action>
			</edit>
			<edit>
				<find><![CDATA[}

// Decode text for message display]]></find>
				<action type="before-add"><![CDATA[//-- mod: Prime Censor Block ------------------------------------------------//
	$prime_censor_block->set_error($error);
//-- end: Prime Censor Block ------------------------------------------------//]]></action>
			</edit>
		</open>

		<open src="includes/functions_profile_fields.php">
			<edit>
				<find><![CDATA[	function submit_cp_field($mode, $lang_id, &$cp_data, &$cp_error)
	{
		global $auth, $db, $user;]]></find>
				<action type="after-add"><![CDATA[//-- mod: Prime Censor Block ------------------------------------------------//
		global $phpbb_root_path, $phpEx;
		include($phpbb_root_path . 'includes/prime_censor_block.' . $phpEx);
//-- end: Prime Censor Block ------------------------------------------------//]]></action>
			</edit>
			<edit>
				<find><![CDATA[				if ($error != '')
				{
					$cp_error[] = $error;
				}
			}]]></find>
				<action type="after-add"><![CDATA[//-- mod: Prime Censor Block ------------------------------------------------//
// If one or more custom profile fields contain forbidden text then display an error.
			$prime_censor_block->check_custom_profile_fields($check_value, $row['lang_name'], $cp_error);
//-- end: Prime Censor Block ------------------------------------------------//]]></action>
			</edit>
		</open>

		<open src="includes/functions_user.php">
			<edit>
				<find><![CDATA[	foreach ($bad_usernames as $bad_username)
	{
		if (preg_match('#^' . $bad_username . '$#', $clean_username))
		{
			return 'USERNAME_DISALLOWED';
		}
	}]]></find>
				<action type="after-add"><![CDATA[//-- mod: Prime Censor Block ------------------------------------------------//
// If the username contain forbidden text then display an error.
	global $phpbb_root_path, $phpEx;
	include($phpbb_root_path . 'includes/prime_censor_block.' . $phpEx);
	return $prime_censor_block->check_username($clean_username);
//-- end: Prime Censor Block ------------------------------------------------//]]></action>
			</edit>
			<edit>
				<find><![CDATA[		if ($row)
		{
			return 'EMAIL_TAKEN';
		}
	}]]></find>
				<action type="after-add"><![CDATA[//-- mod: Prime Censor Block ------------------------------------------------//
// If the e-mail address contain forbidden text then display an error.
	global $phpbb_root_path, $phpEx;
	include($phpbb_root_path . 'includes/prime_censor_block.' . $phpEx);
	return $prime_censor_block->check_email($email);
//-- end: Prime Censor Block ------------------------------------------------//]]></action>
			</edit>
		</open>

		<open src="includes/message_parser.php">
			<edit>
				<find><![CDATA[		// Replace naughty words such as farty pants]]></find>
				<action type="before-add"><![CDATA[//-- mod: Prime Censor Block ------------------------------------------------//
		$uncensored_message = $this->message;
//-- end: Prime Censor Block ------------------------------------------------//]]></action>
			</edit>
			<edit>
				<find><![CDATA[		$this->message = censor_text($this->message);]]></find>
				<action type="after-add"><![CDATA[//-- mod: Prime Censor Block ------------------------------------------------//
// Highlight words to be censored instead of actually censoring them.
		global $phpbb_root_path, $phpEx;
		include($phpbb_root_path . 'includes/prime_censor_block.' . $phpEx);
		$this->message = $prime_censor_block->highlight($uncensored_message, $this->message);
//-- end: Prime Censor Block ------------------------------------------------//]]></action>
			</edit>
		</open>

		<open src="includes/ucp/ucp_pm_compose.php">
			<edit>
				<find><![CDATA[		$message_parser->parse($enable_bbcode, ($config['allow_post_links']) ? $enable_urls : false, $enable_smilies, $img_status, $flash_status, true, $config['allow_post_links']);]]></find>
				<action type="before-add"><![CDATA[//-- mod: Prime Censor Block ------------------------------------------------//
// If forbidden words exist, stop any posting and do a preview so we can highlight the offending words.
		include($phpbb_root_path . 'includes/prime_censor_block.' . $phpEx);
		$prime_censor_block->check_post($subject, $message_parser->message);
		$prime_censor_block->set_preview($preview, $submit);
		$prime_censor_block->update_bbcode_state($enable_bbcode);
//-- end: Prime Censor Block ------------------------------------------------//]]></action>
				<action type="after-add"><![CDATA[//-- mod: Prime Censor Block ------------------------------------------------//
		$prime_censor_block->restore_bbcode_state($enable_bbcode);
//-- end: Prime Censor Block ------------------------------------------------//]]></action>
			</edit>
			<edit>
				<find><![CDATA[		$preview_subject = censor_text($subject);]]></find>
				<action type="after-add"><![CDATA[//-- mod: Prime Censor Block ------------------------------------------------//
		$preview_subject = $prime_censor_block->highlight($subject, $preview_subject);
//-- end: Prime Censor Block ------------------------------------------------//]]></action>
			</edit>
			<edit>
				<find><![CDATA[		unset($message_text);]]></find>
				<action type="after-add"><![CDATA[//-- mod: Prime Censor Block ------------------------------------------------//
		$prime_censor_block->set_error($error);
//-- end: Prime Censor Block ------------------------------------------------//]]></action>
			</edit>
		</open>

		<open src="includes/ucp/ucp_profile.php">
			<edit>
				<find><![CDATA[					if (!sizeof($error))
					{
						$data['notify'] = $user->data['user_notify_type'];]]></find>
				<action type="before-add"><![CDATA[//-- mod: Prime Censor Block ------------------------------------------------//
// If one or more profile fields contain forbidden text then display an error.
					include($phpbb_root_path . 'includes/prime_censor_block.' . $phpEx);
					$prime_censor_block->check_profile_fields($data, $error);
//-- end: Prime Censor Block ------------------------------------------------//]]></action>
			</edit>
			<edit>
				<find><![CDATA[						if (!sizeof($error) && $submit)]]></find>
				<action type="before-add"><![CDATA[//-- mod: Prime Censor Block ------------------------------------------------//
// If one or more profile fields contain forbidden text then display an error.
						include($phpbb_root_path . 'includes/prime_censor_block.' . $phpEx);
						$prime_censor_block->check_signature($message_parser->message, $preview, $submit, $error);
//-- end: Prime Censor Block ------------------------------------------------//]]></action>
			</edit>
		</open>
	</action-group>
</mod>
