###############################################################################
# Downloads.pl #
###############################################################################
# YaBB: Yet another Bulletin Board #
# Open-Source Community Software for Webmasters #
# Version: YaBB 2.4 #
# Packaged: April 12, 2009 #
# Distributed by: http://www.yabbforum.com #
# =========================================================================== #
# Copyright (c) 2000-2009 YaBB (www.yabbforum.com) - All Rights Reserved. #
# Software by: The YaBB Development Team #
# with assistance from the YaBB community. #
# Sponsored by: Xnull Internet Media, Inc. - http://www.ximinc.com #
# Your source for web hosting, web design, and domains. #
###############################################################################
$downloadsplver = 'YaBB 2.4 $Revision$';
if ($GLOBAL::ACTION eq 'detailedversion') { return 1; }
sub DownloadView {
&fatal_error("members_only") if $guest_media_disallowed && $iamguest;
&LoadLanguage('FA');
&print_output_header;
$output = qq~
~;
my $thread = $INFO{'thread'};
unless (ref($thread_arrayref{$thread})) {
@{$thread_arrayref{$thread}} = &read_DBorFILE(0,'',$datadir,$thread,'txt');
}
my $threadname = (split(/\|/, ${$thread_arrayref{$thread}}[0], 2))[0];
my @attachinput = map { split(/,/, (split(/\|/, $_))[12]) } @{$thread_arrayref{$thread}};
chomp(@attachinput);
my (%attachinput,$viewattachments);
map { $attachinput{$_} = 1; } @attachinput;
@attachinput = grep { $_ =~ /$thread\|.+\|(.+)\|\d+\s+/ && exists $attachinput{$1} } &read_DBorFILE(0,'',$vardir,'attachments','txt');
my $max = @attachinput;
my $sort = $INFO{'sort'} || ((($ttsureverse && ${$uid.$username}{'reversetopic'}) || $ttsreverse) ? -1 : 1);
my $newstart = $INFO{'newstart'} || 0;
my $colspan = ($iamadmin || $iamgmod) ? 8 : 7;
if (!$max) {
$viewattachments .= qq~
| $fatxt{'48'} |
| $fatxt{'70'} "$threadname" | $fatxt{'71'} |
~;
} else {
if ($iamadmin || $iamgmod) {
&LoadLanguage('Admin');
$output .= qq~
' if $max && ($iamadmin || $iamgmod);
$output .= qq~
~;
&print_HTML_output_and_finish;
}
sub DownloadFileCouter {
$dfile = $INFO{'file'};
if ($guest_media_disallowed && $iamguest) { &fatal_error("",$maintxt{'40'}); }
if (!&checkfor_DBorFILE("$uploaddir/$dfile")) { &fatal_error("","$dfile $maintxt{'23'}"); }
my @attachments = &read_DBorFILE(0,ATM,$vardir,'attachments','txt');
for (my $a = 0; $a < @attachments; $a++) {
$attachments[$a] =~ s/(.+\|)(.+)\|(\d+)(\s+)$/ $1 . ($dfile eq $2 ? "$2|" . ($3 + 1) : "$2|$3") . $4 /e;
}
&write_DBorFILE(0,ATM,$vardir,'attachments','txt',@attachments);
print "Location: $uploadurl/$dfile\n\r\n\r";
exit;
}
1;