#!/usr/bin/perl use lib "../../lib"; use Bucky; use Bucky::Session; my $bucky = new Bucky; my $session = new Bucky::Session; my $id = $session->param('id'); print "Content-type: text/plain\n\n"; if (length $id && $id !~ /\D/) { my $thread = $bucky->db->select("thread", "id='$id'"); my $files = $bucky->db->select("file", "thread='$id' order by filename asc"); my $comment = $bucky->db->select("comment", "thread='$id' order by id asc"); exit unless ref($thread) == "ARRAY"; my $t = shift @$thread; my $flagged = $t->{'flagged'}; my @result = (); my $i = 0; my $count = 0; foreach my $file (@$files) { if (! $flagged && $file->{'filename'} =~ /(jpg|jpeg|gif|png)/i) { $flagged = $file->{'id'}; } $file->{'filename'} =~ /\.(...)$/i; $file->{'type'} = lc $1 || next; $file->{'title'} = $file->{'filename'}; $file->{'title'} =~ s/\.(...)$//; $file->{'title'} =~ s/_/ /g; $file->{'title'} =~ s/-/ /g; $file->{'title'} =~ s/\s+/ /g; $file->{'title'} =~ s/^\s//; $file->{'title'} =~ s/\s$//; push @result, join("\t", @$file{qw[id type filename title date size]}); } if (ref($comment) == "ARRAY" && scalar(@$comment)) { my $c = shift @$comment; my $words = $c->{'comment'}; $words =~ s/\n//g; $words =~ s/\r//g; push @result, $c->{id}."\tcomment\t".$c->{username}."\t".$c->{date}."\t".$words; } $t->{'flagged'} ||= $flagged; print join "\t", @$t{qw[id title flagged createdate username keyword]}; print "\n"; print join "\n", @result; print "\n"; } else { print "\n"; } 1;