Stefan Muenz: Giga erwähnt www.selfhtml.de

Beitrag lesen

Hallo Andre

mich würde interessieren, wie das Skript aussieht, welches die ganzen Nachrichten zusammenfasst.

#!/usr/bin/perl

Define Variables

$basedir = "/der/pfad/zu/teamon/cgi-local";
$baseurl = "http://www.teamone.de/selfaktuell";
$baseurldir = "/der/pfad/zu/teamon/selfaktuell";

$mesgdir = "self_forum";
$archdir = "self_forum";
$mesgfile = "self_forum.html";

$curr_sec = 0;
$secs = 0;
@section = "";
$curr_link_line = 0;
$links = 0;
@link_line_tree = "";
$ext = "html";
$title = "SELFHTML Forum";
@files = "";
@topics = "";
@names = "";
@times = "";
@titles = "";
@emails = "";
@urls = "";
@contents = "";
$curr_file = 0;

print "Content-type: text/html\n\n";
print "<html><body>\n";

$Input = $ENV{'QUERY_STRING'};
($Tag, $Monat, $Jahr, $split_mesg) = split(/-/, $Input);

print "Tag: $Tag<br>\n";
print "Monat: $Monat<br>\n";
print "Jahr: $Jahr<br>\n";
print "Split-Message: $split_mesg<br><br>\n";

$arch_file = $Jahr.$Monat.$Tag.".html";
open(NEWFILE,">$baseurldir/$archdir/$arch_file");

&make_link_tree;
&make_sections;
&new_file;

#####################

Make Link Tree Subroutine

sub make_link_tree {
print "Link-Tree schreiben<br>\n";

open(MAIN,"$baseurldir/$mesgfile");
@main = <MAIN>;
close(MAIN);

$flag = 1;
foreach $main_line (@main) {  
      if ($main_line =~ /<!--top:.*-->|<!--begin.*-->|<!--insert.*-->|<!--responses*-->|<!--end.*-->|<!--start-->|<!--stop-->|</ul>\n/) {  
         if ($flag != 2) { $flag = 0; }
   if ($main_line =~ /<!--top: (.*)-->/) {
      if ($1 eq $split_mesg) { $flag = 2; $line = "<ul>\n".$main_line; $main_line = $line; }
      if ($flag == 2) {
        $topics[$curr_file] = $1;
        $files[$curr_file] = $1.".html";
        $curr_file++; $secs++; $count++; }
   }
   if ($main_line =~ /</ul>\n/) {
                 $line = "</ul>\n".$main_line; $main_line = $line;    
   }
   if ($flag == 2) {
            $main_line =~ s//selfhtml///g;
            $main_line =~ s/x3.gif/xgdown.gif/g;
            $main_line =~ s/width=15/width=14/g;
   $main_line =~ s/http://www.teamone.de/selfaktuell/self_forum//#a/g;  
   $main_line =~ s/.html//g;  
            $link_line_tree[$curr_link_line] = $main_line;
            $curr_link_line++;
   }
      }
  }
print "Link-Tree geschrieben<br>\n";
@link_tree = @main;
}

#####################

Make Section Subroutine

sub make_sections {
for($i = 0; $i < $secs; $i++) {
   $section[$curr_sec] = "<table bgcolor=#EEEEEE class="doc" width=100%><tr><td>";
   $section[$curr_sec] = $section[$curr_sec]."<a href="#top"><img src="xgoup.gif" width=14 height=10 border=0></a><a href="#bottom"><img src="xgdown.gif" width=14 height=10 border=0></a> ";
   $section[$curr_sec] = $section[$curr_sec]."</td></tr></table>";
   # print "Datei verarbeiten: $baseurldir/$mesgdir/$files[$curr_sec]<br>\n";
   open(MESG_FILE,"$baseurldir/$mesgdir/$files[$curr_sec]");
   @mesg = <MESG_FILE>;
   close(MESG_FILE);
   foreach $mesg_line (@mesg) {
      if ($mesg_line =~ /<title>SELFHTML aktuell: (.*)</title>/) {
     $titles[$curr_sec] = $1;
      }
      if ($mesg_line =~ /Die folgende Nachricht zum Thema stammt von: <b>(.*)</b>, <img src="/selfhtml/xgmail.gif" width=15 height=10 border=0> <a href="mailto:(.*)"><b>.*</b></a>, (.*)<br>/) {
   $names[$curr_sec] = $1;
   $emails[$curr_sec] = $2;
   $times[$curr_sec] = $3;
   $anchor = $files[$curr_sec];
   $anchor =~ s/.html//g;
      $section[$curr_sec] = $section[$curr_sec]."<h2 class="sh2"><a name="a$anchor">$titles[$curr_sec]</a></h2>\n";
      $section[$curr_sec] = $section[$curr_sec]."<p>\n";
      $section[$curr_sec] = $section[$curr_sec]."von: <b>$names[$curr_sec]</b>, <img src="xgmail.gif" width=15 height=10 border=0> <a href="mailto:$emails[$curr_sec]"><b>$emails[$curr_sec]</b></a><br>";
      $section[$curr_sec] = $section[$curr_sec]."geschrieben am: <b>$times[$curr_sec]</b></p>\n";
   }    
   if ($mesg_line =~ /<hr noshade size=1 width=260 align=left><p><tt>/) {
        $flag = 1; }
   if ($mesg_line =~ /</tt></p><br>/) {
        $flag = 0; }
   if ($flag == 1) {
          $contents[$curr_sec] = $contents[$curr_sec].$mesg_line;  }
   }
   $section[$curr_sec] = $section[$curr_sec]."<p>$contents[$curr_sec]</tt></p>\n";
   $curr_sec++;
}  
}

#####################

New File Subroutine

sub new_file {

print NEWFILE "<html>\n";
   print NEWFILE "<head>\n";
   print NEWFILE "<title>SELFHTML-Forum Archiv</title>\n";
   print NEWFILE "<link rel=stylesheet type="text/css" href="wselfhtm.css">\n";
   print NEWFILE "</head>\n";
   print NEWFILE "<body bgcolor=#FFFFFF text=#000000 link=#AA5522 vlink=#772200 alink=#000000>\n";
   print NEWFILE "<p><nobr><a class="an" name="top"><img src="x2.gif" width=16 height=13 border=0></a> ";
   print NEWFILE "<a href="../index.htm"><b>SELFHTML Aktuell</b></a> ";
   print NEWFILE "<img src="x2.gif" width=16 height=13 border=0> <a href="../self_forum.html"><b>SELFHTML Forum</b></a></nobr></p>\n";
   print NEWFILE "<hr noshade size=1>\n";
   print NEWFILE "<table cellpadding=4 cellspacing=1 width=100%>\n";
   print NEWFILE "<tr>\n";
   print NEWFILE "<td bgcolor=#EEEEEE class="doc" width=110><img src="xweb.gif" width=106 height=109></td>\n";
   print NEWFILE "<td bgcolor=#EEEEEE class="doc" valign=bottom width=100%><h2>SELFHTML Forum<br>Themen, begonnen vor dem $Tag.$Monat.$Jahr</h2></td>\n";
   print NEWFILE "</tr>\n";
   print NEWFILE "</table>\n";

print NEWFILE "@link_line_tree";

print NEWFILE "@section";

print NEWFILE "<table cellpadding=4 cellspacing=1 width=100%>\n";
   print NEWFILE "<tr><td bgcolor=#EEEEEE class="doc">\n";
   print NEWFILE "<a href="#top"><img src="xgoup.gif" width=14 height=10 border=0></a>\n";
   print NEWFILE "</td></tr>\n";
   print NEWFILE "</table>\n";
   print NEWFILE "<hr noshade size=1>\n";
   print NEWFILE "<p><nobr><a class="an" name="top"><img src="x2.gif" width=16 height=13 border=0></a> ";
   print NEWFILE "<a href="../index.htm"><b>SELFHTML Aktuell</b></a> ";
   print NEWFILE "<img src="x2.gif" width=16 height=13 border=0> <a href="../self_forum.html"><b>SELFHTML Forum</b></a></nobr></p>\n";
   print NEWFILE "</body>\n";
   print NEWFILE "</html>\n";
   close(NEWFILE);
   print "<p>neue HTML-Datei angelegt</p>\n";
}

foreach $file_entry (@files) {  
   $file_name = $file_entry;
   push(@delfiles,$baseurldir."/".$mesgdir."/".$file_name);
    }
unlink @delfiles;

viel Vergnuegen damit <g>
  Stefan Muenz

PS: eigentlich braucht jemand, der das obige Kauderwelsch versteht, nur noch den Dateinamen des Scripts auf teamone.de kennen, um den Schwanzabschneider selber anzustossen. Aber selbst wenn jemand den Dateinamen herausbekommen sollte - dann apelliere an die allgemeine Vernunft, keinen Unfug damit zu treiben.

viele Gruesse
  Stefan Muenz