<?php
/*
 * AUTHOR:
 *   David Allen 2015
 *
 */

// Get keys from https://www.google.com/recaptcha/admin
$publickey = '6LffwpsUAAAAAI4UEsh1VOeke0Uu2nvneRJW5bVc';
$privatekey='6LffwpsUAAAAAC2ID75Xg6leFw9j9b5_MGfQkDeP';


/**
 * Creates the challenge HTML.
 * This is called from the browser, and the resulting reCAPTCHA HTML widget
 * is embedded within the HTML form it was called from.
 * @param boolean $fieldset Should the challenge be wrapped in a fieldset (optional, default is false)
 * @param string $theme Should the reCaptcha be shown in dark or light theme (optional, default is light)
 * @param string $size Should the reCaptcha be shown in compact or normal size (optional, default is normal)

 * @return string - The HTML to be embedded in the user's form.
 */
function recaptcha_get_html ($fieldset=false, $theme='light', $size='normal') {
	global $publickey;
	$recaptcha_html='';
	if ($fieldset==true) {
		$recaptcha_html.='<fieldset>'."\n";
	}
	$parameters=' class="g-recaptcha" data-sitekey="'.$publickey.'"';
	if ($theme!='light') {
		$parameters.=' data-theme="dark"';
	}
	if ($size!='normal') {
		$parameters.=' data-size="compact"';
	}
	$recaptcha_html.='<script src="https://www.google.com/recaptcha/api.js" async defer></script>'."\n";
	//to display the reCaptcha in French comment out the above line and uncomment the line below. For other language codes see https://developers.google.com/recaptcha/docs/language
	//$recaptcha_html.='<script src="https://www.google.com/recaptcha/api.js?hl=fr" async defer></script>'."\n";

	$recaptcha_html.='<div'.$parameters.'></div>'."\n";
	if ($fieldset==true) {
		$recaptcha_html.='</fieldset>'."\n";
	}
	return $recaptcha_html;
}

?>
