Catalyst-Plugin-Captcha-0.04/000755 000765 000024 00000000000 11355672124 016431 5ustar00diegokstaff000000 000000 Catalyst-Plugin-Captcha-0.04/Changes000644 000765 000024 00000001130 11355401600 017704 0ustar00diegokstaff000000 000000 Revision history for Perl extension Catalyst::Plugin::Captcha. 0.04 Fri Apr 2 16:45:00 2010 - Updated to work nice on Catalyst 5.8 applied patch by Peter Flanigan 0.03 Mon May 29 10:42:00 2006 - Added clear_captcha_string method. - Added pod documents. 0.02 Fri Mar 24 17:15:00 2006 - Added image->out parameter. - Added no-cache headers. - Fixed content_type and documents. thanks John Napiorkowski 0.01 Wed Mar 8 17:38:13 2006 - original version; created by h2xs 1.23 with options -XAn Catalyst::Plugin::Captcha Catalyst-Plugin-Captcha-0.04/MANIFEST000644 000765 000024 00000000236 11355400414 017552 0ustar00diegokstaff000000 000000 Changes Makefile.PL MANIFEST README t/00-load.t lib/Catalyst/Plugin/Captcha.pm META.yml Module meta-data (added by MakeMaker) Catalyst-Plugin-Captcha-0.04/META.yml000644 000765 000024 00000001252 11355672124 017702 0ustar00diegokstaff000000 000000 --- #YAML:1.0 name: Catalyst-Plugin-Captcha version: 0.04 abstract: create and validate Captcha for Catalyst author: - Masahiro Nagano license: unknown distribution_type: module configure_requires: ExtUtils::MakeMaker: 0 build_requires: ExtUtils::MakeMaker: 0 requires: Catalyst: 5.3 Catalyst::Plugin::Session: 0 GD::SecurityImage: 0 HTTP::Date: 0 no_index: directory: - t - inc generated_by: ExtUtils::MakeMaker version 6.55_02 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 Catalyst-Plugin-Captcha-0.04/Makefile.PL000644 000765 000024 00000001112 11355400414 020365 0ustar00diegokstaff000000 000000 use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( NAME => 'Catalyst::Plugin::Captcha', VERSION_FROM => 'lib/Catalyst/Plugin/Captcha.pm', PREREQ_PM => { 'GD::SecurityImage' => 0, 'Catalyst' => 5.30, 'Catalyst::Plugin::Session' => 0, 'HTTP::Date' => 0 }, ($] >= 5.005 ? (ABSTRACT_FROM => 'lib/Catalyst/Plugin/Captcha.pm', AUTHOR => 'Masahiro Nagano ') : ()), ); Catalyst-Plugin-Captcha-0.04/README000644 000765 000024 00000002335 11355402014 017301 0ustar00diegokstaff000000 000000 Catalyst-Plugin-Captcha version 0.04 ==================================== The README is used to introduce the module and provide instructions on how to install the module, any machine dependencies it may have (for example C compilers and installed libraries) and any other information that should be provided before the module is installed. A README file is required for CPAN modules since CPAN extracts the README file from a module distribution so that people browsing the archive can use it get an idea of the modules uses. It is usually a good idea to provide version information here so that people can decide whether fixes for the module are worth downloading. INSTALLATION To install this module type the following: perl Makefile.PL make make test make install DEPENDENCIES This module requires these other modules and libraries: Catalyst Catalyst::Plugin::Session GD::SecurityImage COPYRIGHT AND LICENCE Put the correct copyright and licence information here. Copyright (C) 2006 by Masahiro Nagano This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available. Catalyst-Plugin-Captcha-0.04/lib/000755 000765 000024 00000000000 11355672124 017177 5ustar00diegokstaff000000 000000 Catalyst-Plugin-Captcha-0.04/t/000755 000765 000024 00000000000 11355672124 016674 5ustar00diegokstaff000000 000000 Catalyst-Plugin-Captcha-0.04/t/00-load.t000644 000765 000024 00000000115 11355672014 020210 0ustar00diegokstaff000000 000000 use Test::More tests => 1; BEGIN { use_ok('Catalyst::Plugin::Captcha') }; Catalyst-Plugin-Captcha-0.04/lib/Catalyst/000755 000765 000024 00000000000 11355672124 020763 5ustar00diegokstaff000000 000000 Catalyst-Plugin-Captcha-0.04/lib/Catalyst/Plugin/000755 000765 000024 00000000000 11355672124 022221 5ustar00diegokstaff000000 000000 Catalyst-Plugin-Captcha-0.04/lib/Catalyst/Plugin/Captcha.pm000644 000765 000024 00000007374 11355672014 024133 0ustar00diegokstaff000000 000000 package Catalyst::Plugin::Captcha; use strict; use warnings; use GD::SecurityImage; use HTTP::Date; our $VERSION = '0.04'; use MRO::Compat; sub setup { my $c = shift; my $config = $c->config->{ 'Plugin::Captcha' } || delete $c->config->{captcha}; # Deprecated $config->{session_name} ||= 'captcha_string'; $config->{captcha}->{new} ||= {}; $config->{captcha}->{create} ||= []; $config->{captcha}->{particle} ||= []; $config->{captcha}->{out} ||= {}; $c->config( 'Plugin::Captcha' => $config ); return $c->next::method( @_ ); } sub create_captcha { my $c = shift; my $conf = $c->config->{ 'Plugin::Captcha' }; my $image = GD::SecurityImage->new( %{ $conf->{new} } ); $image->random(); $image->create( @{ $conf->{create} } ); $image->particle( @{ $conf->{particle} } ); my ( $image_data, $mime_type, $random_string ) = $image->out( %{ $conf->{out} } ); $c->session->{ $conf->{session_name} } = $random_string; $c->res->headers->expires( time() ); $c->res->headers->header( 'Last-Modified' => HTTP::Date::time2str ); $c->res->headers->header( 'Pragma' => 'no-cache' ); $c->res->headers->header( 'Cache-Control' => 'no-cache' ); $c->res->content_type("image/$mime_type"); $c->res->output($image_data); } sub validate_captcha { my ( $c, $verify ) = @_; my $string = $c->captcha_string; return ( $verify && $string && $verify eq $string ); } sub captcha_string { my $c = shift; my $conf = $c->config->{ 'Plugin::Captcha' }; return $c->session->{ $conf->{session_name} }; } sub clear_captcha_string { my $c = shift; my $conf = $c->config->{ 'Plugin::Captcha' }; delete $c->session->{ $conf->{session_name} }; return 1; } 1; __END__ # Below is stub documentation for your module. You'd better edit it! =head1 NAME Catalyst::Plugin::Captcha - create and validate Captcha for Catalyst =head1 SYNOPSIS use Catalyst qw/Captcha/; MyApp->config->{ 'Plugin::Captcha' } = { session_name => 'captcha_string', new => { width => 80, height => 30, lines => 7, gd_font => 'giant', }, create => [qw/normal rect/], particle => [100], out => {force => 'jpeg'} }; sub captcha : Local { my ($self, $c) = @_; $c->create_captcha(); } sub do_post : Local { my ($self, $c) = @_; if ($c->validate_captcha($c->req->param('validate')){ .. } else { .. } } #validate with CP::FormValidator::Simple sub do_post : Local { my ($self, $c) = @_; $c->form( validate => [['EQUAL_TO',$c->captcha_string]] ) } =head1 DESCRIPTION This plugin create, validate Captcha. Note: This plugin uses L and requires a session plugins like L =head1 METHODS =head2 create_captcha Create Captcha image and output it. =head2 validate_captcha $c->validate_captcha($key); validate key =head2 captcha_string Return a string for validation which is stroed in session. =head2 clear_captcha_string Clear a string which is stroed in session. =head1 CONFIGURATION =over 4 =item session_name The keyword for storing captcha string =item new =item create =item particle =item out These parameters are passed to each GD::Security's method. Please see L for details. =back =head1 SEE ALSO L, L =head1 AUTHOR Masahiro Nagano Ekazeburo@nomadscafe.jpE =head1 COPYRIGHT AND LICENSE Copyright (C) 2006 by Masahiro Nagano This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available. =cut