You should realy make it so that people do not have to edit manifest.xml to get it working.
make some fields in the config table and an little admin area where people can enter their keys.
I have edited your manifest.xml to do just that, please check it if everything works ok.
I also found that you had entered maby your own private and publickey in the manifest. Not sure if they are used!
You should also make it translatable but that is up to you.
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<!--
/***********************************************************************
@author : Gordie Lachance
@copyright : (c) Copyright by Gordie Lachance
@license : http://www.gnu.org/licenses/gpl-2.0.html
************************************************************************/
-->
<extension engine="1.0">
<id>recaptcha</id>
<title>reCaptcha</title>
<version>0.2</version>
<description>This adds reCaptcha Spam Protection to your fluxBB installation, only when a guest registers or posts.</description>
<author>Gordie Lachance</author>
<minversion>1.3 Beta</minversion>
<maxtestedon>1.3 Beta</maxtestedon>
<note type="install">Don't forget to edit the reCaptcha's public and private keys in the config.php file.</note>
<note type="install">You can get it here : http://recaptcha.net/whyrecaptcha.html.</note>
<install>
<![CDATA[
if (defined('EXT_CUR_VERSION'))
{
// you can make special update code for each previous extension version
}
else
{ // it's a fresh install
$forum_db->query('INSERT INTO '.$forum_db->prefix.'config VALUES (\'recaptcha_privatekey\', \'\')') or error(__FILE__, __LINE__);
$forum_db->query('INSERT INTO '.$forum_db->prefix.'config VALUES (\'recaptcha_publickey\', \'\')') or error(__FILE__, __LINE__);
}
]]>
</install>
<uninstall>
<![CDATA[
$sql = array(
'DELETE' => 'config',
'WHERE' => 'conf_name IN (\'recaptcha_privatekey\', \'recaptcha_publickey\')'
);
$forum_db->query_build($sql) or error(__FILE__, __LINE__);
]]>
</uninstall>
<hooks>
<hook id="hd_head" priority="5">
<![CDATA[
if ($forum_user['is_guest'])
{
$forum_head['recaptchacss'] = '<link rel="stylesheet" type="text/css" media="screen" href="'.$ext_info['url'].'/recaptcha.css" />';
}
]]>
</hook>
<hook id="po_start" priority="5">
<![CDATA[
if ($forum_user['is_guest'])
{
if (file_exists($ext_info['path'].'/recaptchalib.php'))
require_once($ext_info['path'].'/recaptchalib.php');
if (file_exists($ext_info['path'].'/recaptchalib.php'))
require_once($ext_info['path'].'/config.php');
}
]]>
</hook>
<hook id="po_form_submitted" priority="5">
<![CDATA[
if ($forum_user['is_guest'])
{
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid)
$errors[] ="The <b>reCAPTCHA</b> wasn't entered correctly. Go back and try it again.";
}
]]>
</hook>
<hook id="po_req_info_fieldset_end" priority="5">
<![CDATA[
if ($forum_user['is_guest']) {
?>
<div class="frm-group">
<div class="sf-set recaptcha">
<div class="sf-box text required">
<label for="fld1"><span>reCaptcha: <em>(Are you human ?)</em></span></label><br/>
<span class="fld-input">
<?php
echo recaptcha_get_html($publickey);
?>
</span>
</div>
</div>
</div>
<?php
}
]]>
</hook>
<hook id="rg_start" priority="5">
<![CDATA[
if (file_exists($ext_info['path'].'/recaptchalib.php')) {
require_once($ext_info['path'].'/recaptchalib.php');
}
$publickey = $forum_config['recaptcha_publickey'];
$privatekey = $forum_config['recaptcha_privatekey'];
]]>
</hook>
<hook id="rg_register_form_submitted" priority="5">
<![CDATA[
$resp = recaptcha_check_answer ($privatekey,$_SERVER["REMOTE_ADDR"],$_POST["recaptcha_challenge_field"],$_POST["recaptcha_response_field"]);
echo $resp;
]]>
</hook>
<hook id="rg_register_end_validation" priority="5">
<![CDATA[
if (!$resp->is_valid) {
$errors[] ="The <b>reCAPTCHA</b> wasn't entered correctly. Go back and try it again.";
}
]]>
</hook>
<hook id="rg_register_group_end" priority="5">
<![CDATA[
?>
<div class="frm-group">
<div class="sf-set recaptcha">
<div class="sf-box text required">
<label for="fld1"><span>reCaptcha: <em>(Are you human ?)</em></span></label><br/>
<span class="fld-input">
<?php
echo recaptcha_get_html($publickey);
?>
</span>
</div>
</div>
</div>
<?php
]]>
</hook>
<hook id="aop_features_general_fieldset_end">
<![CDATA[
?>
<div class="content-head">
<h2 class="hn"><span>ReCaptcha</span></h2>
</div>
<fieldset class="sf-set group-item<?php echo ++$forum_page['group_count'] ?>">
<legend><span>ReCaptcha:</span></legend>
<div class="sf-box text">
<label for="fld<?php echo ++$forum_page['fld_count'] ?>"><span>Public key</span></label>
<span class="fld-input"><input size="25" type="text" id="fld<?php echo $forum_page['fld_count'] ?>" name="form[recaptcha_publickey]" value="<?php echo $forum_config['recaptcha_publickey'];?>" /></span>
</div>
<div class="sf-box text">
<label for="fld<?php echo ++$forum_page['fld_count'] ?>"><span>Private key</span></label>
<span class="fld-input"><input size="25" type="text" id="fld<?php echo $forum_page['fld_count'] ?>" name="form[recaptcha_privatekey]" value="<?php echo $forum_config['recaptcha_privatekey'];?>" /></span>
</div>
</fieldset>
<?php
]]>
</hook>
<hook id="aop_features_validation">
<![CDATA[
if (!isset($form['recaptcha_publickey']) || empty($form['recaptcha_publickey']))
$form['recaptcha_publickey'] = '';
if (!isset($form['recaptcha_privatekey']) || empty($form['recaptcha_privatekey']))
$form['recaptcha_privatekey'] = '';
]]>
</hook>
<hook id="aop_pre_update_configuration">
<![CDATA[
if (isset($form['recaptcha_publickey']))
{
if ($form['recaptcha_publickey'] != $forum_config['recaptcha_publickey'])
$forum_db->query('UPDATE '.$forum_db->prefix.'config SET conf_value = \''.$forum_db->escape($form['recaptcha_publickey']).'\' WHERE conf_name = \'recaptcha_publickey\'', true) or error(__FILE__, __LINE__);
}
if (isset($form['recaptcha_privatekey']))
{
if ($form['recaptcha_privatekey'] != $forum_config['recaptcha_privatekey'])
$forum_db->query('UPDATE '.$forum_db->prefix.'config SET conf_value = \''.$forum_db->escape($form['recaptcha_privatekey']).'\' WHERE conf_name = \'recaptcha_privatekey\'', true) or error(__FILE__, __LINE__);
}
]]>
</hook>
</hooks>
</extension>
Last edited by kierownik (2009-02-25 16:18:34)