Created
March 29, 2022 13:01
-
-
Save LouisHrg/5216ac4b2a413b20c390dbaa9c275c77 to your computer and use it in GitHub Desktop.
Correction reCaptcha ESGI 3IW Secu
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 characters
| <html> | |
| <head> | |
| <meta http-equiv="content-type" content="text/html; charset=UTF-8"> | |
| <script src="https://www.google.com/recaptcha/api.js" async defer></script> | |
| </head> | |
| <body> | |
| <div> | |
| <form method="POST" id="demo-form" action="/save"> | |
| <input type="text" name="firstname" placeholder="Your firstname" autocomplete="off"> | |
| <div class="g-recaptcha" data-sitekey="{{ $token }}"></div> | |
| <button type="submit"> Valider </button> | |
| </form> | |
| </div> | |
| </body> | |
| </html> |
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 characters
| <?php | |
| require_once __DIR__ . "/vendor/autoload.php"; | |
| require_once __DIR__ . "/helpers/Tooling.php"; | |
| $app = new Leaf\App; | |
| $blade = new Leaf\Blade; | |
| $blade->configure("views", "views/cache"); | |
| $dotenv = Dotenv\Dotenv::createImmutable(__DIR__); | |
| $dotenv->load(); | |
| $app->get("/", function() use($app, $blade) { | |
| echo $blade->make('index', [ | |
| 'token' => $_ENV['V2_SECET'] | |
| ])->render(); | |
| }); | |
| $app->post("/save", function() use($app, $blade) { | |
| $recaptcha_response = $app->request()->get('g-recaptcha-response'); | |
| $client = new GuzzleHttp\Client(); | |
| $res = $client->request('POST', 'https://www.google.com/recaptcha/api/siteverify', [ | |
| 'form_params' => [ | |
| 'response' => $recaptcha_response, | |
| 'secret' => $_ENV['BACK_V2_SECRET'], | |
| ], | |
| ]); | |
| $body = json_decode($res->getBody()); | |
| if($body->success){ | |
| return $app->response()->redirect("/human"); | |
| } | |
| return $app->response()->redirect("/"); | |
| }); | |
| $app->get("/human", function() use($app, $blade) { | |
| echo $app->response()->markup('Bravo vous êtes un humain'); | |
| }); | |
| $app->get("/v3", function() use($app, $blade) { | |
| echo $blade->make('v3', [ | |
| 'token' => $_ENV['V3_SECET'] | |
| ])->render(); | |
| }); | |
| $app->post("/save-v3", function() use($app, $blade) { | |
| $recaptcha_response = $app->request()->get('g-recaptcha-response'); | |
| $client = new GuzzleHttp\Client(); | |
| $res = $client->request('POST', 'https://www.google.com/recaptcha/api/siteverify', [ | |
| 'form_params' => [ | |
| 'response' => $recaptcha_response, | |
| 'secret' => $_ENV['BACK_V3_SECRET'], | |
| ], | |
| ]); | |
| $body = json_decode($res->getBody()); | |
| if($body->success){ | |
| return $app->response()->redirect("/human"); | |
| } | |
| return $app->response()->redirect("/"); | |
| }); | |
| $app->run(); |
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 characters
| <html> | |
| <head> | |
| <meta http-equiv="content-type" content="text/html; charset=UTF-8"> | |
| <script src="https://www.google.com/recaptcha/api.js"></script> | |
| </head> | |
| <body> | |
| <div> | |
| <form method="POST" id="demo-form" action="/save-v3"> | |
| <input type="text" name="firstname" placeholder="Your firstname" autocomplete="off"> | |
| <button class="g-recaptcha" | |
| data-sitekey="{{ $token }}" | |
| data-callback='onSubmit' | |
| data-action='submit'>Submit | |
| </button> | |
| </form> | |
| </div> | |
| <script> | |
| function onSubmit(token) { | |
| document.getElementById("demo-form").submit(); | |
| } | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment