* @author Martin Gross * */ if(!defined('DOKU_INC')) die(); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(dirname(__FILE__).'/lib/autoload.php'); class helper_plugin_recaptcha2 extends DokuWiki_Plugin { /** * Check if the reCAPTCHA should be used. Always check this before using the methods below. * * @return bool true when the reCAPTCHA should be used */ function isEnabled(){ if(!$this->getConf('forusers') && $_SERVER['REMOTE_USER']) return false; return true; } /** * check the validity of the recaptcha * * @return obj (@see ReCaptchaResponse) */ function check() { // Check the recaptcha answer and only submit if correct $recaptcha = new \ReCaptcha\ReCaptcha($this->getConf('privatekey')); $resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']); return $resp; } /** * return the html code for the recaptcha block * @return string */ function getHTML($editblock) { $lang = $this->getConf('lang') ? $this->getConf('lang') : $conf['lang']; $stylewidth = $editblock ? "100%" : "75%"; $captchahtml = '

'; return $captchahtml; } }