blob: d998d4343bda44a17f80d81c20efc98a0155cec3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
<?php
/* quick solution
* https://developers.google.com/recaptcha/docs/verify
*/
class recaptcha
{
function verify(){
global $fs;
$url = 'https://www.google.com/recaptcha/api/siteverify';
$data = array(
'secret' => $fs->prefs['captcha_recaptcha_secret'],
'response' => $_POST['g-recaptcha-response']
);
$options = array(
'http' => array (
'method' => 'POST',
/* for php5.3, default enctype for http_build_query() was added with php5.4, http://php.net/manual/en/function.http-build-query.php */
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => http_build_query($data, '', '&')
)
);
$context = stream_context_create($options);
$verify = file_get_contents($url, false, $context);
$captcha_success=json_decode($verify);
return $captcha_success->success;
}
} # end class
|