###############################################################################
# Display.pm #
# $Date: 06.01.17 $ #
###############################################################################
# YaBB: Yet another Bulletin Board #
# Open-Source Community Software for Webmasters #
# Version: YaBB 2.7.00 #
# Packaged: June 1, 2017 #
# Distributed by: http://www.yabbforum.com #
# =========================================================================== #
# Copyright (c) 2000-2017 YaBB (www.yabbforum.com) - All Rights Reserved. #
# Software by: The YaBB Development Team #
# with assistance from the YaBB community. #
###############################################################################
use strict;
no strict qw(refs);
use warnings;
use CGI::Carp qw(fatalsToBrowser);
our $VERSION = '2.7.00';
our $displaypmver = 'YaBB 2.7.00 $Revision$';
our @displaypmmods = ();
our $displaypmmods = 0;
if (@displaypmmods) {
$displaypmmods = 1;
}
our ($action);
$action ||= q{};
if ( $action eq 'detailedversion' ) { return 1; }
## language ##
our (
$abbr_lang, %att_img, %bookmarks, %croak,
%display_txt, %fatxt, %img, %img_txt,
%index_togl, %maintxt, %micon, %micon_bg,
%pidtxt, %sendtopic_txt, %tmpimg,
);
## locations ##
our (
$scripturl, $datadir, $imagesdir, $memberdir, $vardir,
$htmldir, $uploaddir, $uploadurl, $yyhtml_root, $boardsdir,
$sendtopicemail, $modimgurl, $boardurl
);
## settings ##
our (
$accept_permafull, $accept_permalink,
$allow_hide_email, $allowpics,
$amdisplaypics, $bm_boards,
$bm_subcut, $bypass_lock_perm,
$cookieviewtime, $en_bookmarks,
$enable_alert, $enable_buddylist,
$enable_guest_alert, $enable_guest_view_limit,
$enable_guestposting, $enable_markquote,
$enable_quickjump, $enable_quickreply,
$enable_quoteuser, $enable_ubbc,
$extendedprofiles, $guest_view_limit,
$guest_view_limit_block, $guestaccess,
$hide_signat_for_guests, $hot_topic,
$img_greybox, $ip_lookup,
$max_log_days_old, $maxmessagedisplay,
$mbname, $nestedquotes,
$perm_domain, $pm_level,
$ppostperms, $profilebutton,
$ptopicperms, $quick_quotelength,
$quoteuser_color, $showage,
$showmodify, $showpageall,
$showregdate, $showtopicviewers,
$showuserage, $showuserpic,
$symlink, $tllastmodflag,
$tllastmodtime, $tlnodelflag,
$tlnodeltime, $tlnomodday,
$tlnomodflag, $tlnomodtime,
$ttsreverse, $ttsureverse,
$user_hide_attach_img, $user_hide_avatars,
$user_hide_signat, $user_hide_user_text,
$useraddpoll, $very_hot_topic,
$yymycharset, $cookieusername,
$use_guardian, $use_htaccess
);
## system ##
our (
$annboard, $boardperms, $bot_name,
$cookieview, $currentboard, $date,
$gtalker, $gtalkuser, $iamadmin,
$iamfmod, $iamgmod, $iamguest,
$iammod, $mdadmin, $mdfmod,
$mdglobal, $mdmod, $menusep,
$messageclass, $msgcontrol, $nextlink,
$prevlink, $selecthtml, $sendtopicmail,
$sessionvalid, $showusertext, $staff,
$staff_reason, $tabsep, $uid,
$urlname, $use_menu_type, $useimages,
$usepost_tools, $user_ip, $user_reason,
$username, $usestyle, $usethread_tools,
$vircurrentboard, $yy_setcookies, $yy_setcookies1,
$yy_threadline, $yyjavascript, $yymain,
$yynavigation, $yysetlocation, $yytitle,
%addmembergroup, %board, %catinfo,
%FORM, %gmod_access2, %grp_nopost,
%INFO, %link, %memberinfo,
%memberstar, %moderatorgroups, %moderators,
%moved_file, %mybuddie, %subboard,
%thread_arrayref, %topicstart, %user_pm_level,
%useraccount, %usernames_life_quote, %yy_cookies,
%yy_udloaded, %yyuserlog, @logentries,
@repliers, %memberunfo, $quick_post,
);
## templates ##
our (
$adminhandellist, $contactlist, $disp_arrow_dn,
$disp_arrow_up, $disp_qquname, $display_template,
$guest_view_limit_w, $messageblock, $my_bookmarks,
$my_guest_limit, $mydisp_topicview, $outside_posttools,
$outside_threadtools, $pollmain, $posthandellist,
$threadhandellist, $threadhandellist1, $threadhandellist2,
$visel_0, $visel_1a, $visel_1b,
$visel_2a, $visel_3a, $visel_4,
);
## our Mod Hook ##
load_language('Display');
load_language('FA');
get_micon();
get_template('Display');
get_gmod();
## local ##
my $permbrd = q{};
my $permcat = q{};
if ($accept_permafull) {
$permbrd = qq~$perm_domain/$symlink/~ . 'brd_';
$permcat = qq~$perm_domain/$symlink/~ . 'cat_';
}
sub display_thread {
# Check if board was 'shown to all' - and whether they can view the topic
if ( access_check( $currentboard, q{}, $boardperms ) ne 'granted' ) {
fatal_error('no_access');
}
my $iambot = 0;
if ( $enable_guest_view_limit && $guestaccess ) {
no warnings;
my $user_host =
( gethostbyaddr pack( 'C4', split /[.]/xsm, $user_ip ), 2 )[0];
if ( -e "$vardir/BotsHosts.pm" ) {
our (%botname);
require Variables::BotsHosts;
foreach my $i ( keys %botname ) {
if ( $botname{$i} && $user_host =~ /$i/ixsm ) {
$iambot = 1;
last;
}
}
}
}
my $gtvlcount = 1;
my $guest_view_limit_warn = q{};
if (
$enable_guest_view_limit
&& $iamguest
&& !$iambot
&& ( !$yy_cookies{$cookieview}
|| $yy_cookies{$cookieview} < $guest_view_limit )
)
{
if ( $yy_cookies{$cookieview} ) {
$gtvlcount = $yy_cookies{$cookieview};
$gtvlcount =~ s/\D//gxsm;
$gtvlcount++;
}
else {
$gtvlcount = 1;
}
my $guest_view_limit_clength = q{+} . $cookieviewtime . 'm';
$yy_setcookies1 = write_cookie(
-path => q{/},
-name => $cookieview,
-value => $gtvlcount,
-expires => $guest_view_limit_clength
);
}
elsif (
$enable_guest_view_limit
&& $iamguest
&& !$iambot
&& ( $yy_cookies{$cookieview}
&& $yy_cookies{$cookieview} >= $guest_view_limit )
)
{
if ($guest_view_limit_block) {
$yytitle = $display_txt{'guest_message'};
$yynavigation = qq~› $display_txt{'guest_message'}~;
$yymain .= $my_guest_limit;
$yymain =~
s/\Q{yabb display_txt_guest_message}\E/$display_txt{'guest_message'}/xsm;
$yymain =~
s/\Q{yabb display_txt_guest_message_block}\E/$display_txt{'guest_message_block'}/xsm;
template();
exit;
}
else {
$guest_view_limit_warn = $guest_view_limit_w;
$guest_view_limit_warn =~
s/\Q{yabb display_txt_guest_message}\E/$display_txt{'guest_message'}/xsm;
$guest_view_limit_warn =~
s/\Q{yabb display_txt_guest_message_warn}\E/$display_txt{'guest_message_warn'}/xsm;
}
}
my $newestpost = q{};
if ( !$iamguest
&& $max_log_days_old
&& ( $INFO{'start'} && $INFO{'start'} eq 'new' ) )
{
# This decides which messages were already read in the thread to
# determining 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 = 0;
if (
!$yyuserlog{"$currentboard--mark"}
|| ( $yyuserlog{$mnum}
&& $yyuserlog{"$currentboard--mark"}
&& int( $yyuserlog{$mnum} ) >
int $yyuserlog{"$currentboard--mark"} )
)
{
$dlp = int $yyuserlog{$mnum};
}
else { $dlp = int $yyuserlog{"$currentboard--mark"}; }
$dlp =
$dlp > $date - ( $max_log_days_old * 86400 )
? $dlp
: $date - ( $max_log_days_old * 86400 );
if ( !ref $thread_arrayref{$mnum} ) {
our ($MNUM);
fopen( 'MNUM', '<', "$datadir/$mnum.txt" )
or croak "$croak{'open'} $mnum.txt";
@{ $thread_arrayref{$mnum} } = <$MNUM>;
fclose('MNUM') or croak "$croak{'close'} $mnum.txt";
}
my $i = -1;
foreach ( @{ $thread_arrayref{$mnum} } ) {
$i++;
last if ( split /[|]/xsm )[3] > $dlp;
}
$newestpost = $INFO{'start'} = $i;
}
# Post and Thread Tools
if ($usethread_tools) {
load_tools(
2, 'addfav', 'remfav', 'addpoll',
'reply', 'add_notify', 'del_notify', 'print',
'sendtopic', 'markunread'
);
}
if ($usepost_tools) {
load_tools( 1, 'delete', 'admin_split', 'mquote', 'quote', 'modify',
'printp', 'alertmod' );
}
if ($enable_buddylist) { load_mybuddy(); }
my $viewnum = $INFO{'num'};
# strip off any non numeric values to avoid exploitation
$maxmessagedisplay ||= 10;
load_censor_list();
# Determine category
if ( !$currentboard ) { fatal_error( 'no_topic_found', $viewnum ); }
my $curcat = ${ $uid . $currentboard }{'cat'};
# Figure out the name of the category
get_forum_master();
my $vircurcat = q{};
my $vircat = q{};
my $virboardname = q{};
if ( $currentboard eq $annboard ) {
$vircurrentboard = $INFO{'virboard'} || q{};
$vircurcat = ${ $uid . $vircurrentboard }{'cat'};
if ($vircurcat) {
$vircat = ${ $catinfo{$vircurcat} }[0];
$vircat = to_chars($vircat);
}
if ($vircurrentboard) {
$virboardname = ${ $board{$vircurrentboard} }[0];
$virboardname = to_chars($virboardname);
}
}
my ( $cat, $catperms ) = @{ $catinfo{$curcat} };
$cat = to_chars($cat);
my ( $boardname, $boardview ) = @{ $board{$currentboard} };
$boardname = to_chars($boardname);
# Check to make sure this thread isn't locked.
my (
$mnum, $msubthread, undef, undef, $mdate,
$mreplies, undef, undef, $mstate
) = split /[|]/xsm, $yy_threadline;
$mstate ||= q{};
my ($newnum);
if ( $mstate =~ /m/xsm ) {
if ( $msubthread =~ /\s dest=(\d+)\]/xsm ) {
$newnum = $1;
}
if ( -e "$datadir/$newnum.txt" ) {
$yysetlocation = "$scripturl?num=$newnum";
redirectexit();
}
if ( -e "$vardir/Movedthreads.pm" ) {
require Variables::Movedthreads;
while ( exists $moved_file{$newnum} ) {
$newnum = $moved_file{$newnum};
next if exists $moved_file{$newnum};
if ( -e "$datadir/$newnum.txt" ) {
$yysetlocation = "$scripturl?num=$newnum";
redirectexit();
}
}
}
}
( $msubthread, undef ) = split_splice_move( $msubthread, 0 );
$msubthread = to_chars($msubthread);
$msubthread = do_censor($msubthread);
# Build a list of this board's moderators.
my $showmods = q{};
if ( keys %moderators > 0 ) {
if ( keys %moderators == 1 ) { $showmods = qq~($display_txt{'298'}: ~; }
else { $showmods = qq~($display_txt{'63'}: ~; }
my %sortmd = reverse %moderators;
my @sortmd = sort keys %sortmd;
foreach my $i (@sortmd) {
format_username( $sortmd{$i} );
$showmods .= quick_links( $sortmd{$i}, 1 ) . q{, };
}
$showmods =~ s/,\s$/)/xsm;
}
my $showmodgroups = q{};
if ( keys %moderatorgroups > 0 ) {
if ( keys %moderatorgroups == 1 ) {
$showmodgroups = qq~($display_txt{'298a'}: ~;
}
else { $showmodgroups = qq~($display_txt{'63a'}: ~; }
while ( $_ = each %moderatorgroups ) {
my $tmpmodgrp = $moderatorgroups{$_};
my ( $thismodgrp, undef ) = @{ $grp_nopost{$tmpmodgrp} };
$showmodgroups .= qq~$thismodgrp, ~;
}
$showmodgroups =~ s/,\s\Z/)/xsm;
}
## now we have established credentials,
## can this user bypass locks?
## work out who can bypass locked thread post only if bypass switched on
my $icanbypass = q{};
if ( $mstate =~ /l/ixsm ) {
if ($bypass_lock_perm) { $icanbypass = checkuser_lockbypass(); }
$enable_quickreply = 0;
}
my $permdate = permtimer($mnum);
my $display_permalink =
qq~$display_txt{'10'}~;
# Look for a poll file for this thread.
my $pollbutton = q{};
if ( access_check( $currentboard, 3 ) eq 'granted' ) {
$vircurrentboard ||= q{};
$pollbutton =
qq~$menusep$img{'addpoll'}~;
}
my ($has_poll);
if ( -e "$datadir/$viewnum.poll" ) {
$has_poll = 1;
$pollbutton = q{};
}
else {
$has_poll = 0;
if ( $useraddpoll == 0 ) { $pollbutton = q{}; }
}
# Get the class of this thread, based on lock status and number of replies.
my $replybutton = q{};
my $bypass_reply_button = q{};
if ( ( !$iamguest || $enable_guestposting )
&& access_check( $currentboard, 2 ) eq 'granted' )
{
$vircurrentboard ||= q{};
my $tmplink = (
$enable_quickreply && $enable_quickjump
? 'javascript:document.postmodify.message.focus();'
: qq~$scripturl?action=post;num=$viewnum;virboard=$vircurrentboard;title=PostReply~
);
$replybutton = qq~$img{'reply'}~;
$bypass_reply_button =
qq~$img{'reply'}~;
}
my $threadclass = 'thread';
if ( !$mstate ) { $threadclass = 'thread'; }
if ( $mreplies >= $very_hot_topic ) { $threadclass = 'veryhotthread'; }
elsif ( $mreplies >= $hot_topic ) { $threadclass = 'hotthread'; }
## hidden threads
if ( $mstate =~ /h/ixsm ) {
$threadclass = 'hide';
if ( !$staff ) { fatal_error('no_access'); }
}
## locked thread
elsif ( $mstate =~ /l/ixsm ) {
$threadclass = 'locked'; ## same icon regardless
$pollbutton = q{};
if ($icanbypass) { $replybutton = $bypass_reply_button; }
else { $replybutton = q{}; }
}
## stickies
if ( $mstate =~ /s/ixsm ) {
if ( $threadclass eq 'hide' ) {
if ( $mstate =~ /l/ixsm ) {
$threadclass = 'hidestickylock';
$pollbutton = q{};
if ($icanbypass) { $replybutton = $bypass_reply_button; }
else { $replybutton = q{}; }
}
else {
$threadclass = 'hidesticky';
}
}
elsif ( $threadclass eq 'thread' ) { $threadclass = 'sticky'; }
elsif ( $threadclass eq 'locked' ) {
$threadclass = 'stickylock';
if ($icanbypass) { $replybutton = $bypass_reply_button; }
else { $replybutton = q{}; }
}
}
elsif ( $threadclass eq 'hide' && $mstate =~ /l/ixsm ) {
$threadclass = 'hidelock';
$pollbutton = q{};
if ($icanbypass) { $replybutton = $bypass_reply_button; }
else { $replybutton = q{}; }
}
elsif ( ${$mnum}{'board'} eq $annboard ) {
$threadclass =
$threadclass eq 'locked' ? 'announcementlock' : 'announcement';
}
if ( -e "$datadir/$mnum.mail" && !$iamguest ) {
require Sources::Notify;
managethreadnotify( 'update', $mnum, $username, q{}, q{}, '1' );
}
if ( $showmodgroups && $showmods ) { $showmods .= q~ - ~; }
# Build the page links list.
my $userthreadpage = q{};
if ( !$iamguest ) {
( undef, $userthreadpage, undef, undef ) =
split /[|]/xsm, ${ $uid . $username }{'pageindex'};
}
my ( $pagetxtindex, $pagedropindex1, $pagedropindex2, $all, $allselected );
my $postdisplaynum = 3; # max number of pages to display
my $dropdisplaynum = 10;
my $startpage = 0;
my $max = $mreplies + 1;
my $do_rev = 0;
if ( !$iamguest && $ttsreverse && $ttsureverse && $userthreadpage ) {
$do_rev = 1;
}
my $start = !$do_rev ? 0 : $mreplies;
if ( $INFO{'start'} ) {
if ( $INFO{'start'} =~ /all/xsm && $showpageall ) {
$maxmessagedisplay = $max;
$all = 1;
$allselected = q~ selected="selected"~;
$start = !$do_rev ? 0 : $mreplies;
}
else {
$start =
$INFO{'start'} =~ /\D/xsm
? ( !$do_rev ? 0 : $mreplies )
: $INFO{'start'};
}
}
$start = $start > $mreplies ? $mreplies : $start;
$start =
!$ttsreverse
? ( int( $start / $maxmessagedisplay ) * $maxmessagedisplay )
: (
int( ( $mreplies - $start ) / $maxmessagedisplay ) *
$maxmessagedisplay );
my $tmpa = 1;
my $pagenumb = int( ( $max - 1 ) / $maxmessagedisplay ) + 1;
my $endpage = 0;
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; }
my $lastpn = int( $mreplies / $maxmessagedisplay ) + 1;
my $lastptn = ( $lastpn - 1 ) * $maxmessagedisplay;
my $pageindex1 =
qq~ $display_txt{'139'}: $pagenumb~;
my $pageindex2 = $pageindex1;
my (
$pagetxtindexst, $pageindexadd, $indexpages,
$indexpage, $indexstart, $indexend,
);
my $pageindexjs = q{};
if ( ( $pagenumb && $pagenumb > 1 ) || $all ) {
if ( $userthreadpage || $iamguest ) {
$pagetxtindexst = q~~;
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 ~;
}
foreach my $c ( $startpage .. ( $endpage - 1 ) ) {
if ( $c % $maxmessagedisplay == 0 ) {
$pagetxtindex .=
$start == $c
? qq~[$tmpa] ~
: qq~$tmpa ~;
$tmpa++;
}
}
if ( $endpage < ( $max - $maxmessagedisplay ) ) {
$pageindexadd =
qq~... ~;
}
if ( $endpage != $max ) {
$pageindexadd .=
qq~$lastpn~;
}
$pagetxtindex .= $pageindexadd || q{};
$pageindex1 = qq~$pagetxtindexst$pagetxtindex~;
$pageindex2 = $pageindex1;
}
else {
$pagedropindex1 = q~~;
$pagedropindex1 .=
qq~
~;
$pagedropindex2 = $pagedropindex1;
my $tstart = $start;
my $d_indexpages = $pagenumb / $dropdisplaynum;
my $i_indexpages = int( $pagenumb / $dropdisplaynum );
if ( $d_indexpages > $i_indexpages ) {
$indexpages = int( $pagenumb / $dropdisplaynum ) + 1;
}
else { $indexpages = int( $pagenumb / $dropdisplaynum ) }
my $selectedindex =
int( ( $start / $maxmessagedisplay ) / $dropdisplaynum );
if ( $pagenumb > $dropdisplaynum ) {
$pagedropindex1 .=
qq~\n~;
}
$pagedropindex1 .=
q~ ~;
$pagedropindex2 .=
q~ ~;
my $tmpmaxmessagedisplay = $maxmessagedisplay;
my $prevpage =
!$ttsreverse
? $start - $tmpmaxmessagedisplay
: $mreplies - $start + $tmpmaxmessagedisplay;
my $nextpage =
!$ttsreverse
? $start + $maxmessagedisplay
: $mreplies - $start - $maxmessagedisplay;
my $pagedropindexpvbl =
qq~
~;
my $pagedropindexnxbl =
qq~
~;
my ( $pagedropindexpv, $pagedropindexnx );
if ( ( !$ttsreverse && $start < $maxmessagedisplay )
or ( $ttsreverse && $prevpage > $mreplies ) )
{
$pagedropindexpv .=
qq~
~;
}
else {
$pagedropindexpv .=
qq~
~;
}
if ( ( !$ttsreverse && $nextpage > $lastptn )
or ( $ttsreverse && $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 = '$visel_0';
for(i=vistart; i<=viend; i++) {
if(visel == pagstart) pagedropindex += '$visel_1a' + i + '$visel_1b';
else pagedropindex += '$visel_2a' + i + '$visel_1b';
pagstart ~ . ( !$ttsreverse ? q{+} : q{-} ) . q~= maxpag;
}
~;
if ($showpageall) {
$pageindexjs .= qq~
if (vistart != viend) {
if(visel == 'all') pagedropindex += '$visel_1a$pidtxt{'01'}$visel_1b';
else pagedropindex += '$visel_2a$pidtxt{'01'}$visel_1b';
}
~;
}
$pageindexjs .= qq~
if(visel != 'xx') pagedropindex += '$visel_3a$pagedropindexpv$pagedropindexnx$visel_1b';
else pagedropindex += '$visel_3a$pagedropindexpvbl$pagedropindexnxbl$visel_1b';
pagedropindex += '$visel_4';
document.getElementById("ViewIndex1").innerHTML=pagedropindex;
document.getElementById("ViewIndex1").style.visibility = "visible";
document.getElementById("ViewIndex2").innerHTML=pagedropindex;
document.getElementById("ViewIndex2").style.visibility = "visible";
~;
if ( $pagenumb > $dropdisplaynum ) {
$pageindexjs .= q~
document.getElementById("decselector1").value = decparam;
document.getElementById("decselector2").value = decparam;
~;
}
$pageindexjs .= qq~
}
SelDec('$pagejsindex', '~
. ( !$ttsreverse ? $tstart : ( $mreplies - $tstart ) ) . q~');
~;
}
}
my $notify = q{};
my $notify2 = q{};
if ( !$iamguest ) {
my $addnotlink = $img{'add_notify'};
my $remnotlink = $img{'del_notify'};
if ($usethread_tools) {
$addnotlink =~ s/\[tool=(.+?)\](.+?)\[\/tool\]/$2/gxsm;
$remnotlink =~ s/\[tool=(.+?)\](.+?)\[\/tool\]/$2/gxsm;
}
$yyjavascript .= qq~
var addnotlink = '$addnotlink';
var remnotlink = '$remnotlink';
~;
if ( ${ $uid . $username }{'thread_notifications'}
&& ${ $uid . $username }{'thread_notifications'} =~
/\b$viewnum\b/xsm )
{
$notify =
qq~$menusep$img{'del_notify'}~;
$notify2 =
qq~$menusep$img{'del_notify'}~;
}
else {
$notify =
qq~$menusep$img{'add_notify'}~;
$notify2 =
qq~$menusep$img{'add_notify'}~;
}
}
# update the .ctb file START
message_totals( 'load', $viewnum );
if ( $username ne 'Guest' ) {
my ( %viewer, @tmprepliers, $isrep );
foreach my $i (@logentries)
{ # @logentries already loaded in YaBB.pl => &write_log;
$viewer{ ( split /[|]/xsm, $i, 2 )[0] } = 1;
}
my $j = 0;
foreach my $x (@repliers) {
my ( $reptime, $repuser, $isreplying ) = split /[|]/xsm, $x;
next if $date - $reptime > 600 || !exists $viewer{$repuser};
if ( $repuser eq $username ) {
$tmprepliers[$j] = qq~$date|$repuser|0~;
$isrep = 1;
}
else { $tmprepliers[$j] = qq~$reptime|$repuser|$isreplying~; }
$j++;
}
if ( !$isrep ) { push @tmprepliers, qq~$date|$username|0~; }
@repliers = @tmprepliers;
${$viewnum}{'views'}++; # Add 1 to the number of views of this thread.
message_totals( 'update', $viewnum );
}
else {
message_totals( 'incview', $viewnum );
# Add 1 to the number of views of this thread.
}
# update the .ctb file END
# Mark current board as read if no other new threads are in
getlog();
# &NextPrev => Insert Navigation Bit and get info about number of threads newer than last visit
if ( next_prev( $viewnum, $yyuserlog{$currentboard} ) < 2 ) {
$yyuserlog{$currentboard} = $date;
}
# Mark current thread as read. Save thread and board Mark.
delete $yyuserlog{"$mnum--unread"};
dumplog($mnum);
my $template_home = qq~$mbname~;
my $topviewers = 0;
my ( $template_cat, $template_board, $template_mods, $navback );
if ( ${ $uid . $currentboard }{'ann'} ) {
if ($vircurrentboard) {
$template_cat =
qq~$vircat~;
$template_board =
qq~$virboardname~;
$navback =
qq~‹ $maintxt{'board'}~;
$template_mods = qq~$showmods$showmodgroups~;
}
elsif ( $iamadmin || $iamgmod || $iamfmod ) {
$template_cat = qq~$cat~;
$template_board =
qq~$boardname~;
$navback =
qq~‹ $maintxt{'board'}~;
$template_mods = qq~$showmods$showmodgroups~;
}
else {
$template_cat = $maintxt{'418'};
$template_board = $display_txt{'999'};
$template_mods = q{};
}
}
else {
$template_cat = qq~$cat~;
$template_board =
qq~$boardname~;
$navback =
qq~‹ $maintxt{'board'}~;
$template_mods = qq~$showmods$showmodgroups~;
}
if ($accept_permafull) {
$template_cat =~ s/$scripturl[?]catselect\=/$permcat/xsm;
$template_board =~ s/$scripturl[?]board\=/$permbrd/xsm;
}
my $template_viewers = q{};
if ( $showtopicviewers
&& $staff
&& $sessionvalid == 1 )
{
foreach (@repliers) {
my ( undef, $mrepuser, $misreplying ) = split /[|]/xsm;
load_user($mrepuser);
my $replying =
$misreplying
? qq~ ($display_txt{'645'})~
: q{};
$template_viewers .= qq~$link{$mrepuser}$replying, ~;
$topviewers++;
}
$template_viewers =~ s/,\s\Z/\./xsm;
}
$yyjavascript .= qq~
var addfavlang = '$display_txt{'526'}';
var remfavlang = '$display_txt{'527'}';
var remnotelang = '$display_txt{'530'}';
var addnotelang = '$display_txt{'529'}';
var markfinishedlang = '$display_txt{'528'}';~;
my $template_print = q{};
my $template_favorite = q{};
my $template_favorite2 = q{};
if ( !$iamguest && $currentboard ne $annboard ) {
require Sources::Favorites;
$template_favorite =
is_fav( $viewnum, ( !$ttsreverse ? $start : $mreplies - $start ) );
$template_favorite2 =
is_fav1( $viewnum, ( !$ttsreverse ? $start : $mreplies - $start ) );
}
my $template_threadimage = $micon{$threadclass};
$template_threadimage =~ s/\Q{yabb veryhotthread}\E/$very_hot_topic/gxsm;
$template_threadimage =~ s/\Q{yabb hottopic}\E/$hot_topic/gxsm;
my $template_sendtopic =
$sendtopicmail
? qq~$menusep$img{'sendtopic'}~
: q{};
if ( ( !$iamguest && $ptopicperms > 0 )
|| ( $iamguest && $ptopicperms == 2 ) )
{
$template_print =
qq~$menusep$img{'print'}~;
}
my $template_pollmain = q{};
if ($has_poll) {
require Sources::Poll;
display_poll($viewnum);
$template_pollmain = $pollmain;
}
# Load background color list.
my @cssvalues = qw( windowbg windowbg2 );
my $cssnum = @cssvalues;
my $sm = 0;
if ( !$use_menu_type ) { $sm = 1; }
if ( !ref $thread_arrayref{$viewnum} ) {
our ($MSGTXT);
fopen( 'MSGTXT', '<', "$datadir/$viewnum.txt" )
or fatal_error( 'cannot_open', "$datadir/$viewnum.txt", 1 );
@{ $thread_arrayref{$viewnum} } = <$MSGTXT>;
fclose('MSGTXT') or croak "$croak{'close'} $viewnum.txt";
}
my $counter = 0;
my @messages;
# Skip the posts in this thread until we reach $start.
if ( !$ttsreverse ) {
foreach my $i ( @{ $thread_arrayref{$viewnum} } ) {
if ( $counter >= $start
and $counter < ( $start + $maxmessagedisplay ) )
{
push @messages, $i;
}
$counter++;
}
$counter = $start;
}
else {
foreach my $i ( @{ $thread_arrayref{$viewnum} } ) {
if ( $counter > ( $mreplies - $start - $maxmessagedisplay )
&& $counter <= ( $mreplies - $start ) )
{
push @messages, $i;
}
$counter++;
}
$counter = $mreplies - $start;
@messages = reverse @messages;
}
my ( $hideavatar, $hideusertext, $hideattachimg, $hidesignat );
if ( !$allowpics
|| !$showuserpic
|| ( ${ $uid . $username }{'hide_avatars'} && $user_hide_avatars ) )
{
$hideavatar = 1;
}
if ( !$showusertext
|| ( ${ $uid . $username }{'hide_user_text'} && $user_hide_user_text ) )
{
$hideusertext = 1;
}
if ( ${ $uid . $username }{'hide_attach_img'} && $user_hide_attach_img ) {
$hideattachimg = 1;
}
if ( ( ${ $uid . $username }{'hide_signat'} && $user_hide_signat )
|| ( $hide_signat_for_guests && $iamguest ) )
{
$hidesignat = 1;
}
# For each post in this thread:
my ( %attach_gif, %attach_count );
my $movedflag = q{};
my $tmpoutblock = q{};
foreach (@messages) {
my (
$userlocation, $aimad, $yimad,
$gtalkad, $skypead, $myspacead,
$facebookad, $twitterad, $youtubead,
$icqad, $isbuddy, $addbuddylink,
$user_online, $signature_hr, $lastmodified,
$memberinfo, $template_postinfo, $template_ext_prof,
$template_profile, $template_email, $template_www,
$template_regdate
);
my $css = $cssvalues[ ( $counter % $cssnum ) ];
my (
$msub, $mname, $memail, $mdte, $musername,
$micon, $mattach, $mip, $postmessage, $ns,
$mlm, $mlmb, $mfn
) = split /[|]/xsm;
# If the user isn't a guest, load their info.
if ( $musername ne 'Guest'
&& !$yy_udloaded{$musername}
&& -e "$memberdir/$musername.vars" )
{
my $tmpns = $ns;
$ns = q{};
load_user_display($musername);
$ns = $tmpns;
}
my $messagedate = $mdte;
my $registrationdate = $date;
if ( ${ $uid . $musername }{'regtime'} ) {
$registrationdate = ${ $uid . $musername }{'regtime'};
}
else {
$registrationdate = $date;
}
# Do we have an attachment file?
$mfn ||= q{};
chomp $mfn;
my $attachment = q{};
my $showattach = q{};
my $showattachhr = q{};
if ($mfn) {
# store all downloadcounts in variable
if ( !%attach_count ) {
our ($ATM);
fopen( 'ATM', '<', "$vardir/attachments.db" )
or croak "$croak{'open'} attach";
while (<$ATM>) {
chomp;
my (
undef, undef, undef, undef, undef,
undef, undef, $atfile, $atcount
) = split /[|]/xsm;
if ($atfile) {
$atcount ||= 0;
$attach_count{$atfile} = $atcount;
}
}
fclose('ATM') or croak "$croak{'open'} attach";
if ( !%attach_count ) { $attach_count{'no_attachments'} = 1; }
}
my ($ext);
foreach my $i ( split /,/xsm, $mfn ) {
if ( $i =~ /[.](.+?)$/xsm ) {
$ext = lc $1;
}
if ( !exists $attach_gif{$ext} ) {
$attach_gif{$ext} =
( $att_img{$ext}
&& -e "$htmldir/Templates/Forum/$useimages/$att_img{$ext}"
)
? "$imagesdir/$att_img{$ext}"
: $micon_bg{'paperclip'};
}
my $filesize = -s "$uploaddir/$i";
$urlname = $i;
if ( $urlname =~ m/([[:^alnum:]])/xsm ) {
$urlname =~
s/([[:^alnum:]])/sprintf('%%%02X', ord($1))/egxsm;
}
$attach_count{$i} ||= 0;
my $download_txt =
( $attach_count{$i} == 1 )
? $fatxt{'41b'}
: isempty( $fatxt{'41c'}, $fatxt{'41a'} );
if ($filesize) {
if ( $i =~ /[.](?:bmp|jpe|jpg|jpeg|gif|png)$/ixsm
&& $amdisplaypics == 1 )
{
$showattach .=
qq~