Skip to content

Commit

Permalink
add back in recaptcha
Browse files Browse the repository at this point in the history
  • Loading branch information
Kieren Diment committed Apr 23, 2010
1 parent 3da1732 commit 44eadbd
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 41 deletions.
60 changes: 30 additions & 30 deletions Survey-Perl/lib/Survey/Perl/Controller/Root.pm
Expand Up @@ -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);
# }


}
Expand Down
18 changes: 9 additions & 9 deletions Survey-Perl/lib/Survey/Perl/Controller/Survey.pm
Expand Up @@ -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) {
Expand Down
19 changes: 17 additions & 2 deletions Survey-Perl/root/auth.tt
@@ -1,7 +1,22 @@
<h1>Perl Survey 2009</h1>

<div class="formContainer">
<h1>Note</h1>

<p>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.</p>

<h1> Identify yourself </h1>
<p> 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.

<p> 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.

<form name="recaptcha" action="[% dest %]"
method="post">
[% recaptcha %]
<br/> <input type="submit" value="submit" /> </form>
</p>
</p>
</div>

0 comments on commit 44eadbd

Please sign in to comment.