in reply to Need help with Authen::Captcha instructions

Some of these errors disappeared when I added the '$number_of_characters' value line.

So do that. And please post the resulting code. The code you are actually running.

You'll also want to use strict.

update: sometimes, adding use diagnostics to the top of your program helps a lot.

  • Comment on Re: Need help with Authen::Captcha instructions

Replies are listed 'Best First'.
Re^2: Need help with Authen::Captcha instructions
by newbie00 (Beadle) on Jun 30, 2006 at 01:05 UTC
    Thanks for your replies...I haven't been here in a longgg...time...:)

    Here is the code I used from the referenced link except WITH the '$number_of_characters' var pre-defined:

    #!/usr/bin/perl -w -d use Authen::Captcha; # create a new object my $captcha = Authen::Captcha->new(); # set the data_folder. contains flatfile db to maintain state $captcha->data_folder('/usr/home1/user123/public_html/folder01') +; # set directory to hold publicly accessable images $captcha->output_folder('/usr/home1/user123/public_html/folder01 +/images'); # I created this variable's value my $number_of_characters = 6; # create a captcha. Image filename is "$md5sum.png" my $md5sum = $captcha->generate_code($number_of_characters); # check for a valid submitted captcha # $code is the submitted letter combination guess from the use +r # $md5sum is the submitted md5sum from the user (that we gave +them) my $results = $captcha->check_code($code,$md5sum); # $results will be one of: # 1 : Passed # 0 : Code not checked (file error) # -1 : Failed: code expired # -2 : Failed: invalid code (not in database) # -3 : Failed: invalid code (code does not match crypt) ##############

    Let me know if you need additional info.

    Thanks.

      EDIT: changed above: '$number_of_characters = 6;' to 'my $number_of_characters = 6;'

    (haven't edited a Perl script much recently either...)

      Hello newbie00,

      your code is a copy of the SYNOPSIS part of the manual page of Authen::Captcha.

      The SYNOPSIS part of a manual page to a module is meant to give a quick overview of the way a module works. The code written therein is not meant to be copied and run verbatim.

      For instance, the line

      my $results = $captcha->check_code($code,$md5sum);
      must be run after an image has been created, displaying a random set of characters of $number_of_characters length, it's MD5 sum has been created and a user provided $code, i.e they typed the characters displayed on the image.

      Image creation and verification are two sequential processes, but they are conveniently displayed in the SYNOPSIS of the module in one block.

      I advise you to read the manual page of Authen::Captcha thoroughly, formulate your needs, engage in their fulfilment and come back with some code of your own.

      regards,
      --shmem

      _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                    /\_¯/(q    /
      ----------------------------  \__(m.====·.(_("always off the crowd"))."·
      ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
        Thanks again for your reply.

        I found this link:
        http://search.cpan.org/src/UNRTST/Authen-Captcha-1.023/examples/README

        which says to define the 'number of characters.' I did this (see code in my previous reply) but because the code was not complete, it didn't work.

        Beyond what I have already, I'm at a standstill. I guess I've not had to do something like what this perl module involves. I've customized a number of scripts where the skeletal structure was available for a particular perl module or the module was simpler for me to figure out.

        If someone has a working example that adds image verification either from 'Authen::Captcha' OR 'GD::SecurityImage' OR another that is not readily 'OCRable', please let me know.

        Thank you.