From 44eadbd85d05a292d58592562aa64bf1dc56715b Mon Sep 17 00:00:00 2001 From: Kieren Diment Date: Fri, 23 Apr 2010 18:39:46 +1000 Subject: [PATCH] add back in recaptcha --- .../lib/Survey/Perl/Controller/Root.pm | 60 +++++++++---------- .../lib/Survey/Perl/Controller/Survey.pm | 18 +++--- Survey-Perl/root/auth.tt | 19 +++++- 3 files changed, 56 insertions(+), 41 deletions(-) diff --git a/Survey-Perl/lib/Survey/Perl/Controller/Root.pm b/Survey-Perl/lib/Survey/Perl/Controller/Root.pm index d86cb04..d837bc3 100644 --- a/Survey-Perl/lib/Survey/Perl/Controller/Root.pm +++ b/Survey-Perl/lib/Survey/Perl/Controller/Root.pm @@ -24,45 +24,45 @@ sub do_404 :Path { sub end : ActionClass('RenderView') { my ( $self, $c ) = @_; - # begin by setting our minumum cache time to our default cache time in seconds. - my $cachetime = 3600; +# # begin by setting our minumum cache time to our default cache time in seconds. +# my $cachetime = 3600; - # check to see if we have an error - we don't want error pages to be cached - # so we force our cache-time to 0 in that case. - if ( scalar @{ $c->error }) { - $cachetime = 0; - } else { - # Look at each element of cachecontrol to find the shortest - # cache time set. +# # check to see if we have an error - we don't want error pages to be cached +# # so we force our cache-time to 0 in that case. +# if ( scalar @{ $c->error }) { +# $cachetime = 0; +# } else { +# # Look at each element of cachecontrol to find the shortest +# # cache time set. - foreach my $section ( keys %{$c->stash->{'cachecontrol'}} ) { +# foreach my $section ( keys %{$c->stash->{'cachecontrol'}} ) { - # if the currently selected cache-control element is less - # than the page's cache-time - we drop the cache-time to - # match the new limit. - if ($c->stash->{'cachecontrol'}{$section} < $cachetime) { - $cachetime = $c->stash->{'cachecontrol'}{$section}; - } - } - } +# # if the currently selected cache-control element is less +# # than the page's cache-time - we drop the cache-time to +# # match the new limit. +# if ($c->stash->{'cachecontrol'}{$section} < $cachetime) { +# $cachetime = $c->stash->{'cachecontrol'}{$section}; +# } +# } +# } - # at this point - $cachetime should be set to the most restrictive - # time set by all of the actions. Now it's time to turn it into - # a header that the cache server / browser can understand. +# # at this point - $cachetime should be set to the most restrictive +# # time set by all of the actions. Now it's time to turn it into +# # a header that the cache server / browser can understand. - if ($cachetime == 0) { +# if ($cachetime == 0) { - # if $cachetime is 0 - then we can't cache the page and we - # need to tell our requesting server / browser that. +# # if $cachetime is 0 - then we can't cache the page and we +# # need to tell our requesting server / browser that. - $c->response->header('Cache-Control' => 'no-cache') +# $c->response->header('Cache-Control' => 'no-cache') - } - else { +# } +# else { - # otherwise we set max-age to the cache-time specified. - $c->response->header('Cache-Control' => 'max-age=' . $cachetime); - } +# # otherwise we set max-age to the cache-time specified. +# $c->response->header('Cache-Control' => 'max-age=' . $cachetime); +# } } diff --git a/Survey-Perl/lib/Survey/Perl/Controller/Survey.pm b/Survey-Perl/lib/Survey/Perl/Controller/Survey.pm index 5cf76bd..2dc9ed3 100644 --- a/Survey-Perl/lib/Survey/Perl/Controller/Survey.pm +++ b/Survey-Perl/lib/Survey/Perl/Controller/Survey.pm @@ -7,15 +7,15 @@ use Data::Dumper; sub survey_base : Chained("/") : PathPart("survey") : CaptureArgs(0) { my ( $self, $c ) = @_; - # if (! $c->user) { - # if ($c->req->params->{'dest'} && ! $c->session->{human}) { - - # $c->forward('/recaptcha/test_user'); - # } - # elsif (! $c->session->{human}) { - # $c->detach('/recaptcha/test_user'); - # } - # } + if (! $c->user) { + if ($c->req->params->{'dest'} && ! $c->session->{human}) { + + $c->forward('/recaptcha/test_user'); + } + elsif (! $c->session->{human}) { + $c->detach('/recaptcha/test_user'); + } + } } sub get_root : Chained("survey_base") : PathPart("") : Args(0) { diff --git a/Survey-Perl/root/auth.tt b/Survey-Perl/root/auth.tt index 82fffcf..508ddb2 100644 --- a/Survey-Perl/root/auth.tt +++ b/Survey-Perl/root/auth.tt @@ -1,7 +1,22 @@ +

Perl Survey 2009

+ +
+

Note

+ +

This survey uses javascript for a decent (user friendly) multiselect input. +Please make sure that you have javascript switched on before continuing +further. We also use a session cookie for remembering the fact that you past +the reCaptcha below, so please make sure you also have cookies enabled.

+

Identify yourself

-

To make sure that this survey is only conducted by real humans, first we ask you to fill in the following form. Once you get the answer right, you'll be sent on to the survey. + +

To make sure that this survey is only conducted by real humans, first we +ask you to fill in the following form. Once you get the answer right, you'll +be sent on to the survey. +

[% recaptcha %]
-

\ No newline at end of file +

+
\ No newline at end of file