/ Published in: PHP
CAPTCHAs are often too hard to solve - hard enough to annoy real human users. This CAPTCHA is easy to understand and to modify and is strong enough to keep out bots whilst being easy on human eyes.
The source code below will not work on its own - it requires a TTF font file and a word list both of which are available in the ZIP archive available for download from the URL given here.
The source code below will not work on its own - it requires a TTF font file and a word list both of which are available in the ZIP archive available for download from the URL given here.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php function warpedCaptcha($text) { /* this function takes the original captcha text and shuffles the vowels + y around in order to deliver more variable captcha text */ //only parttime warping 'k'=>'k','l'=>'l','m'=>'m','n'=>'n','p'=>'p','q'=>'q','r'=>'r', 's'=>'s','t'=>'t','v'=>'v','w'=>'w','x'=>'x','z'=>'z'); foreach($vkeys as $ndx=>$vkey) $vowels[$vkey] = $vltrs[$ndx]; //the vowels + y are now jumbled up //full associative array of alphabet with randomized vowels + y $captcha = ''; foreach($text as $txt) $captcha .= $ltrs[$txt]; return $captcha; } /* xsixlw.txt is a long string of 6 letter words concatenated together. We pick a word at random from this text */ $_SESSION['captcha'] = $captcha; //store the captcha to check later once the user has solved it { } //pick a random color for the text $x = 20;$y = 47;//the starting position for drawing for ($i=0;$i<6;$i++) { //draw each letter $x += ($coords[2]-$x) + 1; } ?>
URL: http://jreply.com/freebies/simplephpcaptcha.html