Implementing PlusCaptcha for PHP

Implementing PlusCaptcha for PHP

Wait a minute… I thought that PlusCaptcha was for WordPress only! Absolutely not! You can implement PlusCaptcha on ANY PHP Site.

Steps:

  1. Visit PlusCaptcha.com and Click REGISTER FREE. Once that process is completed, log into your account.
  2. On that next screen, choose the size and difficulty of the PlusCaptcha, and colors you wish to use. They are all interrelated using a sophisticated algorithm. Then, hit SAVE.
  3. Then you are taken to a screen, where you have two rows. Click the box in the top row, which specified how you want to pass the UUID to your PlusCaptcha (UUID was on the previous screen).
  4. Once you select the box at the top, choose the method from the bottom row. It will load the sample code for you to use, complete with commented instructions.
PHP Method Selection Chart
Click me for a much better view. : )

For example, I chose SESSION PHP, and fgets() & fopen(). Here is the sample code:

Place this code where your visitors will be view the captcha. Remember that you must be within the label “form” and receiving the UUID (uidus) in the other script.

<?php

session_start();

$keyC = @fgets(@fopen(‘http://captchakey.biz/’, ‘r’), 4096);

if ($keyC == ‘1’){
$Hostausar = ‘syshtml5.pluscaptcha.com’;
$h = ‘c’;
}else{
$Hostausar = array(‘syshtml5.pluscaptcha.com’,’syshtml5.pluscaptcha.com’,’syshtml5.pluscaptcha.com’);
$Aleatorio = array_rand($Hostausar,1);
$Hostausar = $Hostausar[$Aleatorio];
$h = $Aleatorio;
}

?>

<div style="width:205px; height: auto;">

<?php $c = ‘none’; // BG color of IFRAME Ex: ffa3c8, ffd5a3, none ?>
<?php $uidus = @fgets(@fopen(‘http://’.$Hostausar.’/g?id=a275′.’&c=’.$c, ‘r’), 4096); ?>

<iframe src=”http://<?php echo $Hostausar; ?>/i?iduso=<?php echo $uidus; ?>
&h=<?php echo $_SERVER['HTTP_HOST']; ?>” width=”205″ height=”115″ scrolling=”no” frameborder=”0″></iframe>

<?php $_SESSION[“uidus”] = $uidus.’///’.$h; ?>

</div>

This code will help you verify the captcha. You can adapt it to your liking. PlusCaptcha responds with “1” if the captcha is answered correctly – otherwise it returns “0”.

<?php

session_start();

$limpiado = strip_tags(stripslashes(htmlentities(addslashes(trim($_SESSION[“uidus”])))));
$_SESSION[“uidus”] == ”;
$datosent = explode(“///”,$limpiado);

if($datosent[0] != ”){
if($datosent[1] == ‘c’){
$host = ‘syshtml5.pluscaptcha.com’;
}else{
$HostReg = array(‘syshtml5.pluscaptcha.com’,’syshtml5.pluscaptcha.com’,’syshtml5.pluscaptcha.com’);
$host = $HostReg[$datosent[1]];
}

$r = @fgets(@fopen(‘http://’.$host.’/r?iduso=’.$datosent[0]. ”, ‘r’), 4096);

if($r == ‘-2’){ echo ‘PlusCaptcha system error.’;
}elseif($r == ‘-1’){ echo ‘UUID non-existent or not received. >(form input named: uidus)’;
}elseif($r == ‘0’){ echo ‘Not properly lined up.’;
}elseif($r == ‘1’){ echo ‘PlusCaptcha challenge met.’;
}
}

?>

 

We're happy to share this resource that we found. The content displayed on this page is property of it's original author and/or their organization.

Leave a Reply