############################################################################### # 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~ $fatxt{'39'}  


~; 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~
~; } else { $output .= qq~ ~; } $output .= qq~ ~; my @attachments; if ($sort > 0) { # sort ascending if ($sort == 1 || $sort == 5 || $sort == 6 || $sort == 8) { @attachments = sort { (split(/\|/, $a))[$sort] <=> (split(/\|/, $b))[$sort]; } @attachinput; # sort size, date, count numerically } elsif ($sort == 100) { @attachments = sort { lc((split(/\./, (split(/\|/, $a))[7]))[1]) cmp lc((split(/\./, (split(/\|/, $b))[7]))[1]); } @attachinput; # sort extension lexically } else { @attachments = sort { lc((split(/\|/, $a))[$sort]) cmp lc((split(/\|/, $b))[$sort]); } @attachinput; # sort lexically } } else { # sort descending if ($sort == -1 || $sort == -5 || $sort == -6 || $sort == -8) { @attachments = sort { (split(/\|/, $b))[-$sort] <=> (split(/\|/, $a))[-$sort]; } @attachinput; # sort size, date, count numerically } elsif ($sort == -100) { @attachments = sort { lc((split(/\./, (split(/\|/, $b))[7]))[1]) cmp lc((split(/\./, (split(/\|/, $a))[7]))[1]); } @attachinput; # sort extension lexically } else { @attachments = sort { lc((split(/\|/, $b))[-$sort]) cmp lc((split(/\|/, $a))[-$sort]); } @attachinput; # sort lexically } } $postdisplaynum = 8; $newstart = (int($newstart / 25)) * 25; $tmpa = 1; if ($newstart >= (($postdisplaynum - 1) * 25)) { $startpage = $newstart - (($postdisplaynum - 1) * 25); $tmpa = int( $startpage / 25 ) + 1; } if ($max >= $newstart + ($postdisplaynum * 25)) { $endpage = $newstart + ($postdisplaynum * 25); } else { $endpage = $max; } if ($startpage > 0) { $pageindex = qq~1 ... ~; } if ($startpage == 25) { $pageindex = qq~1 ~;} for ($counter = $startpage; $counter < $endpage; $counter += 25) { $pageindex .= $newstart == $counter ? qq~$tmpa ~ : qq~$tmpa ~; $tmpa++; } $lastpn = int($max / 25) + 1; $lastptn = ($lastpn - 1) * 25; if ($endpage < $max - (25) ) { $pageindexadd = qq~... ~; } if ($endpage != $max) { $pageindexadd .= qq~$lastpn~; } $pageindex .= $pageindexadd; $pageindex = qq~
$fatxt{'64'}: $pageindex
~; $numbegin = ($newstart + 1); $numend = ($newstart + 25); if ($numend > $max) { $numend = $max; } if ($max == 0) { $numshow = ''; } else { $numshow = qq~($numbegin - $numend)~; } my (%attach_gif,$ext); foreach $row (splice(@attachments, $newstart, 25)) { chomp $row; my ($amthreadid, $amreplies, $amthreadsub, $amposter, $amcurrentboard, $amkb, $amdate, $amfn, $amcount) = split(/\|/, $row); $amfn =~ /\.(.+?)$/; $ext = $1; unless (exists $attach_gif{$ext}) { $attach_gif{$ext} = ($ext && -e "$forumstylesdir/$useimages/$ext.gif") ? "$ext.gif" : "paperclip.gif"; } $amdate = &timeformat($amdate); if (length($amthreadsub) > 20) { $amthreadsub = substr($amthreadsub, 0, 20) . "..."; } $viewattachments .= qq~~ . (($iamadmin || $iamgmod) ? qq~ ~ : '') . qq~ $amfn $amkb KB $amdate $amcount $amthreadsub $amposter ~; } $viewattachments .= qq~~ . (($iamadmin || $iamgmod) ? qq~ ~ : '') . qq~
~ . (($iamadmin || $iamgmod) ? qq~<= $amv_txt{'38'}   ~ : ' ') . qq~   $fatxt{'70'} "$threadname"   |   $fatxt{'71'}   $pageindex
~; $output .= qq~ ~; } my $class_sortattach = $sort =~ /7/ ? 'windowbg2' : 'windowbg'; my $class_sorttype = $sort =~ /100/ ? 'windowbg2' : 'windowbg'; my $class_sortsize = $sort =~ /5/ ? 'windowbg2' : 'windowbg'; my $class_sortdate = $sort =~ /6/ ? 'windowbg2' : 'windowbg'; my $class_sorcount = $sort =~ /8/ ? 'windowbg2' : 'windowbg'; my $class_sortsubj = $sort =~ /1$/ ? 'windowbg2' : 'windowbg'; my $class_sortuser = $sort =~ /3/ ? 'windowbg2' : 'windowbg'; $output .= qq~ ~ . (($iamadmin || $iamgmod) ? qq~ ~ : '') . qq~ $viewattachments
 $fatxt{'39'}

$fatxt{'75'}:
"$threadname"

$fatxt{'76'}
$fatxt{'28'} $max $numshow
$pageindex
$fatxt{'45'}$fatxt{'40'} $fatxt{'40a'} $fatxt{'41'} $fatxt{'43'} $fatxt{'41a'} $fatxt{'44'} $fatxt{'42'}
~; $output .= '
' 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;