Captcha for Horde


Here is small patch to implement captcha on Horde login page. We have implemeteded Text_CAPTCHA_Numeral. Package for Centos is here: http://fs12.vsb.cz/hrb33/el5/hrb/stable/i386/repoview/php-pear-Text-CAPTCHA-Numeral.html. Here is the patch.

\--- horde-webmail-1.2.8.orig/imp/login.php	2010-10-25 17:10:05.000000000 +0200
+++ horde-webmail-1.2.8/imp/login.php	2010-11-30 17:36:27.571023703 +0100
@@ -398,6 +398,7 @@
     $t->set('user\_vinfo', Horde::callHook('\_imp\_hook\_vinfo', array('vdomain'), 'imp'));
 }
 $t->set('password\_tabindex', ++$tabindex);
+$t->set('captch\_tabindex', ++$tabindex);

 $t->set('change\_smtphost', (!empty($conf\['server'\]\['change\_smtphost'\])));
 if ($t->get('change\_smtphost')) {
@@ -446,7 +447,16 @@
     'var imp\_auth = ' . intval($imp\_auth),
     'var nomenu = ' . intval(empty($conf\['menu'\]\['always'\])),
 ));
-echo $t->fetch(IMP\_TEMPLATES . '/login/login.html');
+
+// ZMENA
+ini\_set('include\_path', ini\_get('include\_path').':/usr/share/php');
+
+require\_once 'Text/CAPTCHA/Numeral.php';
+$numcap = new Text\_CAPTCHA\_Numeral;
+
+echo str\_replace('Vysledek', $numcap->getOperation().' =', $t->fetch(IMP\_TEMPLATES . '/login/login.html'));
+$\_SESSION\['answer'\] = $numcap->getAnswer();
+//KONEC ZMENY

 if (!empty($recompose\_data)) {
     /\* Prepare recompose template. \*/

--- horde-webmail-1.2.8.orig/imp/redirect.php	2010-10-25 17:10:05.000000000 +0200
+++ horde-webmail-1.2.8/imp/redirect.php	2010-11-30 17:36:27.555023948 +0100
@@ -91,6 +91,14 @@
 require\_once 'Horde/Maintenance.php';

 $actionID = (Util::getFormData('action') == 'compose') ? 'login\_compose' : Util::getFormData('actionID');
+
+$captch = Util::getFormData('captch');
+if (isset($captch) && isset($\_SESSION\['answer'\])) {
+    if ($captch != $\_SESSION\['answer'\]) {
+            \_redirect(Auth::addLogoutParameters(IMP::logoutUrl(), AUTH\_REASON\_FAILED));
+    }
+}
+
 $autologin = Util::getFormData('autologin');
 $imapuser = Util::getPost('imapuser');
 $pass = Util::getPost('pass');

--- horde-webmail-1.2.8.orig/imp/templates/login/login.html	2010-10-25 17:10:05.000000000 +0200
+++ horde-webmail-1.2.8/imp/templates/login/login.html	2010-11-30 17:36:27.215029139 +0100
@@ -94,6 +94,12 @@



+
+     **Vysledek**
+
+
+
+
centos  horde  php