Funcaptcha integration

kalle801

Member
Hello.
I want to integrate the Funcaptcha in my Toplist but im lost with this:

PHP
In your PHP code where you are validating your form, you will need to pass your private key and the value of “fc-token” to the FunCaptcha API server either via POST or GET:


Code:
$private_key="_YOUR_PRIVATE_KEY_";
$session_token=$_POST["fc-token"];
$fc_api_url="https://funcaptcha.com/fc/v/?private_key=".$private_key."&session_token=".$session_token."&simple_mode=1";
if(file_get_contents($fc_api_url)==="1"){
//valid, the user has solved FunCaptcha correctly
}else{
//invalid, the user has failed FunCaptcha
}
Wehre do i have to place this pls?


This is an Example:
Code:
<?php

if ($_POST) {

    $private_key = "_YOUR_PRIVATE_KEY_";

    $session_token = $_POST["fc-token"];

    $fc_api_url = "https://funcaptcha.com/fc/v/?private_key=".$private_key."&session_token=".$session_token."&simple_mode=1";

    if (file_get_contents($fc_api_url) === "1") {

        //valid, the user has solved FunCaptcha correctly

    } else {

        //invalid, the user has failed FunCaptcha

    }

}

?><html>

<head>

<script src="https://funcaptcha.com/fc/api/" async defer></script>

</head>

    <body>

        <form method="post">

            <div id="funcaptcha" data-pkey="_YOUR_PUBLIC_KEY_"></div>

            <input type="submit">

        </form>

    </body>

</html>
 
Last edited:

Basti

Administrator
Staff member
You would need a plugin and the needed hook files would be...

1) classes_check_input.php

PHP:
$error_funcaptcha = 0;

// Only valid on join, not edit
if ($type == 'join') {

    $private_key = "_YOUR_PRIVATE_KEY_";

    $session_token = $_POST["fc-token"];

    $fc_api_url = "https://funcaptcha.com/fc/v/?private_key=".$private_key."&session_token=".$session_token."&simple_mode=1";

    if (file_get_contents($fc_api_url) === "1") {

        //valid, the user has solved FunCaptcha correctly
        // No message needed here

    } else {

        //invalid, the user has failed FunCaptcha

        // Tell the script, we want to display error
       $error_funcaptcha = 1;
       $error_plugin_vars .= "|| {$error_funcaptcha}";

    }

}

2) classes_check_input_style.php

PHP:
// Here we set the error styling and text if the other file said error = 1
if ($error_funcaptcha) {
    $TMPL['error_style_funcaptcha'] = 'join_edit_error has-error';
    $TMPL['error_funcaptcha'] = "<div class=\"text-danger\">YOUR ERROR TEXT HERE</div>";
}
3) {$error_funcaptcha} below your captcha


Not tested, but should be all
 
Top