############################################################################### # 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/Title.pl"; my($msf,$mfn,$attachment,$showattach); 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; # Get the class of this thread, based on lock status and number of replies. $replybutton = qq~$img{'reply'}~; $threadclass = 'thread'; if( $mstate == 1 ) { $threadclass = 'locked'; $replybutton = ""; } 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$notify$menusep $img{'sendtopic'}$menusep $img{'print'}
~; # Look for a poll file for this thread. if (-e "$datadir/$viewnum.poll") { $pollthread = 1; } if ($pollthread) { fopen (FILE, "$datadir/$viewnum.poll"); @polldata = ; fclose (FILE); $pollquestion = $polldata[0]; $pollquestion =~ s~\n~~g; ($question, $lockstatus) = split(/\|/, $pollquestion); $num = 1; $line = 0; my @options; my @votes; foreach $pointer (@polldata) { ($vote, $option) = split(/\|/, $polldata[$num]); $options[$line] = $option; $votes[$line] = $vote; $line++; $num++; } $search = -1; my $found; $usersemail = $settings[2]; $userstatus = $settings[7]; $found = &CheckVoted($viewnum); if ($found) { $userhasvoted = 1; } $viewresults = $INFO{'viewresults'}; if ($lockstatus eq "Locked") { $pollislocked = 1; } if ($username ne "Guest" && ($username eq $susername) || ($userstatus eq "Administrator" or $userstatus eq "Global Moderator" or exists $moderators{$username})) { $modifypoll = qq~$polltxt{'39'} ~; } if (($userstatus eq "Administrator" || $userstatus eq "Global Moderator" || exists $moderators{$username}) && ($pollislocked ne 1)) { $lockpoll = qq~$img{'polliconclosed'} $polltxt{'20'} ~; } if (($userstatus eq "Administrator" || $userstatus eq "Global Moderator" || exists $moderators{$username}) && ($pollislocked eq 1)) { $lockpoll = qq~$img{'polliconclosed'} $polltxt{'21'} ~; } if ($userstatus eq "Administrator"){ $displayvoters = qq~ $polltxt{'33'}~;} $vresults = qq~$polltxt{'19'}~; if ($pollislocked eq 1) { $endedtext = $polltxt{'22'}; } $poll_icon = qq~$img{'pollicon'}~; if ($pollislocked == 1) { $poll_icon = qq~$img{'polliconclosed'}~; } $yymain.= qq~
 $poll_icon $polltxt{'15'} $endedtext $lockpoll   $displayvoters   $modifypoll
~; # Censor the question. foreach (@censored) { ($tmpa,$tmpb) = @{$_}; $question =~ s~\Q$tmpa\E~$tmpb~gi; } if (($userhasvoted) || $viewresults eq 'yes' || $pollislocked eq 1 ) { $yymain.= qq~
$polltxt{'16'}: $question

~; $nums = 0; my $Key; my $Total; $maxvote = 0; foreach $Key (@votes) { $Total += $Key; if ($Key >= $maxvote) { $maxvote = $Key;} } $totalvotes = $Total; pop (@options); foreach (@options) { # Censor the options. foreach (@censored) { ($tmpa,$tmpb) = @{$_}; $options[$nums] =~ s~\Q$tmpa\E~$tmpb~gi; } $message = $options[$nums]; # put the message back into the proper variable to do ubbc on it if(!$yyYaBBCloaded) { require "$sourcedir/YaBBC.pl"; } &MakeSmileys; $options[$nums] = $message; $options[$nums] =~ s~\n~~g; $options[$nums] =~ s~
~~g; $yymain .= qq~ ~; $nums++; } $yymain .= qq~
$options[$nums] ~; # Now lets calculate how many devisions by the total number of votes are needed to make the bar graphs stay nicely sized in the browser window: $pollpercent = 0; $pollbar = 0; if ($totalvotes ne 0 && $maxvote ne 0) { $pollpercent = int(1000 * $votes[$nums] / $totalvotes); $pollpercent = $pollpercent / 10; $pollbar = int( 150 * $votes[$nums] / $maxvote); } $yymain .= qq~   $votes[$nums] ($pollpercent%)

