############################################################################### # Display.pl # ############################################################################### # YaBB: Yet another Bulletin Board # # Open-Source Community Software for Webmasters # # Version: YaBB 1 Gold - SP 1.1 # # Released: December 2001; Updated March 22, 2002 # # Distributed by: http://www.yabbforum.com # # =========================================================================== # # Copyright (c) 2000-2002 Xnull (www.xnull.com) - All Rights Reserved. # # Software by: The YaBB Development Team # # with assistance from the YaBB community. # ############################################################################### $displayplver = "1 Gold - SP 1.1"; sub Display { require "$sourcedir/Karma.pl"; my $viewnum = $INFO{'num'}; if( $viewnum =~ /\D/ ) { &fatal_error($txt{'337'}); } if( $currentboard eq '' ) { &fatal_error($txt{'1'}); } $maxmessagedisplay ||= 10; my($buffer,$views,$lastposter,$moderators,$counter,$counterwords,$pageindex,$msubthread,$mnum,$mstate,$mdate,$msub,$mname,$memail,$mreplies,$musername,$micon,$noposting,$threadclass,$notify,$max,$start,$bgcolornum,$windowbg,$mattach,$mip,$mlm,$mlmb,$lastmodified,$postinfo,$star,$sendm,$topicdate); my(@userprofile,@messages,@bgcolors); # Determine what category we are in. fopen(FILE, "$boardsdir/$currentboard.ctb") || &fatal_error("300 $txt{'106'}: $txt{'23'} $currentboard.ctb"); $curcat = ; fclose(FILE); #$curcat = $cat; fopen(FILE, "$boardsdir/$curcat.cat") || &fatal_error("300 $txt{'106'}: $txt{'23'} $cat.cat"); $cat = ; fclose(FILE); # Load the membergroups list. fopen(FILE, "$vardir/membergroups.txt") || &fatal_error("100 $txt{'106'}: $txt{'23'} membergroups.txt"); @membergroups = ; fclose(FILE); # Mark current thread as read. ($mnum,$tmpa,$tmpa,$tmpa,$mdate) = split(/\|/,$yyThreadLine); &dumplog($mnum,$date); # Add 1 to the number of views of this thread. if(fopen(FILE, "$datadir/$viewnum.data")) { $tmpa = ; fclose(FILE); } elsif( -e "$datadir/$viewnum.data" ) { &fatal_error("102 $txt{'106'}: $txt{'23'} $viewnum.data"); } else { $tmpa = '0'; } ($tmpa, $tmpb) = split( /\|/, $tmpa ); $tmpa++; fopen(FILE, "+>$datadir/$viewnum.data") || &fatal_error("103 $txt{'106'}: $txt{'23'} $viewnum.data"); print FILE qq~$tmpa|$tmpb~; fclose(FILE); $views = $tmpa - 1; # Check to make sure this thread isn't locked. ($mnum,$msubthread,$mname,$memail,$mdate,$mreplies,$musername,$micon,$mstate) = split( /\|/, $yyThreadLine ); $noposting = $viewnum eq $mnum && $mstate == 1 ? 1 : 0; # Look for a poll file for this thread. if (-e "$datadir/$viewnum.poll") { $has_poll = 1; } else { $has_poll = 0; } # Get the class of this thread, based on lock status and number of replies. $replybutton = qq~$img{'reply'}~; $pollbutton = qq~$menusep$img{'addpoll'}~; $threadclass = 'thread'; if( $mstate == 1 ) { $threadclass = 'locked'; $replybutton = ""; $pollbutton = ""; } if ($has_poll || $useraddpoll == 0) { $pollbutton = ""; } elsif( $mreplies > 24 ) { $threadclass = 'veryhotthread'; } elsif( $mreplies > 14 ) { $threadclass = 'hotthread'; } elsif( $mstate == 0 ) { $threadclass = 'thread'; } fopen(FILE, "$boardsdir/sticky.stk") || &fatal_error("300 $txt{'106'}: $txt{'23'} sticky.stk"); @stickys = ; fclose(FILE); foreach $curnum (@stickys) { if ($mnum == $curnum) { if($threadclass eq 'locked') { $threadclass = 'stickylock'; } else { $threadclass = 'sticky'; } } } &LoadCensorList; # Load Censor List # Build a list of this board's moderators. if( scalar keys %moderators > 0 ) { if( scalar keys %moderators == 1 ) { $showmods = qq~($txt{'298'}: ~; } else { $showmods = qq~($txt{'299'}: ~; } while( $_ = each(%moderators) ) { &FormatUserName($_); $showmods .= qq~$moderators{$_}, ~; } $showmods =~ s/, \Z/)/; } if($enable_notification) { my $startnum = $start || '0'; $notify = qq~$menusep$img{'notify'}~; } &jumpto; # create the jumpto list # Build the page links list. $postdisplaynum = 3; # max number of pages to display $max = $mreplies + 1; $start = $INFO{'start'} || 0; $start = $start > $mreplies ? $mreplies : $start; $start = ( int( $start / $maxmessagedisplay ) ) * $maxmessagedisplay; $tmpa = 1; $tmpx = int( $max / $maxmessagedisplay ); 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 } if ($startpage > 0) { $pageindex = qq~1 ... ~; } if ($startpage == $maxmessagedisplay) { $pageindex = qq~1 ~;} for( $counter = $startpage; $counter < $endpage; $counter += $maxmessagedisplay ) { $pageindex .= $start == $counter ? qq~$tmpa ~ : qq~$tmpa ~; $tmpa++; } $tmpx = $max - $maxmessagedisplay; $outerpn = int($tmpx / $maxmessagedisplay) + 0; $lastpn = int($mreplies / $maxmessagedisplay) + 1; $lastptn = ($lastpn - 1) * $maxmessagedisplay; if ($endpage < $max - ($maxmessagedisplay) ) {$pageindexadd = qq~ ... ~;} if ($endpage != $max) {$pageindexadd .= qq~ $lastpn~;} $pageindex .= $pageindexadd; foreach (@censored) { ($tmpa,$tmpb) = @{$_}; $msubthread =~ s~\Q$tmpa\E~$tmpb~gi; } $curthreadurl = $curposlinks ? qq~$msubthread~ : $msubthread; # Create next/prev links fopen(LISTS, "$boardsdir/$INFO{'board'}.txt"); @boardtopics = ; seek LISTS, 0, 0; my $found; my $name = $INFO{'num'}; my $bcount = 0; $CurrentPosition = -1; while($ThreadNum = ) { ++$CurrentPosition; $boardtopics[$bcount] = $ThreadNum; $bcount++; if ($ThreadNum =~ m/\A$name/o) { $found = 1; last; } } fclose(LISTS); $previous = $boardtopics[$CurrentPosition-1]; $next = $boardtopics[$CurrentPosition+1]; @prevthread = split(/\|/, $previous); $goprevious = $prevthread[0]; @nextthread = split(/\|/, $next); $gonext = $nextthread[0]; @getlastthread = @boardtopics; $lastthread = pop(@getlastthread); @lasttopic = split(/\|/, $lastthread); $endthread2 = $lasttopic[0]; if($found) { $prevtopic = "$cgi;action=display;num=$goprevious"; $nexttopic = "$cgi;action=display;num=$gonext"; $endthread = "$cgi;action=display;num=$endthread2"; } if( $endthread eq $prevtopic && $gonext eq "") { $nav = qq~« $txt{'766'} | $txt{'766'} »~; } if($endthread eq $prevtopic && $gonext ne "") { $nav = qq~« $txt{'766'} | $txt{'767'} »~; } if ( $endthread ne $prevtopic && $gonext eq "") { $nav = qq~« $txt{'768'} | $txt{'766'} »~; } if ($endthread ne $prevtopic && $gonext ne "") { $nav = qq~« $txt{'768'} | $txt{'767'} »~; } $yymain .= qq~
   $mbname
   $cat
   $boardname
