Fix some Perl deprecation warnings. Patches from xim.
[pr0n] / perl / Sesse / pr0n / Select.pm
index 21dca6a662611418a828abe2d4d06647e0de432d..53dc8a019d7695eee5e6fe83b682302800c7f338 100644 (file)
@@ -23,30 +23,18 @@ sub handler {
                local $dbh->{AutoCommit} = 0;
                local $dbh->{RaiseError} = 1;
 
-               if (defined($apr->param('mode')) && $apr->param('mode') eq 'single') {
-                       # single mode; enable one (FIXME: need to support disable too)
-                       my $filename = $apr->param('filename');
-                       $dbh->do('UPDATE images SET selected=\'t\' WHERE event=? AND filename=?', undef, $event, $filename);
-               } else {
-                       # traditional multi-mode
-                       $dbh->do('UPDATE images SET selected=\'f\' WHERE event=?', undef, $event);
-               
-                       my @params = $apr->param();
-                       my $key;
-                       for $key (@params) {
-                               if ($key =~ /^sel-(\d+)/ && $apr->param($key) eq 'on') {
-                                       my $id = $1;
-                                       my $q = $dbh->do('UPDATE images SET selected=\'t\' WHERE id=?', undef, $id)
-                                               or dberror($r, "Selection of $id failed: $!");
-                                       $r->print("    <p>Selected image ID `$id'.</p>\n");
-                               }
-                       }
+               my $filename = $apr->param('filename');
+               my $selected = $apr->param('selected');
+               my $sql_selected = 'f';
+               if (!defined($selected) || $selected eq '1') {
+                       $sql_selected = 't';
                }
+               $dbh->do('UPDATE images SET selected=? WHERE vhost=? AND event=? AND filename=?', undef, $sql_selected, $r->get_server_name, $event, $filename);
        }
 
-       $dbh->do('UPDATE events SET last_update=CURRENT_TIMESTAMP WHERE id=?', undef, $event)
+       $dbh->do('UPDATE last_picture_cache SET last_update=CURRENT_TIMESTAMP WHERE vhost=? AND event=?', undef, $r->get_server_name, $event)
                or dberror($r, "Cache invalidation failed");
-
+       Sesse::pr0n::Common::purge_cache($r, "/$event/");
        Sesse::pr0n::Common::footer($r);
 
        return Apache2::Const::OK;