Last active
July 16, 2024 17:06
-
Star
(103)
You must be signed in to star a gist -
Fork
(20)
You must be signed in to fork a gist
-
-
Save jonathanstark/dfb30bdfb522318fc819 to your computer and use it in GitHub Desktop.
Revisions
-
jonathanstark renamed this gist
Apr 1, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
jonathanstark created this gist
Apr 1, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ # # Verify captcha $post_data = http_build_query( array( 'secret' => CAPTCHA_SECRET, 'response' => $_POST['g-recaptcha-response'], 'remoteip' => $_SERVER['REMOTE_ADDR'] ) ); $opts = array('http' => array( 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $post_data ) ); $context = stream_context_create($opts); $response = file_get_contents('https://www.google.com/recaptcha/api/siteverify', false, $context); $result = json_decode($response); if (!$result->success) { throw new Exception('Gah! CAPTCHA verification failed. Please email me directly at: jstark at jonathanstark dot com', 1); }