I wrote 2 patches to enable reCaptcha in the discussion plugins.
2 modifications here:
I only modified the file action.php in /lib/plugins/recaptcha (version 2008-06-17)
49a50,63 > // old hook > $controller->register_hook('HTML_EDITFORM_INJECTION', > 'BEFORE', > $this, > 'insert', > array('editform' => true, 'oldhook' => true)); > > // new hook > $controller->register_hook('HTML_EDITFORM_OUTPUT', > 'BEFORE', > $this, > 'insert', > array('editform' => true, 'oldhook' => false)); > 61a76,80 > // do nothing if logged in user and no CAPTCHA required > if(!$this->getConf('forusers') && $_SERVER['REMOTE_USER']){ > return; > } > 95,97c114,117 < // check if we are in a registration process < if(!('register' == $act && $_POST['save'])) { < return; --- > > // do nothing if logged in user and no CAPTCHA required > if(!$this->getConf('forusers') && $_SERVER['REMOTE_USER']){ > return(0); 98a119,120 > > if (($act == 'register' && $_POST['save']) || ($act == 'show' && $_REQUEST['comment'] == 'add')) { 106c128,129 < $_POST['save'] = false; --- > $_POST['save'] = 0; #for register > return 'recapchta not valid'; 108c131,133 < --- > return (0); > } > return 'unknown action';
You can also see the action.php file with this diff applied. action.php.recaptcha.20080617.txt
You can also download this file, rename it “action.php” & put it in your recaptcha plugins directory. But be sure you are using the same version as me.
In this plugins, I just added a support for Recaptcha:
I only modified the file action.php in /lib/plugins/discussion (version 2008-08-08)
70,72c70,75 < // enable captchas < if ((in_array($_REQUEST['comment'], array('add', 'save'))) < && (@file_exists(DOKU_PLUGIN.'captcha/action.php'))) { --- > // enable [re]captchas > if (in_array($_REQUEST['comment'], array('add', 'save'))) { > if(@file_exists(DOKU_PLUGIN.'recaptcha/action.php')) { > $this->_recaptchaCheck($event); > } > if (@file_exists(DOKU_PLUGIN.'captcha/action.php')) { 74a78 > } 1103a1108,1130 > * Checks if the RECAPTCHA string submitted is valid > * > * @author Aurélien ANTOINE http://ilpleut.be > */ > function _recaptchaCheck(&$event) { > require_once(DOKU_PLUGIN.'recaptcha/action.php'); > > // do nothing if logged in user and no CAPTCHA required > if(!$this->getConf('forusers') && $_SERVER['REMOTE_USER']){ > return; > } > > $recaptcha = new action_plugin_recaptcha; > > $recaptcha_error = $recaptcha->preprocess($event, array()); > > if($recaptcha_error) { > if ($_REQUEST['comment'] == 'save') $_REQUEST['comment'] = 'edit'; > elseif ($_REQUEST['comment'] == 'add') $_REQUEST['comment'] = 'show'; > } > } > > /**
You can also see the action.php file with this diff applied. action.php.discussion.20080808.txt
You can also download this file, rename it “action.php” & put it in your discussion plugins directory. But be sure you are using the same version as me.