reCaptcha

#
reCaptcha
Здравствуйте! Не поможете разобраться с подключением reCaptcha? Что-то не работает она у меня
Вывожу в макете сайта форму и подключаю reCaptcha, как прописано здесь hostcms.ru/documentation/modules/core/captcha/
рекаптча показывается, но проверки не происходит,  а у спамеров осеннее обострение....
   <?php
        $oForm = Core_Entity::factory('Form', 4);  
        $Form_Controller_Show = new Form_Controller_Show($oForm);
         $sSecretKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // Указывается секретный ключ reCAPTCHA

       if (!is_null(Core_Array::getPost($oForm->button_name)))
          {
         $Form_Controller_Show
         ->values($_POST + $_FILES)
         // 0 - html, 1- plain text
         ->mailType(0)
         ->mailXsl(
            Core_Entity::factory('Xsl')->getByName('ПисьмоКураторуФормыВФорматеHTML')
         )
         ->mailFromFieldName('xxxxxxxxxxx@yandex.ru')
         ->process();

        // Отправляем письмо-подтверждение пользователю
        $Form_Controller_Show1 = clone $Form_Controller_Show;
        $sEmail = Core_Array::get($Form_Controller_Show1->values, 'email');
        if (Core_Valid::email($sEmail)){
            ob_start();
            $Form_Controller_Show1
                ->xsl(
                    Core_Entity::factory('Xsl')->getByName($Form_Controller_Show1->mailType == 0 ? 'ПисьмоПодтверждениеПользователюФормыВФорматеHTML' : 'ПисьмоПодтверждениеПользователюФормы')
                )
                ->show();
            $sMailText = ob_get_clean();
            if (mb_strpos($sMailText, 'ERROR TRUE') === FALSE){
                $subject = 'Вами была заполнена форма';// Тема письма отредактировать
                // При текстовой отправке нужно преобразовать HTML-сущности в символы
                $Form_Controller_Show->mailType == 1 && $sMailText = html_entity_decode(strip_tags($sMailText), ENT_COMPAT, 'UTF-8');
                $oCore_Mail = Core_Mail::instance()
                    ->to($sEmail)
                    ->from(EMAIL_TO)
                    ->subject($subject)
                    ->message(trim($sMailText))
                    ->contentType($Form_Controller_Show->mailType == 0 ? 'text/html' : 'text/plain')
                    ->header('X-HostCMS-Reason', 'Form');
                // Массив содержащий пути прикрепленных файлов и их имена
                $aForm_Fields = $oForm->Form_Fields->findAll();
                foreach ($aForm_Fields as $oForm_Field){
                    if ($oForm_Field->type == 2){// File
                        $value = Core_Array::get($Form_Controller_Show->values, $oForm_Field->name);
                        if (!is_null($value)){
                            if (is_array($value) && $value['size'] > 0){
                                $oForm_Fill_Fields = Core_Entity::factory('Form_Fill_Field');
                                $oForm_Fill_Fields->queryBuilder()
                                    ->where('form_field_id', '=', $oForm_Field->id)
                                    ->where('value', '=', $value['name'])
                                    ->limit(1);
                                $aForm_Fill_Fields = $oForm_Fill_Fields->findAll();
                                if (isset($aForm_Fill_Fields[0])){
                                    $oCore_Mail->attach(array(
                                        'filepath' => $aForm_Fill_Fields[0]->getPath(),
                                        'filename' => $value['name']
                                    ));
                                }
                            }
                        }
                    }
                }

                $oCore_Mail->send();
            }
        }
              }
                $Form_Controller_Show
                  ->xsl(
                  Core_Entity::factory('Xsl')->getByName('ОтобразитьФормуБыстрыйЗаказ')
                 )
                          ->addEntity(
                         Core::factory('Core_Xml_Entity')
                          ->name('site_key')->value('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') // Указываете ключ reCAPTCHA
                    )
                  ->show();
              ?>
iNikSite - дизайн и фронтенд разработка
#
Re: reCaptcha
Насколько вижу, вы и не делаете проверки.  Посмотрите,пожалуйста, внимательней пример кода в документации. Вот фрагмент с самой проверкой:


  if (!is_null(Core_Array::getPost($oForm->button_name)))
    {
        if (Core_Array::getPost('g-recaptcha-response'))
        {
            $sResponse = Core_Array::getPost('g-recaptcha-response');

            $sUrl = 'https://www.google.com/recaptcha/api/siteverify?secret=' . $sSecretKey . "&response=" . $sResponse;    
            $Core_Http = Core_Http::instance('curl')
            ->clear()
            ->method('POST')
            ->url($sUrl)
            ->execute();

            $aAnswer = json_decode($Core_Http->getBody(), TRUE);            
            
            if ($aAnswer['success'])
            {
..........
«Не выходи из комнаты, не совершай ошибку…»
Авторизация