Advertisement
rAthus

Simple custom reCAPTCHA

Apr 30th, 2013
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.54 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <html>
  3.     <head>
  4.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  5.         <title>reCAPTCHA</title>
  6.         <style type="text/css">
  7.             body
  8.             {
  9.                 font-family: arial;
  10.                 background: #fff;
  11.                 color: #000;
  12.                 font-size: 12px;
  13.             }
  14.         </style>
  15.     </head>
  16.     <body>
  17.         <form method="POST">
  18.             <?php
  19.                
  20.                 require_once('recaptchalib.php');
  21.                
  22.                 $privatekey = "VOTRE_CLÉ_PRIVÉE";
  23.                
  24.                 $resp = recaptcha_check_answer($privatekey, $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']);
  25.                 if (!isset($_POST['recaptcha_response_field']))
  26.                     echo "reCAPTCHA initialisé !<br /><br />"; // S'affiche quand le formulaire n'a pas encore été validé une première fois.
  27.                 elseif (!$resp->is_valid)
  28.                     echo "Erreur : ".$resp->error."<br /><br />"; // Vaut "incorrect-captcha-sol" quand le reCAPTCHA n'a pas ou mal été remplit.
  29.                 else
  30.                     echo "Recaptcha OK !<br /><br />"; // S'affiche quand le reCAPTCHA a été validé et correctement remplit.
  31.                
  32.             ?>
  33.             <script type="text/javascript">
  34.                 var RecaptchaOptions =
  35.                     {
  36.                         theme: 'custom',
  37.                         custom_theme_widget: 'recaptcha_widget'
  38.                     };
  39.             </script>
  40.             <div id="recaptcha_widget" style="display: none;">
  41.                 <!-- Début de la customisation -->
  42.                 <div id="recaptcha_image"></div>
  43.                 <span class="recaptcha_only_if_image">Recopiez les mots ci-dessus :</span>
  44.                 <span class="recaptcha_only_if_audio">Qu'entendez-vous ?</span>
  45.                 <input type="text" id="recaptcha_response_field" name="recaptcha_response_field">
  46.                 <div><a href="javascript: Recaptcha.reload();">Afficher une autre image CAPTCHA</a></div>
  47.                 <div class="recaptcha_only_if_image"><a href="javascript: Recaptcha.switch_type('audio');">CAPTCHA audio</a></div>
  48.                 <div class="recaptcha_only_if_audio"><a href="javascript: Recaptcha.switch_type('image');">Afficher une image CAPTCHA</a></div>
  49.                 <div><a href="javascript: Recaptcha.showhelp();">Aide</a></div>
  50.                 <!-- Fin de la customisation -->
  51.                 <script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=VOTRE_CLÉ_PUBLIQUE"></script>
  52.                 <noscript><iframe src="http://www.google.com/recaptcha/api/noscript?k=VOTRE_CLÉ_PUBLIQUE" height="300" width="500" frameborder="0"></iframe><br>
  53.                 <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
  54.                 <input type="hidden" name="recaptcha_response_field" value="manual_challenge"></noscript>
  55.             </div>
  56.             <input type="submit" name="Button1" value="Submit">
  57.         </form>
  58.     </body>
  59. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement