*/
// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_INC.'inc/blowfish.php');
class helper_plugin_captcha extends DokuWiki_Plugin {
/**
* Check if the CAPTCHA should be used. Always check this before using the methods below.
*
* @return bool true when the CAPTCHA should be used
*/
function isEnabled(){
if(!$this->getConf('forusers') && $_SERVER['REMOTE_USER']) return false;
return true;
}
/**
* Returns the HTML to display the CAPTCHA with the chosen method
*/
function getHTML(){
global $ID;
$rand = (float) (rand(0,10000))/10000;
$code = $this->_generateCAPTCHA($this->_fixedIdent(),$rand);
$secret = PMA_blowfish_encrypt($rand,auth_cookiesalt());
$out = '';
$out .= '
';
$out .= '';
$out .= ' ';
$out .= ' ';
switch($this->getConf('mode')){
case 'text':
$out .= $code;
break;
case 'js':
$out .= ''.$code.'';
break;
case 'image':
$out .= ' ';
break;
case 'audio':
$out .= ' ';
$out .= '';
$out .= '';
break;
case 'figlet':
require_once(dirname(__FILE__).'/figlet.php');
$figlet = new phpFiglet();
if($figlet->loadfont(dirname(__FILE__).'/figlet.flf')){
$out .= '