blob: ba51e4db04c2c97b9e39411f3a2cf1423b337316 (
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
#!/usr/bin/perl
#########################################
# services_f
# feeds bPod the file list for a valid thread
#########################################
use localbucky;
$dbh = DBI->connect ($dsn);
our $KWAREZ = $BUCKY_CONFIG->{BPOD_SERVICES_WAREZ_DIR};
our ($USER, $lastlog) = checkin();
our $logged_in = ($USER != -1);
# this start/end shit is all broken anyway
#my $start = $input->{s};
#my $end = $input->{e};
my $pid = $input->{pid};
print "Content-type: text/html\r\n\r\n";
my $thread = get_thread( $pid );
my $keyword = get_keyword( $thread->{keyword} );
exit unless check_privacy( $thread, $keyword );
my $files = get_files( $pid );
my $numItems = @$files;
my $returnString = " &numItems=" . ($numItems );
@$files = sort{ lc($a->{filename}) cmp lc($b->{filename}) } @$files;
my $fileCount = 0;
foreach my $file_row (@$files)
{
$returnString .= "&filetype$fileCount=" . fileEXT($file_row->{filename});
$returnString .= "&filename$fileCount=" . lc($file_row->{filename});
$returnString .= "&username$fileCount=" . $file_row->{username};
$returnString .= "&date$fileCount=" . $file_row->{date};
$returnString .= "&url$fileCount=" . $KWAREZ . $file_row->{thread} ."/". spaceReplace($file_row->{filename});
$returnString .= "&size$fileCount=" . sizeinK($file_row->{size});
$fileCount++;
}
print $returnString ;
exit;
sub fileEXT
{
my $filename = shift;
$filename =~ s/.+\.//;
return uc($filename);
}
sub spaceReplace
{
my $filename = shift;
$filename =~ s/\ /\%20/g;
return $filename;
}
sub sizeinK
{
my $bytes = shift;
my $size = $bytes / 1024;
if ( $size < 1024 )
{
$size = sprintf "%2.2f", $size;
$size .= "k";
}
elsif ( $size / 1024 < 1024 )
{
$size = sprintf "%2.2f", $size / 1024;
$size .= "mb";
}
elsif ( $size / 1024 / 1024 < 1024 )
{
$size = sprintf "%2.2f", $size / 1024 / 1024;
$size .= " GB";
}
return $size;
}
|