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 >
Perl Script  |  2017-09-21  |  7KB  |  262 lines

  1. #!/usr/local/bin/perl
  2.  
  3. # theme_add_comment_e.pl
  4. # Comments construction program in Japan theme pavilion for English page
  5. # kawauso@acs.dnp.co.jp
  6. # 95/12/27
  7. # updated 96/02/13 by haruki@st.rim.or.jp
  8. # updated 96/03/08 by haruki@st.rim.or.jp
  9. #
  10. # THIS CODE USES THESE LIBRARIES
  11. #
  12. #   cgi-lib.pl  Copyright 1994 Steven E. Brenner
  13. #
  14. #   jcode.pl    Copyright (c) 1991,1992 Software Research Associates, Inc.
  15. #               Original by srekcah@sra.co.jp, Feb 1992
  16. #               Maintained by Kazumasa Utashiro <utashiro@sra.co.jp>
  17. #
  18.  
  19. require 'cgi-lib.pl';
  20. require 'jcode.pl';
  21.  
  22. &ReadParse(*in);        # initialize for cgi-lib
  23.  
  24. #
  25. # ñññφñññφñ╩╩╤┐⌠ñ╬Ñ╗Ñ├Ñ╚
  26. #
  27. $date = `date`;
  28. chop($date);
  29. #
  30. # Ñ│ÑßÑ≤Ñ╚ñ≥─╔╡¡ñ╣ñδÑ╒ÑíÑñÑδñ╬░╠├╓ñ≥╞└ñδ
  31. #
  32. $ac_comment_file = "/stage/htdocs/Japan/Theme/logs/theme_ac_comments_e.html";
  33. $ac_comment_url = "http://chat.expo96.ad.jp/Japan/Theme/sense";
  34. $ac_tmp = "/stage/htdocs/Japan/Theme/logs/theme_ac_comments_e.html.new";
  35. $ac_comment_file_j = "/stage/htdocs/Japan/Theme/logs/theme_ac_comments.html";
  36. $ac_tmp_j = "/stage/htdocs/Japan/Theme/logs/theme_ac_comments.html.new";
  37.  
  38.  
  39. #
  40. # HTMLÑ╪Ñ├Ñ└╜╨╬╧
  41. #
  42. print "Content-type: text/html\n\n";
  43.  
  44.  
  45. #
  46. # Ñ│ÑßÑ≤Ñ╚ñ¼╢⌡ñ╩ñΘ╜¬╬╗
  47. #
  48. if (!$in{'theme_comment'}) {
  49.     &err("Sorry, your comment seems contains no data.\n");
  50. }
  51.  
  52. #
  53. # ñ└ñ∞ñ½ñ¼╜±ñ¡╣■ñ≤ñ╟ñññδ┤╓ñ╧┬╘ñ─
  54. # ñóñ▐ñΩ┬╘ñ─ñ╩ñΘ╜¬╬╗
  55. #
  56. for($count = 0; -f "$ac_tmp" || -f "$ac_tmp_j"; $count++) {
  57.     sleep(1);
  58.     &err("Sorry, another person is writing now.") if ($count > 5);
  59. }
  60.  
  61.  
  62. #
  63. # Ñ│ÑßÑ≤Ñ╚ñ╬└░╖┴(▓■╣╘▓■╣╘ñ≥<p>ñ╦)
  64. #
  65. $in{'theme_comment'} =~ s/\r//g;
  66. $in{'theme_comment'} =~ s/\n\n/<\/p><p>/g;
  67. $in{'theme_comment'} =~ s/\n//g;
  68. $in{'theme_comment'} =~ s/<p><\/p>//g;
  69.  
  70. # get user's name
  71. get_cookie($UserName);
  72.  
  73. #
  74. # ─╔╡¡Ñ╒ÑíÑñÑδñ╦╦Σñß╣■ñ≤ñ╟íótmpñ╦╜±ñ¡ñ└ñ╣
  75. open (TMP, ">$ac_tmp") || &err("Can not open temporary file");
  76. open (FILE, "$ac_comment_file") || &err("Can not open comment file");
  77. while(<FILE>) {
  78.     if (/<!---INSERT HERE--->/) {
  79.     print TMP "<!---INSERT HERE--->\n";
  80.     print TMP "<!------------ Comments from user ---------->\n";
  81.     print TMP "<table width=450>\n<tr><td width=33 valign=top>\n";
  82.     print TMP "<img src=\"$ac_comment_url/image/zo1.gif\"";
  83.     print TMP "width=32 height=23>\n</td>\n<td width=300>\n";
  84.     print TMP "<font size=1><b>$date (Japan)<br>\n";
  85.     if ($UserName) {
  86.         print TMP "From: $UserName </b></font><br>";
  87.     }
  88.     print TMP "</b></font><br>";
  89.     $code = &jcode'convert($in{'theme_comment'}, 'jis');
  90.     print TMP "$in{'theme_comment'}";
  91.     print TMP "</p></td><td width=67></td></tr>\n</table>\n";
  92.     } else {            
  93.     print TMP $_;        
  94.     }                
  95. }
  96. close(FILE);
  97. close(TMP);
  98.  
  99. #
  100. # tmp ñ╬╞Γ═╞ñ≥Ñ│ÑßÑ≤Ñ╚ñ╬HTMLÑ╒ÑíÑñÑδñ╪╛σ╜±ñ¡
  101. #
  102. open (TMP, "<$ac_tmp") || &err("Can not open tmp file");
  103. open (FILE, ">$ac_comment_file") || &err("Can not open comment file");
  104. while(<TMP>) {
  105.     print FILE $_;
  106. }
  107. close(FILE);
  108. close(TMP);
  109.  
  110.  
  111. #
  112. # ┐╖ñ╖ññ╞Γ═╞ñ≥╔╕╜α╜╨╬╧ñ╪╜╨╬╧
  113. #
  114. open (FILE, "<$ac_comment_file") || &err("Can not open comment file");
  115. while(<FILE>) {
  116.     &ac_kprint($_);
  117. }
  118.  
  119. #
  120. # ╞ⁿ╦▄╕∞╚╟─╔╡¡Ñ╒ÑíÑñÑδñ╦╦Σñß╣■ñ≤ñ╟íótmpñ╦╜±ñ¡ñ└ñ╣
  121. open (TMP_J, ">$ac_tmp_j") || &err("Can not open temporary file for japanese");
  122. open (FILE_J, "$ac_comment_file_j") || &err("Can not open comment file for japanese");
  123. while(<FILE_J>) {
  124.     if (/<!---INSERT HERE--->/) {
  125.     print TMP_J "<!---INSERT HERE--->\n";
  126.     print TMP_J "<!------------ Comments from user ---------->\n";
  127.     print TMP_J "<table width=450>\n<tr><td width=33 valign=top>\n";
  128.     print TMP_J "<img src=\"$ac_comment_url/image/zo1.gif\"";
  129.     print TMP_J "width=32 height=23>\n</td>\n<td width=300>\n";
  130.     print TMP_J "<font size=1><b>$date (Japan)<br>\n";
  131.     if ($UserName) {
  132.         print TMP_J "From: $UserName </b></font><br>";
  133.     }
  134.     print TMP_J "</b></font><br>";
  135.     $code = &jcode'convert($in{'theme_comment'}, 'jis');
  136.     print TMP_J "$in{'theme_comment'}";
  137.     print TMP_J "</p></td><td width=67></td></tr>\n</table>\n";
  138.     } else {            
  139.     print TMP_J $_;        
  140.     }                
  141. }
  142. close(FILE_J);
  143. close(TMP_J);
  144.  
  145. #
  146. # tmp(j) ñ╬╞Γ═╞ñ≥╞ⁿ╦▄╕∞╚╟Ñ│ÑßÑ≤Ñ╚ñ╬HTMLÑ╒ÑíÑñÑδñ╪╛σ╜±ñ¡
  147. #
  148. open (TMP_J, "<$ac_tmp_j") || &err("Can not open tmp file for japanese");
  149. open (FILE_J, ">$ac_comment_file_j") || &err("Can not open comment file for japanese");
  150. while(<TMP_J>) {
  151.     print FILE_J $_;
  152. }
  153. close(FILE_J);
  154. close(TMP_J);
  155.  
  156.  
  157. #
  158. # ┐╖ñ╖ññ╞Γ═╞ñ≥╔╕╜α╜╨╬╧ñ╪╜╨╬╧
  159. #
  160. open (FILE_J, "<$ac_comment_file_j") || &err("Can not open comment file for japanese");
  161. while(<FILE_J>) {
  162.     &ac_kprint($_);
  163. }
  164.  
  165. #
  166. # ┼╨╧┐╜¬╬╗HTML╜╨╬╧
  167. #
  168. #&ac_kprint("<h3><p align=center>ñóñΩñ¼ñ╚ñªñ┤ñ╢ñññ▐ñ╣íú<br>\n");
  169. #&ac_kprint("ñóñ╩ñ┐ñ╬Ñ│ÑßÑ≤Ñ╚ñ≥<a href=\"$ac_comment_url/comments.html\">");
  170. #&ac_kprint("╡─╗÷╧┐</a>ñ╦─╔▓├ñ╖ñ▐ñ╖ñ┐íú</p>\n");
  171. #print "<p align=center>Thank you!<br>\nYour comment has added to";
  172. #print "<a href=\"$ac_comment_url/comments.html\">";
  173. #print "COMMENT LIST.</a></p></h3>\n";
  174.  
  175.  
  176. #
  177. # ┐╖├σÑ│ÑßÑ≤Ñ╚ñ╬─╠├╬
  178. #
  179. if (open(ML, "| /usr/local/bin/nkf -j | /usr/lib/sendmail theme-staff\@expo96.ad.jp")) {
  180.     print ML "From: sensorium-comment-page\@chat.expo96.ad.jp\n";
  181.     print ML "Subject: New Comment Comes!\n";
  182.     print ML "X-Mailer: theme_add_comment_e.pl\n";
  183.     print ML "\n";
  184.     print ML "Ñ│ÑßÑ≤Ñ╚Ñδí╝Ñα(▒╤╕∞╚╟)ñ╦░╩▓╝ñ╬Ñ│ÑßÑ≤Ñ╚ñ¼╞╧ñ¡ñ▐ñ╖ñ┐íú\n";
  185.     print ML "------------------------------------------------------\n";
  186.     if ($UserName) {
  187.         print ML "From: $UserName\n";
  188.     }
  189.     $code = &jcode'convert($in{'theme_comment'}, 'jis');
  190.     print ML "$in{'theme_comment'}";
  191. }
  192. close(ML);
  193.  
  194. #
  195. # tmp Ñ╒ÑíÑñÑδ║∩╜ⁿ
  196. #
  197. unlink "$ac_tmp";
  198. unlink "$ac_tmp_j";
  199.  
  200. #
  201. # ╜¬╬╗
  202. #
  203. exit(0);
  204.  
  205. ### sub routines ###
  206. #
  207. # JIS ñ╟printñ╣ñδ
  208. #
  209. sub ac_kprint {
  210.     ($ac_print_line) = @_;
  211.     $code = &jcode'convert(*ac_print_line, 'jis');    
  212.     print "$ac_print_line";
  213. }
  214.  
  215. #
  216. # Ñ¿ÑΘí╝ñ╬╛∞╣τ
  217. #
  218. sub err{
  219.     print "<html><head>\n";
  220.     print "<title>result</title>";
  221.     print "</head><body bgcolor=\"#ffffff\">\n";
  222.     local($msg) = @_;
  223.     print "<p>$msg</p>\n";
  224.     close FILE;
  225.     close TMP;
  226.     unlink "$ac_tmp";
  227.     unlink "$ac_tmp_j";
  228.     print "</BODY></HTML>\n";
  229.     exit;
  230. }
  231.  
  232.  
  233. #
  234. # Ñ┴ѺÑ├Ñ»ÑñÑ≤ñ╖ñ╞ñññδ┐═ñ╬╠╛┴░ñ≥╞└ñδ
  235. # Copyright 1995 Jonathan Haggan
  236. #
  237. sub get_cookie {
  238.   $CookieEnv = $ENV{'HTTP_COOKIE'};
  239.   @Cookies = split(/\;/,$CookieEnv);
  240.   foreach $Cookie (@Cookies) {
  241. #       print "Cookie : $Cookie\n";
  242.  
  243.     @CurrentCookie = split(/=/,$Cookie);
  244.     $CurrentCookie[0] =~ s/ //;
  245. #      print "Cookie0 : A$CurrentCookie[0]B\n\n";
  246. #      print "Cookie1 : $CurrentCookie[1]\n\n";
  247.     if ($CurrentCookie[0] eq 'NAME') {
  248.       $UserName = $CurrentCookie[1];
  249. #      print "Cookieif : $UserName";
  250.     }
  251.     if ($CurrentCookie[0] eq 'LOCATION') {
  252.       $Location = $CurrentCookie[1];
  253.     }
  254.   }
  255.   if ($UserName && $Location) {
  256.     $UserName = "$UserName\@$Location";
  257.   }
  258. }
  259.  
  260.