]> git.sesse.net Git - pr0n/blob - perl/Sesse/pr0n/Select.pm
Add Escape as a shortcut for closing fullscreen.
[pr0n] / perl / Sesse / pr0n / Select.pm
1 package Sesse::pr0n::Select;
2 use strict;
3 use warnings;
4
5 use Sesse::pr0n::Common qw(error dberror);
6 use Apache2::Request;
7
8 sub handler {
9         my $r = shift;
10         my $apr = Apache2::Request->new($r);
11         my $dbh = Sesse::pr0n::Common::get_dbh();
12         my ($user, $takenby) = Sesse::pr0n::Common::check_access($r);
13         if (!defined($user)) {
14                 return Apache2::Const::OK;
15         }
16
17         my $event = $apr->param('event');
18
19         Sesse::pr0n::Common::header($r, "Selection results");
20
21         {
22                 # Enable transactions and error raising temporarily
23                 local $dbh->{AutoCommit} = 0;
24                 local $dbh->{RaiseError} = 1;
25
26                 $dbh->do('UPDATE images SET selected=\'f\' WHERE event=?', undef, $event);
27
28                 my @params = $apr->param();
29                 my $key;
30                 for $key (@params) {
31                         if ($key =~ /^sel-(\d+)/ && $apr->param($key) eq 'on') {
32                                 my $id = $1;
33                                 my $q = $dbh->do('UPDATE images SET selected=\'t\' WHERE id=?', undef, $id)
34                                         or dberror($r, "Selection of $id failed: $!");
35                                 $r->print("    <p>Selected image ID `$id'.</p>\n");
36                         }
37                 }
38         }
39
40         Sesse::pr0n::Common::footer($r);
41
42         return Apache2::Const::OK;
43 }
44
45 1;
46
47