blob: 3c7def9a6cfbf3a572b0dae73b45a6c5ce01e30b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#!/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/<br\/>/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;
|