39 define(
'RECAPTCHA_API_SERVER',
"http://www.google.com/recaptcha/api");
40 define(
'RECAPTCHA_API_SECURE_SERVER',
"https://www.google.com/recaptcha/api");
41 define(
'RECAPTCHA_VERIFY_SERVER',
"www.google.com");
52 foreach ($data as $key => $value) {
53 $req .= $key .
'=' . urlencode(stripslashes($value)) .
'&';
57 $req = substr($req, 0, strlen($req) - 1);
76 $http_request =
"POST $path HTTP/1.0\r\n";
77 $http_request .=
"Host: $host\r\n";
78 $http_request .=
"Content-Type: application/x-www-form-urlencoded;\r\n";
79 $http_request .=
"Content-Length: " . strlen($req) .
"\r\n";
80 $http_request .=
"User-Agent: reCAPTCHA/PHP\r\n";
81 $http_request .=
"\r\n";
82 $http_request .= $req;
85 if (
false == ($fs = @fsockopen($host, $port, $errno, $errstr, 10))) {
86 die (
'Could not open socket');
89 fwrite($fs, $http_request);
113 if ($pubkey == null || $pubkey ==
'') {
114 die (
"To use reCAPTCHA you must get an API key from <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>");
125 $errorpart =
"&error=" .
$error;
127 return '<script type="text/javascript" src="' . $server .
'/challenge?k=' . $pubkey . $errorpart .
'"></script>
130 <iframe src="' . $server .
'/noscript?k=' . $pubkey . $errorpart .
'" height="300" width="500" frameborder="0"></iframe><br/>
131 <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
132 <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
158 if ($privkey == null || $privkey ==
'') {
159 die (
"To use reCAPTCHA you must get an API key from <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>");
162 if ($remoteip == null || $remoteip ==
'') {
163 die (
"For security reasons, you must pass the remote ip to reCAPTCHA");
167 if ($challenge == null || strlen($challenge) == 0 ||
$response == null || strlen(
$response) == 0) {
169 $recaptcha_response->is_valid =
false;
170 $recaptcha_response->error =
'incorrect-captcha-sol';
171 return $recaptcha_response;
175 "/recaptcha/api/verify",
177 'privatekey' => $privkey,
178 'remoteip' => $remoteip,
179 'challenge' => $challenge,
186 if (trim($answers [0]) ==
'true') {
187 $recaptcha_response->is_valid =
true;
189 $recaptcha_response->is_valid =
false;
190 $recaptcha_response->error = $answers [1];
192 return $recaptcha_response;
207 array(
'domains' => $domain,
'app' => $appname));
217 $numpad = $block_size - (strlen($val) % $block_size);
218 return str_pad($val, strlen($val) + $numpad, chr($numpad));
230 if (!function_exists(
"mcrypt_encrypt")) {
231 die (
"To use reCAPTCHA Mailhide, you need to have the mcrypt php module installed.");
233 $mode = MCRYPT_MODE_CBC;
234 $enc = MCRYPT_RIJNDAEL_128;
236 return mcrypt_encrypt($enc, $ky, $val, $mode,
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");
245 return strtr(base64_encode($x),
'+/',
'-_');
258 if ($pubkey ==
'' || $pubkey == null || $privkey ==
"" || $privkey == null) {
259 die (
"To use reCAPTCHA Mailhide, you have to sign up for a public and private key, " .
"you can do so at <a href='http://www.google.com/recaptcha/mailhide/apikey'>http://www.google.com/recaptcha/mailhide/apikey</a>");
262 $ky = pack(
'H*', $privkey);
278 $arr = preg_split(
"/@/",
$email);
280 if (strlen($arr[0]) <= 4) {
281 $arr[0] = substr($arr[0], 0, 1);
283 if (strlen($arr[0]) <= 6) {
284 $arr[0] = substr($arr[0], 0, 3);
286 $arr[0] = substr($arr[0], 0, 4);
308 return htmlentities($emailparts[0]) .
"<a href='" . htmlentities(
$url) .
"' onclick=\"window.open('" . htmlentities(
$url) .
"', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;\" title=\"Reveal this e-mail address\">...</a>@" . htmlentities($emailparts [1]);
if(empty($settings['ROOT_PATH'])) elseif(empty($settings['DB_PARAMETERS'])) $error
const RECAPTCHA_API_SECURE_SERVER
const RECAPTCHA_VERIFY_SERVER
_recaptcha_aes_encrypt($val, $ky)
_recaptcha_http_post($host, $path, $data, $port=80)
_recaptcha_qsencode($data)
_recaptcha_mailhide_email_parts($email)
recaptcha_mailhide_html($pubkey, $privkey, $email)
recaptcha_mailhide_url($pubkey, $privkey, $email)
const RECAPTCHA_API_SERVER
if($xoops->isUser()&&$isAdmin) $response
recaptcha_get_html($pubkey, $error=null, $use_ssl=false)
recaptcha_check_answer($privkey, $remoteip, $challenge, $response, $extra_params=array())
recaptcha_get_signup_url($domain=null, $appname=null)
_recaptcha_mailhide_urlbase64($x)