Наверное это не фича, но думаю может кому пригодится. Пример использования капчи
<?
include_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/classes/general/captcha.php");
$cpt = new CCaptcha();
$cpt->SetCode();
?>
<form action="" method="POST">
<table>
<tr>
<td colspan="2"><br>
<font class="forumbodytext">
<br>text1 <br><br>
<?
include_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/classes/general/captcha.php");
$cpt = new CCaptcha();
$captchaPass = COption::GetOptionString("main", "captcha_password", "");
if (strlen($captchaPass) <= 0)
{
$captchaPass = randString(10);
COption::SetOptionString("main", "captcha_password", $captchaPass);
}
$cpt->SetCodeCrypt($captchaPass);
?>
<input type="hidden" name="captcha_code" value="<?= htmlspecialchars($cpt->GetCodeCrypt()) ?>">
<img src="/bitrix/tools/captcha.php?captcha_code=<?= htmlspecialchars($cpt->GetCodeCrypt()) ?>"><br><br>
text2 <input type="text" size="10" name="captcha_word" class="inputtext">
</font>
</td>
</tr>
</table>
<input type='submit'>
</form>
<?
$captcha_code = $_POST["captcha_code"];
$captcha_word = $_POST["captcha_word"];
$cpt = new CCaptcha();
if (strlen($captcha_code) > 0)
{
$captchaPass = COption::GetOptionString("main", "captcha_password", "");
if (!$cpt->CheckCodeCrypt($captcha_word, $captcha_code, $captchaPass))
$strErrorMessage .= "error2";
}
else
{
if (!$cpt->CheckCode($captcha_word, $captcha_sid))
$strErrorMessage .= "error2";
}
echo $strErrorMessage;
?>
|