Advertisement
Guest User

Untitled

a guest
Aug 30th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1.  
  2. function isCaptchaValid() {
  3. try {
  4.  
  5. $url = 'https://www.google.com/recaptcha/api/siteverify';
  6. $data = [
  7. 'secret' => PRESS_AREA_RECAPTCHA_SECRET,
  8. 'response' => $_POST['g-recaptcha-response'],
  9. 'remoteip' => $_SERVER['REMOTE_ADDR']
  10. ];
  11.  
  12. $options = [
  13. 'http' => [
  14. 'header' => "Content-type: application/x-www-form-urlencoded\r\n",
  15. 'method' => 'POST',
  16. 'content' => http_build_query($data)
  17. ]
  18. ];
  19.  
  20. $context = stream_context_create($options);
  21. $result = file_get_contents($url, false, $context);
  22. return json_decode($result)->success;
  23. }
  24. catch (Exception $e) {
  25. return null;
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement