#!/usr/bin/perl use lib "../lib"; use Bucky; my $bucky = new Bucky; my $threads = $bucky->db->select("thread"); foreach my $thread (@$threads) { next if $thread->{'flagged'}; my $threadid = $thread->{'id'}; my $files = $bucky->db->select("file", { thread => $threadid }); foreach my $file (@$files) { if ($file->{'filename'} =~ /(gif|jpg)$/i) { my $id = $file->{'id'}; $bucky->db->execute("UPDATE threads SET flagged=$id WHERE id=$threadid"); } } }