index : flyspray | |
Archlinux32 customized Flyspray installation | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | includes/class.recaptcha.php | 33 |
diff --git a/includes/class.recaptcha.php b/includes/class.recaptcha.php new file mode 100644 index 0000000..d998d43 --- /dev/null +++ b/includes/class.recaptcha.php @@ -0,0 +1,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 |