home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Internet 1996 World Exposition
/
park.org.s3.amazonaws.com.7z
/
park.org.s3.amazonaws.com
/
cgi-bin
/
Japan
/
KDD
/
guestbook.pl
< prev
next >
Wrap
Perl Script
|
2017-09-21
|
5KB
|
178 lines
#!/usr/local/bin/perl
# posts guest comment to web page
require 'cgi-lib.pl';
# require 'jcode.pl';
# grab values passed from form:
&ReadParse(*in);
print "Content-type: text/html\n";
print "Pragma: no-cache\n\n";
# print the top part of the response
print "<HTML><HEAD>\n";
print "<TITLE>Post Results</TITLE>\n";
print "</HEAD><BODY>\n";
# resolve return directory
$year_day = (localtime)[7]; # days of year
$first_day = 94; # first day of seimei (April 4)
$moon_day = $year_day - $first_day + 1; # day of sekki
@sekki = ('seimei','koku-u','rikka','shouman','boushu','geshi','shousho',
'taisho','risshu','shosho','hakuro','shubun','kanro','soukou',
'rittou','shousetsu','taisetsu','touji');
@dsekki = (16,15,16,15,16,16,15,16,16,15,16,15,15,15,15,15,14,10);
$csekki = 0; # sekki counter
$cmoon_day = $moon_day; # moon day counter
while ($cmoon_day > 0) {
$cmoon_day = $cmoon_day - $dsekki[$csekki];
$csekki = $csekki + 1;
}
$ddir = $sekki[$csekki - 1];
$month_html = join('',"SEKKI/",$ddir,"/renga_home.html");
# change to your favorite date format:
$date = `date`;
chop($date); # remove "\n"
# Grab the HTML file and make a file name for the temp file.
$file = "$ENV{'PATH_TRANSLATED'}browse_renga.html";
$tmp = "$ENV{'PATH_TRANSLATED'}browse_renga.html.tmp";
$tmp =~ s/\//@/g; # make a unique tmp file name from the path
$tmp = "/tmp/$tmp";
$file2 ="$ENV{'PATH_TRANSLATED'}browse_renga2.html";
$tmp2 = "$ENV{'PATH_TRANSLATED'}browse_renga2.html.tmp";
$tmp2 =~ s/\//@/g; # make a unique tmp2 file name from the path
$tmp2 = "/tmp/$tmp2";
# if any fields are blank, then skip the post and inform user:
if ( !$in{'name'} || !$in{'email'} || !$in{'renga'} ) {
&err("╢τñ╚ñ¬╠╛┴░ñ╚E-mailÑóÑ╔Ñ∞Ñ╣ñ╦ñ┤╡¡╞■╧│ñ∞ñ¼ñóñΩñ▐ñ╣ñ╚┼╨╧┐ñ╟ñ¡ñ▐ñ╗ñ≤íú<BR>ñΓñª░∞┼┘ñ¬│╬ñ½ñßñ╬╛σíóñ┤┼╨╧┐ñ»ñ└ñ╡ññíú");
}
# get an exclusive open on the tmp file, so
# two posts at the same time don't clobber each other.
for ($count = 0; -f "$tmp"; $count++) {
# oh no. someone else is trying to update the message file. so we wait.
sleep(1);
&err("┬╛ñ╬┐═ñ¼╜±ñ¡╣■ñ▀├µñ╟ñ╣íúñ╖ñ╨ñΘñ»ñ¬┬╘ñ┴▓╝ñ╡ññíú(1)") if ($count > 4); # but not for long
}
# open temp file
open(TMP,">$tmp") || &err("║ε╢╚Ñ╒ÑíÑñÑδñ¼│½ñ▒ñ▐ñ╗ñ≤íú(1)");
# open the HTML file
open(FILE,"<$file") || &err("$fileñ¼│½ñ▒ñ▐ñ╗ñ≤íú(1)");
# an HTMLBBS file. look through it for the HTML comments
# that denote stuff we want to change:
$guestbook = 0;
while(<FILE>) {
if (/<!--GUESTBOOK-->/) {
print TMP "<!--GUESTBOOK-->\n";
$guestbook = 1;
}
elsif (/<!--POINTER-->/) {
# add this post
print TMP "<HR>\n";
print TMP "<P>\n";
print TMP "$in{'renga'}<BR>\n";
if ($in{'disp'} =~ /on/ ) {
print TMP "í╩$in{'name'}íí$in{'email'}í╦\n"; #email display : on
}
else {
print TMP "í╩$in{'name'}í╦\n"; #email display : off
}
print TMP "</P>\n";
print TMP "<!--POINTER-->\n";
}
else { print TMP $_; } # copy lines
}
if ($guestbook == 0) {
## print "$guestbook\n";
&err("╧ó▓╬Ñ╬í╝Ñ╚ñ╟ñ╧ñóñΩñ▐ñ╗ñ≤íú(1)");
}
# move the new file over the old:
open(TMP,"<$tmp") || &err("║ε╢╚Ñ╒ÑíÑñÑδñ¼│½ñ▒ñ▐ñ╗ñ≤íú(1)");
# open the HTML file
open(FILE,">$file") || &err("$fileñ¼│½ñ▒ñ▐ñ╗ñ≤íú(1)");
while(<TMP>) {
print FILE $_;
}
close(FILE);
close(TMP);
# get an exclusive open on the tmp file, so
# two posts at the same time don't clobber each other.
for($count = 0; -f "$tmp2"; $count++) {
# oh no. someone else is trying to update the message file. so we wait.
sleep(1);
&err("┬╛ñ╬┐═ñ¼╜±ñ¡╣■ñ▀├µñ╟ñ╣íúñ╖ñ╨ñΘñ»ñ¬┬╘ñ┴▓╝ñ╡ññíú(2)") if ($count > 4); # but not for long
}
# open temp file
open(TMP2,">$tmp2") || &err("║ε╢╚Ñ╒ÑíÑñÑδñ¼│½ñ▒ñ▐ñ╗ñ≤íú(2)");
# open the HTML file
open(FILE2,"<$file2") || &err("$file2ñ¼│½ñ▒ñ▐ñ╗ñ≤íú(2)");
# an HTMLBBS file. look through it for the HTML comments
# that denote stuff we want to change:
$guestbook = 0;
while(<FILE2>) {
if (/<!--LASTDATE-->/) { print TMP2 "<!--LASTDATE--> $date \n"; }
elsif (/<!--GUESTBOOK-->/) {
print TMP2 "<!--GUESTBOOK-->\n";
$guestbook = 1;
}
elsif (/<!--POINTER-->/) {
# add this post
print TMP2 "<HR>\n";
print TMP2 "<P>\n";
print TMP2 "$in{'renga'}<BR>\n";
print TMP2 "í╩$in{'name'}íí$in{'email'}í╦<BR>\n";
print TMP2 "í╬$in{'comment'}í╧\n";
print TMP2 "</P>\n";
print TMP2 "<!--POINTER-->\n";
}
else { print TMP2 $_; } # copy lines
}
if ($guestbook == 0) {
&err("╧ó▓╬Ñ╬í╝Ñ╚ñ╟ñ╧ñóñΩñ▐ñ╗ñ≤íú(2)");
}
# move the new file over the old:
open(TMP2,"<$tmp2") || &err("║ε╢╚Ñ╒ÑíÑñÑδñ¼│½ñ▒ñ▐ñ╗ñ≤íú(2)");
# open the HTML file
open(FILE2,">$file2") || &err("$file2ñ¼│½ñ▒ñ▐ñ╗ñ≤íú(2)");
while(<TMP2>) {
print FILE2 $_;
}
close(FILE2);
close(TMP2);
unlink "$tmp";
unlink "$tmp2";
# print the rest of the response HTML
print "<P><H2>┼╨╧┐ñ╖ñ▐ñ╖ñ┐íú</H2></P>\n";
print "<A HREF=\"$ENV{'PATH_INFO'}$month_html\" TARGET=\"_top\"><B>╔╜╝¿ñ╣ñδ</B></A>\n";
print "<P><FONT size=-1>╔╜╝¿ñ╡ñ∞ñ╩ññ╛∞╣τñ╧íóNetscapeñ╬ReloadÑ▄Ñ┐Ñ≤ñ≥Ñ»ÑΩÑ├Ñ»ñ╖ñ╞▓╝ñ╡ññíú</FONT>\n";
print "</BODY></HTML>\n";
exit;
#
# if we got an error, print message, close & clean up
#
sub err {
local($msg) = @_;
print "<P>$msg</P>\n";
close FILE;
close FILE2;
close TMP;
close TMP2;
unlink "$tmp";
unlink "$tmp2";
print "<A HREF=\"$ENV{'PATH_INFO'}reg_renga.html\"><B>╠ßñδ</B></A>\n";
print "</BODY></HTML>\n";
exit;
}