Clickcha settings saved.
";
}
else if(isset($_POST['clickcha-action-getkeys'])) {
$response=file_get_contents('http://api.clickcha.com/getkeys?url='.urlencode($_POST['clickcha-url']).'&email='.urlencode($_POST['clickcha-email']));
$result = get_submatch('|(.+)|i', $response);
if(!empty($result)) {
$public_key = get_submatch('|([\w\-]+)|', $result);
$private_key = get_submatch('|([\w\-]+)|', $result);
if(empty($public_key) || empty($private_key)) {
echo "Unable to get Clickcha API keys ($result).
";
} else {
bb_update_option('clickcha-public-key',$public_key);
bb_update_option('clickcha-private-key',$private_key);
echo "Clickcha API keys successfully saved. Clickcha is now active!
";
}
}
else {
echo "Unable to get Clickcha API keys. Please contact developer@clickcha.com if this problem persists.
$response
";
}
}
$public_key = bb_get_option('clickcha-public-key');
$private_key = bb_get_option('clickcha-private-key');
if(empty($public_key) || empty($private_key)) {
echo "Clickcha is not yet active. Enter Clickcha API keys below to make it work.
";
}
?>
Clickcha is not yet active. Please enter Clickcha API keys in settings.
";
}
else {
?>
Clickcha - The One-click Captcha
go back and try again.");
}
$public_key = bb_get_option('clickcha-public-key');
$private_key = bb_get_option('clickcha-private-key');
if(empty($public_key) || empty($private_key)) {
echo "Clickcha is not yet active. Please enter Clickcha API keys in settings.
";
}
else {
$response=file_get_contents('http://api.clickcha.com/verify?key='.$public_key.'&token='.$_POST['clickcha_token'].'&private_key='.$private_key.'&x='.$_POST['clickcha_x'].'&y='.$_POST['clickcha_y']);
$result = get_submatch('|(\w+)|', $response);
if(!empty($result)) {
if($result!='PASSED') {
bb_die("Clickcha verification failed ($result). Please go back and try again.");
}
}
else {
bb_die('Unable to verify Clickcha. Please contact the webmaster if this problem persists.'.$result);
}
}
}
}
function clickcha_verification_required() {
if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST) && !bb_current_user_can('moderate')) {
return preg_match('/\b(?:bb-post|register)\.php\b/i',$_SERVER['PHP_SELF']);
}
return false;
}
function get_submatch($pattern, $subject, $submatch=1) {
if(preg_match($pattern, $subject, $match)) {
return $match[$submatch];
}
}
?>