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_test.pl < prev    next >
Perl Script  |  2017-09-21  |  4KB  |  174 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. #
  9. # THIS CODE USES THESE LIBRARIES
  10. #
  11. #   cgi-lib.pl  Copyright 1994 Steven E. Brenner
  12. #
  13. #   jcode.pl    Copyright (c) 1991,1992 Software Research Associates, Inc.
  14. #               Original by srekcah@sra.co.jp, Feb 1992
  15. #               Maintained by Kazumasa Utashiro <utashiro@sra.co.jp>
  16. #
  17.  
  18. require 'cgi-lib.pl';
  19. require 'jcode.pl';
  20.  
  21. &ReadParse(*in);        # initialize for cgi-lib
  22.  
  23. #
  24. # éóéδéóéδé╚ò╧Éöé╠âZâbâg
  25. #
  26. $date = `date`;
  27. chop($date);
  28. #
  29. # âRâüâôâgé≡Æ╟ïLé╖éΘâtâ@âCâïé╠ê╩Æué≡ô╛éΘ
  30. #
  31. $ac_comment_file = "/stage/htdocs/Japan/Theme/logs/theme_ac_comments_test.html";
  32. $ac_comment_url = "http://chat.expo96.ad.jp/Japan/Theme/sense";
  33. $ac_tmp = "/stage/htdocs/Japan/Theme/logs/theme_ac_comments_test.html.new";
  34.  
  35. #
  36. # HTMLâwâbâ_Åoù═
  37. #
  38. #print "Content-type: text/html\n\n";
  39. print "Location: http://chat.expo96.ad.jp/Japan/Theme/forStaff/\n\n";
  40.  
  41.  
  42. #
  43. # âRâüâôâgé¬ï≤é╚éτÅIù╣
  44. #
  45. if (!$in{'theme_comment_translated'}) {
  46.     &err("Sorry, your comment seems contains no data.\n");
  47. }
  48.  
  49. #
  50. # é╛éΩé⌐é¬Åæé½ì₧é±é┼éóéΘè╘é═æ╥é┬
  51. # éáé▄éΦæ╥é┬é╚éτÅIù╣
  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. # âRâüâôâgé╠É«î`(ëⁿìsëⁿìsé≡<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. # Æ╟ïLâtâ@âCâïé╔ûäé▀ì₧é±é┼üAtmpé╔Åæé½é╛é╖
  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 é╠ôαùeé≡âRâüâôâgé╠HTMLâtâ@âCâïé╓ÅπÅæé½
  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. # ÉVé╡éóôαùeé≡òWÅÇÅoù═é╓Åoù═
  132. #
  133. #open (FILE, "<$ac_comment_file") || &err("Can not open comment file");
  134. #while(<FILE>) {
  135. #    &ac_kprint($_);
  136. #}
  137.  
  138. #
  139. # tmp âtâ@âCâïìφÅ£
  140. #
  141. unlink "$ac_tmp";
  142.  
  143. #
  144. # ÅIù╣
  145. #
  146. exit(0);
  147.  
  148. ### sub routines ###
  149. #
  150. # JIS é┼printé╖éΘ
  151. #
  152. sub ac_kprint {
  153.     ($ac_print_line) = @_;
  154.     $code = &jcode'convert(*ac_print_line, 'jis');    
  155.     print "$ac_print_line";
  156. }
  157.  
  158. #
  159. # âGâëü[é╠ÅΩìç
  160. #
  161. sub err{
  162.     print "<html><head>\n";
  163.     print "<title>result</title>";
  164.     print "</head><body bgcolor=\"#ffffff\">\n";
  165.     local($msg) = @_;
  166.     print "<p>$msg</p>\n";
  167.     close FILE;
  168.     close TMP;
  169.     unlink "$ac_tmp";
  170.     print "</BODY></HTML>\n";
  171.     exit;
  172. }
  173.