This mod will replace 4images default captcha graphic with more advanced
reCAPTCHAStep 1Register at
http://recaptcha.netOnce registered, go to "My account" -> "My sites" and add each domain where you want use reCAPTCHA.
Then go to "My account" -> "My sites" and click on each domain you've added, it will show you Public Key and Private Key, write them down, you'll need them in next step.
Download
PHP plugin, extract it and upload
recaptchalib.php into 4images
includes/ folder
Step 2Open
global.phpFind:
$captcha_filter_bg = 1;
Insert
BELOW:
$captcha_recaptcha = 1; //0 = disable; 1 = enable with auto domain select; "yourdomain" = for one specific domain only, this domain must be specified in $recaptcha_domains below
//$captcha_recaptcha = "yourdomain2"; //use only reCAPTCHA keys for yourdomain2
$recaptcha_domains['yourdomain1'] = array("public key for yourdomain1", "private key for yourdomain1");
/*//to add more then one domain:
$recaptcha_domains['example.com'] = array("public key for example.com", "private key for example.com");
$recaptcha_domains['4homepages.de'] = array("asdfasdfasdf", "a98sd7as9df7as");
$recaptcha_domains['google.com'] = array("23kj423h42k", "8fas9d8a9sdf9a");
*/
if ($captcha_enable && $captcha_recaptcha
&& (isset($recaptcha_domains[$captcha_recaptcha])
|| isset($recaptcha_domains[strtolower($_SERVER["HTTP_HOST"])])))
{
$captcha_recaptcha = (isset($recaptcha_domains[$captcha_recaptcha]))
? $recaptcha_domains[$captcha_recaptcha]
: $recaptcha_domains[strtolower($_SERVER["HTTP_HOST"])];
}
else
{
$captcha_recaptcha = 0;
}
In the code you just inserted update
$recaptcha_domains['yourdomain1'] = array("public key for yourdomain1", "private key for yourdomain1"); with the correct data,
yourdomain1 replace with the domain name of your website.
public key for yourdomain1 and
private key for yourdomain1 with the public and private keys from Step 1.
You can add as many domains as you wish.
Step 3Open
includes/captcha_utils.phpFind:
$captcha_enable = $captcha_enable && function_exists("imagecreatetruecolor") && function_exists("imagecopyresampled");
Replace it with:
function recaptcha_image()
{
global $captcha_recaptcha;
if ($captcha_recaptcha)
{
require_once(ROOT_PATH . 'includes/recaptchalib.php');
return recaptcha_get_html($captcha_recaptcha[0]);
}
}
if (!$captcha_recaptcha)
{
$captcha_enable = $captcha_enable && function_exists("imagecreatetruecolor") && function_exists("imagecopyresampled");
}
Step 3.1Find:
$sess_code = trim($site_sess->get_session_var('captcha'));
Insert
ABOVE:
global $captcha_recaptcha, $HTTP_POST_VARS;
if ($captcha_recaptcha)
{
require_once(ROOT_PATH . 'includes/recaptchalib.php');
$resp = recaptcha_check_answer ($captcha_recaptcha[1],
$_SERVER["REMOTE_ADDR"],
$HTTP_POST_VARS["recaptcha_challenge_field"],
$HTTP_POST_VARS["recaptcha_response_field"]);
if ($resp->is_valid)
return true;
}
Step 4Open
includes/page_header.phpFind:
"url_captcha_image" => $site_sess->url(ROOT_PATH."captcha.php"),
Insert
BELOW::
"recaptcha" => ($captcha_recaptcha) ? recaptcha_image() : "",
"recaptcha_public" => @$captcha_recaptcha[0],
"recaptcha_private" => @$captcha_recaptcha[1],
Step 5In templates
comment_form.html,
member_uploadform.html,
postcard_preview.html,
register_form.html and in any others where you were using captcha, use this tag:
{recaptcha}If you wish to customize reCAPTCHA view to match your site theme or whatever, you probably will need do it via javascript (don't ask me how, I don't know), in that case you might need public or private key, for that you can use these tags:
{recaptcha_public}{recaptcha_private}P.S.
You can use both 4images built-in captcha and reCAPTCHA at the same time if you wish.