<?php
  $creds = json_decode(file_get_contents('/etc/menlo/conf/test_page_secrets', false), true);
  $site_key = $creds['recaptcha_enterprise_checkbox']['site_key'];
?>
<html>
  <head>
    <title>reCAPTCHA Enterprise checkbox: Automatically binding the challenge to a button</title>
    <!-- See https://cloud.google.com/recaptcha/docs/instrument-web-pages and
      the integration instructions in the reCAPTCHA section of the GCP console. -->
    <script>
      function onloadCallback() {
        document.getElementById("submit").disabled = false;
      }
    </script>
  </head>
  <body>
    <form id="demo-form" action="verify_token.php" method="POST">
      <!-- reCAPTCHA creates a <div> as a sibling of the button when it
        searches for elements with class="g-recaptcha", and puts a
        <div class=grecaptcha-badge> inside it which contains a <textarea
        id=g-recaptcha-response> which is where the response value is
        filled in by the recaptcha code. -->
      <!-- Using class="g-recaptcha" on the button causes reCAPTCHA to
        automatically bind to it. -->
      <div id="recaptcha_div"
           class="g-recaptcha"
           data-action="submit"
           data-sitekey="<?php echo $site_key ?>"></div>
      <input type="submit" id="submit" value="Submit" disabled/>
    </form>
    <script src="https://www.google.com/recaptcha/enterprise.js?onload=onloadCallback" async defer></script>
  </body>
</html>