$showmods
   $curthreadurl
$nav
$txt{'139'}: $pageindex $replybutton$pollbutton$notify$menusep $img{'sendtopic'}$menusep $img{'print'}
~; if ($has_poll) { require "$sourcedir/Poll.pl"; &display_poll($viewnum); } $yymain .= qq~
   $txt{'29'}  $txt{'118'}: $msubthread  ($txt{'641'} $views $txt{'642'})
~; # Load background color list. @bgcolors = ( $color{windowbg}, $color{windowbg2} ); $bgcolornum = scalar @bgcolors; @cssvalues = ( "windowbg","windowbg2" ); $cssnum = scalar @bgcolors; if(!$MenuType) { $sm = 1; } $counter = 0; fopen(FILE,"$datadir/$viewnum.txt") || &fatal_error("104 $txt{'106'}: $txt{'23'} $viewnum.txt"); # Skip past the posts in this thread until we reach $start. while($counter < $start && ($buffer = )) { $counter++; } $#messages = $maxmessagedisplay - 1; for($counter = 0; $counter < $maxmessagedisplay && ($buffer = ); $counter++) { $messages[$counter] = $buffer; } fclose(FILE); $#messages = $counter - 1; $counter = $start; # For each post in this thread: foreach (@messages) { $windowbg = $bgcolors[($counter % $bgcolornum)]; $css = $cssvalues[($counter % $cssnum)]; chomp; ($msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $postmessage, $ns, $mlm, $mlmb) = split(/[\|]/, $_); # Should we show "last modified by?" if( $mlm && $showmodify && $mlm ne "" && $mlmb ne "") { $mlm = &timeformat($mlm); &LoadUser($mlmb); $mlmb = $userprofile{$mlmb}->[1] || $mlmb || $txt{'470'}; $lastmodified = qq~« $txt{'211'}: $mlm $txt{'525'} $mlmb »~; } else { $mlm = '-'; $lastmodified = ''; } $msub ||= $txt{'24'}; $messdate = &timeformat($mdate); if ($settings[7] eq 'Administrator' || $settings[7] eq 'Global Moderator' && $allow_mod == 1) { $mip = $mip } else { $mip = "$txt{'511'}"; } $sendm = ''; # If the user isn't a guest, load his/her info. if($musername ne 'Guest' && ! $yyUDLoaded{$musername} && -e("$memberdir/$musername.dat") ) { &LoadUserDisplay($musername); # If user is not in memory, s/he must be loaded. } if($yyUDLoaded{$musername}) { @userprofile = @{$userprofile{$musername}}; $displayname = $userprofile[1]; $star = $memberstar{$musername}; $memberinfo = $memberinfo{$musername}; $memberinfo =~ s~\n~~g; $icqad = $icqad{$musername}; $yimon = $yimon{$musername}; if ($userprofile[7] eq 'Administrator' && $micon eq "lamp"){$windowbg = "announcebg"; $css = "announcebg"; } elsif ($userprofile[7] eq 'Administrator' && $micon eq "exclamation"){$windowbg = "adminbg"; $css = "adminbg";} if($username ne 'Guest') { # Allow instant message sending if current user is a member. $sendm = qq~$menusep$img{'message_sm'}~; } $usernamelink = $link{$musername}; $postinfo = qq~$txt{'26'}: $userprofile[6]
~; $memail = $userprofile[2]; $karmainfo = "
$karmaLabel " . &getKarma($musername); my($inMemberGroup) = &isInMemberGroup; if (($username ne "Guest") && ($inMemberGroup == 1)){ $karmainfo .= "
$karmaSmiteLabel $karmaApplaudLabel"; } } else { $musername = "Guest"; $star = ''; $memberinfo = "$txt{'28'}"; $icqad = ''; $yimon = ''; $usernamelink = qq~$mname~; if ($memberinfo eq "$txt{'28'}") { $usernamelink = qq~$mname
~; } $postinfo = ''; @userprofile = (); $displayname = $mname; } # Censor the subject and message. foreach (@censored) { ($tmpa,$tmpb) = @{$_}; $postmessage =~ s~\Q$tmpa\E~$tmpb~gi; $msub =~ s~\Q$tmpa\E~$tmpb~gi; } # Run UBBC interpreter on the message. $message = $postmessage; # put the message back into the proper variable to do ubbc on it &wrap; if($enable_ubbc) { if(!$yyYaBBCloaded) { require "$sourcedir/YaBBC.pl"; } &DoUBBC; } &wrap2; $profbutton = $profilebutton && $musername ne 'Guest' ? qq~$img{'viewprofile_sm'}$menusep~ : ''; if($counter != 0) { $counterwords = "$txt{'146'} #$counter"; } else { $counterwords = ""; } # Print the post and user info for the poster. $yymain .= qq~
$usernamelink $memberinfo
~; if($musername ne "Guest") { fopen(FILE, "$memberdir/$useraccount{$musername}.flg"); @flag = ; fclose(FILE); chomp @flag; $test = $flag[0]; if($test eq '') { $test = "blank"; } $yymain .= qq~ $star


$userprofile[13]$userprofile[12] $karmainfo $pop{$musername}

$userprofile[8] $icqad   $userprofile[10] $yimon   $userprofile[9]
~; } if($musername eq "Guest") { $yymain .= qq~
$img{'email_sm'}

~; } elsif ($userprofile[19] ne "checked" || $settings[7] eq "Administrator" || $settings[7] eq "Global Moderator" || $allow_hide_email ne 1) { $yymain .= qq~ $profbutton$userprofile[4] $img{'email_sm'}$sendm

~; } else { $yymain .= qq~ $profbutton$userprofile[4]$sendm

~; } fopen(FILE, "$memberdir/$useraccount{$musername}.rst"); @relationship = ; fclose(FILE); chomp @relationship; $rsttest = $relationship[0]; if($rsttest eq '') {$rsttest = "N/A";} fopen(FILE, "$memberdir/$useraccount{$musername}.mod"); @moody = ; fclose(FILE); chomp @moody; $modtest = $moody[0]; if($modtest eq '') {$modtest = "blank";} fopen(FILE, "$memberdir/$useraccount{$musername}.zod"); @sign = ; fclose(FILE); chomp @sign; $test = $sign[0]; if($test eq '') {$test = "blank";} elsif($test eq "$zodtxt{'1a'}"){$test = "Aries";} elsif($test eq "$zodtxt{'1b'}"){$test = "Taurus";} elsif($test eq "$zodtxt{'1c'}"){$test = "Gemini";} elsif($test eq "$zodtxt{'1d'}"){$test = "Cancer";} elsif($test eq "$zodtxt{'1e'}"){$test = "Leo";} elsif($test eq "$zodtxt{'1f'}"){$test = "Virgo";} elsif($test eq "$zodtxt{'1g'}"){$test = "Libra";} elsif($test eq "$zodtxt{'1h'}"){$test = "Scorpio";} elsif($test eq "$zodtxt{'1i'}"){$test = "Sagittarius";} elsif($test eq "$zodtxt{'1j'}"){$test = "Capricorn";} elsif($test eq "$zodtxt{'1k'}"){$test = "Aquarius";} elsif($test eq "$zodtxt{'1l'}"){$test = "Pisces";} if($test eq $sign[0]) { $yymain .= qq~ $zodtxt{'2'} $sign[0]
$userprofile[11] $postinfo ~; if($rsttest eq $relationship[0]) { $yymain .= qq~ $txtrst{'0a'} : $relationship[0]
$musername is $moody[0] ~; } else { $yymain .= qq~ $musername is $moody[0] ~; } $yymain .= qq~
$msub
« $counterwords $txt{'30'}: $messdate »
~; } else { $yymain .= qq~ $userprofile[11] $postinfo ~; if($rsttest eq $relationship[0]) { $yymain .= qq~ $txtrst{'0a'} : $relationship[0]
$musername is $moody[0] ~; } else { $yymain .= qq~ $musername is $moody[0] ~; } $yymain .= qq~
$msub
« $counterwords $txt{'30'}: $messdate »
~; } if ($mstate != 1) { $yymain .= qq~ $img{'replyquote'}$menusep$img{'modify'} ~; if(exists $moderators{$username} || $settings[7] eq 'Administrator' || $username eq $musername || $settings[7] eq 'Global Moderator') { $yymain .= qq~ $menusep$img{'delete'}~; } } $yymain .= qq~

