For those that are willing, I’ve implemented the above:
This is a quick hack.
Files (sorry it’s a funky OSX zip archive, but you should be able to yank the contents out on any platform, I have):
http://www.asherwolf.com/captcha_package_config.zip.
I apologize ahead of time for the language files I couldn’t translate, and if I made errors on the ones I did. I have setup a fall-back method (I saw there was some kind of fallback method built in to the core for language but I didn’t quite understand it) for language as well, to english. If you already have made modifications to your installation obviously don’t just copy the files right over. To help you, I have included the code changes I made:
(english language file and others)
...
$_lang["captcha_code"] = 'Security code';
$_lang["captcha_message"] = 'Enable this to strengthen security by requiring users to enter a code which is unreadable by machines (and scriptkiddy hacking scripts).';
$_lang["captcha_title"] = 'Use CAPTCHA codes:';
$_lang["captcha_words_message"] = 'Here you can specify the dimensions and number of letters for your CAPTCHA block.';
$_lang["captcha_words_title"] = 'CAPTCHA Settings';
$_lang["captcha_dimensions_height"] = 'Height:';
$_lang["captcha_dimensions_width"] = 'Width:';
$_lang["captcha_number_letters"] = 'Characters:';
$_lang["category_heading"] = 'Category';
...
The fallback file (captcha_english_fallback.inc.php) can be copied.
(veriword.php)
...
include_once("config.inc.php");
if ( !isset( $captcha_height ) ) {
$captcha_height = 30;
}
if ( !isset( $captcha_width ) ) {
$captcha_width = 120;
}
if ( !isset( $captcha_chars ) ) {
$captcha_chars = 6;
}
$vword = new VeriWord( $captcha_width, $captcha_height, $captcha_chars );
$vword->output_image();
...
...
function VeriWord($w=100, $h=40, $c=6) {
/* create session to set word for verification */
startCMSSession();
$this->set_veriword();
$this->im_width = $w;
$this->im_height = $h;
$this->word_length = $c;
}
...
(accesscontrol.inc.php)
...
if($use_captcha==1) {
$modx->setPlaceholder('login_captcha_message',$_lang["login_captcha_message"]);
$modx->setPlaceholder('captcha_image','<a href="'.$_SERVER['PHP_SELF'].'" class="loginCaptcha"><img id="captcha_image" src="'.$modx->getManagerPath().'includes/veriword.php?rand='.rand().'&h='.$captcha_height.'&w='.$captcha_width.'&c='.$captcha_chars.'" alt="'.$_lang["login_captcha_message"].'" /></a>');
$modx->setPlaceholder('captcha_input','<label>'.$_lang["captcha_code"].'</label> <input type="text" name="captcha_code" tabindex="3" value="" />');
}
...
(mutate_settings.dynamic.php)
...
<tr>
<?php if ( !isset( $_lang["captcha_dimensions_height"] ) ) { include( 'lang/captcha_english_fallback.inc.php' ); } ?>
<td nowrap class="warning"><b><?php echo $_lang["captcha_words_title"] ?></b></td>
<td><?php echo( $_lang["captcha_dimensions_height"] ); ?> <input name="captcha_height" style="width:75px" value="<?php echo isset($captcha_height) ? $captcha_height : "30" ; ?>" /> <?php echo( $_lang["captcha_dimensions_width"] ); ?> <input name="captcha_width" style="width:75px" value="<?php echo isset($captcha_width) ? $captcha_width : "120" ; ?>" /><br /><?php echo( $_lang["captcha_number_letters"] ); ?> <input name="captcha_chars" style="width:75px" value="<?php echo isset($captcha_chars) ? $captcha_chars : "6" ; ?>" /></td>
<!-- <input name="captcha_words" style="width:250px" value="<?php // echo isset($captcha_words) ? $captcha_words : "MODx,Access,Better,BitCode,Chunk,Cache,Desc,Design,Excell,Enjoy,URLs,TechView,Gerald,Griff,Humphrey,Holiday,Intel,Integration,Joystick,Join(),Oscope,Genetic,Light,Likeness,Marit,Maaike,Niche,Netherlands,Ordinance,Oscillo,Parser,Phusion,Query,Question,Regalia,Righteous,Snippet,Sentinel,Template,Thespian,Unity,Enterprise,Verily,Tattoo,Veri,Website,WideWeb,Yap,Yellow,Zebra,Zygote" ; ?>" /></td> -->
</tr>
...
And if you want case-insensitive captcha (no necessary capitals)...
(login.processor.php)
...
if($use_captcha==1) {
if (!isset ($_SESSION['veriword'])) {
jsAlert('Captcha is not configured properly.');
return;
}
elseif ( strtolower( $_SESSION['veriword'] ) != strtolower( $captcha_code ) ) {
jsAlert($e->errors[905]);
$newloginerror = 1;
}
}
...