• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/captcha.php
  • Класс: CCaptcha
  • Вызов: CCaptcha::CheckCode
function CheckCode($userCode, $sid, $bUpperCode = true)
{
	if (!defined("CAPTCHA_COMPATIBILITY"))
		return CCaptcha::CheckCaptchaCode($userCode, $sid, $bUpperCode);

	if (!is_array(BitrixMainApplication::getInstance()->getSession()["CAPTCHA_CODE"]) || empty(BitrixMainApplication::getInstance()->getSession()["CAPTCHA_CODE"]))
		return false;

	if (!array_key_exists($sid, BitrixMainApplication::getInstance()->getSession()["CAPTCHA_CODE"]))
		return false;

	if ($bUpperCode)
		$userCode = mb_strtoupper($userCode);

	if (BitrixMainApplication::getInstance()->getSession()["CAPTCHA_CODE"][$sid] != $userCode)
		return false;

	unset(BitrixMainApplication::getInstance()->getSession()["CAPTCHA_CODE"][$sid]);

	return true;
}