$message
$lastmodified $mip
$userprofile[5]
~; $counter++; } if($settings[7] eq 'Administrator') { $sadminf = qq($img{'admin_func'}  $img{'admin_move'}$img{'admin_rem'}$img{'admin_lock'}$img{'admin_sticky'}); } if(exists $moderators{$username} && $settings[7] ne 'Administrator' || $settings[7] eq 'Global Moderator') { $sadminf = qq($img{'moderator_func'}  $img{'admin_move'}$img{'admin_rem'}$img{'admin_lock'}$img{'admin_sticky'}); } $yymain .= qq~
$txt{'139'}: $pageindex $replybutton$pollbutton$notify$menusep $img{'sendtopic'}$menusep $img{'print'}

~; $yymain .= qq~
~; if(exists $moderators{$username} || $settings[7] eq 'Administrator' || $settings[7] eq 'Global Moderator') { $yymain .= qq~$sadminf~; } $yymain .= qq~ $selecthtml
$nav
~; # MBCO2 Reply access check if ($reply_users{$currentboard} || $reply_groups{$currentboard}) { my $access = &AccessCheck($currentboard, 2) || ""; if ($access eq "denied") {$enable_quickreply = 0;} } if ($username ne "Guest" && $mstate != 1 && $enable_quickreply == 1) { $yymain .= qq~
$quick_txt{'2'}
~; if ($enable_quicksmilies == 1) { $yymain .= qq~ ~; } $yymain .= qq~
$txt{'70'}:
$txt{'297'}:
$txt{'72'}:
 
~; } $yytitle = $msubthread; &template; exit; } 1;