• Better Veriword Captcha Display#

  • jamesehly Reply #1, 4 years, 8 months ago

    Reply
    I really like MODx I especially like how accessible the core code is when you want to make a modification. One of the things that really bugged me about MODx is how the Veriword Captcha is displayed - both the look of it and the default words used for the captcha. I really didn't want my clients having to type in words like Zygote,BitCode,MODx,etc. I just wanted a 'normal' looking captcha with random characters. So I modified the veriword script to output what I think looks nice, and it uses a random string of characters. I just wanted to post the code and images that I redid in case someone else wanted a different look, or wanted to see what I did so they could make the captcha look how they wanted. It isn't too hard if you know PHP and an image manipulation tool like Photoshop or the Gimp.

    Here is an example of what the script looks like (used with the eForm snippet).

    Enjoy,
    James


  • rthrash Reply #2, 4 years, 8 months ago

    Reply
    Does look much better indeed. Thanks for sharing.


  • sinbad Reply #3, 3 years, 2 months ago

    Reply
    anyway to make it non case sensitive?
    I tried just lowercase the letters in the file but that makes the letters sometime* unreadable inside the box as they drop down...


  • BobRay Reply #4, 3 years, 2 months ago

    Reply
    I don't think it's available as a settable option, but you could easily change the code that evaluates the user's input against the $_SESSION variable to do a case-insensitive compare.  These are off the top of my head and untested:

    If it's eForm that's doing the check for example, you'd need to change this line (line 178 in eform.inc.php):

    if($fields['vericode']!=$code) {

    to
    if (strtolower($fields['vericode']) !=  strtolower($code) ) {


    or

    if (strcasecmp($fields['vericode'], $code) == 0) {

    Which might be a little faster.

    WebLoginPE, OTOH, has

    if ($_SESSION['veriword'] !== $formcode)


    which could be changed to

    if (strcasecmp($_SESSION['veriword'],formcode) != 0)


    The Manager login comparison is in manager/processors/login.processor.php:

    elseif ($_SESSION['veriword'] != $captcha_code) {


    would change to

    elseif (strcasecmp($_SESSION['veriword'],$captcha_code) != 0 )  {



    Note that if the captcha words have non-English characters (e.g. é, you might need a more complicated comparison function.


  • sinbad Reply #5, 3 years, 2 months ago

    Reply
    consider
    if (strcasecmp($fields['vericode'], $code) == 0) {
    


    as tested. it works perfect
    however the manager capacha gives an error in the related file. mind trying again that one?


  • BobRay Reply #6, 3 years, 2 months ago

    Reply
    Quote from: sinbad at Dec 04, 2008, 12:30 AM
    . . . however the manager capacha gives an error in the related file. mind trying again that one?

    Oops, missing right bracket and right parend. It should be:

    elseif (strcasecmp($_SESSION['veriword'],$captcha_code) != 0) {

    (fixed in post above also -- I hope).

    Thanks for checking.

    Bob


  • mrhaw Reply #7, 3 years, 2 months ago

    Reply
    Thank you BobRay!!


  • sinbad Reply #8, 3 years, 2 months ago

    Reply
    No, thank YOU for checking. This works well. Guess we have both tested. sorry don't have WLPE.
    Thank you very much!


  • sinbad Reply #9, 3 years, 2 months ago

    Reply
    btw, for the standard modx capacha you can simply type your words in lower case. I use this modified capacha from devtrench and don't want to lose users due to frustration so bob's solution is perfect...


  • dev_cw Reply #10, 3 years, 2 months ago

    Reply
    Nice tip, bookmarked
    BobRay is becoming quite an encyclopedia of modx code (old and new), I am impressed that he knew all those code bits off the top of his head (I would have been opening files and searching for hours). Looks like another team member who 'eats php for breakfast'