#!/usr/bin/perl # HEADLINE MOD by [CV]XXL http://boardmod.xnull.com use CGI::Carp qw(fatalsToBrowser); use Time::Local 'timelocal'; require "Settings.pl"; ################################################# ## Here comes the part you can/have to edit ## ################################################# $display = 10; # number of headlines displayed $snip_headlines_when_longer_than = 40; # was 30 - snip off a too long title, set 0 to always display the full title #$fontsize = 1; # font size $fontsize = 2; # font size $fontcolor = "#ff7f00"; # font color $fontface = "arial"; # font face #$scripturl = qq~$boardurl/YaBB.pl~; # change the .pl ending to .cgi if you have the cgi version of yabb $scripturl = qq~$boardurl/YaBB.cgi~; # change the .pl ending to .cgi if you have the cgi version of yabb ################################################# # # matt's stuff $snip_message_when_longer_than = 150; # truncate message summaries to this length # ################################################# foreach (split(/; /,$ENV{'HTTP_COOKIE'})) { $_ =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; ($cookie,$value) = split(/=/); $yyCookies{$cookie} = $value; } if( $yyCookies{$cookiepassword} ) { $password = $yyCookies{$cookiepassword}; $username = $yyCookies{$cookieusername} || 'Guest'; } else { $password = ''; $username = 'Guest'; } $cgi = qq~$scripturl?board=$currentboard~; print "Content-type: text/html\n\n"; @categories = (); open(FILE, "$vardir/cat.txt"); &lock(FILE); @categories = ; &unlock(FILE); close(FILE); $oldestfound = stringtotime("01/10/37 at 00:00:00"); foreach $curcat (@categories) { chomp $curcat; open(FILE, "$boardsdir/$curcat.cat"); &lock(FILE); $catname{$curcat} = ; chomp $catname{$curcat}; $cataccess{$curcat} = ; chomp $cataccess{$curcat}; @{$catboards{$curcat}} = ; &unlock(FILE); close(FILE); $openmemgr{$curcat} = 0; @membergroups = split( /,/, $cataccess{$curcat} ); if( ! $cataccess{$curcat} ) { $openmemgr{$curcat} = 1; } unless( $openmemgr{$curcat} ) { next; } foreach $curboard (@{$catboards{$curcat}}) { chomp $curboard; open(FILE, "$boardsdir/$curboard.txt"); &lock(FILE); @threads = ; &unlock(FILE); close(FILE); open(FILE, "$boardsdir/$curboard.dat"); &lock(FILE); @boardinfo = ; &unlock(FILE); close(FILE); foreach (@boardinfo) { chomp; } @{$boardinfo{$curboard}} = @boardinfo; $cat{$curboard} = $curcat; for ($i = 0; $i < @threads; $i++) { chomp $threads[$i]; ($tnum, $tsub, $tname, $temail, $tdate, $treplies, $tusername, $ticon, $tstate) = split( /\|/, $threads[$i] ); open(FILE, "$datadir/$tnum.txt") || next; &lock(FILE); while( ) { $message = $_; } # get only the last post for this thread. &unlock(FILE); close(FILE); chomp $message; if( $message ) { ($msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $message, $mns) = split(/\|/,$message); $mtime = stringtotime($mdate); if( $numfound >= $display && $mtime <= $oldestfound ) { next; } else { # Decide if thread should have the "NEW" indicator next to it. # Do this by reading the user's log for last read time on thread, # and compare to the last post time on the thread. $dlp = &getlog($tnum); $threaddate = stringtotime($tdate); if( $max_log_days_old && $dlp != $threaddate && $username ne 'Guest' && &getlog("$curboard--mark") < $threaddate ) { $tmpx = &getlog("$curboard--mark"); ### 061602MEC CHANGE COLOR OF NEW FROM YELLOW TO RED $new = qq~ NEW~; $new = qq~ NEW~; } else { $new = ''; } $data{$mtime} = [$curboard, $tnum, $treplies, $tusername, $tname, $tsub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $message, $mns, $new]; if( $mtime < $oldestfound ) { $oldestfound = $mtime; } ++$numfound; } } } } } @messages = sort {$b <=> $a } keys %data; if( @messages ) { if( @messages > $display ) { $#messages = $display - 1; } $counter = 1; #### #### MEC 061702 REMOVED TO NOT CENSOR HEADLINES TO IMPROVE LOAD SPEED #### #### open(FILE,"$vardir/censor.txt"); #### &lock(FILE); #### while( chomp( $buffer = ) ) { #### ($tmpa,$tmpb) = split(/=/,$buffer); #### push(@censored,[$tmpa,$tmpb]); #### } #### &unlock(FILE); #### close(FILE); } else { print qq~
No Entries available
~; } ### Added 061802 To print user name print "
Welcome, $username!
"; if( $username eq 'Guest') { print <<"EOT"; Please Login or Register
EOT }; ### End added 061802 To print username print <<"EOT"; EOT for( $i = 0; $i < @messages; $i++ ) { ($board, $tnum, $c, $tusername, $tname, $msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $message, $mns, $new) = @{ $data{$messages[$i]} }; #### #### MEC 061702 REMOVED TO NOT CENSOR HEADLINES TO IMPROVE LOAD SPEED #### #### foreach (@censored) { #### ($tmpa,$tmpb) = @{$_}; #### $message =~ s~\Q$tmpa\E~$tmpb~gi; #### $msub =~ s~\Q$tmpa\E~$tmpb~gi; #### } if ($snip_headlines_when_longer_than) { if (length($msub) > $snip_headlines_when_longer_than) { $msub = substr($msub,0,$snip_headlines_when_longer_than); $msub .= "...";} } # MATT'S STUFF STARTS $csub=$message; $csub =~ s/<.*?>/ /g; # discard html between <> $csub =~ s/\[.*?\]//g; # remove leftover UBB between [] if ($snip_message_when_longer_than) { if (length($csub) > $snip_message_when_longer_than) { $csub = substr($csub,0,$snip_message_when_longer_than); $csub .= "...";} } # MATT'S STUFF ENDS $capboard=uc($board); if ($capboard ne "TEST") { #skip test posts print <<"EOT"; EOT ++$counter; }; # end skip test } #end of for messages print <<"EOT";
$counter. $msub$new
EOT sub lock { my $lock_file = $_[0]; my $flag = 1; my $count = 0; if($use_flock==1) { flock($lock_file, $LOCK_EX); } elsif ($use_flock==2) { while($flag and $count < 15) { $flag = check_flock($lock_file); $count++; } unlink($lock_file) if ($count == 15); open(LOCK_FILE, ">$lock_file"); } } sub unlock { my $lock_file = $_[0]; if($use_flock==1) { flock($lock_file, $LOCK_UN); } elsif ($use_flock==2) { close(LOCK_FILE); unlink($lock_file) if (-e $lock_file); } } sub stringtotime { unless( $_[0] ) { return 0; } my( $adate, $atime ) = split(m~ at ~, $_[0]); my( $amonth, $aday, $ayear ) = split(m~/~, $adate); my( $ahour, $amin, $asec ) = split (m~:~, $atime); $asec = int($asec) || 0; $amin = int($amin) || 0; $ahour = int($ahour) || 0; $ayear = int($ayear) || 0; $amonth = int($amonth) || 0; $aday = int($aday) || 0; $ayear += 100; if( $amonth < 1 ) { $amonth = 0; } elsif( $amonth > 12 ) { $amonth = 11; } else { --$amonth; } if( $aday < 1 ) { $aday = 1; } elsif( $aday > 31 ) { $aday = 31; } return( timelocal($asec, $amin, $ahour, $aday, $amonth, $ayear) - (3600*$timeoffset) ); } sub getlog { if( $username eq 'Guest' || $max_log_days_old == 0 ) { return; } my $entry = $_[0]; unless( defined %yyuserlog ) { %yyuserlog = (); my( $name, $value, $thistime, $adate, $atime, $amonth, $aday, $ayear, $ahour, $amin, $asec ); my $mintime = time - ( $max_log_days_old * 86400 ); open(MLOG, "$memberdir/$username.log"); &lock(MLOG); while( ) { chomp; ($name, $value, $thistime) = split( /\|/, $_ ); unless( $name ) { next; } if( $value ) { $thistime = stringtotime($value); } if( $thistime > $mintime ) { $yyuserlog{$name} = $thistime; } } &unlock(MLOG); close(MLOG); } return $yyuserlog{$entry}; } exit;