$polltxt{'17'}: $totalvotes
~; } else { $board = $INFO{'board'}; $yymain.= qq~
$polltxt{'16'}: $question
~; $nums = 0; pop (@options); foreach (@options) { # Censor the options. foreach (@censored) { ($tmpa,$tmpb) = @{$_}; $options[$nums] =~ s~\Q$tmpa\E~$tmpb~gi; } $options[$nums] =~ s~\n~~g; $options[$nums] =~ s~
~~g; $message = $options[$nums]; # put the message back into the proper variable to do ubbc on it if(!$yyYaBBCloaded) { require "$sourcedir/YaBBC.pl"; } &MakeSmileys; $options[$nums] = $message; $yymain .= qq~ ~; $nums++; } $yymain .= qq~
$options[$nums]

$vresults
~; } $yymain .= qq~
~; } $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, $msf, $mfn) = split(/[\|]/, $_); # Should we show an attachment file? if( $msf && $mfn && $msf ne "" && $mfn ne "") { if (-e ("$upload_dir/$mfn")) { $attachment = qq~ $mfn~; if(($mfn =~ /(jpg|gif|bmp|png|jpeg)$/i) && ($amdisplaypics == 1)) { $showattach = qq~
~; } else { $showattach = ''; } } else { $attachment = qq~ $mfn $fatxt{'1'}~; $showattach = ''; } } else { $attachment = ''; $showattach = ''; } # 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); $mip = $settings[7] eq 'Administrator' ? $mip : "$txt{'511'}"; $sendm = ''; # If the user isn't a guest, load his/her info. $online = ""; if($musername ne 'Guest' && ! $yyUDLoaded{$musername} && -e("$memberdir/$musername.dat") ) { &LoadUserDisplay($musername); # If user is not in memory, s/he must be loaded. } my($loccode, $displocal, $dispcountry, $dispcontin, $dispx, $dispy, $dispstate, $dispflag); my($loccode, $displocal, $dispcountry, $dispcontin, $dispx, $dispy, $dispstate, $dispflag); if($yyUDLoaded{$musername}) { @userprofile = @{$userprofile{$musername}}; ($loccode, $displocal, $dispcountry, $dispcontin, $dispx, $dispy, $dispstate) = split(/\|/, $userprofile[15]); if($view_flag && $dispcountry ne "") { my($initstat, $namestat, $disploc); if($dispstate ne "") { ($initstat, $namestat) = split(/\,/, $dispstate); } if($displocal ne "") { $disploc = qq~$displocal $initstat~; } if($loccode eq "x1") { $dispflag = qq~$dispcountry $disploc~; } elsif($loccode eq "x0") { $dispflag = qq~$dispcountry $disploc~; } else { $dispflag = ""; } } ($loccode, $displocal, $dispcountry, $dispcontin, $dispx, $dispy, $dispstate) = split(/\|/, $userprofile[15]); if($view_flag && $dispcountry ne "") { my($initstat, $namestat, $disploc); if($dispstate ne "") { ($initstat, $namestat) = split(/\,/, $dispstate); } if($displocal ne "") { $disploc = qq~$displocal $initstat~; } if($loccode eq "x1") { $dispflag = qq~$dispcountry $disploc~; } elsif($loccode eq "x0") { $dispflag = qq~$dispcountry $disploc~; } else { $dispflag = ""; } } $displayname = $userprofile[1]; fopen(NUMBERFILEREAD,"$memberdir/$musername.yam"); @number = ; fclose(NUMBERFILEREAD); chomp @number; if ($musername eq "admin") { $displaynumb = ''; } else { $displaynumb = qq~$membtxt{'23'} $number[0]~; } $star = $memberstar{$musername}; $memberinfo = $memberinfo{$musername}; $titlesettings = &getTitle($musername); if( $titlesettings eq '' ) { $titlesettings = $cuttxt{'2'}; } $memberinfo =~ s~\n~~g; $icqad = $icqad{$musername}; $yimon = $yimon{$musername}; if($username ne 'Guest') { # Allow instant message sending if current user is a member. $sendm = qq~$menusep$img{'message_sm'}~; } if((exists $moderators{$useraccount{$musername}})){ $usernamelink = qq~$userprofile[1]~; } else{ $usernamelink = qq~$userprofile[1]~; } $postinfo = qq~$txt{'26'}: $userprofile[6]
~; $memail = $userprofile[2]; $online = ""; fopen(FILE, "$vardir/log.txt"); @entries = ; fclose(FILE); foreach $curentry (@entries) { chomp $curentry; ($name, $value) = split(/\|/, $curentry); if( $name eq $musername) { $online = qq~~; } } } else { $musername = "Guest"; $displaynumb = ''; $star = ''; $memberinfo = "$txt{'28'}"; $icqad = ''; $yimon = ''; $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; } ################ Media Player mod if ($musername ne 'Guest') { $mediausername = $userprofile[1]; } else{ $mediausername = $mname; } ################ Media Player mod end # 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 $online
~; if($musername ne "Guest") { if($titlesettings eq $cuttxt{'2'}) { $yymain .= qq~ $titlesettings $memberinfo
~; } else { $yymain .= qq~ $memberinfo
$titlesettings
~; } } else { $yymain .= qq~ $memberinfo
~; } if($musername ne "Guest") { $yymain .= qq~ ~; if($view_flag) { $yymain .= qq~ $dispflag
~; } $yymain .= qq~ ~; if($view_flag) { $yymain .= qq~ $dispflag
~; } $yymain .= qq~ $star
$displaynumb

$userprofile[13]$userprofile[12]

$userprofile[8] $icqad  ~; fopen(FILE, "$memberdir/$useraccount{$musername}.om", 1); @msnsettings = ; fclose ; chomp @msnsettings; if ($msnsettings[0] ne '') { $yymain .= qq~ Chat to $msnsettings[0]   Add $msnsettings[0] to your Buddy List  ~; } $yymain .= qq~ $userprofile[10] $yimon   $userprofile[9]
~; } if($musername eq "Guest") { $yymain .= qq~
$img{'email_sm'}

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

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

~; } $yymain .= qq~ $userprofile[11] $postinfo
$msub  $attachment
« $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 && $userpostdel != 1) { $yymain .= qq~ $menusep$img{'delete'}~; if((exists $moderators{$username} && $mdmod eq 1) || ($settings[7] eq 'Administrator' && $mdadmin eq 1) || ($settings[7] eq 'Global Moderator' && $mdglobal eq 1)) { $yymain .= qq~ ~; } if((exists $moderators{$username} && $mdmod eq 1) || ($settings[7] eq 'Administrator' && $mdadmin eq 1) || ($settings[7] eq 'Global Moderator' && $mdglobal eq 1)) { $yymain .= qq~ ~; } } } $yymain .= qq~

