\n"
."Click on the support link below to learn how to upgrade your config-file.";
&display_error;
}
}
#------( Check for datafile override in URL. )------
if ($FORM{'data'}) {
$data_file = $FORM{'data'}.".data";
}
#------( Check for language override in URL. )------
if ($FORM{'lang'}) {
$language = "guestbook-".$FORM{'lang'}."\.lang";
}
#------( Read language-file, if any. )------
if (open(LANGUAGEFILE,"<${dirpath}${language}")) {
if (($languageline = \n"
."Click on the support link below to download the newest language-file.";
&display_error;
}
}
}
} else {
$error_message = "Couldn't read the configuration file: \"${dirpath}${scriptname}.config\"! \n\"$!\"\n";
&display_error;
}
}
#######################################################################
# The correct date.
#######################################################################
sub make_date {
@months = (0,'January','February','March','April','May','June','July',
'August','September','October','November','December');
($thissec,$thismin,$thishour,$mday,$mon,$thisyear,$t,$t,$t) = localtime(time);
$mon++;
$thisyear += 1900;
$thisdate = "$mday.$mon.$thisyear";
$thistime = "$thishour:$thismin:$thissec";
$byline = "
Guestbook System v$cgi_version made by Lars Ellingsen - Copyright © 1996-$thisyear";
}
#######################################################################
# Read the FORM information.
# Split it into understandable data.
# Strip name, eMail and URL for any HTML-tags.
#######################################################################
sub extract_forminfo {
if ($ENV{'REQUEST_METHOD'} eq "GET") {
$buffer = $ENV{'QUERY_STRING'};
} else {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
}
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, @values) = split(/=/, $pair);
$value = join ("=", @values);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
$FORM{'name'} =~ s/\<[^\>]*\>//ig;
$FORM{'name'} =~ s/\/g;
$FORM{'name'} =~ s/\>//g;
$FORM{'email'} =~ s/\<[^\>]*\>//ig;
$FORM{'email'} =~ s/\/g;
$FORM{'email'} =~ s/\>//g;
$FORM{'email'} =~ s/\"/_/g;
if ($FORM{'email'} !~ /^[^\@]*[\@][^\@]*?\.[^\@]*$/g) {
$FORM{'email'} = undef;
}
$FORM{'homepage'} =~ s/\<[^\>]*\>//ig;
$FORM{'homepage'} =~ s/\/g;
$FORM{'homepage'} =~ s/\>//g;
$FORM{'homepage'} =~ s/\"/_/g;
$FORM{'location'} =~ s/\<[^\>]*\>//ig;
$FORM{'location'} =~ s/\/g;
$FORM{'location'} =~ s/\>//g;
}
#######################################################################
# Test the guestbook-entry for errors. (No name etc.)
#######################################################################
sub test_form {
$form_ok = 1;
if ($FORM{'name'} eq "") {
$form_ok = 0;
if ($error_name && $error_goback) {
$error_message = $error_name."! ".$error_goback.".";
} else {
$error_message = "You have to fill in your name in order to " .
"sign this guestbook! Go back with your browser and retry.";
}
} elsif (($FORM{'location'} eq "nowhere") || ($FORM{'location'} eq "") || ($FORM{'location'} eq "?")) {
$form_ok = 0;
if ($error_location && $error_goback) {
$error_message = $error_location."! ".$error_goback.".";
} else {
$error_message = "You have to apply where you're located! " .
"Go back with your browser and retry.";
}
}
}
#######################################################################
# Add new signature to the guestbook-file.
#######################################################################
sub add_signature {
$FORM{'message'} =~ s/\%\&\&2/\"/g if ($FORM{'FromPreview'});
$FORM{'message'} =~ s/\ \n\"$!\"\n";
&display_error;
}
}
#######################################################################
# Make and show the guestbook HTML-document.
#######################################################################
sub make_htmlView {
if (!(($view_page =~ / "
."\"One or more of the guestbook tags are missing.\" "
."Click here"
." to learn how to configure the view_page option.";
&display_error;
}
#------( Check for show_images override in URL. )------
if ($FORM{'images'} eq "no") {
undef $show_images;
} elsif ($FORM{'images'} eq "yes") {
$show_images = 1;
}
if ($FORM{'old_datafile'} && $show_old_files) {
$data_file = $FORM{'old_datafile'};
undef $entries_shown;
}
if (open(GUESTFILE,"<${dirpath}${data_file}")) {
undef $/;
$guestfile = \n\"$!\"\n";
&display_error;
}
}
#######################################################################
# Make and show the HTML sign-page.
#######################################################################
sub make_htmlForm {
if (!(($form_page =~ / "
."\"One or more of the guestbook tags are missing, or they "
."are written in the wrong order.\" "
."Click here"
." to learn how to configure the form_page option.";
&display_error;
}
if (($form_page =~ / "
."One or more of the Guestbook Tags appears more than once!";
&display_error;
}
if (($form_page =~ / "
."\"At least one Guestbook Tag ( <GB-...> ) is written outside the <GB-xxxFORM> tags.\" "
."Click here"
." to learn how to configure the form_page option.";
&display_error;
}
if ($form_page =~ /\n".$all_entries."
\n";
$view_page =~ s/