Ændring af en .pl fil.
Hej alle sammenKender i det med at man bliver mere og mere gråhåret, når man sidder med et problem som man ikke kan løse ?
Lige nu sidder jeg med denne .pl fil :
#!/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 = 30; # snip off a too long title, set 0 to always display the full title
$fontsize = 1; # 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
#################################################
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 = <FILE>;
&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} = <FILE>;
chomp $catname{$curcat};
$cataccess{$curcat} = <FILE>;
chomp $cataccess{$curcat};
@{$catboards{$curcat}} = <FILE>;
&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 = <FILE>;
&unlock(FILE);
close(FILE);
open(FILE, "$boardsdir/$curboard.dat");
&lock(FILE);
@boardinfo = <FILE>;
&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( <FILE> ) { $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");
$new = qq~ <font size=1 color=yellow face=verdana><i>NEW</i></font>~;
}
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;
open(FILE,"$vardir/censor.txt");
&lock(FILE);
while( chomp( $buffer = <FILE> ) ) {
($tmpa,$tmpb) = split(/=/,$buffer);
push(@censored,[$tmpa,$tmpb]);
}
&unlock(FILE);
close(FILE);
}
else {
print qq~<hr><b>No Entries available</b><hr>~;
}
print <<"EOT";
<table border=0 cellpadding=0 cellspacing=0>
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]} };
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 .= "...";}
}
print <<"EOT";
<tr><td width="2" valign="top"><font face="$fontface" color="$fontcolor" size="$fontsize"><nobr>$counter. </nobr></font></a></td>
<td><font face="$fontface" color="$fontcolor" size="$fontsize"><a href="$scripturl?board=$board&action=display&num=$tnum" target="_blank">$msub</a>$new</font></td></tr>
EOT
++$counter;
}
print <<"EOT";
</table>
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( <MLOG> ) {
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;
Hvor jeg gerne ville have hvert resultat til at blive præsenteret i en linie magen til dette :
<td onmouseover="this.style.backgroundColor='#EEEBCB'" style="BACKGROUND-COLOR: white" onmouseout="this.style.backgroundColor='white'" bgColor="#ffffff"><font size="2"><a href="http://www.rejsebeskrivelser.dk/build01/temaer/transportsyge.php" target="_top">Undgå
transportsyge</a></font></td>
( Du kan se et eksempel på hvad jeg gerne vil kunne gøre her : http://www.rejsebeskrivelser.dk/build01/pressemeddelser/pressemeddelser.htm
Nogen kreative forslag ?
