summaryrefslogtreecommitdiff
path: root/bucky2/t/flag-images.pl
blob: 7962cab59e1d9fab5dca12462877dfcf3847064d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/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");
			}
		}
	}