如何在TYPO 3服务器端验证中实施?

时间:2019-05-20 15:05:31

标签: validation typo3 server-side

我正在使用TYPO 3版本6.2.14。在此版本中,我使用Formhandler插件生成联系表。我已经实现了Google的自定义代码 reCAPTCHA V2显式渲染。现在,生成了reCAPTCHA代码。但是它没有执行服务器端验证。我还已经在fileadmin / templates / fromhandler / serversidevalidation.php中创建了用于服务器端验证的php文件

if(isset($_POST['g-recaptcha-response']))
      {
        $captcha=$_POST['g-recaptcha-response'];
       }
        if(!$captcha){
          echo '<h2>Please check the the captcha form.</h2>';
          exit;
        }
        $secretKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
        $ip = $_SERVER['REMOTE_ADDR'];
        $response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretKey."&response=".$captcha."&remoteip=".$ip);
        $responseKeys = json_decode($response,true);
        echo $responseKeys;
        if(intval($responseKeys["success"]) !== 1) {
          echo '<h2>You are spammer ! Get the bot out</h2>';
        } else {
          echo '<h2>Thanks for posting </h2>';
        }

但是,这个简单的php文件不包含在TypoScript中。如何使用formhandler扩展实现服务器端验证。由于兼容性问题,我不想使用扩展名。有人可以引导我吗?

0 个答案:

没有答案