1 package Sesse::pr0n::Listing;
5 use Sesse::pr0n::Common qw(error dberror);
9 my $dbh = Sesse::pr0n::Common::get_dbh();
12 if ($r->get_server_name =~ /internal/) {
13 my $user = Sesse::pr0n::Common::check_access($r);
14 if (!defined($user)) {
15 return Apache2::Const::OK;
19 # my $q = $dbh->prepare('SELECT t1.id,t1.date,t1.name FROM events t1 LEFT JOIN images t2 ON t1.id=t2.event WHERE t1.vhost=? GROUP BY t1.id,t1.date,t1.name ORDER BY COALESCE(MAX(t2.date),\'1970-01-01 00:00:00\'),t1.id') or
20 # dberror($r, "Couldn't list events");
21 my $q = $dbh->prepare('SELECT id,date,name FROM events WHERE vhost=? ORDER BY last_picture DESC')
22 or dberror($r, "Couldn't list events");
23 $q->execute($r->get_server_name)
24 or dberror($r, "Couldn't get events");
26 $r->content_type('text/html; charset=utf-8');
29 Sesse::pr0n::Common::header($r, Sesse::pr0n::Templates::fetch_template($r, 'event-listing'));
32 while (my $ref = $q->fetchrow_hashref()) {
33 my $id = $ref->{'id'};
34 my $date = $ref->{'date'};
35 my $name = $ref->{'name'};
37 $r->print(" <li><a href=\"$id/\">$name</a> ($date)</li>\n");
40 $r->print(" </ul>\n");
41 Sesse::pr0n::Common::footer($r);
44 return Apache2::Const::OK;