Fix some Perl deprecation warnings. Patches from xim.
[pr0n] / perl / Sesse / pr0n / Select.pm
index 1086587ae77769df03fbf93864e662de94d370ba..53dc8a019d7695eee5e6fe83b682302800c7f338 100644 (file)
@@ -23,20 +23,18 @@ sub handler {
                local $dbh->{AutoCommit} = 0;
                local $dbh->{RaiseError} = 1;
 
-               $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 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;