<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="modx.prosilver.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.2.xsd">
	<header>
		<license>http://opensource.org/licenses/gpl-license.php GNU General Public License v2</license>
		
		<title lang="en">Anti Bot Question</title>
		
		<description lang="en">Add an Admin controlled anti-bot question to the registration page and ACP.</description>
		
		<author-notes lang="en">Mod will need to be switched on before use</author-notes>
		
		<author-group>
			<author>
				<username>CoC</username>
				<realname>Chris</realname>
				<homepage>http://www.skyblueuntrust.com</homepage>
			</author>
		</author-group>
		
		<mod-version>1.2.0</mod-version>
		
		<installation>
			<level>easy</level>
			<time>300</time>
			<target-version>3.0.4</target-version>
		</installation>
		
	    <link-group>
			<link type="template" lang="en-gb" href="templates/subsilver2.xml">Changes for subsilver2</link>
	    </link-group>
		
		<history>
			<entry>
				<date>2009-02-23</date>
				<rev-version>1.2.0</rev-version>
				<changelog lang="en-gb">
					<change>Update to ModX 1.2.2</change>
				</changelog>
			</entry>
			<entry>
				<date>2008-01-10</date>
				<rev-version>1.1.0</rev-version>
				<changelog lang="en-gb">
					<change>Fixed bug with answer two being submitted as empty</change>
				</changelog>
			</entry>
			<entry>
				<date>2008-01-02</date>
				<rev-version>1.0.4</rev-version>
				<changelog lang="en-gb">
					<change>Fixed typo in laguage file (Thanks Pinecamguy)</change>
				</changelog>
			</entry>
			<entry>
				<date>2007-12-30</date>
				<rev-version>1.0.3</rev-version>
				<changelog lang="en-gb">
					<change>Fixed error if question and answer are set but mod is switched off.</change>
				</changelog>
			</entry>
			<entry>
				<date>2007-10-28</date>
				<rev-version>1.0.2</rev-version>
				<changelog lang="en-gb">
					<change>Updated template edits, and better incorect answer message.</change>
				</changelog>
			</entry>
			<entry>
				<date>2007-10-11</date>
				<rev-version>1.0.1</rev-version>
				<changelog lang="en-gb">
					<change>Altered to fit to Mod Standards</change>
				</changelog>
			</entry>
			<entry>
				<date>2007-08-08 </date>
				<rev-version>1.0.0</rev-version>
				<changelog lang="en-gb">
					<change>Submitted to MoDDB</change>
				</changelog>
			</entry>
			<entry>
				<date>2007-07-29</date>
				<rev-version>0.0.4</rev-version>
				<changelog lang="en-gb">
					<change>Added second answer option</change>
				</changelog>
			</entry>
			<entry>
				<date>2007-07-27</date>
				<rev-version>0.0.3</rev-version>
				<changelog lang="en-gb">
					<change>Added switch to turn mod on or off in the ACP</change>
				</changelog>
			</entry>
			<entry>
				<date>2007-07-21</date>
				<rev-version>0.0.2</rev-version>
				<changelog lang="en-gb">
					<change>Fixed case insensitive when upercase letters used in the ACP</change>
				</changelog>
			</entry>
			<entry>
				<date>2007-07-20</date>
				<rev-version>0.0.1</rev-version>
				<changelog lang="en-gb">
					<change>First Release</change>
				</changelog>
			</entry>
		</history>
	</header>

	<action-group>
				<sql>INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('enable_abquestion', '0', '0');
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('abquestion','','0');
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('abanswer','','0');
INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('abanswer2','','0');</sql>

		<open src="includes/ucp/ucp_register.php">
			<edit>
				<find><![CDATA[			'tz'				=> request_var('tz', (float) $timezone),]]></find>
				<action type="after-add"><![CDATA[			'AB_Question'		=> strtolower(request_var('AB_Question', '')),]]></action>
			</edit>
			<edit>
				<find><![CDATA[				'email_confirm'		=> array('string', false, 6, 60),]]></find>
				<action type="after-add"><![CDATA[				'AB_Question'		  => array('string', !$config['abanswer']),]]></action>
			</edit>
			<edit>
				<find><![CDATA[				if ($data['email'] != $data['email_confirm'])
				{
					$error[] = $user->lang['NEW_EMAIL_ERROR'];
				}]]></find>
				<action type="after-add"><![CDATA[				if ($config['enable_abquestion'])
				{
					if ($data['AB_Question'] == '')
					{
						$error[] = $user->lang['AB_NO_ANSWER'];
					}
						else if ($data['AB_Question'] != strtolower($config['abanswer']) && $data['AB_Question'] != strtolower($config['abanswer2']))
						{
							$error[] = $user->lang['AB_QUESTION_ERROR'];
						}
				}]]></action>
			</edit>
			<edit>
				<find><![CDATA[			'EMAIL_CONFIRM'		=> $data['email_confirm'],]]></find>
				<action type="after-add"><![CDATA[			'AB_QUESTION'		=> $data['AB_Question'],]]></action>
			</edit>
			<edit>
				<find><![CDATA[			'L_PASSWORD_EXPLAIN'		=> sprintf($user->lang[$config['pass_complex'] . '_EXPLAIN'], $config['min_pass_chars'], $config['max_pass_chars']),]]></find>
				<action type="after-add"><![CDATA[			'L_AB_QUESTION'				=> $config['abquestion'],]]></action>
			</edit>
			<edit>
			  <find><![CDATA[			'S_CONFIRM_CODE'	=> ($config['enable_confirm']) ? true : false,]]></find>
			  <action type="after-add"><![CDATA[			'S_ABQ_CODE'	=> ($config['enable_abquestion'] == 1) ? true : false,]]></action>
			</edit>
		</open>
		<open src="includes/acp/acp_board.php">
			<edit>
			  <find><![CDATA[						'coppa_fax'			=> array('lang' => 'COPPA_FAX',			'validate' => 'string',	'type' => 'text:25:100', 'explain' => false),]]></find>
			  <action type="after-add"><![CDATA[						'legend4'			=> 'AB_QUESTION_MOD',
						'enable_abquestion'	=> array('lang' => 'ABQ_ENABLE',		'validate' => 'bool',	'type' => 'radio:yes_no', 'explain' => true),
						'abquestion'	=> array('lang' => 'AB_QUESTION',		'validate' => 'string',	'type' => 'text:40:100', 'explain' => true),
						'abanswer'	=> array('lang' => 'AB_ANSWER',			'validate' => 'string',	'type' => 'text:40:100', 'explain' => true),
						'abanswer2'	=> array('lang' => 'AB_ANSWER_2',		'validate' => 'string',	'type' => 'text:40:100', 'explain' => true),]]></action>
			</edit>
		</open>
		<open src="language/en/acp/board.php">
			<edit>
			  <find><![CDATA[	'ACP_REGISTER_SETTINGS_EXPLAIN'		=> 'Here you are able to define registration and profile related settings.',]]></find>
			  <action type="before-add"><![CDATA[	'AB_ANSWER'							=> 'Anti-Bot Answer',
	'AB_ANSWER_EXPLAIN'			=> 'This is the main answer for the question.',
	'AB_ANSWER_2'						=> 'Anti-Bot Answer Two',
	'AB_ANSWER_2_EXPLAIN'		=> 'Here you can add a second answer, a good idea if using a question that requires a numerical answer.',
	'AB_QUESTION_MOD'				=> 'Anti-Bot Question',
	'AB_QUESTION'						=> 'Anti-Bot Question',
	'AB_QUESTION_EXPLAIN'		=> 'This is the question a user must answer to register.',
	'ABQ_ENABLE'						=> 'Enable Anti-Bot Question',
	'ABQ_ENABLE_EXPLAIN'		=> 'Enable the Anti-Bot question for registering.',]]></action>
			</edit>
		</open>
		<open src="language/en/ucp.php">
			<edit>
			  <find><![CDATA[	'ACCOUNT_ACTIVE'				=> 'Your account has now been activated. Thank you for registering.',]]></find>
			  <action type="before-add"><![CDATA[	'AB_QUESTION_ERROR'				=> 'The Answer to the Anti-Bot Question you entered is incorrect, Please check your answer and try again.',
	'AB_NO_ANSWER'				=> 'No Anti-Bot Question Answer Entered.',]]></action>
			</edit>
		</open>
		<open src="language/en/common.php">
			<edit>
			  <find><![CDATA[	'ACCOUNT_ALREADY_ACTIVATED'		=> 'Your account has already been activated.',]]></find>
			  <action type="before-add"><![CDATA[	'AB_QUESTION_EXPLAIN'			=> 'For protection against spam, Answer the above question.',]]></action>
			</edit>
		</open>
		<open src="styles/prosilver/template/ucp_register.html">
			<edit>
			  <find><![CDATA[		<dl>
		<dt><label for="password_confirm">{L_CONFIRM_PASSWORD}:</label></dt>
		<dd><input type="password" tabindex="5" name="password_confirm" id="password_confirm" size="25" value="{PASSWORD_CONFIRM}" class="inputbox autowidth" title="{L_CONFIRM_PASSWORD}" /></dd>
	</dl>]]></find>
			  <action type="after-add"><![CDATA[	<!-- IF S_ABQ_CODE -->
	<dl>
		<dt><label for="AB_Question">{L_AB_QUESTION}:</label><br /><span>{L_AB_QUESTION_EXPLAIN}</span></dt>
		<dd><input type="text" tabindex="6" name="AB_Question" id="AB_Question" size="25" maxlength="255" value="{AB_QUESTION}" class="inputbox autowidth" title="{L_AB_QUESTION}" /></dd>
	</dl>
	<!-- ENDIF -->]]></action>
			</edit>
		</open>		
				<diy-instructions lang="en">To Install the style edits for subsilver2 or styles bassed on subsilver2, look inside the templates folder.
Purge the cache after install.

</diy-instructions>
	</action-group>
</mod>
