. 2.

: 23.01.2017 11:45:23 | : 05.08.2017 21:56:42 | : 2133

, . « / (bitrix:iblock.element.add.form)» (bitrix:news.list) . , . "OnAfterIBlockElementAdd". "OnBeforeIBlockElementAdd" . , .

, , – CAPTCHA (Completely Automated Public Turing test to tell Computers and Humans Apart). CAPTCHA , .

1.jpg

. . . . , . CAPTCHA : ; ; ; ; . , . , , .

. . (, , ), . , . , .

, . , SPAM. , .

2.jpg

.

3.jpg

. .

4.jpg

: "OnBeforeIBlockElementAdd". , . , , .

template.php. p, :

<p<?if (intval($propertyID) > 0&&$arResult["PROPERTY_LIST_FULL"][$propertyID]["CODE"] == "SPAM"):?>
 style="display: none"
<?endif?>>

, SPAM, .

event_handlers.php (/bitrix/php_interface/include). "OnAfterIBlockElementAdd" . :

AddEventHandler("iblock", "OnBeforeIBlockElementAdd", Array("CGuestbook", "OnBeforeIBlockElementAddHandler"));
    CGuestbook   OnBeforeIBlockElementAddHandler.    :

function OnBeforeIBlockElementAddHandler(&$arFields) { if($arFields["IBLOCK_ID"] == 3) { $db_props = CIBlockElement::GetProperty(3, $arFields["ID"], array("sort" => "asc"), Array("CODE"=>"SPAM")); if($ar_props = $db_props->Fetch()) { if(strlen($arFields['PROPERTY_VALUES'][$ar_props['ID']]) > 0) { global $APPLICATION; $APPLICATION->throwException("!"); return false; } } } }

, SPAM , $APPLICATION->throwException("!") .

. event_handlers.php , , -.