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.cgi < prev    next >
Text File  |  2017-09-21  |  4KB  |  177 lines

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