#!/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/ # ############################################################################## # If you run into any problems while trying to configure this scripts, help # # is available. The steps you should take to get the fastest results, are: # # 1) Read this file thoroughly # # 2) Consult the Matt's Script Archive Frequently Asked Questions: # # http://www.worldwidemart.com/scripts/faq/ # # 3) If you are still having difficulty installing this script, send # # e-mail to: scripts-help@tahoenet.com # # Include any error messages you are receiving and as much detail # # as you can so we can spot your problem. Also include the variable# # configuration block that is located at the top of the script. # # # # Hopefully we will be able to help you solve your problems. Thank you. # ############################################################################## # 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.# ############################################################################## ############################################################################## # 留言簿 版本 2.3.1 # ############################################################################## # COPYRIGHT NOTICE # # Copyright 1996 Matthew M. Wright All Rights Reserved. # # # # 此版本為作者 Matthew M. Wright 所有, # # 不得做銷售用途。為方便中文使用者,太陽黑子已獲作者請准, # # 得以翻譯留言簿作非商業用途。 # # # # 請網友使用時勿刪除以上著作權申明 # # 討論區位於 http://cgiperl.asits.net/bbs/, 歡迎網友們踊躍討論。 # ############################################################################## # # # 太陽黑子 CGI 網路教學 # # http://cgiperl.asits.net # # # # 會員將獲強化版本的留言簿,附自動轉頁功能,和信件回复等功能。 # # CGI 權限開放, 10MB 空間, 加入會員只需 NT999 一年。 # # http://999.asits.net/~會員帳號 # # # ############################################################################## # Set Variables 設定更改 $guestbookurl = "http://ind.ntou.edu.tw/~b8533061/guestbook.htm"; #置放 guestbook.html 的網址 $guestbookreal = "/home/class85/b8533061/www/guestbook.htm"; #置放 guestbook.html 的絕對路徑 $guestlog = "/home/class85/b8533061/www/guestlog.log"; #置放 guestlog.html 的絕對路徑 $cgiurl = "http://ind.ntou.edu.tw/cgi-bin/cgiwrap/~b8533061/guestbook.pl"; #置放 guestboo.cgi 程式的網址 $date_command = "/usr/bin/date"; #主機呼叫日期的絕對路徑 # Set Your Options: $mail = 1; # 1 = Yes; 0 = No $uselog = 1; # 1 = Yes; 0 = No $linkmail = 1; # 1 = Yes; 0 = No $separator = 1; # 1 =
$redirection = 0; # 1 = Yes; 0 = No
$entry_order = 1; # 1 = 新留言先行排列在上;
# 0 = 舊留言先行排列在上.
$remote_mail = 1; # 1 = Yes; 0 = No
$allow_html = 1; # 1 = Yes; 0 = No
$line_breaks = 1; # 1 = Yes; 0 = No
# 如果 $mail 和 $remote_mail 的選項是設定為 1 的話,
# 您需要填寫以下的設定
$mailprog = '/usr/lib/sendmail'; #主機發信區
$recipient = 'b8533061@ind.ntou.edu.tw'; #您的 email
# 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///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= \n\n";
}
if ($entry_order eq '0') {
print GUEST "\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: 新訪客留言\n\n";
print MAIL "您有新訪客留言哦:\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: 謝謝您的留言\n\n";
print MAIL "謝謝您的留言,您的留言如下:\n\n";
print MAIL "------------------------------------------------------\n";
print MAIL "$FORM{'comments'}\n";
print MAIL "$FORM{'realname'}\n\n\n";
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\n";
print MAIL "--中文程式來源 -- 太陽黑子 CGI 網路教學\n";
print MAIL "--http://cgiperl.asits.net\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 " \n";
print " \n";
print "
\n/g;
}
print GUEST "$FORM{'comments'}
\n";
if ($FORM{'url'}) {
print GUEST "$FORM{'realname'}";
}
else {
print GUEST "$FORM{'realname'}";
}
if ( $FORM{'username'} ){
if ($linkmail eq '1') {
print GUEST " \<";
print GUEST "$FORM{'username'}\>";
}
else {
print GUEST " <$FORM{'username'}>";
}
}
print GUEST "
\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
\n\n";
}
else {
print GUEST " - $date錯誤:沒有留言
\n";
print "請留下您的留言.
\n";
print "返回訪客留言區.\n\n";
print "";
print "";
print "
";
print "\n\n";
# Log The Error
if ($uselog eq '1') {
&log('no_comments');
}
exit;
}
sub no_name {
print "Content-type: text/html\n\n";
print "錯誤:沒有名字
\n";
print "請留下您的名字.