###############################################################################
# Display.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. #
###############################################################################
$displayplver = 'YaBB 2.4 $Revision$';
if ($GLOBAL::ACTION eq 'detailedversion') { return 1; }
&LoadLanguage('Display');
&LoadLanguage('FA');
require "$templatesdir/$usedisplay/Display.template";
if ($iamgmod) { require "$vardir/gmodsettings.txt"; }
sub Display {
# Check if board was 'shown to all' - and whether they can view the topic
if (&AccessCheck($currentboard, '', $boardperms) ne "granted") { &fatal_error("no_access"); }
# Get the "NEW"est Post for this user.
my $newestpost;
if (!$iamguest && $max_log_days_old && $INFO{'start'} eq "new") {
# This decides which messages were already read in the thread to
# determing where the redirect should go. It is done by
# comparing times in the username.log and the boardnumber.txt files.
&getlog;
my $mnum = $INFO{'num'};
my $dlp = int($yyuserlog{$mnum}) > int($yyuserlog{"$currentboard--mark"}) ? int($yyuserlog{$mnum}) : int($yyuserlog{"$currentboard--mark"});
$dlp = $dlp > $date - ($max_log_days_old * 86400) ? $dlp : $date - ($max_log_days_old * 86400);
unless (ref($thread_arrayref{$mnum})) {
@{$thread_arrayref{$mnum}} = &read_DBorFILE(0,'',$datadir,$mnum,'txt');
}
my $i = -1;
foreach (@{$thread_arrayref{$mnum}}) {
$i++;
last if (split(/\|/, $_))[3] > $dlp;
}
$newestpost = $INFO{'start'} = $i;
}
if ($buddyListEnabled) { &loadMyBuddy; }
my $viewnum = $INFO{'num'};
# strip off any non numeric values to avoid exploitation
$maxmessagedisplay ||= 10;
my ($msubthread, $mnum, $mstate, $mdate, $msub, $mname, $memail, $mreplies, $musername, $micon, $mip, $mlm, $mlmb);
my ($counter, $counterwords, $threadclass, $notify, $max, $start, $windowbg, $mreplyno, $pagedropindex, $template_viewers, $template_favorite, $template_pollmain, $navback, $mark_unread, $pollbutton, $icanbypass, $replybutton, $bypassReplyButton);
&LoadCensorList;
# Determine category
$curcat = ${$uid.$currentboard}{'cat'};
if ($currentboard eq $annboard) {
$vircurrentboard = $INFO{'virboard'};
$vircurcat = ${$uid.$vircurrentboard}{'cat'};
($vircat, undef) = split(/\|/, $catinfo{$vircurcat});
($virboardname, undef) = split(/\|/, $board{$vircurrentboard},2);
&ToChars($virboardname);
}
($cat, $catperms) = split(/\|/, $catinfo{"$curcat"});
&ToChars($cat);
($boardname, $boardperms, $boardview) = split(/\|/, $board{$currentboard});
&ToChars($boardname);
# Check to make sure this thread isn't locked.
($mnum, $msubthread, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate) = split(/\|/, $yyThreadLine);
if ($mstate =~ /m/) {
$msubthread =~ / dest=(\d+)\]/;
my $newnum = $1;
if (&checkfor_DBorFILE("$datadir/$newnum.txt")) {
$yySetLocation = "$scripturl?num=$newnum";
&redirectexit;
}
eval { require "$datadir/movedthreads.cgi" };
while (exists $moved_file{$newnum}) {
$newnum = $moved_file{$newnum};
next if exists $moved_file{$newnum};
if (&checkfor_DBorFILE("$datadir/$newnum.txt")) {
$yySetLocation = "$scripturl?num=$newnum";
&redirectexit;
}
}
}
($msubthread, undef) = &Split_Splice_Move($msubthread,0);
&ToChars($msubthread);
$msubthread = &Censor($msubthread);
# Build a list of this board's moderators.
if (keys %moderators > 0) {
if (keys %moderators == 1) { $showmods = qq~($display_txt{'298'}: ~; }
else { $showmods = qq~($display_txt{'63'}: ~; }
while ($_ = each(%moderators)) {
&FormatUserName($_);
$showmods .= &QuickLinks($_,1) . ", ";
}
$showmods =~ s/, \Z/)/;
}
if (keys %moderatorgroups > 0) {
if (keys %moderatorgroups == 1) { $showmodgroups = qq~($display_txt{'298a'}: ~; }
else { $showmodgroups = qq~($display_txt{'63a'}: ~; }
my ($tmpmodgrp,$thismodgrp);
while ($_ = each(%moderatorgroups)) {
$tmpmodgrp = $moderatorgroups{$_};
($thismodgrp, undef) = split(/\|/, $NoPost{$tmpmodgrp}, 2);
$showmodgroups .= qq~$thismodgrp, ~;
}
$showmodgroups =~ s/, \Z/)/;
}
## now we've established credentials,
## can this user bypass locks?
## work out who can bypass locked thread
if ($mstate =~ /l/i) {
$icanbypass = &checkUserLockBypass;
$enable_quickreply = 0;
} elsif ($staff) {
$icanbypass = 2;
}
my $permdate = &permtimer($mnum);
my $display_permalink = qq~$display_txt{'10'}~;
# Look for a poll file for this thread.
if (&AccessCheck($currentboard, 3) eq 'granted') {
$pollbutton = qq~$menusep$img{'addpoll'}~;
}
if (&checkfor_DBorFILE("$datadir/$viewnum.poll")) {
$has_poll = 1;
$pollbutton = '';
} else {
$has_poll = 0;
if ($useraddpoll == 0) { $pollbutton = ''; }
}
# Get the class of this thread, based on lock status and number of replies.
if ((!$iamguest || $enable_guestposting) && &AccessCheck($currentboard, 2) eq 'granted') {
$replybutton = qq~$menusep$img{'reply'} ~;
$replybutton .= qq~">$img{'reply'} ~;
}
$threadclass = 'thread';
## hidden threads
if ($mstate =~ /h/i) {
$threadclass = 'hide';
if (!$staff) { &fatal_error('no_access'); }
}
## locked thread
elsif ($mstate =~ /l/i) {
$threadclass = 'locked'; ## same icon regardless
$pollbutton = '';
if ($icanbypass) { $replybutton = $bypassReplyButton; }
else { $replybutton = ''; } # squish
}
elsif ($mreplies >= $VeryHotTopic) { $threadclass = 'veryhotthread'; }
elsif ($mreplies >= $HotTopic) { $threadclass = 'hotthread'; }
elsif ($mstate eq '') { $threadclass = 'thread'; }
if ($threadclass eq 'hide') { ## hidden
if ($mstate =~ /s/i && $mstate !~ /l/i) { $threadclass = 'hidesticky'; }
elsif ($mstate =~ /l/i && $mstate !~ /s/i) {
$threadclass = 'hidelock'; $pollbutton = '';
if ($icanbypass) { $replybutton = $bypassReplyButton; }
else { $replybutton = ''; } # squish
}
elsif ($mstate =~ /s/i && $mstate =~ /l/i) {
$threadclass = 'hidestickylock'; $pollbutton = '';
if ($icanbypass) { $replybutton = $bypassReplyButton; }
else { $replybutton = ''; } # squish
}
}
elsif ($threadclass eq 'locked' && $mstate =~ /s/i) {
$threadclass = 'stickylock';
if ($icanbypass) { $replybutton = $bypassReplyButton; }
else { $replybutton = ''; } # squish
}
elsif ($mstate =~ /s/i) { $threadclass = 'sticky'; }
elsif (${$mnum}{'board'} eq $annboard) { $threadclass = $threadclass eq 'locked' ? 'announcementlock' : 'announcement'; }
if (!$iamguest && &checkfor_DBorFILE("$datadir/$mnum.mail")) {
require "$sourcedir/Notify.pl";
&ManageThreadNotify("update", $mnum, $username, '', '', 1);
}
if ($showmodgroups ne "" && $showmods ne "") { $showmods .= qq~ - ~; }
# Build the page links list.
if (!$iamguest) {
(undef, $userthreadpage, undef) = split(/\|/, ${$uid.$username}{'pageindex'}, 3);
}
my ($pagetxtindex, $pagetextindex, $pagedropindex1, $pagedropindex2, $all, $allselected);
$postdisplaynum = 3; # max number of pages to display
$dropdisplaynum = 10;
$startpage = 0;
$max = $mreplies + 1;
if (substr($INFO{'start'}, 0, 3) eq 'all' && $showpageall != 0) { $maxmessagedisplay = $max; $all = 1; $allselected = qq~ selected="selected"~; $start = !$ttsreverse ? 0 : $mreplies; }
else { $start = $INFO{'start'} !~ /\d/ ? (!$ttsreverse ? 0 : $mreplies) : $INFO{'start'}; }
$start = $start > $mreplies ? $mreplies : $start;
$start = !$ttsreverse ? (int($start / $maxmessagedisplay) * $maxmessagedisplay) : (int(($mreplies - $start) / $maxmessagedisplay) * $maxmessagedisplay);
$tmpa = 1;
$pagenumb = int(($max - 1) / $maxmessagedisplay) + 1;
if ($start >= (($postdisplaynum - 1) * $maxmessagedisplay)) {
$startpage = $start - (($postdisplaynum - 1) * $maxmessagedisplay);
$tmpa = int($startpage / $maxmessagedisplay) + 1;
}
if ($max >= $start + ($postdisplaynum * $maxmessagedisplay)) { $endpage = $start + ($postdisplaynum * $maxmessagedisplay); }
else { $endpage = $max; }
$lastpn = int($mreplies / $maxmessagedisplay) + 1;
$lastptn = ($lastpn - 1) * $maxmessagedisplay;
$pageindex1 = qq~
$display_txt{'139'}: $pagenumb~;
$pageindex2 = $pageindex1;
if ($pagenumb > 1 || $all) {
if ($userthreadpage == 1 || $iamguest) {
$pagetxtindexst = qq~~;
if (!$iamguest) { $pagetxtindexst .= qq~
$display_txt{'139'}: ~; }
else { $pagetxtindexst .= qq~
$display_txt{'139'}: ~; }
if ($startpage > 0) { $pagetxtindex = qq~1 ... ~; }
if ($startpage == $maxmessagedisplay) { $pagetxtindex = qq~1 ~; }
for ($counter = $startpage; $counter < $endpage; $counter += $maxmessagedisplay) {
$pagetxtindex .= $start == $counter ? qq~$tmpa ~ : qq~$tmpa ~;
$tmpa++;
}
if ($endpage < $max - ($maxmessagedisplay)) { $pageindexadd = qq~... ~; }
if ($endpage != $max) { $pageindexadd .= qq~$lastpn~; }
$pagetxtindex .= qq~$pageindexadd~;
$pageindex1 = qq~$pagetxtindexst$pagetxtindex~;
$pageindex2 = $pageindex1;
} else {
$pagedropindex1 = qq~~;
$pagedropindex1 .= qq~
~;
$pagedropindex2 = $pagedropindex1;
$tstart = $start;
#if (substr($INFO{'start'}, 0, 3) eq "all") { ($tstart, $start) = split(/\-/, $INFO{'start'}); }
$d_indexpages = $pagenumb / $dropdisplaynum;
$i_indexpages = int($pagenumb / $dropdisplaynum);
if ($d_indexpages > $i_indexpages) { $indexpages = int($pagenumb / $dropdisplaynum) + 1; }
else { $indexpages = int($pagenumb / $dropdisplaynum) }
$selectedindex = int(($start / $maxmessagedisplay) / $dropdisplaynum);
if ($pagenumb > $dropdisplaynum) {
$pagedropindex1 .= qq~\n~;
}
$pagedropindex1 .= qq~ ~;
$pagedropindex2 .= qq~ ~;
$tmpmaxmessagedisplay = $maxmessagedisplay;
$prevpage = !$ttsreverse ? $start - $tmpmaxmessagedisplay : $mreplies - $start + $tmpmaxmessagedisplay;
$nextpage = !$ttsreverse ? $start + $maxmessagedisplay : $mreplies - $start - $maxmessagedisplay;
$pagedropindexpvbl = qq~
~;
$pagedropindexnxbl = qq~
~;
if ((!$ttsreverse and $start < $maxmessagedisplay) or ($ttsreverse and $prevpage > $mreplies)) { $pagedropindexpv .= qq~
~; }
else { $pagedropindexpv .= qq~
~; }
if ((!$ttsreverse and $nextpage > $lastptn) or ($ttsreverse and $nextpage < $mreplies - $lastptn)) { $pagedropindexnx .= qq~
~; }
else { $pagedropindexnx .= qq~
~; }
$pageindex1 = qq~$pagedropindex1~;
$pageindex2 = qq~$pagedropindex2~;
$pageindexjs = qq~
function SelDec(decparam, visel) {
splitparam = decparam.split("|");
var vistart = parseInt(splitparam[0]);
var viend = parseInt(splitparam[1]);
var maxpag = parseInt(splitparam[2]);
var pagstart = parseInt(splitparam[3]);
//var allpagstart = parseInt(splitparam[3]);
if(visel == 'xx' && decparam == '$pagejsindex') visel = '$tstart';
var pagedropindex = '
| ' + i + ' | '; else pagedropindex += '' + i + ' | '; pagstart ~ . (!$ttsreverse ? '+' : '-') . qq~= maxpag; } ~; if ($showpageall) { $pageindexjs .= qq~ if (vistart != viend) { if(visel == 'all') pagedropindex += '$pidtxt{'01'} | '; else pagedropindex += '$pidtxt{'01'} | '; } ~; } $pageindexjs .= qq~ if(visel != 'xx') pagedropindex += '$pagedropindexpv$pagedropindexnx | '; else pagedropindex += '$pagedropindexpvbl$pagedropindexnxbl | '; pagedropindex += '
~;
$template_sendtopic = $sendtopicmail ? qq~$menusep$img{'sendtopic'}~ : '';
$template_print = qq~$menusep$img{'print'}~;
if ($has_poll) { require "$sourcedir/Poll.pl"; &display_poll($viewnum); $template_pollmain = qq~$pollmain
$usernamelink~ if $enable_quickreply && $enable_quoteuser && (!$iamguest || $enable_guestposting);
if (!$movedflag || $staff) {
if ($enable_quickreply) {
$quote_mname = $useraccount{$musername};
$quote_mname =~ s/'/\\'/g;
if ($enable_markquote) {
$outblock =~ s/(