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

  1. #!/usr/local/bin/perl
  2.  
  3. # theme_add_comment_e.pl
  4. # Comments construction program in Japan theme pavilion
  5. #
  6. # 96/03/27 by haruki@st.rim.or.jp
  7. #
  8. # THIS CODE USES THESE LIBRARIES
  9. #
  10. #   cgi-lib.pl  Copyright 1994 Steven E. Brenner
  11. #
  12. #   jcode.pl    Copyright (c) 1991,1992 Software Research Associates, Inc.
  13. #               Original by srekcah@sra.co.jp, Feb 1992
  14. #               Maintained by Kazumasa Utashiro <utashiro@sra.co.jp>
  15. #
  16.  
  17. require 'cgi-lib.pl';
  18. require 'jcode.pl';
  19.  
  20. &ReadParse(*in);        # initialize for cgi-lib
  21.  
  22. #
  23. # ñññφñññφñ╩╩╤┐⌠ñ╬Ñ╗Ñ├Ñ╚
  24. #
  25. $date = `date`;
  26. chop($date);
  27. #
  28. # Ñ│ÑßÑ≤Ñ╚ñ≥─╔╡¡ñ╣ñδÑ╒ÑíÑñÑδñ╬░╠├╓ñ≥╞└ñδ
  29. #
  30. $ac_comment_file = "/stage/htdocs/Japan/Theme/logs/theme_ac_comments_e.html";
  31. $ac_comment_url = "http://chat.expo96.ad.jp/Japan/Theme/sense";
  32. $ac_tmp = "/stage/htdocs/Japan/Theme/logs/theme_ac_comments_e.html.new";
  33.  
  34. #
  35. # HTMLÑ╪Ñ├Ñ└╜╨╬╧
  36. #
  37. print "Location: http://chat.expo96.ad.jp/Japan/Theme/forStaff/\n\n";
  38.  
  39.  
  40. #
  41. # Ñ│ÑßÑ≤Ñ╚ñ¼╢⌡ñ╩ñΘ╜¬╬╗
  42. #
  43. if (!$in{'theme_comment_staff'}) {
  44.     &err("Sorry, your comment seems contains no data.\n");
  45. }
  46.  
  47. #
  48. # ñ└ñ∞ñ½ñ¼╜±ñ¡╣■ñ≤ñ╟ñññδ┤╓ñ╧┬╘ñ─
  49. # ñóñ▐ñΩ┬╘ñ─ñ╩ñΘ╜¬╬╗
  50. #
  51. for($count = 0; -f "$ac_tmp"; $count++) {
  52.     sleep(1);
  53.     &err("Sorry, another person is writing now.") if ($count > 5);
  54. }
  55.  
  56.  
  57. #
  58. # Ñ│ÑßÑ≤Ñ╚ñ╬└░╖┴(▓■╣╘▓■╣╘ñ≥<p>ñ╦)
  59. #
  60. $in{'theme_comment_staff'} =~ s/\r//g;
  61. $in{'theme_comment_staff'} =~ s/\n\n/<\/p><p>/g;
  62. $in{'theme_comment_staff'} =~ s/\n//g;
  63. $in{'theme_comment_staff'} =~ s/<p><\/p>//g;
  64.  
  65. #
  66. # ─╔╡¡Ñ╒ÑíÑñÑδñ╦╦Σñß╣■ñ≤ñ╟íótmpñ╦╜±ñ¡ñ└ñ╣
  67. open (TMP, ">$ac_tmp") || &err("Can not open temporary file");
  68. open (FILE, "$ac_comment_file") || &err("Can not open comment file");
  69. while(<FILE>) {
  70.     if (/<!---INSERT HERE--->/) {
  71. #    print TMP "\[<a href=\"$ENV{'HTTP_REFERER'}\">Back</a>\]<br><br>";
  72.     print TMP "<!---INSERT HERE--->\n";
  73.     print TMP "<!------------ Comments from staff ---------->\n";
  74.     print TMP "<table width=450>\n<tr><td width=107></td>\n";
  75.     print TMP "<td width=280>\n";
  76.     print TMP "<font size=1><b>$date (Japan)<br>\n";
  77.     print TMP "From: \"sensorium\" staff</b></font><br><br>";
  78.     $code = &jcode'convert($in{'theme_comment_staff'}, 'jis');
  79.     print TMP "$in{'theme_comment_staff'}";
  80.     print TMP "</p>";
  81.     print TMP "<td width=33 valign=top><img src=\"$ac_comment_url/image/zo2.gif\"></td>\n";
  82.     print TMP "</tr>\n</table>\n";
  83.     } else {            
  84.     print TMP $_;        
  85.     }                
  86. }
  87. close(FILE);
  88. close(TMP);
  89.  
  90. #
  91. # tmp ñ╬╞Γ═╞ñ≥Ñ│ÑßÑ≤Ñ╚ñ╬HTMLÑ╒ÑíÑñÑδñ╪╛σ╜±ñ¡
  92. #
  93. open (TMP, "<$ac_tmp") || &err("Can not open tmp file");
  94. open (FILE, ">$ac_comment_file") || &err("Can not open comment file");
  95. while(<TMP>) {
  96.     print FILE $_;
  97. }
  98. close(FILE);
  99. close(TMP);
  100.  
  101. #
  102. #╔╕╜α╜╨╬╧ñ╪ñ╬╜╨╬╧ñ╧ñ╖ñ╩ññ
  103. #
  104.  
  105. #
  106. # tmp Ñ╒ÑíÑñÑδ║∩╜ⁿ
  107. #
  108. unlink "$ac_tmp";
  109.  
  110. #
  111. # ╜¬╬╗
  112. #
  113. exit(0);
  114.  
  115. ### sub routines ###
  116. #
  117. # JIS ñ╟printñ╣ñδ
  118. #
  119. sub ac_kprint {
  120.     ($ac_print_line) = @_;
  121.     $code = &jcode'convert(*ac_print_line, 'jis');    
  122.     print "$ac_print_line";
  123. }
  124.  
  125. #
  126. # Ñ¿ÑΘí╝ñ╬╛∞╣τ
  127. #
  128. sub err{
  129.     print "<html><head>\n";
  130.     print "<title>result</title>";
  131.     print "</head><body bgcolor=\"#ffffff\">\n";
  132.     local($msg) = @_;
  133.     print "<p>$msg</p>\n";
  134.     close FILE;
  135.     close TMP;
  136.     unlink "$ac_tmp";
  137.     print "</BODY></HTML>\n";
  138.     exit;
  139. }
  140.  
  141.  
  142. #
  143. # Ñ┴ѺÑ├Ñ»ÑñÑ≤ñ╖ñ╞ñññδ┐═ñ╬╠╛┴░ñ≥╞└ñδ
  144. # Copyright 1995 Jonathan Haggan
  145. #
  146. sub get_cookie {
  147.   $CookieEnv = $ENV{'HTTP_COOKIE'};
  148.   @Cookies = split(/\;/,$CookieEnv);
  149.   foreach $Cookie (@Cookies) {
  150. #       print "Cookie : $Cookie\n";
  151.  
  152.     @CurrentCookie = split(/=/,$Cookie);
  153.     $CurrentCookie[0] =~ s/ //;
  154. #      print "Cookie0 : A$CurrentCookie[0]B\n\n";
  155. #      print "Cookie1 : $CurrentCookie[1]\n\n";
  156.     if ($CurrentCookie[0] eq 'NAME') {
  157.       $UserName = $CurrentCookie[1];
  158. #      print "Cookieif : $UserName";
  159.     }
  160.     if ($CurrentCookie[0] eq 'LOCATION') {
  161.       $Location = $CurrentCookie[1];
  162.     }
  163.   }
  164.   if ($UserName && $Location) {
  165.     $UserName = "$UserName\@$Location";
  166.   }
  167. }
  168.  
  169.