Make /select purge cache.
[pr0n] / perl / Sesse / pr0n / Wizard.pm
1 package Sesse::pr0n::Wizard;
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
13         # Internal? (Ugly?)
14         if ($r->get_server_name =~ /internal/ || $r->get_server_name =~ /skoyen\.bilder\.knatten\.com/ || $r->get_server_name =~ /lia\.heimdal\.org/) {
15                 my $user = Sesse::pr0n::Common::check_access($r);
16                 if (!defined($user)) {
17                         return Apache2::Const::OK;
18                 }
19         }
20
21         # Find events
22         my $q = $dbh->prepare('SELECT event,date,name FROM events e JOIN last_picture_cache c USING (vhost,event) WHERE vhost=? ORDER BY last_picture DESC')
23                 or dberror($r, "Couldn't list events");
24         $q->execute($r->get_server_name)
25                 or dberror($r, "Couldn't get events");
26
27         $r->content_type('text/html; charset=utf-8');
28         $r->print(Sesse::pr0n::Templates::fetch_template($r, 'wizard-header'));
29         
30         while (my $ref = $q->fetchrow_hashref()) {
31                 my $id = $ref->{'event'};
32                 my $date = $ref->{'date'};
33                 my $name = $ref->{'name'};
34                 
35                 $r->print("              <option value=\"$id\">$name</option>\n");
36         }
37
38         $r->print(Sesse::pr0n::Templates::fetch_template($r, 'wizard-footer'));
39
40         return Apache2::Const::OK;
41 }
42         
43 1;
44
45