$message
$lastmodified $mip
$showattach $userprofile[5]
~; $counter++; } $yymain .= qq~
$txt{'139'}: $pageindex $replybutton$notify$menusep $img{'sendtopic'}$menusep $img{'print'}

~; $yymain .= qq~
~; if(exists $moderators{$username} || $settings[7] eq 'Administrator') { $yymain .= qq~$img{'admin_func'}  $img{'admin_move'}$menusep $img{'admin_rem'}$menusep $img{'admin_lock'}$menusep $img{'admin_sticky'} ~; } if((exists $moderators{$username} && $mdmod eq 1) || ($settings[7] eq 'Administrator' && $mdadmin eq 1) || ($settings[7] eq 'Global Moderator' && $mdglobal eq 1)) { if ($mstate != 1) {$yymain .= qq~~;} } if((exists $moderators{$username} && $mdmod eq 1) || ($settings[7] eq 'Administrator' && $mdadmin eq 1) || ($settings[7] eq 'Global Moderator' && $mdglobal eq 1)) { if ($mstate != 1) {$yymain .= qq~~;} } $yymain .= qq~ $selecthtml
$nav
~; if ($username ne "Guest" && $mstate != 1 && $enable_quickreply == 1) { $yymain .= qq~
$txt{'172a'}
~; if ($enable_quicksmilies == 1) { $yymain .= qq~ ~; } $yymain .= qq~
$txt{'70'}:
$txt{'297'}:
$txt{'72'}:
 
~; } if ($username ne "Guest" && $mstate != 1 && $enable_quickreply == 1) { $yymain .= qq~
$txt{'172a'}
~; if ($enable_quicksmilies == 1) { $yymain .= qq~ ~; } $yymain .= qq~
$txt{'70'}:
$txt{'297'}:
$txt{'72'}:
 
~; } if ($username ne "Guest" && $mstate != 1 && $enable_quickreply == 1) { $yymain .= qq~
$txt{'172a'}
~; if ($enable_quicksmilies == 1) { $yymain .= qq~ ~; } $yymain .= qq~
$txt{'70'}:
$txt{'297'}:
$txt{'72'}:
 
~; } $yytitle = $msubthread; &template; exit; } 1;