#! /usr/local/bin/perl ############################################################################## # guestbook.pl V3.0 # # COPYRIGHT NOTICE # # Copyright 1998 Wolfgang Wiese All Rights Reserved. # # EMail: unrzc9@rrze.uni-erlangen.de # # URL : http://www.rrze.uni-erlangen.de/~unrzc9 # # # # 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 Wolfgang Wiese 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.# ############################################################################## require "/home/iti_db/eike/public_html/pzguest/cgi-library.pl"; # Constants. $HOST = $ENV{'REMOTE_HOST'}; $guestbook_log ='/home/iti_db/eike/public_html/pzguest/guestbooks.dat'; $guestbook_helppage='http://cgi.xwolf.com/cgi/guestbook.shtml'; $progurl = 'http://wwwiti.cs.uni-magdeburg.de/~eike/pzguest/guestbook.cgi'; $tempfile = '/home/iti_db/eike/public_html/pzguest/guestbook.tmp1'; $temp2 = '/home/iti_db/eike/public_html/pzguest/guestbook.tmp2'; $mailprog = '/usr/lib/sendmail'; ############################################################################## # Get the variables passed down via the web &ReadParse; $rw_book = $in{'rw'}; # rw must be either 'read' or 'write'. $varfile = $in{'varfile'}; # This definies the filename, where all # parameters I explained above gave to be # written in. $name = $in{'name'}; # Eingabe: Name des USers $email = $in{'email'}; # Eingabe: Email des Users $text = $in{'text'}; # Eingabe: Text des Users $homepage = $in{'homepage'}; # Eingabe: Homepage des Users $input_zeit = $in{'input_zeit'}; # Eingabe: Zeit der Eingabe. # The following constants can be written in the $varfile, but it works here too $hintergrund = $in{'hintergrund'}; # background of the book (
-tag) for the old version... $bodytag = $in{'bodytag'}; # bodytags for html, replaces background! () $titel = $in{'titel'} || 'Guestbook'; # Title of the book $kopf = $in{'top'} || ' '; # Here, you can give in HTML-code, the head of your document. Esp. If # you like to have icons there. The title is after it! $bottom = $in{'bottom'}; # Same as above, but it will be at the bottom $book_file = $in{'book'}; # Text-File of the book $forbit_html = $in{'forbit_html'} || 0; # If this is set to 1, no html-tags are allowed $counter = $in{'counter'} || 0; # 0 = Counter off, 1 = Dumb Counter on, 2 = HideCounter and normal on. # The numbers of accesses of the normal counter will # be written in the file $varfile, if it was set to 1 # If the hidecounter is on, the hosts/accesses will be written in # another file too. $ignore = $in{'ignore'} || 'off'; $allow_home = $in{'allow_home'} || 1; # 1 = Feld fuer Homepage da, 0 = ohne Feld. $language = $in{'language'} || 'german'; # default=german, english possible in the future $need_mail = $in{'need_mail'} || 0; # 0 or 1. If 1, then the user has to enter an email. If 0, it don't # matter, if he lets it out. But notice, that if this value is 0, # no mail will be send to the user of writing a message. $answer_mail = $in{'answer_mail'} || 0; # 1 or 0, If 1 is set the author of a new entry will get a 'thank'-mail $new_file = $in{'new_file'}; # If this field is given, a html-file named new_file will be created, # in which all entrys will be written. $seperator = $in{'seperator'} || ''; #
. Is for the deviding of the entrys in the book
$add_beginning = $in{'add_beginning'} || 1;
# 1 or 0. If 1 is set the entry will inserted at the top of the document.
$italic = $in{'italic'} || 1;
# If 1 the text of the entries will be displyed italic.
$pre_text = $in{'pre_text'};
$entry_ask = $in{'entry_ask'};
$past_text = $in{'past_text'};
$newconfig = $in{'new_config'};
# This is the message, which is displayed above the guestbook-data.
# entry_ask is the text, with the link to the input of new entries, why pre_text
# and past_text are surrounding this field.
# Notice: If $entry_ask is set to 'none', it won't be displayed.
$okval = $in{'ok'};
# To test if the input is right
if ($need_mail == 0) {$answer_mail=0;}
if ($italic ==1) {$starti = ''; $stopi = '';}
else {$starti = ''; $stopi='';}
$varfile=&Check_Name($varfile);
#########################Main program is starting here#########################
print(&PrintHeader);
if ($okval) {
if (($okval =~ /wiederholen /i) || ($okval =~/ Dismiss /i)) { $rw_book="dismiss";}
else { $rw_book="save_now";}
}
if (!($varfile)) { &Fehlermeldung("You gave no $varfile! ";
print "Script written by\n";
print "xwolf Error Cannot open $tempmess";
&NLock($temp2);
while( \n";
print " The following failure was detected: \n";
print " ";
print " There is a help avaible for this. Check out: \n";
print "Informations about the guestbook\n";
print " \n";
if (! $name) { print "Sie gaben keinen Namen an!\n";}
if ((! $email) && ($need_mail==1)) { print "Nanu?! Keine EMail? \n";}
if (! $text) { print "Einen Eintrag ohne Text??\n";}
print " \n";
print " \n";
if (! $name) { print "You gave no name??\n";}
if ((! $email) && ($need_mail ==1)) { print "Strange! No EMail?! \n";}
if (! $text) { print "A message without text??\n";}
print " \n";
print " Error Cannot open $tempmess";
print f1 "$text\n";
close f1;
# Now the preview:
&preview;
}
}
#####################################################################################
sub preview { # Here the users will get a preview of their new entry
local($shorttext,$short_laenge);
if ($language =~ /german/) { print " Error Cannot open $tempmess";
&NLock($temp2);
while( ";
for ($i=0;$i<$short_laenge;$i++) {
print " Error Cannot open $temp2";
&NLock($temp2);
while(
The guestbook cannot run without it");}
&LadeParameter;
&AutoRemove;
if (($rw_book eq 'read') && ($counter)) {
if ($counter == 2) {
# Call for the hidecounter, if he was set on.
$kurz=$book_file.','.$ignore;
&Hidecount($kurz);
} else {
# Add 1 to the dumb counter:
$access++;
&SaveParameter;
}
}
if ($newconfig) {&SaveParameter;}
if ((($rw_book =~ /write/) || ($rw_book =~ /dismiss/)) && ($INPUT_LAYOUT)) {
# Es liegt eine Eingabe vor und diese hat ihren eigenen Style,
# also mach keine HTML_TOP-Ausgabe
} else {
if ($HTML_TOP) {
open (f5,"<$HTML_TOP") || &Fehlermeldung("Cannot open HTML_TOP: $HTML_TOP ");
while(
Diese Seite wurde bisher $access mal aufgerufen.\n";}
} elsif ($language =~ /english/i) {
if ($counter) {print "
This page was accessed $access times.\n";}
}
if (not $HTML_TOP) {print "
\n";}
&read_data;
}
#if ((($rw_book ne 'write') || ($rw_book ne 'dismiss')) && ($INPUT_LAYOUT)) {
if ($HTML_BOT) {
open (f5,"<$HTML_BOT") || &Fehlermeldung("Cannot open HTML_BOT: $HTML_BOT");
while(
\n";
print "
";
print "\n";
print "
\n";
} else {
# Now in german
print "Jetzt können Sie einen neuen Eintrag in das Gästebuch machen.\n";
if ($forbit_html == 1) {print "Bitte beachten Sie, dass HTML-Tags nicht angenommen werden.\n";}
else {print "HTML-Tags werden innerhalb des Textfeldes unterstützt.\n";}
print "\n";
print "
\n";
}
}
}
#####################################################################################
sub Fehlermeldung { # Gibt Fehlermeldungen aus
local($fehlertext)=@_;
if ($HEADER) {&HtmlTop(',,');}
print "$fehlertext
\n";
print "
";
print "Skript written by xwolf, feedback welcome";
exit(0);
}
#####################################################################################
sub check_entry {
my($server,$subpage);
if (length($homepage) < 11) {$homepage="";}
if (($allow_home) && ($homepage =~ /http/)) {
$server=substr($homepage,7,length($homepage));
$subpage=substr($server,index($server,'/'),length($server));
$server=substr($server,0,index($server,'/'));
$status = &httpstatus($server,$subpage);
if ($status >= 400) {$homepage='';}
}
if ((! $name) || ((! $email) && ($need_mail==1)) || (! $text)) {
if ($language =~ /german/) {
print "Voransicht:
\n";}
else {print "Preview:
\n";}
print "$seperator";
$i=0;
open(f1, "<$temp2") || print "
';
$i++;
}
&NUnlock($temp2);
close f1;
$short_laenge=$i;
if (($allow_home==1) && ($homepage)) {
print "