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);
}