[Bps-public-commit] r15317 - in RT-Extension-Captcha/html: . Callbacks Callbacks/RT-Extension-Captcha Callbacks/RT-Extension-Captcha/Ticket Callbacks/RT-Extension-Captcha/Ticket/Create.html Helpers
ruz at bestpractical.com
ruz at bestpractical.com
Thu Aug 21 00:06:22 EDT 2008
Author: ruz
Date: Thu Aug 21 00:06:21 2008
New Revision: 15317
Added:
RT-Extension-Captcha/html/
RT-Extension-Captcha/html/Callbacks/
RT-Extension-Captcha/html/Callbacks/RT-Extension-Captcha/
RT-Extension-Captcha/html/Callbacks/RT-Extension-Captcha/Ticket/
RT-Extension-Captcha/html/Callbacks/RT-Extension-Captcha/Ticket/Create.html/
RT-Extension-Captcha/html/Callbacks/RT-Extension-Captcha/Ticket/Create.html/BeforeCreate
RT-Extension-Captcha/html/Callbacks/RT-Extension-Captcha/Ticket/Create.html/FormStart
RT-Extension-Captcha/html/Callbacks/RT-Extension-Captcha/Ticket/Display.html/
RT-Extension-Captcha/html/Callbacks/RT-Extension-Captcha/Ticket/Display.html/Initial
RT-Extension-Captcha/html/Helpers/
RT-Extension-Captcha/html/Helpers/Captcha
Log:
* import html
Added: RT-Extension-Captcha/html/Callbacks/RT-Extension-Captcha/Ticket/Create.html/BeforeCreate
==============================================================================
--- (empty file)
+++ RT-Extension-Captcha/html/Callbacks/RT-Extension-Captcha/Ticket/Create.html/BeforeCreate Thu Aug 21 00:06:21 2008
@@ -0,0 +1,33 @@
+<%ARGS>
+$ARGSRef => {}
+$checks_failure
+$skip_create
+$results => []
+</%ARGS>
+<%INIT>
+return if $$skip_create;
+return if $checks_failure;
+
+my $queue = RT::Queue->new( $session{'CurrentUser'} );
+$queue->Load( $ARGSRef->{'Queue'} );
+return unless $queue->id;
+
+return if $queue->CurrentUserHasRight('NoCaptchaOnCreate');
+
+my ($captcha) = ($ARGSRef->{'CaptchaString'});
+unless ( $captcha ) {
+ push @$results, loc("You have to solve CAPTCHA");
+ $$skip_create = 1;
+}
+elsif ( !$session{'Captcha'}{'String'} ) {
+ push @$results, loc("Don't play with me. You must solve CAPTCHA");
+ $$skip_create = 1;
+}
+elsif ( lc($captcha) ne lc $session{'Captcha'}{'String'} ) {
+ delete $session{'Captcha'};
+ push @$results, loc("Not equal. Give you another CAPTCHA");
+ $$skip_create = 1;
+}
+return;
+</%INIT>
+
Added: RT-Extension-Captcha/html/Callbacks/RT-Extension-Captcha/Ticket/Create.html/FormStart
==============================================================================
--- (empty file)
+++ RT-Extension-Captcha/html/Callbacks/RT-Extension-Captcha/Ticket/Create.html/FormStart Thu Aug 21 00:06:21 2008
@@ -0,0 +1,22 @@
+<div id="Ticket-Create-captcha">
+<a name="captcha"></a>
+
+<&| /Widgets/TitleBox, title => loc("You must solve a CAPTACHA to create a new ticket") &>
+
+<table border="0" cellpadding="0" cellspacing="0">
+<tr><td><img src="<% RT->Config->Get('WebURL') %>Helpers/Captcha" /></td>
+<td><input type="text" name="CaptchaString" /></td></tr>
+</table>
+
+</&>
+<%ARGS>
+$ARGSRef => {}
+</%ARGS>
+<%INIT>
+my $queue = RT::Queue->new( $session{'CurrentUser'} );
+$queue->Load( $ARGSRef->{'Queue'} );
+return unless $queue->id;
+
+return if $queue->CurrentUserHasRight('NoCaptchaOnCreate');
+
+</%INIT>
Added: RT-Extension-Captcha/html/Callbacks/RT-Extension-Captcha/Ticket/Display.html/Initial
==============================================================================
--- (empty file)
+++ RT-Extension-Captcha/html/Callbacks/RT-Extension-Captcha/Ticket/Display.html/Initial Thu Aug 21 00:06:21 2008
@@ -0,0 +1,32 @@
+<%ARGS>
+$ARGSRef => {}
+</%ARGS>
+<%INIT>
+$RT::Logger->crit("woot");
+return unless ($ARGSRef->{'id'}||'') eq 'new';
+
+my $queue = RT::Queue->new( $session{'CurrentUser'} );
+$queue->Load( $ARGSRef->{'Queue'} );
+return unless $queue->id;
+
+return if $queue->CurrentUserHasRight('NoCaptchaOnCreate');
+
+my ($captcha) = ($ARGSRef->{'CaptchaString'});
+
+if ( !$captcha || lc($captcha) ne lc($session{'Captcha'}{'String'}||'') ) {
+ my $key = Digest::MD5::md5_hex( rand(1024) );
+ push @{ $session{"Actions"}->{ $key } ||= [] },
+ loc("You have to solve CAPTCHA");
+ $session{'i'}++;
+ RT::Interface::Web::Redirect(
+ RT->Config->Get('WebURL')
+ ."Ticket/Create.html"
+ ."?Queue=". $m->interp->apply_escapes( $ARGSRef->{'Queue'}, 'u' )
+ ."&results=". $key
+ );
+ $m->abort;
+}
+
+delete $session{'Captcha'};
+return;
+</%INIT>
Added: RT-Extension-Captcha/html/Helpers/Captcha
==============================================================================
--- (empty file)
+++ RT-Extension-Captcha/html/Helpers/Captcha Thu Aug 21 00:06:21 2008
@@ -0,0 +1,20 @@
+<%INIT>
+my $str = $session{'Captcha'}{'String'}
+ ||= uc $session{'CurrentUser'}->GenerateRandomPassword(6, 9);
+my ($image, $type, $rnd) = GD::SecurityImage->new(
+ width => 320,
+ height => 100,
+ ptsize => 40,
+ lines => 10,
+ font => RT->Config->Get('ChartFont') || '/usr/share/fonts/corefonts/georgia.ttf',
+)->random( $str )->create( 'ttf', 'circle' )->particle->out;
+
+$session{'Captcha'}{'String'} = $str;
+
+$m->clear_buffer;
+$r->content_type( $type );
+$m->out( $image );
+$m->flush_buffer;
+$m->abort;
+
+</%INIT>
More information about the Bps-public-commit
mailing list