RECAPTCHA.

 RECAPTCHA.


, :

1 -- http://www.google.com/recaptcha/whyrecaptcha

recaptcha Public Key Private key

2 -- signup.php

* :


$signup_secure = $_POST['signup_secure'];
$code_found = false;
if( $signup_secure && @$_SESSION['code'] == $signup_secure )
$code_found = true;

if( !empty($_SESSION['codes']) && is_array($_SESSION['codes']) )
{
foreach( $_SESSION['codes'] as $index => $code_info )
{
if( $code_info['code'] == $signup_secure )
{
$code_found = true;
unset($_SESSION['codes'][$index]);
}
}
}


* :

if ( $_POST["recaptcha_challenge_field"] )
{
if ( $_COOKIE[recaptcha_cooked] == $_POST["recaptcha_challenge_field"] )
{
setcookie("recaptcha_cooked", $_POST["recaptcha_challenge_field"],time() - 24*60*60,'/');
$code_found = true;
}
else
{
require_once('recaptchalib.php');
$privatekey = "[B]__PRIVATE_KEY[/B]";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);

if (!$resp->is_valid)
$code_found = false;
else
{
setcookie("recaptcha_cooked", $_POST["recaptcha_challenge_field"],0,'/');
$code_found = true;
}
}
}
else
{
$code_found = true;
}



* :

 // ASSIGN VARIABLES AND INCLUDE FOOTER


*

require_once('recaptchalib.php');
$publickey = "[B]__PUBLIC_KEY[/B]"; //
$smarty->assign('recaptcha',recaptcha_get_html($publickey));
$smarty->assign('recaptcha_challenge_field', $_POST[recaptcha_challenge_field]);
$smarty->assign('recaptcha_response_field', $_POST[recaptcha_response_field]);


3 -- templates/signup.tpl

* :
<input type='hidden' name='signup_cat' value='{$signup_cat}'>


*
<input type='hidden' name='recaptcha_challenge_field' value='{$recaptcha_challenge_field}'>
<input type='hidden' name='recaptcha_response_field' value='{$recaptcha_response_field}'>




* :
<td><input type='text' name='signup_secure' class='text' size='6' maxlength='10'>&nbsp;</td>
<td>
<table cellpadding='0' cellspacing='0'>
<tr>
<td align='center'>
<img src='./images/secure.php' id='secure_image' border='0' height='20' width='67' class='signup_code'><br />
<a href="javascript:void(0);" onclick="$('secure_image').src = './images/secure.php?' + (new Date()).getTime();">{lang_print id=975}</a>
</td>
<td>{capture assign=tip}{lang_print id=691}{/capture}<img src='./images/icons/tip.gif' border='0' class='Tips1' title='{$tip|escape:quotes}'></td>
</tr>
</table>
</td>



* :
<td height=100>
{$recaptcha}
</td>



4 -- recaptchalib.php recaptcha_mod.rar [4,36 Kb] (c: 114) ( )

! , ., - , Google`

!

Talk.SocEngine.Ru

: