Wer kennt sich mit Perl aus?
Wer kennt sich mit Perl aus?

Antworten
Regina
registrierte BenutzerIn
Beiträge: 1511
Registriert: Fr 19. Dez 2008, 13:24
Geschlecht: meist männlich
Pronomen:
Wohnort (Name): Hamburg
Hat sich bedankt: 149 Mal
Danksagung erhalten: 77 Mal
Gender:
Kontaktdaten:

Wer kennt sich mit Perl aus?

Post 1 im Thema

Beitrag von Regina »

Hallo zusammen,

einige von Euch wissen ja evtl., dass ich die Webseite von crossdressinghamburg.de pflege.
Naja, soweit ich es kann.
Seit kurzem lässt sich da das Gästebuch http://www.crossdressinghamburg.de/cgi- ... estbook.pl nicht mehr aufrufen. Es kommt nur eine leere Seite. Wenn ich mir den Quellcode der Antwortseite anschaue steht da nur eine "1". Ich habe an dem Gästebuch keine Änderungen vorgenommen. Wenn ich ein Backup zurück spiele kommt auch nichts. Obwohl das vorher problemlos funktionierte. Es sind auch keine korrupten Einträge im Datensatz.
Die Adminoberfläche des Gästebuchs lässt sich aber problemlos laden: http://www.crossdressinghamburg.de/cgi- ... k/admin.pl.
Da kann ich auch alle Einträge sehen und bearbeiten.

Woran kann das liegen?
Was muss ich prüfen / verändern?
Wer kann mir helfen?

Liebe Grüße,
eine leicht verzweifelte Regina
Die höchste Form des Glücks ist ein Leben mit einem gewissen Grad an Verrücktheit. (Erasmus von Rotterdam)
Lina
registrierte BenutzerIn
Beiträge: 4369
Registriert: Di 25. Jan 2011, 00:34
Pronomen:
Hat sich bedankt: 52 Mal
Danksagung erhalten: 189 Mal
Gender:
Kontaktdaten:

Re: Wer kennt sich mit Perl aus?

Post 2 im Thema

Beitrag von Lina »

Unmittelbar würde ich mich gar nicht so sehr mit der Pers-Programmierung rum schlagen, denn die hat ja funktioniert und entstammt wahrscheinlich eh von einem vorgefertigten Script das du in den CGP-Bin des Providers hochgeladen hast. Daran kann Programmierungsmäßig nichts verändert haben. Entweder läuft es oder die Datei ist irgendwie beschädigt und muss ersetzt werden.

Ich würde erst mal checken, ob du ungewollt etwas in der Struktur verändert hast, dann ob evtl. etwas mit der Groß-/Kleinschreibung in den Dateinamen nicht stimmt. Bei einigen Servern ist das egal, bei anderen nicht. Etwas kann sich ja technisch beim Provder verändet haben.
Und falls nichts feststellbar ist, dein Script nochmals hochladen, genau so wie du es machen würdest, wenn alles ganz neu wäre.
Pauline

Re: Wer kennt sich mit Perl aus?

Post 3 im Thema

Beitrag von Pauline »

Hallo Regina :()b

also ich kenn' mich damit nicht aus, obwohl ich Dir liebend gern helfen würde!
Aber wir haben doch hier unser "IT-Abteilung"...oder? viewtopic.php?f=54&t=4842

Also liebe IT-lerinnen, helft doch mal der armen Regina (flo)

LG Pauline )))(:
Regina
registrierte BenutzerIn
Beiträge: 1511
Registriert: Fr 19. Dez 2008, 13:24
Geschlecht: meist männlich
Pronomen:
Wohnort (Name): Hamburg
Hat sich bedankt: 149 Mal
Danksagung erhalten: 77 Mal
Gender:
Kontaktdaten:

Re: Wer kennt sich mit Perl aus?

Post 4 im Thema

Beitrag von Regina »

Hi zusammen,

Ich konnte den Fehler einkreisen. In dem Perl Skript "guestbook.pl" gibt es eine Zeile mit folgendem Inhalt:

increaseStats($ENV{'REMOTE_ADDR'});

Wenn ich die Zeile mit Gartenzäunen ausblende (####) läuft das Gästebuch wieder.
increaseStats ist eine Subroutine welche zwei Dateien öffnet und dort hinein schreibt. Ich habe beide Dateien auf CHMOD 0666 gesetzt. Das scheint jedoch nichts zu ändern.

Was passiert denn da noch, was zum Hängen des Gästebuchs führen könnte?

Es wäre schön, wen mir jemand helfen könnte.

Liebe Grüße,
Regina

sub increaseStats {
my $check_ip = shift;
my $ip = "";
my $lastvisited = "";
my $lastvisitedinsecs = 0;
my $line = "";
my $linestokeep = "";
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$ydat,$isdst) = localtime();
my $dateandtimeinsecs = timelocal($sec,$min,$hour,$mday,$mon,$year);

my $countthisvisit = 1;
open (IPS, "visitorip.txt");
while (defined($line=<IPS>)) {
($ip, $lastvisited) = split(/ /,$line);
$lastvisited =~ s/\n//g;
my ($cyear, $cmon, $cmday, $chour, $cmin, $csec) = split(/-/, $lastvisited);
$lastvisitedinsecs = timelocal($csec,$cmin,$chour,$cmday,$cmon - 1,$cyear - 1900);

if ($check_ip eq $ip && ($dateandtimeinsecs - $lastvisitedinsecs) < 900 ) {
# Don't count this visitor again
$countthisvisit = 0;
}
if ($lastvisitedinsecs + 900 < $dateandtimeinsecs) {
# We can forget about this line, the record is too old, the ip should no longer be blocked
} else {
# We need to keep this blocking
$linestokeep = $linestokeep . $line;
}
}
close (IPS);

open (IPS, ">visitorip.txt");
print IPS $linestokeep;
close (IPS);

if ($countthisvisit) {
my $line = "";
my $currentmonth = $mon + 1;
open (DT, "stats.txt");
$stats_counter_nrofmonth = <DT>;
$stats_counter_thismonth = <DT>;
$stats_counter_total = <DT>;
close (DT);
open (DT, ">stats.txt");
print DT ($mon+1)."\n".
($currentmonth != $stats_counter_nrofmonth ? "1" : ($stats_counter_thismonth+1))."\n".
($stats_counter_total+1)."\n";
close (DT);

store_visitor_ip($check_ip);
}
}
Die höchste Form des Glücks ist ein Leben mit einem gewissen Grad an Verrücktheit. (Erasmus von Rotterdam)
Anne-Mette
Administratorin
Beiträge: 27521
Registriert: Sa 24. Nov 2007, 18:19
Geschlecht: W
Pronomen: sie
Wohnort (Name): Ringsberg
Forum-Galerie: gallery/album/1
Hat sich bedankt: 205 Mal
Danksagung erhalten: 2421 Mal
Gender:
Kontaktdaten:

Re: Wer kennt sich mit Perl aus?

Post 5 im Thema

Beitrag von Anne-Mette »

Moin,

eigentlich verstellt sich da nichts. Es kann eher sein, dass der Provider etwas auf dem Server geändert hat (?)
Das Script ist ja schon relativ alt, stammt von 1995/96
Gibt es keine anderen Lösungen?

Ansonsten könntest Du nur Deine vorhandenen Dateien (vorher sichern!!!) ersetzen - oder erst einmal mit neu heruntergeladenen vergleichen.
Die guestbook.pl müsste jene sein:

Code: Alles auswählen

#!/usr/bin/perl
##############################################################################
# Guestbook                     Version 2.3.1                                #
# Copyright 1996 Matt Wright    mattw@scriptarchive.com                      #
# Created 4/21/95               Last Modified 10/29/95                       #
# Scripts Archive at:           http://www.scriptarchive.com/                #
##############################################################################
# COPYRIGHT NOTICE                                                           #
# Copyright 1996 Matthew M. Wright  All Rights Reserved.                     #
#                                                                            #
# Guestbook may be used and modified free of charge by anyone so long as     #
# this copyright notice and the comments above remain intact.  By using this #
# code you agree to indemnify Matthew M. Wright from any liability that      #
# might arise from it's use.                                                 #
#                                                                            #
# Selling the code for this program without prior written consent is         #
# expressly forbidden.  In other words, please ask first before you try and  #
# make money off of my program.                                              #
#                                                                            #
# Obtain permission before redistributing this software over the Internet or #
# in any other medium.        In all cases copyright and header must remain intact.#
##############################################################################
# Set Variables

$guestbookurl = "http://your.host.com/~yourname/guestbook.html";
$guestbookreal = "/home/yourname/public_html/guestbook.html";
$guestlog = "/home/yourname/public_html/guestlog.html";
$cgiurl = "http://your.host.com/cgi-bin/guestbook.pl";
$date_command = "/usr/bin/date";

# Set Your Options:
$mail = 0;              # 1 = Yes; 0 = No
$uselog = 1;            # 1 = Yes; 0 = No
$linkmail = 1;          # 1 = Yes; 0 = No
$separator = 1;         # 1 = <hr>; 0 = <p>
$redirection = 0;       # 1 = Yes; 0 = No
$entry_order = 1;       # 1 = Newest entries added first;
                        # 0 = Newest Entries added last.
$remote_mail = 0;       # 1 = Yes; 0 = No
$allow_html = 1;        # 1 = Yes; 0 = No
$line_breaks = 0;        # 1 = Yes; 0 = No

# If you answered 1 to $mail or $remote_mail you will need to fill out
# these variables below:
$mailprog = '/usr/lib/sendmail';
$recipient = 'you@your.com';

# Done
##############################################################################

# Get the Date for Entry
$date = `$date_command +"%A, %B %d, %Y at %T (%Z)"`; chop($date);
$shortdate = `$date_command +"%D %T %Z"`; chop($shortdate);

# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

# Split the name-value pairs
@pairs = split(/&/, $buffer);

foreach $pair (@pairs) {
   ($name, $value) = split(/=/, $pair);

   # Un-Webify plus signs and %-encoding
   $value =~ tr/+/ /;
   $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
   $value =~ s/<!--(.|\n)*-->//g;

   if ($allow_html != 1) {
      $value =~ s/<([^>]|\n)*>//g;
   }

   $FORM{$name} = $value;
}

# Print the Blank Response Subroutines
&no_comments unless $FORM{'comments'};
&no_name unless $FORM{'realname'};

# Begin the Editing of the Guestbook File
open (FILE,"$guestbookreal") || die "Can't Open $guestbookreal: $!\n";
@LINES=<FILE>;
close(FILE);
$SIZE=@LINES;

# Open Link File to Output
open (GUEST,">$guestbookreal") || die "Can't Open $guestbookreal: $!\n";

for ($i=0;$i<=$SIZE;$i++) {
   $_=$LINES[$i];
   if (/<!--begin-->/) {

      if ($entry_order eq '1') {
         print GUEST "<!--begin-->\n";
      }

      if ($line_breaks == 1) {
         $FORM{'comments'} =~ s/\cM\n/<br>\n/g;
      }

      print GUEST "<b>$FORM{'comments'}</b><br>\n";

      if ($FORM{'url'}) {
         print GUEST "<a href=\"$FORM{'url'}\">$FORM{'realname'}</a>";
      }
      else {
         print GUEST "$FORM{'realname'}";
      }

      if ( $FORM{'username'} ){
         if ($linkmail eq '1') {
            print GUEST " \<<a href=\"mailto:$FORM{'username'}\">";
            print GUEST "$FORM{'username'}</a>\>";
         }
         else {
            print GUEST " <$FORM{'username'}>";
         }
      }

      print GUEST "<br>\n";

      if ( $FORM{'city'} ){
         print GUEST "$FORM{'city'},";
      }

      if ( $FORM{'state'} ){
         print GUEST " $FORM{'state'}";
      }

      if ( $FORM{'country'} ){
         print GUEST " $FORM{'country'}";
      }

      if ($separator eq '1') {
         print GUEST " - $date<hr>\n\n";
      }
      else {
         print GUEST " - $date<p>\n\n";
      }

      if ($entry_order eq '0') {
         print GUEST "<!--begin-->\n";
      }

   }
   else {
      print GUEST $_;
   }
}

close (GUEST);

# Log The Entry

if ($uselog eq '1') {
   &log('entry');
}


#########
# Options

# Mail Option
if ($mail eq '1') {
   open (MAIL, "|$mailprog $recipient") || die "Can't open $mailprog!\n";

   print MAIL "Reply-to: $FORM{'username'} ($FORM{'realname'})\n";
   print MAIL "From: $FORM{'username'} ($FORM{'realname'})\n";
   print MAIL "Subject: Entry to Guestbook\n\n";
   print MAIL "You have a new entry in your guestbook:\n\n";
   print MAIL "------------------------------------------------------\n";
   print MAIL "$FORM{'comments'}\n";
   print MAIL "$FORM{'realname'}";

   if ( $FORM{'username'} ){
      print MAIL " <$FORM{'username'}>";
   }

   print MAIL "\n";

   if ( $FORM{'city'} ){
      print MAIL "$FORM{'city'},";
   }

   if ( $FORM{'state'} ){
      print MAIL " $FORM{'state'}";
   }

   if ( $FORM{'country'} ){
      print MAIL " $FORM{'country'}";
   }

   print MAIL " - $date\n";
   print MAIL "------------------------------------------------------\n";

   close (MAIL);
}

if ($remote_mail eq '1' && $FORM{'username'}) {
   open (MAIL, "|$mailprog -t") || die "Can't open $mailprog!\n";

   print MAIL "To: $FORM{'username'}\n";
   print MAIL "From: $recipient\n";
   print MAIL "Subject: Entry to Guestbook\n\n";
   print MAIL "Thank you for adding to my guestbook.\n\n";
   print MAIL "------------------------------------------------------\n";
   print MAIL "$FORM{'comments'}\n";
   print MAIL "$FORM{'realname'}";

   if ( $FORM{'username'} ){
      print MAIL " <$FORM{'username'}>";
   }

   print MAIL "\n";

   if ( $FORM{'city'} ){
      print MAIL "$FORM{'city'},";
   }

   if ( $FORM{'state'} ){
      print MAIL " $FORM{'state'}";
   }

   if ( $FORM{'country'} ){
     print MAIL " $FORM{'country'}";
   }

   print MAIL " - $date\n";
   print MAIL "------------------------------------------------------\n";

   close (MAIL);
}

# Print Out Initial Output Location Heading
if ($redirection eq '1') {
   print "Location: $guestbookurl\n\n";
}
else {
   &no_redirection;
}

#######################
# Subroutines

sub no_comments {
   print "Content-type: text/html\n\n";
   print "<html><head><title>No Comments</title></head>\n";
   print "<body><h1>Your Comments appear to be blank</h1>\n";
   print "The comment section in the guestbook fillout form appears\n";
   print "to be blank and therefore the Guestbook Addition was not\n";
   print "added.  Please enter your comments below.<p>\n";
   print "<form method=POST action=\"$cgiurl\">\n";
   print "Your Name:<input type=text name=\"realname\" size=30 ";
   print "value=\"$FORM{'realname'}\"><br>\n";
   print "E-Mail: <input type=text name=\"username\"";
   print "value=\"$FORM{'username'}\" size=40><br>\n";
   print "City: <input type=text name=\"city\" value=\"$FORM{'city'}\" ";
   print "size=15>, State: <input type=text name=\"state\" ";
   print "value=\"$FORM{'state'}\" size=15> Country: <input type=text ";
   print "name=\"country\" value=\"$FORM{'country'}\" size=15><p>\n";
   print "Comments:<br>\n";
   print "<textarea name=\"comments\" COLS=60 ROWS=4></textarea><p>\n";
   print "<input type=submit> * <input type=reset></form><hr>\n";
   print "Return to the <a href=\"$guestbookurl\">Guestbook</a>.";
   print "\n</body></html>\n";

   # Log The Error
   if ($uselog eq '1') {
      &log('no_comments');
   }

   exit;
}

sub no_name {
   print "Content-type: text/html\n\n";
   print "<html><head><title>No Name</title></head>\n";
   print "<body><h1>Your Name appears to be blank</h1>\n";
   print "The Name Section in the guestbook fillout form appears to\n";
   print "be blank and therefore your entry to the guestbook was not\n";
   print "added.  Please add your name in the blank below.<p>\n";
   print "<form method=POST action=\"$cgiurl\">\n";
   print "Your Name:<input type=text name=\"realname\" size=30><br>\n";
   print "E-Mail: <input type=text name=\"username\"";
   print " value=\"$FORM{'username'}\" size=40><br>\n";
   print "City: <input type=text name=\"city\" value=\"$FORM{'city'}\" ";
   print "size=15>, State: <input type=text name=\"state\" ";
   print "value=\"$FORM{'state'}\" size=2> Country: <input type=text ";
   print "value=USA name=\"country\" value=\"$FORM{'country'}\" ";
   print "size=15><p>\n";
   print "Comments have been retained.<p>\n";
   print "<input type=hidden name=\"comments\" ";
   print "value=\"$FORM{'comments'}\">\n";
   print "<input type=submit> * <input type=reset><hr>\n";
   print "Return to the <a href=\"$guestbookurl\">Guestbook</a>.";
   print "\n</body></html>\n";

   # Log The Error
   if ($uselog eq '1') {
      &log('no_name');
   }

   exit;
}

# Log the Entry or Error
sub log {
   $log_type = $_[0];
   open (LOG, ">>$guestlog");
   if ($log_type eq 'entry') {
      print LOG "$ENV{'REMOTE_HOST'} - [$shortdate]<br>\n";
   }
   elsif ($log_type eq 'no_name') {
      print LOG "$ENV{'REMOTE_HOST'} - [$shortdate] - ERR: No Name<br>\n";
   }
   elsif ($log_type eq 'no_comments') {
      print LOG "$ENV{'REMOTE_HOST'} - [$shortdate] - ERR: No ";
      print LOG "Comments<br>\n";
   }
}

# Redirection Option
sub no_redirection {

   # Print Beginning of HTML
   print "Content-Type: text/html\n\n";
   print "<html><head><title>Thank You</title></head>\n";
   print "<body><h1>Thank You For Signing The Guestbook</h1>\n";

   # Print Response
   print "Thank you for filling in the guestbook.  Your entry has\n";
   print "been added to the guestbook.<hr>\n";
   print "Here is what you submitted:<p>\n";
   print "<b>$FORM{'comments'}</b><br>\n";

   if ($FORM{'url'}) {
      print "<a href=\"$FORM{'url'}\">$FORM{'realname'}</a>";
   }
   else {
      print "$FORM{'realname'}";
   }

   if ( $FORM{'username'} ){
      if ($linkmail eq '1') {
         print " <<a href=\"mailto:$FORM{'username'}\">";
         print "$FORM{'username'}</a>>";
      }
      else {
         print " <$FORM{'username'}>";
      }
   }

   print "<br>\n";

   if ( $FORM{'city'} ){
      print "$FORM{'city'},";
   }

   if ( $FORM{'state'} ){
      print " $FORM{'state'}";
   }

   if ( $FORM{'country'} ){
      print " $FORM{'country'}";
   }

   print " - $date<p>\n";

   # Print End of HTML
   print "<hr>\n";
   print "<a href=\"$guestbookurl\">Back to the Guestbook</a>\n";         print "- You may need to reload it when you get there to see your\n";
   print "entry.\n";
   print "</body></html>\n";

   exit;
}
Regina
registrierte BenutzerIn
Beiträge: 1511
Registriert: Fr 19. Dez 2008, 13:24
Geschlecht: meist männlich
Pronomen:
Wohnort (Name): Hamburg
Hat sich bedankt: 149 Mal
Danksagung erhalten: 77 Mal
Gender:
Kontaktdaten:

Re: Wer kennt sich mit Perl aus?

Post 6 im Thema

Beitrag von Regina »

Hallo Claus Peter,

Ich glaube auch nicht das sich da etwas verstellt. Ich dachte das dort evtl. Code verwendet wird, der heute nicht mehr unterstützt wird und es somit zum Absturz kommt.

Ich verstehe auch die Subroutine nicht wirklich. Das Gästebuch verhindert mehrere Einträge hintereinander. Dies wird an der Stelle, anhand der IP, wohl abgefragt. Zunächst dachte ich, dass die Berechtigungen auf die beiden txt Dateien nicht Korrekt wären. Aber mit 655 haben ja alle Schreib- und Leserecht. Ich hatte zwischenzeitlich auch 777 probiert. Das ändert jedoch auch nichts. Wenn ich Subroutine nicht anspringen lasse läuft der Rest des Scripts.

Ich habe schon ein anders Gästebuch installiert. Es gibt aber keine Möglichkeit die alten Beiträge zu übernehmen.
Bei dem jetzigen Gästebuch wird mir bei einem Neueintrag eine Mail gesendet. Ich kann den Beitrag dann über einen Link in der Mail entweder löschen oder freigeben. Das bieten die neuen Gästebücher nicht.

Der von Dir gezeigte Code ist es nicht. Der Code des Gästebuchs ist folgendermaßen.

Code: Alles auswählen

#!/usr/bin/perl -w
#/xampp/perl/bin/perl.exe

##########################################################################
# COPYRIGHT NOTICE:
#
# Copyright FocalMedia.Net 2001
#
# This program is free to use for commercial and non commercial use.
# This script may be used and modified by anyone, so long as this copyright
# notice and the header above remain intact. Selling the code for this
# program without prior written consent is expressly forbidden.
#
# This program is distributed "as is" and without warranty of any
# kind, either express or implied.
#
##########################################################################

use strict;
use Time::Local;
use Fcntl ':flock'; # import LOCK_* constants

use Cwd;

my %fields;

chdir "E:/xampp/htdocs/water/";


######## config from setup.cfg
my $cgiscriptgb = "";
my $cgiscriptad = "";
my $html_loc = "";
my $html_url = "";
my $username = "";
my $password = "";
my $AdminAddress = "";
my $cfg_visible = "";
my $cfg_Homepage = '';
my $cfg_GuestbookTitle = '';
my $cfg_language = '';
my $cfg_prompt_NameTooShort = '';
my $cfg_prompt_MsgMissing = '';
my $cfg_prompt_MsgTooLong = '';
my $cfg_prompt_EmailInvalid = '';
my $cfg_prompt_MathResultMissing = '';
my $cfg_prompt_MathResultWrong = '';
my $cfg_prompt_IpIsBlocked = '';

my $stats_counter_thismonth = 0;
my $stats_counter_total = 0;
my $stats_counter_nrofmonth = 0;

my $imagep = "";

my $fsize1 = 0;

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

&get_env;
&get_setup;

if ($fields{'fct'} eq "post") {
  &post_operation;
} else {
  &display_guestbook;
}

exit;




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


sub display_guestbook {
    my $ml = "";
    my $listformat = "";
    my $pagenavigationformat = "";
    my $answerformat = "";
    my $locationformat = "";
    my $homepageformat = "";
    my $randnum1 = 0;
    my $randnum2 = 0;
    my $randresult = 0;
    my $fsize1 = 0;

    ### Entries in data.txt
    my $line = "";
    my $entryId = "";
    my $visible = "";
    my $location = "";
    my $msg = "";
    my $email = "";
    my $emailvisible = "";
    my $homepage = "";
    my $ip = "";
    my $date = "";
    my $name = "";
    my $answer = "";

    my $listings = "";
    my $gentries = "";

    #### increaseStats($ENV{'REMOTE_ADDR'});
    getStatistics();


    $fsize1 = (-s "$html_loc/main_layout.html");
    open (RVF, "$html_loc/main_layout.html");
    read(RVF,$ml,$fsize1);
    close (RVF);

    $fsize1 = (-s "$html_loc/navigation.html");
    open (RVF, "$html_loc/navigation.html");
    read(RVF,$pagenavigationformat,$fsize1);
    close (RVF);

    $fsize1 = (-s "$html_loc/answer.html");
    open (RVF, "$html_loc/answer.html");
    read(RVF,$answerformat,$fsize1);
    close (RVF);

    $fsize1 = (-s "$html_loc/location.html");
    open (RVF, "$html_loc/location.html");
    read(RVF,$locationformat,$fsize1);
    close (RVF);

    $fsize1 = (-s "$html_loc/homepage.html");
    open (RVF, "$html_loc/homepage.html");
    read(RVF,$homepageformat,$fsize1);
    close (RVF);

    if ($imagep eq "Y"){$ml = &InsertImages($ml);}
    $ml =~ s/!!cgiscript!!/$cgiscriptgb/g;
    $ml =~ s/!!guestbook_title!!/$cfg_GuestbookTitle/g;
    $ml =~ s/!!guestbook_homepage!!/$cfg_Homepage/g;

    $randnum1 = int(rand( 10 +1 ) ) + 1;
    $randnum2 = int(rand( 10 +1 ) ) + 1;
    $randresult = $randnum1 * $randnum2;
    $ml =~ s/!!rnum1!!/$randnum1/g;
    $ml =~ s/!!rnum2!!/$randnum2/g;
    $ml =~ s/!!rresult!!/$randresult/g;

    $fsize1 = (-s "$html_loc/listings.html");
    open (RVF, "$html_loc/listings.html");
    read(RVF,$listformat,$fsize1);
    close (RVF);

    open (DT, "data.txt");
    my $totalnr = 0;
    while (defined($line=<DT>)) {
        ($entryId, $visible, $name, $location, $msg, $email, $emailvisible,
                   $homepage, $ip, $date, $answer) = split(/::-::/,$line);
        if ($visible eq '1') {
            $totalnr++;
        }
    }
    close (DT);

    my $totalpages = int($totalnr / 10);
    if ($totalpages < ($totalnr / 10)) { $totalpages++ }

    my $pagenr = 1;
    if ($fields{'page'} =~ /^[1-9]+[0-9]*$/) {
        $pagenr = $fields{'page'};
        if ($pagenr > $totalpages ) {
            $pagenr = $totalpages;
        }
    }
    my $startnr = 0; my $endnr = 0;
    $startnr = ($pagenr * 10) - 9;
    $endnr = $pagenr * 10;
    if ($totalnr < $endnr) {
        $endnr = $totalnr;
    }
    if ($totalnr == 0) {
        $startnr = 0;
    }

    open (DT, "data.txt");
    my $currentnr = 0;
    my $entrynr = $totalnr+1;
    while (defined($line=<DT>)) {
        ($entryId, $visible, $name, $location, $msg, $email, $emailvisible, $homepage,
                   $ip, $date, $answer) = split(/::-::/,$line);
        my ($entry_year, $entry_month, $entry_day, $entry_hour, $entry_minute, $entry_second, $entry_weekday);
        ($entry_year, $entry_month, $entry_day, $entry_hour, $entry_minute, $entry_second, $entry_weekday) =
            decode_date($date);

        if ($visible eq '1') {
            $currentnr++;
            $entrynr--;

            if ($currentnr >= $startnr and $currentnr <= $endnr ) {
                $listings = $listformat;

                if ($email ne "" && $emailvisible eq "1") {$name = "<a href=\"mailto:$email\">$name</a>";}

                $listings =~ s/!!from!!/$name/g;
                $listings =~ s/!!entry_nr!!/$entrynr/g;
                $listings =~ s/!!entry_email!!/$email/g;
                $listings =~ s/!!entry_year!!/$entry_year/g;
                $listings =~ s/!!entry_month!!/$entry_month/g;
                $listings =~ s/!!entry_day!!/$entry_day/g;
                $listings =~ s/!!entry_hour!!/$entry_hour/g;
                $listings =~ s/!!entry_minute!!/$entry_minute/g;
                $listings =~ s/!!entry_second!!/$entry_second/g;
                $listings =~ s/!!entry_weekday!!/$entry_weekday/g;
                $listings =~ s/!!entry_ip!!/$ip/g;
                $listings =~ s/!!comment!!/$msg/g;

                if ($answer =~ /.+/) {
                    my $tmp = $answerformat;
                    $tmp =~ s/!!answer!!/$answer/g;
                    $listings =~ s/!!answer!!/$tmp/g;
                } else {
                    $listings =~ s/!!answer!!//g;
                }
                if ($location =~ /.+/) {
                    my $tmp = $locationformat;
                    $tmp =~ s/!!location!!/$location/g;
                    $listings =~ s/!!location!!/$tmp/g;
                } else {
                    $listings =~ s/!!location!!//g;
                }
                if ($homepage =~ /.+/) {
                    my $tmp = $homepageformat;
                    $tmp =~ s/!!homepage!!/$homepage/g;
                    $listings =~ s/!!homepage!!/$tmp/g;
                } else {
                    $listings =~ s/!!homepage!!//g;
                }

                $gentries = $gentries . $listings;
            }
        }
    }
    close (DT);

    $listformat = &strip_html_body_tags ($listformat);

    $ml =~ s/!!guest_book_entries!!/$gentries/g;
    my $pagenavigation = $pagenavigationformat;
    my $pagelinks = "";
    my $i;

    if ($totalpages == 1 or $totalnr == 0) { # only one page, so we do not need pagelinks
        $pagenavigation = "";
    } else {
        for ( $i = 1; $i <= $totalpages; $i++) {
            if ($i == $pagenr) {
                $pagelinks .= "$i ";
            } else {
                $pagelinks .= "<a href=\"".$cgiscriptgb."?page=$i#entries\">$i</a> ";
            }
        }
        $pagenavigation =~ s/!!navigation_links!!/$pagelinks/g;
    }

    $startnr = $totalnr - $startnr + 1;
    $endnr = $totalnr - $endnr + 1;
    $ml =~ s/!!entry_start_nr!!/$startnr/g;
    $ml =~ s/!!entry_end_nr!!/$endnr/g;
    $ml =~ s/!!entry_total_nr!!/$totalnr/g;

    $ml =~ s/!!guest_book_pagenavigation!!/$pagenavigation/g;

    $ml =~ s/!!counter_thismonth!!/$stats_counter_thismonth/g;
    $ml =~ s/!!counter_total!!/$stats_counter_total/g;

    print $ml;
}


sub post_operation
{
    my $slen = 0;

    $slen = length ($fields{'name'});
    if ($slen < 3) {
        &post_prb ($cfg_prompt_NameTooShort);
    }

    $slen = length($fields{'comment'});
    if ($slen == 0) {
        &post_prb ($cfg_prompt_MsgMissing);
    }
    if ($slen > 5000) {
        &post_prb ($cfg_prompt_MsgTooLong);
    }

    if (length($fields{'email'}) != 0) {
        if (!isValidEmailAddr($fields{'email'})) {
            &post_prb ($cfg_prompt_EmailInvalid);
        }
    }

    if (length($fields{'exprslt'}) == 0 || length($fields{'usrrslt'}) == 0) {
        &post_prb ($cfg_prompt_MathResultMissing);
    }
    if ($fields{'exprslt'} ne $fields{'usrrslt'}) {
        &post_prb ($cfg_prompt_MathResultWrong);
    }

    $fields{'comment'}      = sanitizeField($fields{'comment'});
    $fields{'location'}     = sanitizeField($fields{'location'});
    $fields{'name'}         = sanitizeField($fields{'name'});
    $fields{'email'}        = sanitizeField($fields{'email'});
    $fields{'emailvisible'} = sanitizeField($fields{'emailvisible'});
    $fields{'homepage'}     = sanitizeField($fields{'homepage'});

    if ($fields{'emailvisible'}eq 'visible') {
        $fields{'emailvisible'} = '1';
    } else {
        $fields{'emailvisible'} = '0';
    }

    my $tdata = ""; my $ml = "";

    $fsize1 = (-s "data.txt");
    open (RVF, "data.txt");
    read (RVF,$tdata,$fsize1);
    close (RVF);

    my ($sec,$min,$hour,$mday,$mon,$year,$wday,$ydat,$isdst) = localtime();
    my $today = ($year+1900)."-".
                 sprintf("%0*d",2,($mon+1))."-".
                 sprintf("%0*d",2,$mday)."-".
                 sprintf("%0*d",2,$hour)."-".
                 sprintf("%0*d",2,$min)."-".
                 sprintf("%0*d",2,$wday)."-$wday";

    my $nextid  = getnextid();
    my $cryptid = getcryptid();

    if ( ip_allowed($ENV{'REMOTE_ADDR'}) ) {
        open (DT, ">data.txt");
        print DT $nextid ."::-::".
                 $cfg_visible ."::-::".           # entries can be visible or invisible, see setup.cfg
                 $fields{'name'} ."::-::".
                 $fields{'location'} ."::-::".
                 $fields{'comment'} ."::-::".
                 $fields{'email'} ."::-::".
                 $fields{'emailvisible'} ."::-::".
                 $fields{'homepage'} ."::-::".
                 $ENV{'REMOTE_ADDR'} ."::-::".    # log the user's IP
                 $today ."::-::".
                 "".                              # no answer for new entries
                 "\n" .
                 $tdata;
        close (DT);

        store_cryptid($cryptid, $nextid);

        send_email_to_admin( $fields{'name'}, $fields{'email'}, $fields{'comment'}, $cryptid );

        $fsize1 = (-s "$html_loc/thanks.html");
        open (RVF, "$html_loc/thanks.html");
        read(RVF,$ml,$fsize1);
        close (RVF);

        if ($imagep eq "Y"){$ml = &InsertImages($ml);}
        $ml =~ s/!!cgiscript!!/$cgiscriptgb/g;
        $ml =~ s/!!guestbook_homepage!!/$cfg_Homepage/g;

        print $ml;

        &store_ip($ENV{'REMOTE_ADDR'});

    } else {

        &post_prb ($cfg_prompt_IpIsBlocked);

    }

    exit;
}


sub sanitizeField {
    my $tmp = shift;

    $tmp =~ s/\n/<br>/g;
    $tmp =~ s/</</g;
    $tmp =~ s/>/>/g;
    $tmp =~ s/<br>/<br>/g;
    $tmp =~ s/\n//g;

    my $crit = "";
    $crit = chr(10);
    $tmp  =~ s/$crit//g;
    $crit = chr(13);
    $tmp  =~ s/$crit//g;
    return $tmp;
}




sub getnextid {
    my $currentId = '';
    my $line = '';

    open (IDFILE, 'id.txt');
    flock(IDFILE, LOCK_EX);
    while (defined($line=<IDFILE>)) {
        $currentId = $line;
    }
    close (IDFILE);

    if ($currentId < 1) {
        $currentId = 1;
    }

    open (IDFILE, '>id.txt');
    print IDFILE $currentId+1;
    close (IDFILE);

    flock(IDFILE,LOCK_UN);

    return $currentId;
}

sub getcryptid {
    my @list = ('A'..'Z','a'..'z','0'..'9');
    my $id = '';
    my $i = 20 + int( rand(20) );
    while($i > 0) {
        $id .= $list[ int( rand(62) ) ];
        $i--;
    }
    return $id;
}

sub ip_allowed {
    my $check_ip = shift;
    my $ip = "";
    my $lastposted = "";
    my $lastpostedinsecs = 0;
    my $line = "";
    my $linestokeep = "";
    my ($sec,$min,$hour,$mday,$mon,$year,$wday,$ydat,$isdst) = localtime();
    my $dateandtimeinsecs = timelocal($sec,$min,$hour,$mday,$mon,$year);

    my $allowed = 1;
    open (IPS, "ip.txt");
    while (defined($line=<IPS>)) {
        ($ip, $lastposted) = split(/ /,$line);
        $lastposted =~ s/\n//g;
        my ($cyear, $cmon, $cmday, $chour, $cmin, $csec) = split(/-/, $lastposted);
        $lastpostedinsecs = timelocal($csec,$cmin,$chour,$cmday,$cmon - 1,$cyear - 1900);

        if ($check_ip eq $ip && ($dateandtimeinsecs - $lastpostedinsecs) < 900 ) {
            $allowed = 0;
        }
        if ($lastpostedinsecs + 900 < $dateandtimeinsecs) {
            # We can forget about this line, the record is too old, the ip should no longer be blocked
        } else {
            # We need to keep this blocking
            $linestokeep = $linestokeep . $line;
        }
    }
    close (IPS);

    open (IPS, ">ip.txt");
    print IPS $linestokeep;
    close (IPS);

    return $allowed;
}

sub store_ip {
    my $storeip = shift;
    my $tdata = "";

    my ($sec,$min,$hour,$mday,$mon,$year,$wday,$ydat,$isdst) = localtime();
    my $today = ($year+1900)."-".
                sprintf("%0*d", 2, $mon+1)."-".$mday."-".
                sprintf("%0*d", 2, $hour)."-".
                sprintf("%0*d", 2, $min)."-".
                sprintf("%0*d", 2, $sec);

    my $fsize1 = (-s "ip.txt");
    open (RVF, "ip.txt");
    read (RVF,$tdata,$fsize1);
    close (RVF);

    $tdata = $tdata . $storeip ." ". $today ."\n";
    open (IPS, "> ip.txt");
    print IPS $tdata;
    close (IPS);
}

sub store_visitor_ip {
    my $storeip = shift;
    my $tdata = "";

    my ($sec,$min,$hour,$mday,$mon,$year,$wday,$ydat,$isdst) = localtime();
    my $today = ($year+1900)."-".
                sprintf("%0*d", 2, $mon+1)."-".$mday."-".
                sprintf("%0*d", 2, $hour)."-".
                sprintf("%0*d", 2, $min)."-".
                sprintf("%0*d", 2, $sec);

    my $fsize1 = (-s "visitorip.txt");
    open (RVF, "visitorip.txt");
    read (RVF,$tdata,$fsize1);
    close (RVF);

    $tdata = $tdata . $storeip ." ". $today ."\n";
    open (IPS, "> visitorip.txt");
    print IPS $tdata;
    close (IPS);
}

sub increaseStats {
    my $check_ip = shift;
    my $ip = "";
    my $lastvisited = "";
    my $lastvisitedinsecs = 0;
    my $line = "";
    my $linestokeep = "";
    my ($sec,$min,$hour,$mday,$mon,$year,$wday,$ydat,$isdst) = localtime();
    my $dateandtimeinsecs = timelocal($sec,$min,$hour,$mday,$mon,$year);

    my $countthisvisit = 1;
    open (IPS, "visitorip.txt");
    while (defined($line=<IPS>)) {
        ($ip, $lastvisited) = split(/ /,$line);
        $lastvisited =~ s/\n//g;
        my ($cyear, $cmon, $cmday, $chour, $cmin, $csec) = split(/-/, $lastvisited);
        $lastvisitedinsecs = timelocal($csec,$cmin,$chour,$cmday,$cmon - 1,$cyear - 1900);

        if ($check_ip eq $ip && ($dateandtimeinsecs - $lastvisitedinsecs) < 900 ) {
            # Don't count this visitor again
            $countthisvisit = 0;
        }
        if ($lastvisitedinsecs + 900 < $dateandtimeinsecs) {
            # We can forget about this line, the record is too old, the ip should no longer be blocked
        } else {
            # We need to keep this blocking
            $linestokeep = $linestokeep . $line;
        }
    }
    close (IPS);

    open (IPS, ">visitorip.txt");
    print IPS $linestokeep;
    close (IPS);

    if ($countthisvisit) {
        my $line = "";
        my $currentmonth = $mon + 1;
        open (DT, "stats.txt");
        $stats_counter_nrofmonth = <DT>;
        $stats_counter_thismonth = <DT>;
        $stats_counter_total     = <DT>;
        close (DT);
        open (DT, ">stats.txt");
        print DT ($mon+1)."\n".
            ($currentmonth != $stats_counter_nrofmonth ? "1" : ($stats_counter_thismonth+1))."\n".
            ($stats_counter_total+1)."\n";
        close (DT);

        store_visitor_ip($check_ip);
    }
}

sub store_cryptid {
    my $cryptid = shift;
    my $entryid = shift;
    my $tdata = "";

    my $fsize1 = (-s "cryptid.txt");
    open (CEID, "cryptid.txt");
    read (CEID,$tdata,$fsize1);
    close (CEID);

    $tdata = $tdata . $cryptid ." ". $entryid ."\n";
    open (CEID, "> cryptid.txt");
    print CEID $tdata;
    close (CEID);
}


sub getStatistics {
    my $line = "";
    open (DT, "stats.txt");
    $stats_counter_nrofmonth = <DT>;
    $stats_counter_thismonth = <DT>;
    $stats_counter_total     = <DT>;
    $stats_counter_nrofmonth =~ s/\n//g;
    $stats_counter_thismonth =~ s/\n//g;
    $stats_counter_total     =~ s/\n//g;
    close (DT);
}


sub isValidEmailAddr { #check if e-mail address format is valid

  my $mail = shift;                                                  #in form name@host

  return 0 if ( $mail !~ /^[0-9a-zA-Z\.\-\_]+\@[0-9a-zA-Z\.\-]+$/ ); #characters allowed on name: 0-9a-Z-._ on host: 0-9a-Z-. on between: @
  return 0 if ( $mail =~ /^[^0-9a-zA-Z]|[^0-9a-zA-Z]$/);             #must start or end with alpha or num
  return 0 if ( $mail !~ /([0-9a-zA-Z]{1})\@./ );                    #name must end with alpha or num
  return 0 if ( $mail !~ /.\@([0-9a-zA-Z]{1})/ );                    #host must start with alpha or num
  return 0 if ( $mail =~ /.\.\-.|.\-\..|.\.\..|.\-\-./g );           #pair .- or -. or -- or .. not allowed
  return 0 if ( $mail =~ /.\.\_.|.\-\_.|.\_\..|.\_\-.|.\_\_./g );    #pair ._ or -_ or _. or _- or __ not allowed
  return 0 if ( $mail !~ /\.([a-zA-Z]{2,4})$/ );                     #host must end with '.' plus 2 or 4 alpha for TopLevelDomain (MUST be modified in future!)
  return 1;
}



sub send_email_to_admin {
    my $strname = shift;
    my $stremail = shift;
    my $strcomment = shift;
    my $cryptid = shift;
    my $link_release = '';
    my $link_delete = '';

    if ($cfg_visible eq '0') {
        # Add a link to release the entry if new entries are hidden by default
        $link_release = "Diesen Eintrag freischalten:\n\n\t".$cgiscriptad."?fct=release&cryptid=$cryptid\n\n";
    }
    $link_delete  = "Diesen Eintrag loeschen:\n\n\t"    .$cgiscriptad."?fct=delete&cryptid=$cryptid\n\n";

    my $MailProg = '/usr/sbin/sendmail';
    open (EMAIL, "|$MailProg $AdminAddress");
    print EMAIL "To: $AdminAddress\n";
    print EMAIL "From: ".$stremail."\n";
    print EMAIL "Reply-To: ".$stremail."\n";
    print EMAIL "Subject: Neuer Beitrag im Gaestebuch\n\n\n";
    print EMAIL "Eintrag von ".$strname."\n\n";
    print EMAIL "- - - - - - - - - - - - - - - - - - - - - - - -\n\n";
    $strcomment =~ s/<br>/\n/g;
    print EMAIL $strcomment."\n\n";
    print EMAIL "- - - - - - - - - - - - - - - - - - - - - - - -\n\n";
    print EMAIL $link_release;
    print EMAIL $link_delete;
    close(EMAIL);
}


sub post_prb {
    my ($problem) = @_;
    my $ml = "";

    $fsize1 = (-s "$html_loc/problem.html");
    open (RVF, "$html_loc/problem.html");
    read(RVF,$ml,$fsize1);
    close (RVF);

    if ($imagep eq "Y"){$ml = &InsertImages($ml);}
    $ml =~ s/!!problem!!/$problem/g;
    $ml =~ s/!!guestbook_homepage!!/$cfg_Homepage/g;

    print "$ml";
    exit;

}




sub get_env
{
    my $temp = "";

    if ($ENV{'QUERY_STRING'} ne "") {
        $temp = $ENV{'QUERY_STRING'};
    }
    else
    {
        read(STDIN, $temp, $ENV{'CONTENT_LENGTH'});
    }

    my @pairs=split(/&/,$temp);
    my $item = "";
    my $content = "";
    my $key = "";

    foreach $item(@pairs) {
        ($key,$content)=split (/=/,$item,2);
        $content=~tr/+/ /;
        $content=~ s/%(..)/pack("c",hex($1))/ge;
        $fields{$key}=$content;
    }
}






sub get_setup
{
#### GET CONFIGURATION ########################################################

    my $line = ""; my $r = 0;
    my $key = ''; my $value = '';

    my $setupcfg = "setup.cfg";

    my $exists = (-e "$setupcfg");
    if ($exists > 0) {

        open (STP, "$setupcfg");
        while (defined($line=<STP>)) {
            if ($line =~ m/#/g)        {
                $r = pos($line);
                $line = substr($line, 0, $r - 1);
            }

            $line =~ s/\n//g;

            if ($line =~ /^\s*(\w*)\s*(.*)$/ ) {
                $key = $1;
                $value = $2;
            }

            if ($line =~ /CGIURL/) {
                $line =~ s/CGIURL//g;
                $line =~ s/ //g;
                $cgiscriptgb = $line.'/guestbook.pl';
                $cgiscriptad = $line.'/admin.pl';
            }
            if ($line =~ /PASSWORD/) {$line =~ s/PASSWORD//g; $line =~ s/ //g; $password = $line;}
            if ($line =~ /USERNAME/) {$line =~ s/USERNAME//g; $line =~ s/ //g; $username = $line;}
            if ($line =~ /ADMINADDRESS/) {$line =~ s/ADMINADDRESS//g; $line =~ s/ //g; $AdminAddress = $line;}
            if ($line =~ /NEW_ENTRIES_VISIBLE/) {
                $line =~ s/NEW_ENTRIES_VISIBLE//g; $line =~ s/ //g; $cfg_visible = $line;
            }
            if ($line =~ /HTML_LOC/) {$line =~ s/HTML_LOC//g; $line =~ s/ //g; $html_loc = $line;}
            if ($line =~ /HTML_URL/) {$line =~ s/HTML_URL//g; $line =~ s/ //g; $html_url = $line;}
            if ($line =~ /IMAGEP/) {$line =~ s/IMAGEP//g; $line =~ s/ //g; $imagep = $line;}

            if ($key =~ /LANGUAGE/i)                 {$cfg_language = $value;}
            if ($key =~ /HOMEPAGE/i)                 {$cfg_Homepage = $value;}
            if ($key =~ /GUESTBOOK_TITLE/i)          {$cfg_GuestbookTitle = $value;}

            if ($key =~ /PROB_NAME_TOO_SHORT/i)      {$cfg_prompt_NameTooShort = $value;}
            if ($key =~ /PROB_MSG_MISSING/i)         {$cfg_prompt_MsgMissing = $value;}
            if ($key =~ /PROB_MSG_TOO_LONG/i)        {$cfg_prompt_MsgTooLong = $value;}
            if ($key =~ /PROB_EMAIL_INVALID/i)       {$cfg_prompt_EmailInvalid = $value;}
            if ($key =~ /PROB_MATH_RESULT_MISSING/i) {$cfg_prompt_MathResultMissing = $value;}
            if ($key =~ /PROB_MATH_RESULT_WRONG/i)   {$cfg_prompt_MathResultWrong = $value;}
            if ($key =~ /PROB_IP_IS_BLOCKED/i)       {$cfg_prompt_IpIsBlocked = $value;}
        }
        close (STP);

    } else {

        print "Content-type: text/html\n\n";
        print "Could not find setup.cfg";
print getcwd;

        exit;

    }

#### END CONFIGURATION ########################################################
}





sub InsertImages
{
    my ($html) = @_;
    my $item = "";
    my @lines = ();
    my $newline = "";

    if ($html =~ /<img/i) {
        $html =~ s/<img/:-:image::_::-:tag:-:/gi;

        @lines = split(/::-:tag:-:/,$html);

        foreach $item (@lines) {
            if (($item =~ m/\.gif/gi) or ($item =~ m/\.jpg/gi))
            {
                $item = &ProcessLine ($item);
                $newline = $newline . $item;
            }
            else
            {
                 $newline = $newline . $item;
            }
        }

        $newline =~ s/:-:image::_/<img/g;
    } else {
        $newline = $html;
    }

    return ($newline);

} ### END SUB



sub ProcessLine
{

my ($aline) = @_;

my ($iname, $r, $acn, $orgp, $ichar, $geturl, $sb);

        if (($aline =~ m/\.gif/gi) or ($aline =~ m/\.jpg/gi))
         {
         $r = pos($aline);
         $orgp = $r;
         $r = $r -1;
         }

        while ($r >= 0)
        {
        $ichar = substr($aline, $r, 1);
        $r = $r - 1;


        if (($ichar eq "\\") or ($ichar eq "/"))
                {
                $sb = "true";
                }


        if (($ichar eq "=") or ($ichar eq "\""))
                {
                if ($geturl ne "true")
                        {
                        $sb = "";
                        $iname = "$html_url/" . $iname;
                        $geturl = "true";
                        }
                }


        if ($sb ne "true")
                {
                $iname = $ichar . $iname;
                }
        }

$iname = $iname . substr($aline, $orgp, length($aline) - $orgp);

#print "==> $iname <br>";
return ($iname);

}





sub strip_html_body_tags
{
    my ($thehtml) = @_;
    my $thestripped = "";

    my @html_lines=split(/\n/,$thehtml);
    my $item = "";

    foreach $item (@html_lines) {
        if (($item !~ /<html>/) and ($item !~ /<head>/) and ($item !~ /<meta name/) and ($item !~ /<body>/) and ($item !~ /<title>/) and
            ($item !~ /<\/html>/) and ($item !~ /<\/head>/) and ($item !~ /<\/body>/))
        {
            $thestripped = $thestripped . "$item" . "\n";
        }

    }

    return ($thestripped);

}


sub decode_date {
  my ($line) = @_;
  my ($entry_year, $entry_month, $entry_day, $entry_hour, $entry_minute, $entry_second, $entry_weekday) = split(/-/,$line);

  $entry_month = decode_month($entry_month);
  $entry_weekday = decode_weekday($entry_weekday);
  return ($entry_year, $entry_month, $entry_day, $entry_hour, $entry_minute, $entry_second, $entry_weekday);
}

sub decode_month {
  my ($themonth) = @_;

  if ($cfg_language eq 'English') {
    if ($themonth == 1) {$themonth = "January";}
    if ($themonth == 2) {$themonth = "February";}
    if ($themonth == 3) {$themonth = "March";}
    if ($themonth == 4) {$themonth = "April";}
    if ($themonth == 5) {$themonth = "May";}
    if ($themonth == 6) {$themonth = "June";}
    if ($themonth == 7) {$themonth = "July";}
    if ($themonth == 8) {$themonth = "August";}
    if ($themonth == 9) {$themonth = "September";}
    if ($themonth == 10) {$themonth = "October";}
    if ($themonth == 11) {$themonth = "November";}
    if ($themonth == 12) {$themonth = "December";}
  }

  if ($cfg_language eq 'Deutsch') {
    if ($themonth == 1) {$themonth = "Januar";}
    if ($themonth == 2) {$themonth = "Februar";}
    if ($themonth == 3) {$themonth = "März";}
    if ($themonth == 4) {$themonth = "April";}
    if ($themonth == 5) {$themonth = "Mai";}
    if ($themonth == 6) {$themonth = "Juni";}
    if ($themonth == 7) {$themonth = "Juli";}
    if ($themonth == 8) {$themonth = "August";}
    if ($themonth == 9) {$themonth = "September";}
    if ($themonth == 10) {$themonth = "Oktober";}
    if ($themonth == 11) {$themonth = "November";}
    if ($themonth == 12) {$themonth = "Dezember";}
  }
  return ($themonth);
}



sub decode_weekday {
  my ($theweekday) = @_;

  if ($cfg_language eq 'English') {
    if ($theweekday == 0) {$theweekday = "Sunday";}
    if ($theweekday == 1) {$theweekday = "Monday";}
    if ($theweekday == 2) {$theweekday = "Tuesday";}
    if ($theweekday == 3) {$theweekday = "Wednesday";}
    if ($theweekday == 4) {$theweekday = "Thursday";}
    if ($theweekday == 5) {$theweekday = "Freyday";}
    if ($theweekday == 6) {$theweekday = "Saturday";}
  }

  if ($cfg_language eq 'Deutsch') {
    if ($theweekday == 0) {$theweekday = "Sonntag";}
    if ($theweekday == 1) {$theweekday = "Montag";}
    if ($theweekday == 2) {$theweekday = "Dienstag";}
    if ($theweekday == 3) {$theweekday = "Mittwoch";}
    if ($theweekday == 4) {$theweekday = "Donnerstag";}
    if ($theweekday == 5) {$theweekday = "Freitag";}
    if ($theweekday == 6) {$theweekday = "Samstag";}
  }
  return ($theweekday);
}
Die höchste Form des Glücks ist ein Leben mit einem gewissen Grad an Verrücktheit. (Erasmus von Rotterdam)
Regina
registrierte BenutzerIn
Beiträge: 1511
Registriert: Fr 19. Dez 2008, 13:24
Geschlecht: meist männlich
Pronomen:
Wohnort (Name): Hamburg
Hat sich bedankt: 149 Mal
Danksagung erhalten: 77 Mal
Gender:
Kontaktdaten:

Re: Wer kennt sich mit Perl aus?

Post 7 im Thema

Beitrag von Regina »

Habe es hin bekommen.

In der Datei visitorip.txt war eine fehlerhaft Zeile, die das Script zu Absturz brachte.

Nun geht es wieder.

Liebe Grüße,
Regina
Die höchste Form des Glücks ist ein Leben mit einem gewissen Grad an Verrücktheit. (Erasmus von Rotterdam)
Anne-Mette
Administratorin
Beiträge: 27521
Registriert: Sa 24. Nov 2007, 18:19
Geschlecht: W
Pronomen: sie
Wohnort (Name): Ringsberg
Forum-Galerie: gallery/album/1
Hat sich bedankt: 205 Mal
Danksagung erhalten: 2421 Mal
Gender:
Kontaktdaten:

Re: Wer kennt sich mit Perl aus?

Post 8 im Thema

Beitrag von Anne-Mette »

Moin,
Nun geht es wieder.
Glückwunsch!

Gruß
Anne-Mette
Antworten

Zurück zu „Netzwelt & Computer & Technik-Ecke“