<?php /* Callback resource for Confident CAPTCHA AJAX calls */ require_once 'config.php'; require_once 'confidentcaptcha/ccap_api.php'; require_once 'confidentcaptcha/ccap_persist.php'; require_once 'confidentcaptcha/ccap_policy_factory.php'; session_start(); $ccap_api = new CCAP_API($ccap_api_settings['customer_id'], $ccap_api_settings['site_id'], $ccap_api_settings['api_username'], $ccap_api_settings['api_password'], $ccap_server_url); $ccap_persist = new CCAP_PersistSession(); $ccap_policy = CCAP_PolicyFactory::restore($ccap_persist, $ccap_api, $ccap_default_policy); /* Generate callback response */ function captcha_callback($ccap_policy) { // Peform any setup needed at the start of a page w/ CAPTCHA $start_error = $ccap_policy->start_captcha_page(); if ($start_error !== NULL) { return "Error starting callback page: {$start_error}"; } $endpoint = isset($_REQUEST['endpoint']) ? $_REQUEST['endpoint'] : ''; return $ccap_policy->callback($endpoint, $_REQUEST); } if ($ccap_policy) { $ret = captcha_callback($ccap_policy); $content = $ret[0]; $headers = $ret[1]; foreach ($headers as $h) { header($h); } echo $content;
the form to work even when the CAPTCHA doesn\'t.', 'CCAP_ProductionFailClosed' => 'When CAPTCHA creation fails, the form will fail. Useful for account creation forms, where you don\'t want the form to proceed without a CAPTCHA check.', 'CCAP_DevelopmentPolicy' => 'Records all calls made to the CAPTCHA API server. Useful for initial form development and troubleshooting, but will leak secrets if used in production.'); if (empty($policy)) { $used_policy = $ccap_default_policy; } elseif (in_array($policy, array_keys($valid_policies))) { $used_policy = $policy; } else { $used_policy = $ccap_default_policy; if (!in_array($used_policy, array_keys($valid_policies))) { die("Bad default policy '{$ccap_default_policy}'"); } } $ccap_policy = CCAP_PolicyFactory::create($used_policy, $ccap_api, $ccap_persist); function option_get($key) { if (isset($_REQUEST["ccap_{$key}"])) { return $_REQUEST["ccap_{$key}"]; } elseif (isset($ccap_options[$key])) { return $ccap_options[$key]; } else { return NULL; } } // Load CAPTCHA parameters $display_style = option_get('display_style'); $include_audio = option_get('include_audio'); $height = option_get('height'); $width = option_get('width');