Nedenunder en gæstebog lige til at kopiere, om senere modoficere.
mvh
ellebye
#!/usr/bin/perl
##############################################################################
# Guestbook Version 2.3.1 #
# Copyright 1996 Matt Wright mattw@worldwidemart.com #
# Created 4/21/95 Last Modified 10/29/95 #
# Scripts Archive at:
http://www.worldwidemart.com/scripts/ #
##############################################################################
# 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.#
##############################################################################
# Opsætnings VEJLEDNING
#
# FIL Placering:
#
# guestbook.pl skal placeres i mappen /cgi-bin på dit webhotel
# I mappen /log på dit webhotel oprettes en ny mappe der hedder "guestbook"
# guestbook.html skal placeres i /log/guestbook
# addguest.html skal placeres i /log/guestbook
#
#
# Opsætning af script
#
# Udskift
www.dit-domæne.dk med dit domænenavn. Eks.
www.dandomain.dk
# I linjen $guestbookreal skrives dit domænenavn uden "
www." og ".dk"
# Eks. dandomain
#
# Ret nedenstående 3 linjer
##############################################################################
$guestbookurl = "
http://www.dit-domæne.dk/log/guestbook/guestbook.html";
$guestbookreal = "/www2/dit-domæne/log/guestbook/guestbook.html";
$cgiurl = "
http://www.dit-domæne.dk/cgi-bin/guestbook.pl";
##############################################################################
# Set Your Options:
$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.
$allow_html = 1; # 1 = Yes; 0 = No
$line_breaks = 0; # 1 = Yes; 0 = No
##############################################################################
# Det er ikke nødvendigt at ændre koden herunder
##############################################################################
# Get the Date for Entry
$date = localtime;
$shortdate = localtime;
# 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);
# 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>Ingen besked</title></head>\n";
print "<body><font face=Tahoma size=2 color=#ff0000>FEJL! Du har ikke indtastet nogen besked<br>\n";
print "<br><br><font face=Tahoma size=2 color=#000000><a href=javascript:history.back()>Prøv igen...</a><br><br>\n";
print "<a href=\"$guestbookurl\">Tilbage til gæstebogen</a>.";
print "\n</body></html>\n";
exit;
}
sub no_name {
print "Content-type: text/html\n\n";
print "<html><head><title>Ingen navn</title></head>\n";
print "<body><font face=Tahoma size=2 color=#ff0000>FEJL! Du har ikke indtastet dit navn<br>\n";
print "<br><br><font face=Tahoma size=2 color=#000000><a href=javascript:history.back()>Prøv igen...</a><br><br>\n";
print "<a href=\"$guestbookurl\">Tilbage til gæstebogen</a>.";
print "\n</body></html>\n";
exit;
}
# Redirection Option
sub no_redirection {
# Print Beginning of HTML
print "Content-Type: text/html\n\n";
print "<html><head><title>Tak</title></head>\n";
print "<body><h1>Tak fordi at du skrev i min gæstebog</h1>\n";
# Print Response
print "<font face=Tahoma size=2 color=#000000>Tak fordi at du skrev i min gæstebog. Din besked\n";
print "er blevet tilføjet til gæstebogen.<hr>\n";
print "Her er hvad du skrev:<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\">Tilbage til gæstebogen</a>\n"; print "- (Det er måske nødvendigt at trykke på Opdater for at se din besked)\n";
print "</body></html>\n";
exit;
}