<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<?xml-stylesheet type="text/xsl" href="./modx.smith2.en.xsl"?>
<!--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">Confirmation for New Posters</title>
		
		<description lang="en">
			Adds a CAPTCHA prompt to posting for registered users below a configurable post count.
		</description>
		
		<author-notes lang="en"><![CDATA[
This modification adds a new setting to phpBB's CAPTCHA configuration.  When the setting is enabled, registered users with a post count below the number defined in the setting are required to complete a confirmation prompt before posting.  This adds an extra level of security to prevent automated posting attacks on a forum.  Even if an automated script is able to successfully register an account, this modification will likely slow them from flooding a board with spam simply because they will not expect the extra confirmation prompt.
		]]></author-notes>
		
		<author-group>
			<author>
				<realname>Jeremy Rogers</realname>
				<username>Thoul</username>
				<homepage>http://www.phpbbsmith.com</homepage>
			</author>
		</author-group>
		
		<mod-version>1.0.0</mod-version>
		
		<installation>
			<level>easy</level>
			<time>120</time>
			<target-version>3.0.7-pl</target-version>
		</installation>

		<history>
			<entry>
				<date>2010-04-01</date>
				<rev-version>1.0.0</rev-version>
				<changelog lang="en">
					<change>Initial release.</change>
				</changelog>
			</entry>
		</history>
	</header>
	
	<action-group>
		<open src="posting.php">
			<edit>
				<find><![CDATA[if ($config['enable_post_confirm'] && !$user->data['is_registered'])]]></find>
				<action type="replace-with"><![CDATA[//------------------------------------------------------------
// Begin Modification: Confirmation for New Posters
//
/* Original Code:
if ($config['enable_post_confirm'] && !$user->data['is_registered'])
*/
$use_captcha = flag_posting_captcha();
if ($use_captcha)
//
// End Modification: Confirmation for New Posters
//------------------------------------------------------------]]></action>
			</edit>
			<edit>
				<find><![CDATA[	if ($config['enable_post_confirm'] && !$user->data['is_registered'] && in_array($mode, array('quote', 'post', 'reply')))]]></find>
				<action type="replace-with"><![CDATA[//------------------------------------------------------------
// Begin Modification: Confirmation for New Posters
//
/* Original Code:
	if ($config['enable_post_confirm'] && !$user->data['is_registered'] && in_array($mode, array('quote', 'post', 'reply')))
*/
	if ($use_captcha && in_array($mode, array('quote', 'post', 'reply')))
//
// End Modification: Confirmation for New Posters
//------------------------------------------------------------]]></action>
			</edit>
			<edit>
				<find><![CDATA[			if ($config['enable_post_confirm'] && !$user->data['is_registered'] && (isset($captcha) && $captcha->is_solved() === true) && ($mode == 'post' || $mode == 'reply' || $mode == 'quote'))]]></find>
				<action type="replace-with"><![CDATA[//------------------------------------------------------------
// Begin Modification: Confirmation for New Posters
//
/* Original Code:
			if ($config['enable_post_confirm'] && !$user->data['is_registered'] && (isset($captcha) && $captcha->is_solved() === true) && ($mode == 'post' || $mode == 'reply' || $mode == 'quote'))
*/
			if ($use_captcha && (isset($captcha) && $captcha->is_solved() === true) && ($mode == 'post' || $mode == 'reply' || $mode == 'quote'))
//
// End Modification: Confirmation for New Posters
//------------------------------------------------------------]]></action>
			</edit>
			<edit>
				<find><![CDATA[if ($config['enable_post_confirm'] && !$user->data['is_registered'] && (isset($captcha) && $captcha->is_solved() === false) && ($mode == 'post' || $mode == 'reply' || $mode == 'quote'))]]></find>
				<action type="replace-with"><![CDATA[//------------------------------------------------------------
// Begin Modification: Confirmation for New Posters
//
/* Original Code:
if ($config['enable_post_confirm'] && !$user->data['is_registered'] && (isset($captcha) && $captcha->is_solved() === false) && ($mode == 'post' || $mode == 'reply' || $mode == 'quote'))
*/
if ($use_captcha && (isset($captcha) && $captcha->is_solved() === false) && ($mode == 'post' || $mode == 'reply' || $mode == 'quote'))
//
// End Modification: Confirmation for New Posters
//------------------------------------------------------------]]></action>
			</edit>
		</open>
		<open src="adm/style/acp_captcha.html">
			<edit>
				<find><![CDATA[<dl>
	<dt><label for="enable_post_confirm">{L_VISUAL_CONFIRM_POST}:</label><br /><span>{L_VISUAL_CONFIRM_POST_EXPLAIN}</span></dt>
	<dd><label><input type="radio" class="radio" id="enable_post_confirm" name="enable_post_confirm" value="1"<!-- IF POST_ENABLE --> checked="checked"<!-- ENDIF --> /> {L_ENABLED}</label>
		<label><input type="radio" class="radio" name="enable_post_confirm" value="0"<!-- IF not POST_ENABLE --> checked="checked"<!-- ENDIF --> /> {L_DISABLED}</label></dd>
</dl>]]></find>
				<action type="after-add"><![CDATA[<dl>
	<dt><label for="cnp_threshold">{L_VISUAL_CONFIRM_REG_POST}:</label><br /><span>{L_VISUAL_CONFIRM_REG_POST_EXPLAIN}</span></dt>
	<dd><input id="cnp_threshold" type="text" size="4" maxlength="4" name="cnp_threshold" value="{CNP_THRESHOLD}" /></dd>
</dl>]]></action>
			</edit>
		</open>
		<open src="includes/functions_posting.php">
			<edit>
				<find><![CDATA[?>]]></find>
				<action type="before-add"><![CDATA[//------------------------------------------------------------
// Begin Modification: Confirmation for New Posters
//
function flag_posting_captcha()
{
	global $config, $user;

	if( $config['enable_post_confirm'] && !$user->data['is_registered'] )
	{
		return true;
	}

	if( $user->data['is_registered'] && !empty($config['cnp_threshold']) )
	{
		if ( $user->data['user_posts'] < $config['cnp_threshold'] )
		{
			return true;
		}
	}

	return false;
}
//
// End Modification: Confirmation for New Posters
//------------------------------------------------------------]]></action>
			</edit>

		</open>
		<open src="includes/acp/acp_captcha.php">
			<edit>
				<find><![CDATA[				'max_login_attempts'		=> array('tpl' => 'MAX_LOGIN_ATTEMPTS', 'default' => 0),]]></find>
				<action type="after-add"><![CDATA[//------------------------------------------------------------
// Begin Modification: Confirmation for New Posters
//
				'cnp_threshold'			=> array('tpl' => 'CNP_THRESHOLD', 'default' => 0),
//
// End Modification: Confirmation for New Posters
//------------------------------------------------------------]]></action>
			</edit>
			<edit>
				<find><![CDATA[			$this->tpl_name = 'acp_captcha';]]></find>
				<action type="before-add"><![CDATA[//------------------------------------------------------------
// Begin Modification: Confirmation for New Posters
//
			if( !isset($config['cnp_threshold']) )
			{
				set_config('cnp_threshold', 0);
			}
//
// End Modification: Confirmation for New Posters
//------------------------------------------------------------]]></action>
			</edit>

		</open>
		<open src="language/en/acp/board.php">
			<edit>
				<find><![CDATA[	'VISUAL_CONFIRM_POST']]></find>
				<action type="before-add"><![CDATA[//------------------------------------------------------------
// Begin Modification: Confirmation for New Posters
//
	'VISUAL_CONFIRM_REG_POST'				=> 'Posting threshold for new users',
	'VISUAL_CONFIRM_REG_POST_EXPLAIN'		=> 'Requires registered users with a post count below this amount to enter a random code matching an image to help prevent mass postings. Enter 0 to disable this feature.',
//
// End Modification: Confirmation for New Posters
//------------------------------------------------------------]]></action>
			</edit>

		</open>
		<diy-instructions lang="en">Browse to your board's Administration Panel, the "CAPTCHA module settings"
link to complete the install and configure the new setting.</diy-instructions>
	</action-group>
</mod>
