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_translated.pl < prev    next >
Perl Script  |  2017-09-21  |  4KB  |  171 lines

  1. #!/usr/local/bin/perl
  2.  
  3. # theme_add_comment_translated.pl
  4. # Comments construction program in Japan theme pavilion
  5. # to add translated comment to English comments file
  6. #
  7. # 96/03/08 by haruki@st.rim.or.jp
  8. # 96/03/27 updated 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.  
  36. #
  37. # HTMLÑ╪Ñ├Ñ└╜╨╬╧
  38. #
  39. print "Location: http://chat.expo96.ad.jp/Japan/Theme/forStaff/\n\n";
  40.  
  41.  
  42. #
  43. # Ñ│ÑßÑ≤Ñ╚ñ¼╢⌡ñ╩ñΘ╜¬╬╗
  44. #
  45. if (!$in{'theme_comment_translated'}) {
  46.     &err("Sorry, your comment seems contains no data.\n");
  47. }
  48.  
  49. #
  50. # ñ└ñ∞ñ½ñ¼╜±ñ¡╣■ñ≤ñ╟ñññδ┤╓ñ╧┬╘ñ─
  51. # ñóñ▐ñΩ┬╘ñ─ñ╩ñΘ╜¬╬╗
  52. #
  53. for($count = 0; -f "$ac_tmp"; $count++) {
  54.     sleep(1);
  55.     &err("Sorry, another person is writing now.") if ($count > 5);
  56. }
  57.  
  58.  
  59. #
  60. # Ñ│ÑßÑ≤Ñ╚ñ╬└░╖┴(▓■╣╘▓■╣╘ñ≥<p>ñ╦)
  61. #
  62. $in{'theme_comment_translated'} =~ s/\r//g;
  63. $in{'theme_comment_translated'} =~ s/\n\n/<\/p><p>/g;
  64. $in{'theme_comment_translated'} =~ s/\n//g;
  65. $in{'theme_comment_translated'} =~ s/<p><\/p>//g;
  66.  
  67. #
  68. # ─╔╡¡Ñ╒ÑíÑñÑδñ╦╦Σñß╣■ñ≤ñ╟íótmpñ╦╜±ñ¡ñ└ñ╣
  69. open (TMP, ">$ac_tmp") || &err("Can not open temporary file");
  70. open (FILE, "$ac_comment_file") || &err("Can not open comment file");
  71. while(<FILE>) {
  72.     if (/<!---INSERT HERE--->/) {
  73.      if ($in{'commenter'} eq "Readers' Comment") {
  74.         print TMP "<!---INSERT HERE--->\n";
  75.         print TMP "<!------------ Comments from user ---------->\n";
  76.         print TMP "<table width=450>\n<tr><td width=33 valign=top>\n";
  77.         print TMP "<img src=\"$ac_comment_url/image/zo1.gif\"";
  78.         print TMP "width=32 height=23>\n</td>\n<td width=300>\n";
  79.         if ($in{'theDate'}) {
  80.              print TMP "<font size=1><b>$in{'theDate'}<br>\n";
  81.         } else {
  82.              print TMP "<font size=1><b>$date (Japan)<br>\n";
  83.         }
  84.         if ($in{'theName'}) {
  85.              print TMP "From: $in{'theName'}<br>";
  86.         }
  87.         print TMP "translated at: $date<br>";
  88.         print TMP "</b></font><br>";
  89.         $code = &jcode'convert($in{'theme_comment_translated'}, 'jis');
  90.         print TMP "$in{'theme_comment_translated'}";
  91.         print TMP "</p></td><td width=67></td></tr>\n</table>\n";
  92.     } elsif ($in{'commenter'} eq "Staff Comment") {
  93.         print TMP "<!---INSERT HERE--->\n";
  94.         print TMP "<!------------ Comments from staff ---------->\n";
  95.         print TMP "<table width=450>\n<tr><td width=107></td>\n";
  96.         print TMP "<td width=280>\n";
  97.         if ($in{'theDate'}) {
  98.              print TMP "<font size=1><b>$in{'theDate'}<br>\n";
  99.         } else {
  100.              print TMP "<font size=1><b>$date (Japan)<br>\n";
  101.         }
  102.         print TMP "translated at: $date<br>";
  103.         print TMP "From: \"sensorium\" staff</b></font><br><br>";
  104.         $code = &jcode'convert($in{'theme_comment_translated'}, 'jis');
  105.         print TMP "$in{'theme_comment_translated'}";
  106.         print TMP "</p>";
  107.         print TMP "<td width=33 valign=top><img src=\"$ac_comment_url/image/zo2.gif\"></td>\n";
  108.         print TMP "</tr>\n</table>\n";
  109.  
  110.     }
  111.      } else {            
  112.           print TMP $_;        
  113.     }                
  114. }
  115. close(FILE);
  116. close(TMP);
  117.  
  118. #
  119. # tmp ñ╬╞Γ═╞ñ≥Ñ│ÑßÑ≤Ñ╚ñ╬HTMLÑ╒ÑíÑñÑδñ╪╛σ╜±ñ¡
  120. #
  121. open (TMP, "<$ac_tmp") || &err("Can not open tmp file");
  122. open (FILE, ">$ac_comment_file") || &err("Can not open comment file");
  123. while(<TMP>) {
  124.     print FILE $_;
  125. }
  126. close(FILE);
  127. close(TMP);
  128.  
  129.  
  130.  
  131. #
  132. #╔╕╜α╜╨╬╧ñ╪ñ╬╜╨╬╧ñ╧ñ╖ñ╩ññ
  133. #
  134.  
  135. #
  136. # tmp Ñ╒ÑíÑñÑδ║∩╜ⁿ
  137. #
  138. unlink "$ac_tmp";
  139.  
  140. #
  141. # ╜¬╬╗
  142. #
  143. exit(0);
  144.  
  145. ### sub routines ###
  146. #
  147. # JIS ñ╟printñ╣ñδ
  148. #
  149. sub ac_kprint {
  150.     ($ac_print_line) = @_;
  151.     $code = &jcode'convert(*ac_print_line, 'jis');    
  152.     print "$ac_print_line";
  153. }
  154.  
  155. #
  156. # Ñ¿ÑΘí╝ñ╬╛∞╣τ
  157. #
  158. sub err{
  159.     print "<html><head>\n";
  160.     print "<title>result</title>";
  161.     print "</head><body bgcolor=\"#ffffff\">\n";
  162.     local($msg) = @_;
  163.     print "<p>$msg</p>\n";
  164.     close FILE;
  165.     close TMP;
  166.     unlink "$ac_tmp";
  167.     print "</BODY></HTML>\n";
  168.     exit;
  169. }
  170.