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
/
Theme
/
theme_add_comment_e.pl
< prev
next >
Wrap
Perl Script
|
2017-09-21
|
7KB
|
262 lines
#!/usr/local/bin/perl
# theme_add_comment_e.pl
# Comments construction program in Japan theme pavilion for English page
# kawauso@acs.dnp.co.jp
# 95/12/27
# updated 96/02/13 by haruki@st.rim.or.jp
# updated 96/03/08 by haruki@st.rim.or.jp
#
# THIS CODE USES THESE LIBRARIES
#
# cgi-lib.pl Copyright 1994 Steven E. Brenner
#
# jcode.pl Copyright (c) 1991,1992 Software Research Associates, Inc.
# Original by srekcah@sra.co.jp, Feb 1992
# Maintained by Kazumasa Utashiro <utashiro@sra.co.jp>
#
require 'cgi-lib.pl';
require 'jcode.pl';
&ReadParse(*in); # initialize for cgi-lib
#
# ñññφñññφñ╩╩╤┐⌠ñ╬Ñ╗Ñ├Ñ╚
#
$date = `date`;
chop($date);
#
# Ñ│ÑßÑ≤Ñ╚ñ≥─╔╡¡ñ╣ñδÑ╒ÑíÑñÑδñ╬░╠├╓ñ≥╞└ñδ
#
$ac_comment_file = "/stage/htdocs/Japan/Theme/logs/theme_ac_comments_e.html";
$ac_comment_url = "http://chat.expo96.ad.jp/Japan/Theme/sense";
$ac_tmp = "/stage/htdocs/Japan/Theme/logs/theme_ac_comments_e.html.new";
$ac_comment_file_j = "/stage/htdocs/Japan/Theme/logs/theme_ac_comments.html";
$ac_tmp_j = "/stage/htdocs/Japan/Theme/logs/theme_ac_comments.html.new";
#
# HTMLÑ╪Ñ├Ñ└╜╨╬╧
#
print "Content-type: text/html\n\n";
#
# Ñ│ÑßÑ≤Ñ╚ñ¼╢⌡ñ╩ñΘ╜¬╬╗
#
if (!$in{'theme_comment'}) {
&err("Sorry, your comment seems contains no data.\n");
}
#
# ñ└ñ∞ñ½ñ¼╜±ñ¡╣■ñ≤ñ╟ñññδ┤╓ñ╧┬╘ñ─
# ñóñ▐ñΩ┬╘ñ─ñ╩ñΘ╜¬╬╗
#
for($count = 0; -f "$ac_tmp" || -f "$ac_tmp_j"; $count++) {
sleep(1);
&err("Sorry, another person is writing now.") if ($count > 5);
}
#
# Ñ│ÑßÑ≤Ñ╚ñ╬└░╖┴(▓■╣╘▓■╣╘ñ≥<p>ñ╦)
#
$in{'theme_comment'} =~ s/\r//g;
$in{'theme_comment'} =~ s/\n\n/<\/p><p>/g;
$in{'theme_comment'} =~ s/\n//g;
$in{'theme_comment'} =~ s/<p><\/p>//g;
# get user's name
get_cookie($UserName);
#
# ─╔╡¡Ñ╒ÑíÑñÑδñ╦╦Σñß╣■ñ≤ñ╟íótmpñ╦╜±ñ¡ñ└ñ╣
#
open (TMP, ">$ac_tmp") || &err("Can not open temporary file");
open (FILE, "$ac_comment_file") || &err("Can not open comment file");
while(<FILE>) {
if (/<!---INSERT HERE--->/) {
print TMP "<!---INSERT HERE--->\n";
print TMP "<!------------ Comments from user ---------->\n";
print TMP "<table width=450>\n<tr><td width=33 valign=top>\n";
print TMP "<img src=\"$ac_comment_url/image/zo1.gif\"";
print TMP "width=32 height=23>\n</td>\n<td width=300>\n";
print TMP "<font size=1><b>$date (Japan)<br>\n";
if ($UserName) {
print TMP "From: $UserName </b></font><br>";
}
print TMP "</b></font><br>";
$code = &jcode'convert($in{'theme_comment'}, 'jis');
print TMP "$in{'theme_comment'}";
print TMP "</p></td><td width=67></td></tr>\n</table>\n";
} else {
print TMP $_;
}
}
close(FILE);
close(TMP);
#
# tmp ñ╬╞Γ═╞ñ≥Ñ│ÑßÑ≤Ñ╚ñ╬HTMLÑ╒ÑíÑñÑδñ╪╛σ╜±ñ¡
#
open (TMP, "<$ac_tmp") || &err("Can not open tmp file");
open (FILE, ">$ac_comment_file") || &err("Can not open comment file");
while(<TMP>) {
print FILE $_;
}
close(FILE);
close(TMP);
#
# ┐╖ñ╖ññ╞Γ═╞ñ≥╔╕╜α╜╨╬╧ñ╪╜╨╬╧
#
open (FILE, "<$ac_comment_file") || &err("Can not open comment file");
while(<FILE>) {
&ac_kprint($_);
}
#
# ╞ⁿ╦▄╕∞╚╟─╔╡¡Ñ╒ÑíÑñÑδñ╦╦Σñß╣■ñ≤ñ╟íótmpñ╦╜±ñ¡ñ└ñ╣
#
open (TMP_J, ">$ac_tmp_j") || &err("Can not open temporary file for japanese");
open (FILE_J, "$ac_comment_file_j") || &err("Can not open comment file for japanese");
while(<FILE_J>) {
if (/<!---INSERT HERE--->/) {
print TMP_J "<!---INSERT HERE--->\n";
print TMP_J "<!------------ Comments from user ---------->\n";
print TMP_J "<table width=450>\n<tr><td width=33 valign=top>\n";
print TMP_J "<img src=\"$ac_comment_url/image/zo1.gif\"";
print TMP_J "width=32 height=23>\n</td>\n<td width=300>\n";
print TMP_J "<font size=1><b>$date (Japan)<br>\n";
if ($UserName) {
print TMP_J "From: $UserName </b></font><br>";
}
print TMP_J "</b></font><br>";
$code = &jcode'convert($in{'theme_comment'}, 'jis');
print TMP_J "$in{'theme_comment'}";
print TMP_J "</p></td><td width=67></td></tr>\n</table>\n";
} else {
print TMP_J $_;
}
}
close(FILE_J);
close(TMP_J);
#
# tmp(j) ñ╬╞Γ═╞ñ≥╞ⁿ╦▄╕∞╚╟Ñ│ÑßÑ≤Ñ╚ñ╬HTMLÑ╒ÑíÑñÑδñ╪╛σ╜±ñ¡
#
open (TMP_J, "<$ac_tmp_j") || &err("Can not open tmp file for japanese");
open (FILE_J, ">$ac_comment_file_j") || &err("Can not open comment file for japanese");
while(<TMP_J>) {
print FILE_J $_;
}
close(FILE_J);
close(TMP_J);
#
# ┐╖ñ╖ññ╞Γ═╞ñ≥╔╕╜α╜╨╬╧ñ╪╜╨╬╧
#
open (FILE_J, "<$ac_comment_file_j") || &err("Can not open comment file for japanese");
while(<FILE_J>) {
&ac_kprint($_);
}
#
# ┼╨╧┐╜¬╬╗HTML╜╨╬╧
#
#&ac_kprint("<h3><p align=center>ñóñΩñ¼ñ╚ñªñ┤ñ╢ñññ▐ñ╣íú<br>\n");
#&ac_kprint("ñóñ╩ñ┐ñ╬Ñ│ÑßÑ≤Ñ╚ñ≥<a href=\"$ac_comment_url/comments.html\">");
#&ac_kprint("╡─╗÷╧┐</a>ñ╦─╔▓├ñ╖ñ▐ñ╖ñ┐íú</p>\n");
#print "<p align=center>Thank you!<br>\nYour comment has added to";
#print "<a href=\"$ac_comment_url/comments.html\">";
#print "COMMENT LIST.</a></p></h3>\n";
#
# ┐╖├σÑ│ÑßÑ≤Ñ╚ñ╬─╠├╬
#
if (open(ML, "| /usr/local/bin/nkf -j | /usr/lib/sendmail theme-staff\@expo96.ad.jp")) {
print ML "From: sensorium-comment-page\@chat.expo96.ad.jp\n";
print ML "Subject: New Comment Comes!\n";
print ML "X-Mailer: theme_add_comment_e.pl\n";
print ML "\n";
print ML "Ñ│ÑßÑ≤Ñ╚Ñδí╝Ñα(▒╤╕∞╚╟)ñ╦░╩▓╝ñ╬Ñ│ÑßÑ≤Ñ╚ñ¼╞╧ñ¡ñ▐ñ╖ñ┐íú\n";
print ML "------------------------------------------------------\n";
if ($UserName) {
print ML "From: $UserName\n";
}
$code = &jcode'convert($in{'theme_comment'}, 'jis');
print ML "$in{'theme_comment'}";
}
close(ML);
#
# tmp Ñ╒ÑíÑñÑδ║∩╜ⁿ
#
unlink "$ac_tmp";
unlink "$ac_tmp_j";
#
# ╜¬╬╗
#
exit(0);
### sub routines ###
#
# JIS ñ╟printñ╣ñδ
#
sub ac_kprint {
($ac_print_line) = @_;
$code = &jcode'convert(*ac_print_line, 'jis');
print "$ac_print_line";
}
#
# Ñ¿ÑΘí╝ñ╬╛∞╣τ
#
sub err{
print "<html><head>\n";
print "<title>result</title>";
print "</head><body bgcolor=\"#ffffff\">\n";
local($msg) = @_;
print "<p>$msg</p>\n";
close FILE;
close TMP;
unlink "$ac_tmp";
unlink "$ac_tmp_j";
print "</BODY></HTML>\n";
exit;
}
#
# Ñ┴ѺÑ├Ñ»ÑñÑ≤ñ╖ñ╞ñññδ┐═ñ╬╠╛┴░ñ≥╞└ñδ
# Copyright 1995 Jonathan Haggan
#
sub get_cookie {
$CookieEnv = $ENV{'HTTP_COOKIE'};
@Cookies = split(/\;/,$CookieEnv);
foreach $Cookie (@Cookies) {
# print "Cookie : $Cookie\n";
@CurrentCookie = split(/=/,$Cookie);
$CurrentCookie[0] =~ s/ //;
# print "Cookie0 : A$CurrentCookie[0]B\n\n";
# print "Cookie1 : $CurrentCookie[1]\n\n";
if ($CurrentCookie[0] eq 'NAME') {
$UserName = $CurrentCookie[1];
# print "Cookieif : $UserName";
}
if ($CurrentCookie[0] eq 'LOCATION') {
$Location = $CurrentCookie[1];
}
}
if ($UserName && $Location) {
$UserName = "$UserName\@$Location";
}
}